Skip to content

feat: show oracle info on order detail page (Phase 4)#2459

Merged
hardyjosh merged 2 commits intofeat/signed-context-oracle-fetchfrom
feat/signed-context-oracle-ui
Mar 6, 2026
Merged

feat: show oracle info on order detail page (Phase 4)#2459
hardyjosh merged 2 commits intofeat/signed-context-oracle-fetchfrom
feat/signed-context-oracle-ui

Conversation

@hardyjosh
Copy link
Contributor

@hardyjosh hardyjosh commented Feb 15, 2026

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

  • Order detail page: new "Oracle" card property shown when oracleUrl exists, displayed as clickable link with info tooltip
  • Quotes section: purple "Oracle" badge with database icon, tooltip explaining signed context usage
  • Quotes already use oracle data transparently via SDK (feat: signed context oracle fetch module (Phase 3) #2458)

Checks

By submitting this for review, I'm confirming I've done the following:

  • made this PR as small as possible
  • unit-tested any new functionality
  • linked any relevant issues or PRs
  • included screenshots (if this involves a front-end change)

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 15, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5359038a-4829-444d-8aa5-36677140fdf4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/signed-context-oracle-ui

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

hardyjosh pushed a commit that referenced this pull request Feb 16, 2026
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)
@hardyjosh hardyjosh force-pushed the feat/signed-context-oracle-fetch branch from 929dcff to 1d940d3 Compare February 17, 2026 16:35
@hardyjosh hardyjosh force-pushed the feat/signed-context-oracle-ui branch from b349274 to e375cee Compare February 17, 2026 16:36
hardyjosh pushed a commit that referenced this pull request Feb 17, 2026
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)
@hardyjosh hardyjosh force-pushed the feat/signed-context-oracle-fetch branch from 1d940d3 to 63ea51f Compare February 22, 2026 22:55
@hardyjosh hardyjosh force-pushed the feat/signed-context-oracle-ui branch from e375cee to 10a7183 Compare February 22, 2026 22:55
hardyjosh pushed a commit that referenced this pull request Feb 22, 2026
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)
@hardyjosh hardyjosh requested a review from findolor February 23, 2026 17:55
@hardyjosh hardyjosh assigned JuaniRios and hardyjosh and unassigned JuaniRios Feb 23, 2026
@hardyjosh hardyjosh requested a review from JuaniRios February 23, 2026 17:56
@hardyjosh hardyjosh force-pushed the feat/signed-context-oracle-ui branch from 57bb022 to 5963780 Compare February 23, 2026 20:34
hardyjosh pushed a commit that referenced this pull request Feb 23, 2026
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)
@hardyjosh hardyjosh force-pushed the feat/signed-context-oracle-ui branch from 5963780 to 7fb4b52 Compare February 24, 2026 21:15
hardyjosh pushed a commit that referenced this pull request Feb 24, 2026
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)
Copy link
Collaborator

@findolor findolor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you think that we can update the order detail tests for the UI changes?

Josh Hardy added 2 commits March 6, 2026 00:50
Covers both presence and absence of oracleUrl on orders, verifying the
oracle section renders correctly with link attributes.
@hardyjosh hardyjosh force-pushed the feat/signed-context-oracle-ui branch from 456b907 to 3e4ac64 Compare March 6, 2026 00:50
@hardyjosh hardyjosh merged commit 681e300 into feat/signed-context-oracle-fetch Mar 6, 2026
19 checks passed
hardyjosh added a commit that referenced this pull request Mar 6, 2026
* 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>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 6, 2026

@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:

  • Simple bug fixes, typos, or minor refactoring
  • Single-purpose changes affecting 1-2 files
  • Documentation updates
  • Configuration tweaks
  • Changes that require minimal context to review

Review Effort: Would have taken 5-10 minutes

Examples:

  • Fix typo in variable name
  • Update README with new instructions
  • Adjust configuration values
  • Simple one-line bug fixes
  • Import statement cleanup

Medium (M)

Characteristics:

  • Feature additions or enhancements
  • Refactoring that touches multiple files but maintains existing behavior
  • Breaking changes with backward compatibility
  • Changes requiring some domain knowledge to review

Review Effort: Would have taken 15-30 minutes

Examples:

  • Add new feature or component
  • Refactor common utility functions
  • Update dependencies with minor breaking changes
  • Add new component with tests
  • Performance optimizations
  • More complex bug fixes

Large (L)

Characteristics:

  • Major feature implementations
  • Breaking changes or API redesigns
  • Complex refactoring across multiple modules
  • New architectural patterns or significant design changes
  • Changes requiring deep context and multiple review rounds

Review Effort: Would have taken 45+ minutes

Examples:

  • Complete new feature with frontend/backend changes
  • Protocol upgrades or breaking changes
  • Major architectural refactoring
  • Framework or technology upgrades

Additional Factors to Consider

When deciding between sizes, also consider:

  • Test coverage impact: More comprehensive test changes lean toward larger classification
  • Risk level: Changes to critical systems bump up a size category
  • Team familiarity: Novel patterns or technologies increase complexity

Notes:

  • the assessment must be for the totality of the PR, that means comparing the base branch to the last commit of the PR
  • the assessment output must be exactly one of: S, M or L (single-line comment) in format of: SIZE={S/M/L}
  • do not include any additional text, only the size classification
  • your assessment comment must not include tips or additional sections
  • do NOT tag me or anyone else on your comment

hardyjosh added a commit that referenced this pull request Mar 24, 2026
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants