feat: add SignedContextOracleV1 to ParsedMeta and expose oracle_url#2457
feat: add SignedContextOracleV1 to ParsedMeta and expose oracle_url#2457
Conversation
…n RaindexOrder - Add SignedContextOracleV1 variant to ParsedMeta enum - Add match arm for KnownMagic::SignedContextOracleV1 in parsing logic - Add oracle_url() wasm_bindgen getter on RaindexOrder - Depends on rain.metadata feat/signed-context-oracle-meta branch
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds a new RaindexSignedContextOracleV1 metadata variant, wires parsing and TryFrom logic for it (including multi-item and byte parsing tests), exposes an oracle_url getter on RaindexOrder (WASM and non‑WASM), and updates a submodule pointer for lib/rain.interpreter. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant RaindexOrder
participant ParsedMeta
participant Parser
Client->>RaindexOrder: get oracleUrl / oracle_url
RaindexOrder->>ParsedMeta: parsed_meta()
ParsedMeta->>Parser: parse meta items (detect KnownMagic::RaindexSignedContextOracleV1)
Parser-->>ParsedMeta: RaindexSignedContextOracleV1(...)
ParsedMeta-->>RaindexOrder: RaindexSignedContextOracleV1(oracle)
RaindexOrder-->>Client: return oracle.0 or None
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@crates/common/src/parsed_meta.rs`:
- Line 19: Add a unit test that covers parsing of the SignedContextOracleV1
variant: construct a SignedContextOracleV1 meta item (with a test URL), wrap it
into a RainMetaDocumentV1Item, call from_meta_item (and optionally
parse_multiple) and assert the result matches ParsedMeta::SignedContextOracleV1
with the original URL; use an insta snapshot for the resulting ParsedMeta to
follow project testing style and name the test clearly (e.g.
signed_context_oracle_v1_roundtrip) so it exercises the SignedContextOracleV1
parsing path.
In `@crates/common/src/raindex_client/orders.rs`:
- Around line 275-282: The non-wasm impl RaindexOrder is missing the
oracle_url() getter present in the wasm-exported block, causing non-wasm callers
to fail; add a pub fn oracle_url(&self) -> Option<String> to the non-wasm impl
RaindexOrder that mirrors the WASM getter implementation by calling
self.parsed_meta().into_iter().find_map(|meta| match meta {
ParsedMeta::SignedContextOracleV1(oracle) => Some(oracle.0), _ => None, }) so
server-side Rust and tests can call oracle_url() the same way.
- Add 3 tests for SignedContextOracleV1 parsing (from_meta_item, parse_multiple, parse_from_bytes roundtrip) - Add oracle_url() to non-wasm impl block (mirrors wasm getter) - All 11 parsed_meta tests passing
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@crates/common/src/raindex_client/orders.rs`:
- Around line 275-282: In oracle_url (the wasm getter) avoid direct tuple-field
access on ParsedMeta::SignedContextOracleV1 by calling the accessor method
instead: when matching ParsedMeta::SignedContextOracleV1(oracle) return
oracle.url() (or convert its return to String if needed) instead of using
oracle.0; update the match arm in the oracle_url function to call the
oracle.url() accessor to improve encapsulation and resilience to upstream struct
changes.
| /// Returns the signed context oracle URL if this order has oracle metadata. | ||
| #[wasm_bindgen(getter = oracleUrl)] | ||
| pub fn oracle_url(&self) -> Option<String> { | ||
| self.parsed_meta().into_iter().find_map(|meta| match meta { | ||
| ParsedMeta::SignedContextOracleV1(oracle) => Some(oracle.0), | ||
| _ => None, | ||
| }) | ||
| } |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Search for SignedContextOracleV1 struct definition
rg -n 'struct SignedContextOracleV1' --type rust -A 5Repository: rainlanguage/rain.orderbook
Length of output: 53
🏁 Script executed:
#!/bin/bash
# Search for url() method on SignedContextOracleV1
rg -n 'fn url' --type rust -B 3 -A 3Repository: rainlanguage/rain.orderbook
Length of output: 881
🏁 Script executed:
#!/bin/bash
# Check the parsed_meta module to understand the structure
find . -name "parsed_meta.rs" -o -name "*parsed_meta*" | head -10Repository: rainlanguage/rain.orderbook
Length of output: 105
🏁 Script executed:
#!/bin/bash
# Look at the orders.rs file to see how oracle.0 is used and understand the context
sed -n '275,282p' crates/common/src/raindex_client/orders.rs
sed -n '359,365p' crates/common/src/raindex_client/orders.rsRepository: rainlanguage/rain.orderbook
Length of output: 732
🏁 Script executed:
#!/bin/bash
# Read the parsed_meta.rs file to understand SignedContextOracleV1 definition
cat crates/common/src/parsed_meta.rsRepository: rainlanguage/rain.orderbook
Length of output: 9749
🏁 Script executed:
#!/bin/bash
# Search for SignedContextOracleV1 definition in rain_metadata or dependencies
rg -n 'SignedContextOracleV1' --type rust -B 2 -A 10 | head -100Repository: rainlanguage/rain.orderbook
Length of output: 7161
🏁 Script executed:
#!/bin/bash
# Check if there's a dependency on rain_metadata and what version
grep -r "rain_metadata" --include="Cargo.toml" | head -20Repository: rainlanguage/rain.orderbook
Length of output: 53
🏁 Script executed:
#!/bin/bash
# Check if SignedContextOracleV1 is a tuple struct or regular struct
rg -n 'struct SignedContextOracleV1' --type rustRepository: rainlanguage/rain.orderbook
Length of output: 53
🏁 Script executed:
#!/bin/bash
# Check the Cargo.toml in crates/common to see rain_metadata version/source
grep -A 5 "rain_metadata" crates/common/Cargo.tomlRepository: rainlanguage/rain.orderbook
Length of output: 53
🏁 Script executed:
#!/bin/bash
# Look at how DotrainSourceV1 is accessed in orders.rs to understand the pattern
sed -n '260,270p' crates/common/src/raindex_client/orders.rs
sed -n '345,355p' crates/common/src/raindex_client/orders.rsRepository: rainlanguage/rain.orderbook
Length of output: 994
🏁 Script executed:
#!/bin/bash
# Let's check if there are any compile or test errors related to oracle.0
# First, let's see what the actual types are by examining Cargo.lock or checking dependencies
find . -name "Cargo.lock" -o -name "Cargo.toml" | grep -E "(Cargo.lock|common/Cargo.toml)" | head -5Repository: rainlanguage/rain.orderbook
Length of output: 110
🏁 Script executed:
#!/bin/bash
# Check the actual oracle_url() method implementation more carefully
# and see if there's a test for it in orders.rs
rg -n 'oracle_url' --type rust -B 2 -A 5Repository: rainlanguage/rain.orderbook
Length of output: 1493
🏁 Script executed:
#!/bin/bash
# Let's search for where oracle.0 or oracle.url() appears in tests
rg -n 'oracle\.' --type rust -B 1 -A 1 | grep -E "(\.0|\.url)" | head -30Repository: rainlanguage/rain.orderbook
Length of output: 728
Consider using .url() instead of .0 for better encapsulation.
Tests in parsed_meta.rs use oracle.url() to access the URL, but the implementation uses oracle.0 (direct tuple field access). While both approaches work and .0 is consistent with the existing DotrainSourceV1 pattern in this file, using the accessor method would be more resilient to internal struct changes in the external rain_metadata crate.
♻️ Optional refactor
pub fn oracle_url(&self) -> Option<String> {
self.parsed_meta().into_iter().find_map(|meta| match meta {
- ParsedMeta::SignedContextOracleV1(oracle) => Some(oracle.0),
+ ParsedMeta::SignedContextOracleV1(oracle) => Some(oracle.url().to_string()),
_ => None,
})
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| /// Returns the signed context oracle URL if this order has oracle metadata. | |
| #[wasm_bindgen(getter = oracleUrl)] | |
| pub fn oracle_url(&self) -> Option<String> { | |
| self.parsed_meta().into_iter().find_map(|meta| match meta { | |
| ParsedMeta::SignedContextOracleV1(oracle) => Some(oracle.0), | |
| _ => None, | |
| }) | |
| } | |
| /// Returns the signed context oracle URL if this order has oracle metadata. | |
| #[wasm_bindgen(getter = oracleUrl)] | |
| pub fn oracle_url(&self) -> Option<String> { | |
| self.parsed_meta().into_iter().find_map(|meta| match meta { | |
| ParsedMeta::SignedContextOracleV1(oracle) => Some(oracle.url().to_string()), | |
| _ => None, | |
| }) | |
| } |
🤖 Prompt for AI Agents
In `@crates/common/src/raindex_client/orders.rs` around lines 275 - 282, In
oracle_url (the wasm getter) avoid direct tuple-field access on
ParsedMeta::SignedContextOracleV1 by calling the accessor method instead: when
matching ParsedMeta::SignedContextOracleV1(oracle) return oracle.url() (or
convert its return to String if needed) instead of using oracle.0; update the
match arm in the oracle_url function to call the oracle.url() accessor to
improve encapsulation and resilience to upstream struct changes.
…leV1 metadata Points rain.interpreter at feat/signed-context-oracle-meta-submodule branch which updates the rain.metadata submodule to feat/signed-context-oracle-meta.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@lib/rain.interpreter`:
- Line 1: The submodule commit referenced by the PR is missing the
SignedContextOracleV1 implementation and its magic constant
(0xff7a1507ba4419ca); update the submodule pointer to the commit/branch that
actually contains SignedContextOracleV1 or remove/adjust the commit message and
code that claim to add it. Specifically, either: 1) change the submodule
reference to the commit that implements SignedContextOracleV1 and exposes the
magic value, or 2) if that implementation belongs in a separate PR
(rain.metadata PR `#92`), revert the claims and any code paths expecting
SignedContextOracleV1 (look for references to SignedContextOracleV1 and the
magic value) and add a TODO linking to the pending PR. Also add a short unit
test or sanity check that asserts the magic value (0xff7a1507ba4419ca) and
SignedContextOracleV1 type are present after the submodule update so future
reviews can verify the support.
lib/rain.interpreter
Outdated
| @@ -1 +1 @@ | |||
| Subproject commit c11023d69e745fb4aa76366918dd89d672c68616 | |||
| Subproject commit ef58bce5deb4445f220e0ac25589e17a5bce7259 | |||
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify submodule commit and check for SignedContextOracleV1 support
echo "=== Checking if submodule reference exists ==="
if [ -f "lib/rain.interpreter" ]; then
echo "File 'lib/rain.interpreter' exists (likely gitlink)"
cat lib/rain.interpreter
else
echo "No regular file at lib/rain.interpreter"
fi
echo -e "\n=== Checking .gitmodules for submodule configuration ==="
if [ -f ".gitmodules" ]; then
grep -A 3 "rain.interpreter" .gitmodules 2>/dev/null || echo "No rain.interpreter submodule config found"
else
echo "No .gitmodules file found"
fi
echo -e "\n=== Checking git config for submodule URL ==="
git config --file .gitmodules --get-regexp "rain\.interpreter" 2>/dev/null || echo "No submodule config in git"
echo -e "\n=== Listing directory structure to understand layout ==="
ls -la lib/ 2>/dev/null | head -20
echo -e "\n=== Checking recent commits affecting lib/rain.interpreter ==="
git log --oneline -n 20 -- "lib/rain.interpreter" 2>/dev/null || echo "No git history for this path"
echo -e "\n=== Current state of git status ==="
git status --short lib/rain.interpreter 2>/dev/null || echo "No changes detected"Repository: rainlanguage/rain.orderbook
Length of output: 1307
🏁 Script executed:
#!/bin/bash
# Get the actual submodule commit hash and verify its contents
echo "=== Getting current submodule commit hash ==="
git ls-tree HEAD lib/rain.interpreter
echo -e "\n=== Checking .gitmodules for url and branch tracking ==="
cat .gitmodules | grep -A 5 "rain.interpreter"
echo -e "\n=== Reading the actual submodule state ==="
cd lib/rain.interpreter 2>/dev/null && {
echo "Inside submodule:"
git rev-parse HEAD
echo -e "\n=== Searching for SignedContextOracleV1 in submodule ==="
find . -type f \( -name "*.rs" -o -name "*.toml" \) -not -path "./.git/*" | head -20 | xargs rg "SignedContextOracleV1" -l 2>/dev/null || echo "No SignedContextOracleV1 found via rg"
echo -e "\n=== Checking for magic value 0xff7a1507ba4419ca ==="
find . -type f \( -name "*.rs" \) -not -path "./.git/*" | xargs rg "0xff7a1507ba4419ca" 2>/dev/null || echo "Magic value not found"
echo -e "\n=== Recent commits in submodule ==="
git log --oneline -n 5
} || echo "Could not cd into submodule"
echo -e "\n=== Checking current branch/state ==="
cd - > /dev/null 2>&1
git rev-parse --abbrev-ref HEADRepository: rainlanguage/rain.orderbook
Length of output: 962
🏁 Script executed:
#!/bin/bash
# Investigate what's actually in the recent commit
cd lib/rain.interpreter 2>/dev/null || exit 1
echo "=== Commit details for f2566dc92 ==="
git show --stat f2566dc92
echo -e "\n=== Full commit message ==="
git show f2566dc92 --no-patch --pretty=full
echo -e "\n=== Checking for any KnownMagic or Oracle references ==="
git show f2566dc92 | rg -i "magic|oracle|0xff7a" -C 2 | head -50
echo -e "\n=== Files changed in this commit ==="
git show --name-only --pretty="" f2566dc92
echo -e "\n=== Checking parent commit ==="
git show f2566dc92^:. 2>/dev/null | head -5 || echo "Cannot access parent"
echo -e "\n=== Recent branch info ==="
git branch -a | head -10
git log --oneline -n 10
echo -e "\n=== Checking for any SignedContext references (broader search) ==="
rg -i "signedcontext" --type rust . 2>/dev/null || echo "No SignedContext found"Repository: rainlanguage/rain.orderbook
Length of output: 50384
Submodule points to feature branch with incomplete functionality—SignedContextOracleV1 support not found.
The commit message claims to add SignedContextOracleV1 metadata support, but verification found no trace of SignedContextOracleV1 or its associated magic value (0xff7a1507ba4419ca) in the current submodule commit. The submodule points to a feature branch (feat/signed-context-oracle-meta-submodule), which may indicate this is part of an incomplete PR chain pending the merge of rain.metadata PR #92. Clarify whether this incomplete state is expected, or if the promised functionality is missing from the submodule commit.
🤖 Prompt for AI Agents
In `@lib/rain.interpreter` at line 1, The submodule commit referenced by the PR is
missing the SignedContextOracleV1 implementation and its magic constant
(0xff7a1507ba4419ca); update the submodule pointer to the commit/branch that
actually contains SignedContextOracleV1 or remove/adjust the commit message and
code that claim to add it. Specifically, either: 1) change the submodule
reference to the commit that implements SignedContextOracleV1 and exposes the
magic value, or 2) if that implementation belongs in a separate PR
(rain.metadata PR `#92`), revert the claims and any code paths expecting
SignedContextOracleV1 (look for references to SignedContextOracleV1 and the
magic value) and add a TODO linking to the pending PR. Also add a short unit
test or sanity check that asserts the magic value (0xff7a1507ba4419ca) and
SignedContextOracleV1 type are present after the submodule update so future
reviews can verify the support.
Matches rename in rain.metadata#92. The metadata type is specific to the Raindex calculateOrderIO entrypoint.
There was a problem hiding this comment.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@crates/common/src/raindex_client/orders.rs`:
- Around line 275-282: The getter oracle_url() currently extracts the oracle
string by accessing the tuple field oracle.0; change this to call the accessor
oracle.url() instead (i.e., when matching
ParsedMeta::RaindexSignedContextOracleV1(oracle) return Some(oracle.url())), and
make the identical change in the non-WASM implementation(s) that also use
oracle.0 (see the other occurrence around the
ParsedMeta::RaindexSignedContextOracleV1 match at lines mentioned in the
review); this keeps behavior consistent with parsed_meta.rs tests and resilient
to upstream struct changes.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@lib/rain.interpreter`:
- Line 1: CI is failing because git submodule fetch requires authentication;
update submodule access in one of two ways: either make the submodule URL public
in .gitmodules (replace SSH/private URL with a public HTTPS GitHub URL) so git
submodule update works without credentials, or modify the CI workflow (e.g., the
GitHub Actions workflow file under .github/workflows) to provide credentials by
exporting/using GITHUB_TOKEN and configuring git to use it before running git
submodule update (ensure actions/checkout uses submodules: true or run git
config credential.helper and set remote URL with the token). Choose one approach
and update the .gitmodules or the workflow to fix submodule access for CI.
---
Duplicate comments:
In `@lib/rain.interpreter`:
- Line 1: Check that the referenced submodule commit
55a78efc8f1aabbd398264f34c1c949688470951 actually adds the SignedContextOracleV1
symbol and the magic constant 0xff7a1507ba4419ca by inspecting the commit diff
or files; run git show or git diff on that commit and grep for
"SignedContextOracleV1" and "0xff7a1507ba4419ca", or open the source files that
define or register oracles/constants and confirm those identifiers are present,
then report back or update the submodule pointer only if both identifiers are
found.
lib/rain.interpreter
Outdated
| @@ -1 +1 @@ | |||
| Subproject commit c11023d69e745fb4aa76366918dd89d672c68616 | |||
| Subproject commit 55a78efc8f1aabbd398264f34c1c949688470951 | |||
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Submodule fetch requires auth; fix CI/submodule access.
CI failed with git submodule update due to missing GitHub credentials. Ensure the submodule URL is publicly accessible for CI or provide GITHUB_TOKEN/auth for submodule fetch so pipeline stays green.
🧰 Tools
🪛 GitHub Actions: Git is clean
[error] 1-1: Command failed: git submodule update --init --force --recursive. Error: could not read Username for 'https://github.com': terminal prompts disabled.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@lib/rain.interpreter` at line 1, CI is failing because git submodule fetch
requires authentication; update submodule access in one of two ways: either make
the submodule URL public in .gitmodules (replace SSH/private URL with a public
HTTPS GitHub URL) so git submodule update works without credentials, or modify
the CI workflow (e.g., the GitHub Actions workflow file under .github/workflows)
to provide credentials by exporting/using GITHUB_TOKEN and configuring git to
use it before running git submodule update (ensure actions/checkout uses
submodules: true or run git config credential.helper and set remote URL with the
token). Choose one approach and update the .gitmodules or the workflow to fix
submodule access for CI.
Caution
Merge order: Merge rain.metadata#92 and rain.interpreter#427 first, then this PR.
Motivation
Orders that require signed context data (e.g. oracle price feeds) currently have no discovery mechanism — takers have no way to know where to fetch
SignedContextV1data.Solution
SignedContextOracleV1variant to theParsedMetaenum incrates/common/src/parsed_meta.rsKnownMagic::SignedContextOracleV1infrom_meta_item()parsing logicoracle_url()getter onRaindexOrderin both wasm and non-wasm impl blocksSignedContextOracleV1item, the SDK parses it and exposes the oracle endpoint URLChecks
By submitting this for review, I'm confirming I've done the following:
Summary by CodeRabbit
New Features
Tests
Chores