Skip to content

RaindexClient UI implementation#1956

Merged
hardyjosh merged 74 commits intomainfrom
2025-06-25-raindex-client-orders-ui-implementation
Jul 8, 2025
Merged

RaindexClient UI implementation#1956
hardyjosh merged 74 commits intomainfrom
2025-06-25-raindex-client-orders-ui-implementation

Conversation

@findolor
Copy link
Copy Markdown
Collaborator

@findolor findolor commented Jun 26, 2025

Caution

Merge this PR before merge rainlanguage/rain.strategies#46

Motivation

See issue: #1960

This PR implements the new RaindexClient sdk into the webapp and tauri app and removes the old versions of the wasm bindings during the process.

Things changed in this PR:

  1. Updated chain id to be u32 instead of u64.
  2. Updated RaindexClient to include more wasm bindings that were previously missing.
  3. Updated all the raindex structs to be typed properly. These types include U256, Bytes, Address and more.
  4. Updated the inline documentation of the new client to properly display input/output parameter information. This follows the same patterns we have in DotrainOrderGui
  5. Remove the old wasm bindings that are no longer used due to the new client and the overall refactor.
  6. Updated the orderbook yaml logic to return multiple orderbooks that match a given network key. This means we can now combine multiple orderbooks under a single network key.
  7. Removed unused store variables that are no longer needed in webapp and tauri app.
  8. Removed unused helper functions that helped us to query in webapp and tauri app.
  9. Refactor both of the apps to use the new client logic.
  10. Refactor both of the apps to use a new url structure. We now have chain id, orderbook address and the order/vault id in the url.
  11. Update tauri app to fetch settings from our github link to populate during first app launch.

Solution

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)

fix #1960

Summary by CodeRabbit

  • New Features

    • Added WASM methods for generating calldata for adding and removing orders.
    • Introduced direct quoting capabilities on order objects with async WASM bindings.
    • Enhanced client support for multiple orderbooks per network and multi-chain querying.
    • Added new fields and methods to orders, trades, vaults, and transactions for richer data access.
  • Refactor

    • Unified ID and address types, replacing string IDs with typed hex/binary representations.
    • Updated APIs to accept explicit chain IDs, orderbook addresses, and hex strings.
    • Consolidated subgraph and RPC interactions under a single client interface.
    • Updated UI components and props to use new types and data structures.
    • Removed dependency on subgraph URLs in favor of client-based data fetching.
    • Simplified and unified test mocks and fixtures to use new client and types.
  • Bug Fixes

    • Improved error handling and validation for calldata generation and quoting.
    • Fixed inconsistencies in chain ID and address handling across the app.
  • Chores

    • Removed legacy subgraph modules, WASM APIs, and obsolete test fixtures.
    • Updated and removed outdated tests to align with the new client-based architecture.
    • Cleaned up unused imports and props related to subgraph URLs and network keys.
  • Tests

    • Added tests for new client methods, calldata generation, quoting, and error cases.
    • Refactored UI component tests to use new types and client interfaces.
    • Updated test data to use explicit chain IDs, orderbook addresses, and typed hex IDs.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 26, 2025

Caution

Review failed

The head commit changed during the review from cf1a484 to a9a9c0a.

Walkthrough

This change is a large-scale refactor that migrates the Rain Orderbook webapp and Tauri app to use a new RaindexClient architecture. It replaces legacy subgraph and JS API modules with strongly-typed, WASM-exported Rust interfaces, updates all entity ID and chain ID types, removes legacy test and fixture files, and adapts UI components and tests to the new client-based data model and API.

Changes

File(s) / Path(s) Change Summary
Cargo.toml, crates/quote/Cargo.toml, crates/quote/src/lib.rs, crates/quote/src/js_api/mod.rs Updated wasm-bindgen-utils dependency, removed cdylib crate type, and deleted WASM JS API module and its exports.
crates/common/Cargo.toml, crates/common/src/fuzz/impls.rs, crates/common/src/fuzz/mod.rs Added rain_orderbook_quote dependency, updated types for chain IDs in fuzzing modules.
crates/common/src/raindex_client/* Major refactor: introduced multi-orderbook/chain support, new WASM-exported async methods, updated error handling, types, and tests.
crates/js_api/src/common/mod.rs, crates/js_api/src/subgraph/* Deleted all subgraph and common WASM JS API modules and their exports, including error types and test code.
crates/js_api/src/gui/* Updated types for chain IDs, removed/get_network_key method, updated test constants.
crates/js_api/src/lib.rs Removed public modules and re-exports, added TypeScript type section for Address/Hex.
crates/settings/src/network.rs, crates/settings/src/remote/chains/chainid.rs, crates/settings/src/remote/tokens.rs, crates/settings/src/yaml/* Changed all chain ID and network ID types from u64 to u32, updated parsing and test helpers.
packages/orderbook/test/js_api/*.test.ts, packages/orderbook/test/quote/test.test.ts Deleted all legacy JS API and quote package test files.
packages/ui-components/src/tests/* Refactored all UI tests to use new RaindexClient, RaindexOrder, RaindexVault types, updated test props, mocks, and assertions.
packages/ui-components/src/lib/fixtures/orderDetail.ts Deleted legacy order detail fixture file.
packages/ui-components/src/lib/mocks/stores.ts Replaced active subgraphs store with selected chain IDs store.
packages/ui-components/src/lib/components/* Updated all components to use new Raindex types, props, and client-based data fetching; updated prop signatures and URL formats.
packages/ui-components/src/lib/types/modal.ts Updated modal types to use new Raindex types and function signatures.

Sequence Diagram(s)

sequenceDiagram
    participant UI
    participant RaindexClient
    participant WASM
    participant Subgraph/RPC

    UI->>RaindexClient: Call getOrderByHash(chainId, orderbookAddress, orderHash)
    RaindexClient->>WASM: Convert params, get orderbook client
    WASM->>Subgraph/RPC: Query subgraph for order by hash
    Subgraph/RPC-->>WASM: Return order data
    WASM-->>RaindexClient: Return RaindexOrder
    RaindexClient-->>UI: Return RaindexOrder

    UI->>RaindexOrder: Call getQuotes(blockNumber, gas)
    RaindexOrder->>RaindexClient: Get RPC URLs for chain
    RaindexOrder->>WASM: Call get_order_quotes with params
    WASM->>Subgraph/RPC: Perform quote simulation
    Subgraph/RPC-->>WASM: Return quote result
    WASM-->>RaindexOrder: Return BatchOrderQuotesResponse[]
    RaindexOrder-->>UI: Return quotes
Loading

Assessment against linked issues

Objective Addressed Explanation
Refactor webapp and Tauri app to use new RaindexClient architecture, removing legacy subgraph and JS API code (#1960)
Update all entity types and APIs to use new strongly-typed RaindexOrder, RaindexVault, etc. (#1960)
Migrate all UI components and tests to use new client-based data model and WASM bindings (#1960)
Remove legacy test and fixture files and update all mocks to new types (#1960)

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
None found

Possibly related PRs

Suggested labels

rust, webapp, Tauri

Suggested reviewers

  • hardyjosh

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-07-08T16_43_01_736Z-debug-0.log

🔧 Clippy (1.86.0)
Updating crates.io index
Updating git repository `https://github.com/rainlanguage/rain.wasm`

error: failed to get wasm-bindgen-utils as a dependency of package rain_orderbook_bindings v0.0.0-alpha.0 (/crates/bindings)

Caused by:
failed to load source for dependency wasm-bindgen-utils

Caused by:
Unable to update https://github.com/rainlanguage/rain.wasm?rev=06990d85a0b7c55378a1c8cca4dd9e2bc34a596a#06990d85

Caused by:
failed to create directory /usr/local/git/db/rain.wasm-45eded9facc525c2

Caused by:
Permission denied (os error 13)

✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@findolor findolor self-assigned this Jul 1, 2025
@hardyjosh hardyjosh self-requested a review July 8, 2025 20:13
@hardyjosh hardyjosh merged commit 765de45 into main Jul 8, 2025
17 checks passed
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.

Refactor webapp and tauri app with RaindexClient changes

3 participants