feat: show oracle info on order detail page (Phase 4)#2459
feat: show oracle info on order detail page (Phase 4)#2459hardyjosh merged 2 commits intofeat/signed-context-oracle-fetchfrom
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
Adds optional oracle-url field to OrderCfg, parsed from the YAML front matter orders section. When present, this URL identifies a signed context oracle server for the order. Changes: - Add oracle_url: Option<String> to OrderCfg struct - Parse oracle-url via optional_string in YAML parsing - Add oracle-url to ALLOWED_ORDER_KEYS - Update Default and PartialEq impls - Add test for oracle-url parsing (present + absent) Spec: rainlanguage/specs#45 Chained on: #2459 (Phase 4)
929dcff to
1d940d3
Compare
b349274 to
e375cee
Compare
Adds optional oracle-url field to OrderCfg, parsed from the YAML front matter orders section. When present, this URL identifies a signed context oracle server for the order. Changes: - Add oracle_url: Option<String> to OrderCfg struct - Parse oracle-url via optional_string in YAML parsing - Add oracle-url to ALLOWED_ORDER_KEYS - Update Default and PartialEq impls - Add test for oracle-url parsing (present + absent) Spec: rainlanguage/specs#45 Chained on: #2459 (Phase 4)
1d940d3 to
63ea51f
Compare
e375cee to
10a7183
Compare
Adds optional oracle-url field to OrderCfg, parsed from the YAML front matter orders section. When present, this URL identifies a signed context oracle server for the order. Changes: - Add oracle_url: Option<String> to OrderCfg struct - Parse oracle-url via optional_string in YAML parsing - Add oracle-url to ALLOWED_ORDER_KEYS - Update Default and PartialEq impls - Add test for oracle-url parsing (present + absent) Spec: rainlanguage/specs#45 Chained on: #2459 (Phase 4)
57bb022 to
5963780
Compare
Adds optional oracle-url field to OrderCfg, parsed from the YAML front matter orders section. When present, this URL identifies a signed context oracle server for the order. Changes: - Add oracle_url: Option<String> to OrderCfg struct - Parse oracle-url via optional_string in YAML parsing - Add oracle-url to ALLOWED_ORDER_KEYS - Update Default and PartialEq impls - Add test for oracle-url parsing (present + absent) Spec: rainlanguage/specs#45 Chained on: #2459 (Phase 4)
5963780 to
7fb4b52
Compare
Adds optional oracle-url field to OrderCfg, parsed from the YAML front matter orders section. When present, this URL identifies a signed context oracle server for the order. Changes: - Add oracle_url: Option<String> to OrderCfg struct - Parse oracle-url via optional_string in YAML parsing - Add oracle-url to ALLOWED_ORDER_KEYS - Update Default and PartialEq impls - Add test for oracle-url parsing (present + absent) Spec: rainlanguage/specs#45 Chained on: #2459 (Phase 4)
findolor
left a comment
There was a problem hiding this comment.
do you think that we can update the order detail tests for the UI changes?
Covers both presence and absence of oracleUrl on orders, verifying the oracle section renders correctly with link attributes.
456b907 to
3e4ac64
Compare
* fix: prettier formatting * feat: parse oracle-url from YAML order config (Phase 6) Adds optional oracle-url field to OrderCfg, parsed from the YAML front matter orders section. When present, this URL identifies a signed context oracle server for the order. Changes: - Add oracle_url: Option<String> to OrderCfg struct - Parse oracle-url via optional_string in YAML parsing - Add oracle-url to ALLOWED_ORDER_KEYS - Update Default and PartialEq impls - Add test for oracle-url parsing (present + absent) Spec: rainlanguage/specs#45 Chained on: #2459 (Phase 4) * feat: encode oracle-url into order metadata (Phase 7) When an order has oracle_url set in its config, new_from_deployment now creates a SignedContextOracleV1 meta item and includes it in the order's additional_meta. This means orders deployed with oracle-url in their YAML will have the oracle endpoint encoded in their onchain RainMetaDocumentV1, making it discoverable by takers and indexers (Phase 2 reads it back). Changes: - Import SignedContextOracleV1 in add_order.rs - In new_from_deployment: parse oracle_url, create meta item, append to additional_meta * propagate RaindexSignedContextOracleV1 rename to add_order.rs * fix: cargo fmt formatting --------- Co-authored-by: Josh Hardy <josh@rainlang.xyz>
|
@coderabbitai assess this PR size classification for the totality of the PR with the following criterias and report it in your comment: S/M/L PR Classification Guidelines:This guide helps classify merged pull requests by effort and complexity rather than just line count. The goal is to assess the difficulty and scope of changes after they have been completed. Small (S)Characteristics:
Review Effort: Would have taken 5-10 minutes Examples:
Medium (M)Characteristics:
Review Effort: Would have taken 15-30 minutes Examples:
Large (L)Characteristics:
Review Effort: Would have taken 45+ minutes Examples:
Additional Factors to ConsiderWhen deciding between sizes, also consider:
Notes:
|
* feat: add SignedContextOracleV1 to ParsedMeta and expose oracle_url on 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 * fix: add tests, non-wasm oracle_url(), address review feedback - 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 * chore: update rain.interpreter submodule to include SignedContextOracleV1 metadata Points rain.interpreter at feat/signed-context-oracle-meta-submodule branch which updates the rain.metadata submodule to feat/signed-context-oracle-meta. * rename SignedContextOracleV1 → RaindexSignedContextOracleV1 Matches rename in rain.metadata#92. The metadata type is specific to the Raindex calculateOrderIO entrypoint. * chore: bump rain.interpreter to include metadata rename * fix: cargo fmt parsed_meta.rs * fix: update rain.interpreter submodule to include metadata fmt fix * feat: add oracle fetch module and wire signed context into take-order flows Phase 3 of signed context oracle discovery: - New oracle.rs module with fetch_signed_context(url) and OracleResponse type - OracleResponse maps directly to SignedContextV1 (signer, context as bytes32[], signature) - Added signed_context field to TakeOrderCandidate - Wired oracle fetching into: - build_take_order_candidates_for_pair (batch flow, concurrent fetch) - execute_single_take (single take flow, oracle_url param) - build_take_orders_config_from_simulation (passes through to TakeOrderConfigV4) - Oracle fetch is best-effort: failures log a warning and use empty signed context - 3 oracle tests + 9 parsed_meta tests passing * feat: wire oracle signed context into quote flow - Add get_order_quotes_with_context() to quote crate (accepts signed_context param) - RaindexOrder.get_quotes() now fetches oracle data and passes to quotes - Original get_order_quotes() unchanged (delegates with empty context) * fix: clippy lints and formatting * fix: conditionally apply reqwest timeout for non-WASM targets reqwest::ClientBuilder::timeout() is not available on WASM targets. Use cfg(not(target_family = "wasm")) to only set it on native. * feat: show oracle info on order detail page - OrderDetail: show Oracle card property with URL link when order has oracle metadata - Includes tooltip explaining signed context oracle usage - TanstackOrderQuote: show purple 'Oracle' badge next to quotes heading when oracle is active - Indicates quotes include signed context data from oracle - Both use the oracleUrl getter exposed via WASM bindings on RaindexOrder * revert: remove frontend changes from Phase 3 PR * switch oracle fetch to POST with ABI-encoded body The oracle endpoint now receives order details via POST so it can tailor responses based on the specific order, counterparty, and IO indexes. POST body: abi.encode(OrderV4, inputIOIndex, outputIOIndex, counterparty) Falls back to GET when no body is provided (simple oracles). Callers currently pass None - ABI encoding will be wired in once the order data is available at each call site. * oracle fetch: body is required, no GET fallback POST with ABI-encoded order data is mandatory. Callers currently pass empty vec — will be wired to abi.encode(OrderV4, inputIOIndex, outputIOIndex, counterparty) at each call site. * wire ABI-encoded per-pair oracle fetches - encode_oracle_body: abi.encode(OrderV4, inputIOIndex, outputIOIndex, counterparty) - get_quotes: fetches oracle per IO pair concurrently, counterparty=address(0) - build_take_order_candidates: fetches oracle per quote pair - execute_single_take: encodes with actual taker as counterparty - get_order_quotes_with_context_fn: accepts per-pair context callback * refactor: move oracle into quote crate, remove closure pattern - Oracle fetch logic moved from common to quote crate (common re-exports) - get_order_quotes now extracts oracle URL directly from SgOrder.meta - Removed get_order_quotes_with_context and get_order_quotes_with_context_fn - No more closures, HashMaps, or pre-fetching — oracle context fetched inline per IO pair inside the quote loop - RaindexOrder.get_quotes() simplified to just call get_order_quotes() * fmt: cargo fmt fixes * feat: update oracle to batch format - Add encode_oracle_body_batch() for array encoding: abi.encode((OrderV4, uint256, uint256, address)[]) - Update fetch_signed_context_batch() to handle Vec responses - Maintain backward compatibility with single request functions - Add comprehensive tests for both single and batch formats - Response format now expects JSON array per spec * fix: prettier formatting * feat: parse oracle-url from YAML order config (Phase 6) Adds optional oracle-url field to OrderCfg, parsed from the YAML front matter orders section. When present, this URL identifies a signed context oracle server for the order. Changes: - Add oracle_url: Option<String> to OrderCfg struct - Parse oracle-url via optional_string in YAML parsing - Add oracle-url to ALLOWED_ORDER_KEYS - Update Default and PartialEq impls - Add test for oracle-url parsing (present + absent) Spec: rainlanguage/specs#45 Chained on: #2459 (Phase 4) * feat: encode oracle-url into order metadata (Phase 7) When an order has oracle_url set in its config, new_from_deployment now creates a SignedContextOracleV1 meta item and includes it in the order's additional_meta. This means orders deployed with oracle-url in their YAML will have the oracle endpoint encoded in their onchain RainMetaDocumentV1, making it discoverable by takers and indexers (Phase 2 reads it back). Changes: - Import SignedContextOracleV1 in add_order.rs - In new_from_deployment: parse oracle_url, create meta item, append to additional_meta * propagate RaindexSignedContextOracleV1 rename to add_order.rs * fix: cargo fmt formatting * fmt: cargo fmt oracle.rs * fmt: cargo fmt oracle.rs * fix: sync rain.interpreter submodule with main * fix: remove accidentally committed embedded git repos * fmt: fix import ordering in oracle.rs tests * fix: surface oracle fetch errors in quote results instead of silently degrading When oracle-url is present but the fetch fails (e.g. wrong response format, timeout, network error), the quote now shows the oracle error in the UI rather than proceeding without signed context and getting an unhelpful out-of-bounds panic. * fix: propagate oracle fetch errors in take-order flow too * fix: type annotation for results, cargo fmt candidates.rs * fix: remove embedded repos, add to gitignore * fix: handle OracleFetchError in to_readable_msg match * fix: address all CodeRabbit review comments - URL validation (SSRF prevention): validate http/https scheme before POST - Deduplicate oracle meta in add_order to prevent double entries - Move oracle fetch below early exits in take-order flow (price-cap, approval) - Document historical quote + live oracle limitation - Validate batch response length matches request count - Restrict oracle URL href to http(s) in Svelte UI - Redact oracle URL from warning logs - Remove redundant token equality check (outer loop already filters) - Add URL validation unit tests - Add explanatory comment for Address::ZERO counterparty - Fix single-fetch doc comment to match actual JSON array contract * fix: remove duplicate InvalidUrl variant in OracleError * Fix clippy warnings: remove unused import and use slice::from_ref * clean up .gitignore: remove submodule entries added in error * Address Arda's review comments - Refactor execute_single_take to reduce parameter count - Created TakeOrderExecutionParams and RpcContext structs - Removed #[allow(clippy::too_many_arguments)] attribute - Updated function signature from 8 to 3 parameters - Added create_execution_params helper for tests - Updated 3 test calls (12 more need updating) - Add comprehensive UI tests for Oracle URL functionality - Tests Oracle section visibility based on oracleUrl presence - Tests clickable links for http/https URLs with proper security attributes - Tests XSS protection: non-http URLs render as safe plain text - Tests Oracle tooltip information display * Fix all remaining compilation errors for function refactoring - Add missing Address import in single_tests.rs - Update execute_single_take call in orders.rs to use new signature - Fix all 15 test function calls to use new parameter structs - Apply cargo formatting to pass static checks All static checks now pass ✅ * remove accidentally tracked submodule directories * Fix final UI test issue - Simplify Oracle tooltip test to avoid complex DOM text matching - All UI tests now pass (635 tests ✅) - CI should now pass completely * remove accidentally added submodule directories (again) * Fix Prettier formatting in OrderDetail test file - Apply prettier formatting to fix CI lint check - This was the missing step causing CI to fail despite tests passing locally --------- Co-authored-by: Josh Hardy <josh@rainlang.xyz>
Caution
Merge order: Merge #2458 first, then this PR.
Motivation
Orders with signed context oracles should visually indicate this to users. Currently there is no UI signal that an order uses external oracle data for its quotes.
Solution
oracleUrlexists, displayed as clickable link with info tooltipChecks
By submitting this for review, I'm confirming I've done the following: