Skip to content

Refactor local DB data fetching for RaindexClient #2341

Merged
findolor merged 8 commits intomainfrom
local-db-query-helper
Dec 1, 2025
Merged

Refactor local DB data fetching for RaindexClient #2341
findolor merged 8 commits intomainfrom
local-db-query-helper

Conversation

@findolor
Copy link
Copy Markdown
Collaborator

@findolor findolor commented Dec 1, 2025

Chained PR

Motivation

Current logic for fetching local DB orders has a leaky abstraction where we need to know about the internal details about whether to use subgraph or local DB data. Instead of this, we should just expose a getter function without any selection for data source and be able to use that.

With this we need a new way to fetch local DB data. One that is not tied to RaindexClient, but is a structure on its own.

Solution

  • Add local DB struct that implements DB query executor so it can work with different kind of executors
  • Refactor RaindexClient's local_db_callback field to use this new LocalDb struct
  • Introduce a new trade for fetching orders data, either as a list or form a hash
  • For both subgraph and local DB, implement the trait separately
  • In get_orders and get_by_hash functions, use the correct data source
  • Refactor other parts of RaindexClient with the new local db field change
  • Add/update tests

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)

Summary by CodeRabbit

  • Refactor

    • Reworked local database integration to use a unified LocalDb handle across orders, trades, vaults and scheduler.
    • Streamlined data retrieval to merge local and remote results more reliably.
  • Bug Fixes

    • Improved error messages and added clearer not-found reporting for orders.
  • Tests

    • Expanded unit and wasm tests to validate local DB behaviors and error propagation.

✏️ Tip: You can customize this high-level summary in your review settings.

@findolor findolor requested review from 0xgleb and hardyjosh December 1, 2025 12:38
@findolor findolor self-assigned this Dec 1, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 1, 2025

Walkthrough

Introduces a concrete LocalDb abstraction (async function hooks + LocalDbQueryExecutor impl) and replaces prior JS-callback-based local DB usage across scheduler, RaindexClient, and local query paths (orders, trades, vaults), adding LocalDbOrders/SubgraphOrders data-source routing and related tests.

Changes

Cohort / File(s) Change Summary
LocalDb core
crates/common/src/raindex_client/local_db/mod.rs
Add LocalDb struct (Rc-wrapped ExecuteBatchFn/QueryTextFn/QueryJsonFn aliases), constructors (new, from_js_callback), Debug impl, LocalDbQueryExecutor impl, and unit + wasm tests for delegation/error propagation.
Local DB — Orders data source
crates/common/src/raindex_client/local_db/orders.rs
Add LocalDbOrders<'a> and implement OrdersDataSource (list, get_by_hash) using LocalDb; adjust signatures (chain_ids Option, use &Bytes) and construct RaindexOrder with Rc.
Orders routing / Subgraph
crates/common/src/raindex_client/orders.rs
Add SubgraphOrders and OrdersDataSource trait; refactor RaindexClient::get_orders and get_order_by_hash to route between LocalDbOrders and SubgraphOrders; add Default derives.
Scheduler / runner
crates/common/src/raindex_client/local_db/pipeline/runner/scheduler.rs, .../runner/mod.rs
Replace JsCallbackExecutor/Function params with LocalDb; change start visibility to pub(crate) and signatures to accept LocalDb; remove Sync bound on generic runner methods; update tests and add noop_local_db helper.
RaindexClient integration
crates/common/src/raindex_client/mod.rs
Replace local_db_callback: Rc<RefCell<Option<js_sys::Function>>> with local_db: Rc<RefCell<Option<LocalDb>>>; store LocalDb::from_js_callback in setter; add RaindexError::OrderNotFound(Bytes...) variant and format handling.
Trades & Vaults local-db usage
crates/common/src/raindex_client/trades.rs, crates/common/src/raindex_client/vaults.rs
Switch local-DB call sites from callback/executor to concrete LocalDb; update helper signatures to accept LocalDb and refactor vaults to partition chain IDs, run concurrent local/subgraph queries, and merge results.
Tests / wasm adjustments
crates/common/src/.../tests
Update wasm/unit tests to construct LocalDb via JS callback helper, exercise query_text/query_json/execute_batch paths, and adapt scheduler/runner tests to use noop_local_db.

Sequence Diagram(s)

mermaid
sequenceDiagram
autonumber
participant JS as JavaScript caller
participant Ra as RaindexClient
participant DB as LocalDb
participant SG as Subgraph (network)
participant Scheduler

JS->>Ra: set_local_db_callback(js_fn)
Ra->>DB: LocalDb::from_js_callback(js_fn) (store)
Scheduler->>DB: start(..., db)
Scheduler->>DB: runner.run(db) (periodic)
Ra->>Ra: get_orders(filters)
alt LocalDb supports chains
    Ra->>DB: LocalDb.query_json / query_text
    DB-->>Ra: local results
else fallback needed
    Ra->>SG: subgraph queries
    SG-->>Ra: sg results
end
Ra->>JS: return merged orders

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Areas requiring focused review:
    • LocalDb hook types and async delegation (mod.rs): ensure correct lifetimes, error propagation, and FromDbJson deserialization.
    • Scheduler/runner signature changes and removal of Sync bound: verify thread-safety assumptions and any wasm vs native implications.
    • Orders/vaults partitioning and merge logic (orders.rs, vaults.rs): confirm chain-id routing, empty/None handling, and concurrency correctness.
    • RaindexClient local_db storage and lifecycle (mod.rs): ensure setter/getter semantics and wasm callback-to-LocalDb conversion are correct.
    • Tests: wasm unit tests and scheduler runner test updates must correctly simulate JS callbacks and LocalDb behavior.

Possibly related issues

Possibly related PRs

Suggested reviewers

  • hardyjosh
  • 0xgleb

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Refactor local DB data fetching for RaindexClient' directly and clearly summarizes the main change: restructuring how local database data is fetched by the RaindexClient, which is the primary objective across multiple files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch local-db-query-helper

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

@findolor
Copy link
Copy Markdown
Collaborator Author

findolor commented Dec 1, 2025

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 1, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5f129fe and 6ce4749.

📒 Files selected for processing (7)
  • crates/common/src/raindex_client/local_db/mod.rs (8 hunks)
  • crates/common/src/raindex_client/local_db/orders.rs (4 hunks)
  • crates/common/src/raindex_client/local_db/pipeline/runner/scheduler.rs (11 hunks)
  • crates/common/src/raindex_client/mod.rs (5 hunks)
  • crates/common/src/raindex_client/orders.rs (9 hunks)
  • crates/common/src/raindex_client/trades.rs (2 hunks)
  • crates/common/src/raindex_client/vaults.rs (6 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
crates/**/*.rs

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

crates/**/*.rs: For Rust crates in crates/*, run lints using nix develop -c cargo clippy --workspace --all-targets --all-features -D warnings
For Rust crates in crates/*, run tests using nix develop -c cargo test --workspace or --package <crate>

Files:

  • crates/common/src/raindex_client/trades.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/orders.rs
  • crates/common/src/raindex_client/local_db/orders.rs
  • crates/common/src/raindex_client/local_db/pipeline/runner/scheduler.rs
  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/vaults.rs
**/crates/**

📄 CodeRabbit inference engine (AGENTS.md)

Rust workspace organized as crates/* with subdirectories: cli, common, bindings, js_api, quote, subgraph, settings, math, integration_tests

Files:

  • crates/common/src/raindex_client/trades.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/orders.rs
  • crates/common/src/raindex_client/local_db/orders.rs
  • crates/common/src/raindex_client/local_db/pipeline/runner/scheduler.rs
  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/vaults.rs
**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

**/*.rs: Rust: format code with nix develop -c cargo fmt --all
Rust: lint with nix develop -c rainix-rs-static (preconfigured flags included)
Rust: crates and modules use snake_case; types use PascalCase

Files:

  • crates/common/src/raindex_client/trades.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/orders.rs
  • crates/common/src/raindex_client/local_db/orders.rs
  • crates/common/src/raindex_client/local_db/pipeline/runner/scheduler.rs
  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/vaults.rs
🧠 Learnings (57)
📓 Common learnings
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2145
File: crates/common/src/raindex_client/local_db/query/create_tables/query.sql:71-72
Timestamp: 2025-10-06T11:44:07.888Z
Learning: The local DB feature in the rain.orderbook codebase is not live yet (as of PR #2145), so schema migrations for existing databases are not required when modifying table structures in `crates/common/src/raindex_client/local_db/query/create_tables/query.sql`.
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2117
File: crates/js_api/src/gui/select_tokens.rs:421-424
Timestamp: 2025-09-02T08:04:34.729Z
Learning: User findolor in the rainlanguage/rain.orderbook codebase prefers not to change test code when tests are already passing, even if there appear to be type mismatches or potential issues. Working tests should be left alone unless there are actual errors.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1956
File: crates/common/src/fuzz/mod.rs:64-64
Timestamp: 2025-07-04T09:02:57.301Z
Learning: In rainlanguage/rain.orderbook, user findolor prefers to limit type consistency changes to only the parts directly related to the current work scope. For example, when updating chain_id fields from u64 to u32 in fuzz-related code, unrelated files like tauri-app wallet commands can remain as u64 if they serve different purposes and aren't part of the current changes.
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2000
File: crates/common/src/raindex_client/vaults.rs:183-183
Timestamp: 2025-07-16T10:40:05.717Z
Learning: In the rainlanguage/rain.orderbook codebase, user findolor considers breaking changes from Option<U256> to U256 for required fields like decimals in RaindexVaultToken to be acceptable and safe, even when they affect multiple usage sites across the codebase.
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1994
File: crates/common/src/raindex_client/vaults.rs:282-292
Timestamp: 2025-07-15T08:01:38.534Z
Learning: In the rainlanguage/rain.orderbook codebase, findolor prefers to avoid concurrency optimizations like using `futures::future::try_join_all` for parallel processing of balance changes, considering such optimizations "not that critical at the moment" when the performance impact is minimal.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:25:47.873Z
Learning: After each new commit review for rainlanguage/rain.orderbook repository, generate a PR size report in a separate comment with the format: "TOTAL=number ADDITIONS=number DELETIONS=number". This report should exclude irrelevant files such as lock files (e.g., package-lock.json, cargo.lock).
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2123
File: crates/common/src/raindex_client/local_db/mod.rs:23-29
Timestamp: 2025-10-06T11:13:29.956Z
Learning: In `crates/common/src/raindex_client/local_db/mod.rs`, the `Default` implementation for `LocalDb` that creates an RPC client pointing to `http://localhost:4444` is acceptable because the RPC client must be explicitly configured before actual usage in production scenarios.
📚 Learning: 2025-10-06T14:13:18.531Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2155
File: crates/common/src/raindex_client/trades.rs:133-152
Timestamp: 2025-10-06T14:13:18.531Z
Learning: In the rain.orderbook codebase, the `page` parameter in `RaindexOrder::get_trades_list` method (in crates/common/src/raindex_client/trades.rs) is kept for backwards compatibility with subgraph logic, but the LocalDb fast-path intentionally returns all trades without implementing pagination.

Applied to files:

  • crates/common/src/raindex_client/trades.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/orders.rs
  • crates/common/src/raindex_client/local_db/orders.rs
  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/vaults.rs
📚 Learning: 2025-10-14T07:51:55.148Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2202
File: crates/common/src/raindex_client/local_db/sync.rs:33-34
Timestamp: 2025-10-14T07:51:55.148Z
Learning: In `crates/common/src/raindex_client/local_db/sync.rs`, the hard-coded `DEFAULT_SYNC_CHAIN_ID` constant (set to `SUPPORTED_LOCAL_DB_CHAINS[0]`) will be replaced with proper chain ID handling in downstream PRs as part of the multi-network/orderbook implementation.

Applied to files:

  • crates/common/src/raindex_client/trades.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/orders.rs
  • crates/common/src/raindex_client/local_db/orders.rs
  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/vaults.rs
📚 Learning: 2025-10-06T11:44:07.888Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2145
File: crates/common/src/raindex_client/local_db/query/create_tables/query.sql:71-72
Timestamp: 2025-10-06T11:44:07.888Z
Learning: The local DB feature in the rain.orderbook codebase is not live yet (as of PR #2145), so schema migrations for existing databases are not required when modifying table structures in `crates/common/src/raindex_client/local_db/query/create_tables/query.sql`.

Applied to files:

  • crates/common/src/raindex_client/trades.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/local_db/orders.rs
  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/vaults.rs
📚 Learning: 2025-10-06T11:13:29.956Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2123
File: crates/common/src/raindex_client/local_db/mod.rs:23-29
Timestamp: 2025-10-06T11:13:29.956Z
Learning: In `crates/common/src/raindex_client/local_db/mod.rs`, the `Default` implementation for `LocalDb` that creates an RPC client pointing to `http://localhost:4444` is acceptable because the RPC client must be explicitly configured before actual usage in production scenarios.

Applied to files:

  • crates/common/src/raindex_client/trades.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/orders.rs
  • crates/common/src/raindex_client/local_db/orders.rs
  • crates/common/src/raindex_client/local_db/pipeline/runner/scheduler.rs
  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/vaults.rs
📚 Learning: 2025-10-18T10:38:41.273Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2237
File: crates/common/src/raindex_client/local_db/sync.rs:79-89
Timestamp: 2025-10-18T10:38:41.273Z
Learning: In `crates/common/src/raindex_client/local_db/sync.rs`, the sync_database method currently only supports indexing a single orderbook per chain ID, which is why `.first()` is used to select the orderbook configuration. Multi-orderbook support per chain ID is planned for future PRs.

Applied to files:

  • crates/common/src/raindex_client/trades.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/orders.rs
  • crates/common/src/raindex_client/local_db/orders.rs
  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/vaults.rs
📚 Learning: 2025-08-01T09:07:20.383Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2044
File: packages/orderbook/README.md:186-189
Timestamp: 2025-08-01T09:07:20.383Z
Learning: In the rainlanguage/rain.orderbook project, Rust methods on structs like RaindexVaultsList are exported as JavaScript getters in WASM bindings using #[wasm_bindgen(getter)]. This means while the Rust code uses method calls like items(), the JavaScript/WASM API exposes them as property access like .items. The README.md correctly documents the JavaScript API surface, not the Rust implementation details.

Applied to files:

  • crates/common/src/raindex_client/trades.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/orders.rs
  • crates/common/src/raindex_client/vaults.rs
📚 Learning: 2025-08-02T02:34:32.237Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2036
File: crates/js_api/src/filters/raindex_filter_store.rs:446-533
Timestamp: 2025-08-02T02:34:32.237Z
Learning: In the rainlanguage/rain.orderbook project's RaindexFilterStore WASM tests (crates/js_api/src/filters/raindex_filter_store.rs), brusherru decided to focus on testing only methods without side effects (that don't use web_sys) due to difficulties with mocking localStorage and window APIs in the WASM test environment. This pragmatic approach tests pure logic separately from browser integration.

Applied to files:

  • crates/common/src/raindex_client/trades.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/orders.rs
  • crates/common/src/raindex_client/local_db/orders.rs
📚 Learning: 2025-07-04T10:24:56.163Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1956
File: crates/common/src/raindex_client/trades.rs:215-223
Timestamp: 2025-07-04T10:24:56.163Z
Learning: In the rain.orderbook codebase, the get_trade_count method implementation that fetches all trades to count them is intentionally consistent with previous implementations and not considered a performance issue, as indicated by findolor for the trades counting functionality in crates/common/src/raindex_client/trades.rs.

Applied to files:

  • crates/common/src/raindex_client/trades.rs
📚 Learning: 2025-06-06T16:38:04.182Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1913
File: Cargo.toml:55-55
Timestamp: 2025-06-06T16:38:04.182Z
Learning: In rain.orderbook repository, during PR chains involving dependency updates, wasm-bindgen-utils may temporarily point to git commits that don't contain the full required functionality, with the understanding that subsequent PRs in the chain will update it to the correct commit.

Applied to files:

  • crates/common/src/raindex_client/trades.rs
📚 Learning: 2025-07-16T10:40:05.717Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2000
File: crates/common/src/raindex_client/vaults.rs:183-183
Timestamp: 2025-07-16T10:40:05.717Z
Learning: In the rainlanguage/rain.orderbook codebase, user findolor considers breaking changes from Option<U256> to U256 for required fields like decimals in RaindexVaultToken to be acceptable and safe, even when they affect multiple usage sites across the codebase.

Applied to files:

  • crates/common/src/raindex_client/trades.rs
  • crates/common/src/raindex_client/orders.rs
  • crates/common/src/raindex_client/vaults.rs
📚 Learning: 2025-06-20T07:26:50.488Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1941
File: crates/settings/src/yaml/orderbook.rs:112-123
Timestamp: 2025-06-20T07:26:50.488Z
Learning: In crates/settings/src/yaml/orderbook.rs, the user prefers to keep the get_network_by_chain_id implementation simple with O(n) lookup rather than adding caching complexity for performance optimization, even if the method might be called frequently.

Applied to files:

  • crates/common/src/raindex_client/trades.rs
📚 Learning: 2025-10-06T11:28:30.692Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2145
File: crates/common/src/raindex_client/local_db/query/fetch_orders/query.sql:6-7
Timestamp: 2025-10-06T11:28:30.692Z
Learning: In `crates/common/src/raindex_client/local_db/query/fetch_orders/query.sql`, the orderbook_address is currently hardcoded to '0x2f209e5b67A33B8fE96E28f24628dF6Da301c8eB' because the system only supports a single orderbook at the moment. Multiorderbook logic is not yet implemented and will be added in the future.

Applied to files:

  • crates/common/src/raindex_client/trades.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/orders.rs
  • crates/common/src/raindex_client/local_db/orders.rs
  • crates/common/src/raindex_client/mod.rs
📚 Learning: 2025-10-02T19:17:20.332Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2163
File: crates/common/src/raindex_client/orders.rs:738-741
Timestamp: 2025-10-02T19:17:20.332Z
Learning: In crates/common/src/raindex_client/orders.rs, fetch_dotrain_source() is intentionally called in try_from_sg_order for every order conversion because the dotrain source information is needed immediately. A future optimization with local DB logic is planned to eliminate the network round-trip concern.

Applied to files:

  • crates/common/src/raindex_client/trades.rs
  • crates/common/src/raindex_client/orders.rs
  • crates/common/src/raindex_client/local_db/orders.rs
  • crates/common/src/raindex_client/mod.rs
📚 Learning: 2025-06-17T16:32:04.554Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1903
File: crates/js_api/src/gui/order_operations.rs:124-134
Timestamp: 2025-06-17T16:32:04.554Z
Learning: In the rain.orderbook codebase, RPC lists are typically small (2 items maximum), so performance optimizations around cloning and converting small Vec<Url> collections are generally unnecessary.

Applied to files:

  • crates/common/src/raindex_client/trades.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/orders.rs
  • crates/common/src/raindex_client/mod.rs
📚 Learning: 2025-07-15T08:01:38.534Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1994
File: crates/common/src/raindex_client/vaults.rs:282-292
Timestamp: 2025-07-15T08:01:38.534Z
Learning: In the rainlanguage/rain.orderbook codebase, findolor prefers to avoid concurrency optimizations like using `futures::future::try_join_all` for parallel processing of balance changes, considering such optimizations "not that critical at the moment" when the performance impact is minimal.

Applied to files:

  • crates/common/src/raindex_client/trades.rs
  • crates/common/src/raindex_client/orders.rs
  • crates/common/src/raindex_client/mod.rs
📚 Learning: 2025-07-04T10:27:22.544Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1956
File: crates/common/src/raindex_client/orders.rs:609-609
Timestamp: 2025-07-04T10:27:22.544Z
Learning: In the rainlanguage/rain.orderbook codebase, user findolor prefers not to implement overflow protection for trades count casting (usize to u16) at this time, considering it unnecessary for the current scope since the practical risk of orders having 65,535+ trades is extremely low.

Applied to files:

  • crates/common/src/raindex_client/trades.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-10-06T14:41:41.909Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2159
File: crates/cli/src/commands/local_db/sync/runner/mod.rs:52-113
Timestamp: 2025-10-06T14:41:41.909Z
Learning: The local DB sync CLI command (crates/cli/src/commands/local_db/sync/) is designed for CI-only usage, and simple println! statements are preferred over structured logging for status messages.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/local_db/pipeline/runner/scheduler.rs
  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/vaults.rs
📚 Learning: 2025-08-26T14:52:37.000Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2099
File: crates/common/src/hyper_rpc.rs:3-7
Timestamp: 2025-08-26T14:52:37.000Z
Learning: In the rain.orderbook codebase, creating new reqwest::Client instances per request in HyperRpcClient is not considered an issue by the maintainers, despite potential performance benefits of client reuse.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/orders.rs
  • crates/common/src/raindex_client/mod.rs
📚 Learning: 2025-05-19T13:40:56.080Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1858
File: crates/subgraph/src/orderbook_client/mod.rs:54-58
Timestamp: 2025-05-19T13:40:56.080Z
Learning: The `wasm_bindgen_utils` crate in the Rain Orderbook project handles conditional compilation for `JsValue` and `JsError` internally, allowing `impl From<Error> for JsValue` to work on non-WASM targets without explicit cfg guards.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
📚 Learning: 2025-06-24T13:36:28.797Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1950
File: crates/common/src/raindex_client/orders.rs:301-301
Timestamp: 2025-06-24T13:36:28.797Z
Learning: In the RaindexClient codebase, when Arc::new(RwLock::new(self.clone())) is used (e.g., in get_orders and get_order_by_hash methods), this creates new Arc/RwLock wrappers around a cloned RaindexClient, but the underlying client data is functionally the same. This pattern is used to provide the correct Arc<RwLock<RaindexClient>> type expected by RaindexOrder::try_from_sg_order() method.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/orders.rs
  • crates/common/src/raindex_client/local_db/orders.rs
  • crates/common/src/raindex_client/mod.rs
📚 Learning: 2025-06-20T07:51:08.790Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1941
File: crates/js_api/src/raindex/vaults.rs:175-181
Timestamp: 2025-06-20T07:51:08.790Z
Learning: In the RaindexClient vault methods, `&self` parameters are intentionally kept for API consistency to make all vault operations instance methods, even when the methods don't use client state. This is a design preference for maintaining a uniform interface.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/vaults.rs
📚 Learning: 2025-05-20T10:20:08.206Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1859
File: crates/quote/src/quote_debug.rs:472-492
Timestamp: 2025-05-20T10:20:08.206Z
Learning: In the Rain Orderbook codebase, the `#[tokio::test(flavor = "multi_thread")]` annotation is specifically needed for tests that use `LocalEvm`, not just for consistency across all async tests.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-10-21T05:15:50.518Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2256
File: crates/common/src/raindex_client/local_db/query/fetch_tables.rs:7-7
Timestamp: 2025-10-21T05:15:50.518Z
Learning: In Rust 2021+ editions, passing a reference to a temporary into an async function within the same expression (e.g., `exec.query_json(&fetch_tables_stmt()).await`) is safe and idiomatic. The temporary lifetime is extended across the await point, so this pattern should not be flagged as an issue.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-04-30T09:28:36.960Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1715
File: crates/js_api/src/common/mod.rs:111-118
Timestamp: 2025-04-30T09:28:36.960Z
Learning: In the rain.orderbook repository, the WASM tests are already properly configured with conditional compilation using `#[cfg(target_family = "wasm")]` and `#[cfg(not(target_family = "wasm"))]`, and don't require additional `wasm_bindgen_test_configure!(run_in_browser)` directives.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-05-27T06:16:35.738Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1874
File: tauri-app/src-tauri/src/transaction_status.rs:69-127
Timestamp: 2025-05-27T06:16:35.738Z
Learning: In tauri-app/src-tauri/src/transaction_status.rs, directly accessing internal RwLock state in tests using `notice.0.read().unwrap()` is acceptable and does not require encapsulation through public getter methods.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
📚 Learning: 2025-11-25T16:50:31.752Z
Learnt from: CR
Repo: rainlanguage/rain.orderbook PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T16:50:31.752Z
Learning: Applies to crates/integration_tests/**/*.rs : Rust: write tests using `cargo test`; integration tests live in `crates/integration_tests`. Prefer `insta` snapshots and `proptest` where helpful

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
📚 Learning: 2025-10-06T10:23:57.479Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2111
File: packages/webapp/src/routes/db-playground/+page.svelte:149-153
Timestamp: 2025-10-06T10:23:57.479Z
Learning: The db-playground page at packages/webapp/src/routes/db-playground/+page.svelte is used for testing purposes, and production-level concerns (such as invalid RPC tokens) are acceptable in this context.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
📚 Learning: 2025-07-18T10:31:05.498Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2008
File: crates/common/src/raindex_client/add_orders.rs:85-86
Timestamp: 2025-07-18T10:31:05.498Z
Learning: In the rainlanguage/rain.orderbook codebase, cfg-guarded imports like `#[cfg(not(target_family = "wasm"))] use super::*;` in test modules are sometimes needed to fix compiler warnings, even when similar imports exist in nested sub-modules. These should not be removed as they serve a specific purpose in the compilation process.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-05-14T05:51:50.277Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1715
File: crates/js_api/src/common/mod.rs:55-59
Timestamp: 2025-05-14T05:51:50.277Z
Learning: In the Rain Orderbook project, the error handling for WASM exported functions uses WasmEncodedError which includes both the original error message and a human-readable version, making direct modification of the JsValue conversion unnecessary.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
📚 Learning: 2025-10-21T05:16:07.124Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2256
File: crates/common/src/raindex_client/local_db/query/fetch_tables.rs:46-52
Timestamp: 2025-10-21T05:16:07.124Z
Learning: In Rust projects using wasm_bindgen_utils, the glob import `use wasm_bindgen_utils::prelude::*;` re-exports `Closure` from wasm_bindgen, so `Closure::wrap` can be used without explicitly importing `use wasm_bindgen::prelude::Closure;`.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
📚 Learning: 2025-06-24T13:30:02.968Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1950
File: crates/common/src/raindex_client/transactions.rs:34-38
Timestamp: 2025-06-24T13:30:02.968Z
Learning: When using #[wasm_bindgen] on an impl block, all methods within that block must have wasm_bindgen attributes, even if they are conditionally compiled for non-WASM targets using #[cfg(not(target_family = "wasm"))]. Removing these attributes causes compiler errors because the wasm_bindgen macro expansion processes the entire impl block and expects consistent attribute usage across all methods.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
📚 Learning: 2025-10-19T15:52:58.239Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2245
File: crates/common/src/raindex_client/local_db/executor.rs:17-46
Timestamp: 2025-10-19T15:52:58.239Z
Learning: When formatting JsValue errors in Rust wasm code using `{:?}`, the Debug output is sufficiently informative and does not produce unhelpful "[object Object]" strings in practice.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
📚 Learning: 2025-05-14T04:49:14.621Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1710
File: crates/quote/Cargo.toml:30-30
Timestamp: 2025-05-14T04:49:14.621Z
Learning: In the rain.orderbook repository, wasm-bindgen-utils is intentionally used as an unconditional dependency because non-wasm targets (like tests) sometimes need to use it.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-05-14T05:13:59.713Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1744
File: crates/subgraph/src/orderbook_client.rs:44-46
Timestamp: 2025-05-14T05:13:59.713Z
Learning: In the rain.orderbook project, WASM dependencies are intentionally made available in non-WASM targets to facilitate testing of WASM-related functionality, so conditional compilation guards like `#[cfg(target_family = "wasm")]` should not be added to imports or implementations that may be needed for tests.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-08-02T03:55:25.215Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2036
File: packages/orderbook/test/js_api/filters.test.ts:19-36
Timestamp: 2025-08-02T03:55:25.215Z
Learning: In the rainlanguage/rain.orderbook project's WASM tests, the pattern of chaining `.value!` calls on WASM result types (like from VaultsFilterBuilder methods) is the established and preferred approach for handling WASM results, and should not be refactored into intermediate variables as it would add unnecessary verbosity without improving the code.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-08-01T07:44:53.910Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2036
File: crates/js_api/src/filters/raindex_filter_store.rs:319-336
Timestamp: 2025-08-01T07:44:53.910Z
Learning: In the rainlanguage/rain.orderbook project's RaindexFilterStore (crates/js_api/src/filters/raindex_filter_store.rs), the team chose a simplified monolithic approach with hard-coded keys and default auto-save behavior over configurable stores. The update_vaults method intentionally auto-saves to both localStorage and URL after each update as the default behavior, following a design evolution from a previous configurable approach.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/local_db/orders.rs
  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/vaults.rs
📚 Learning: 2025-06-17T16:54:43.176Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1903
File: crates/common/src/deposit.rs:63-64
Timestamp: 2025-06-17T16:54:43.176Z
Learning: In the rain.orderbook codebase, the maintainer findolor prefers to keep the current implementation that clones the rpcs vector when calling ReadableClient::new_from_urls rather than optimizing it to avoid the clone or adding early validation for empty rpcs. Performance micro-optimizations like avoiding vector clones in this context are not a priority.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
📚 Learning: 2025-05-09T05:28:22.089Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1744
File: crates/js_api/src/subgraph/order.rs:109-114
Timestamp: 2025-05-09T05:28:22.089Z
Learning: In the rain.orderbook project, SubgraphError contains or converts from OrderbookSubgraphClientError, so using OrderbookSubgraphClientError in error creation followed by a conversion to SubgraphError (via ? operator) is acceptable.

Applied to files:

  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-07-21T16:34:31.193Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1911
File: crates/subgraph/src/types/impls.rs:7-15
Timestamp: 2025-07-21T16:34:31.193Z
Learning: In the rainlanguage/rain.orderbook codebase, user 0xgleb considers breaking changes that remove unsafe default behaviors to be intentional and acceptable. Specifically, the get_decimals() method in crates/subgraph/src/types/impls.rs was intentionally changed to return MissingDecimals error instead of defaulting to 18 decimals, as defaulting to 18 is considered unsafe and should never have been done.

Applied to files:

  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-06-24T08:46:03.368Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1947
File: crates/common/src/raindex_client/orders.rs:98-125
Timestamp: 2025-06-24T08:46:03.368Z
Learning: In the vault merging logic in crates/common/src/raindex_client/orders.rs, optimization isn't necessary because the maximum list items are usually around 5 items. For such small datasets, the simple three-loop approach is preferred over HashMap-based optimization due to clarity and minimal performance impact.

Applied to files:

  • crates/common/src/raindex_client/orders.rs
  • crates/common/src/raindex_client/local_db/orders.rs
  • crates/common/src/raindex_client/vaults.rs
📚 Learning: 2025-05-09T05:21:40.234Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1744
File: crates/js_api/src/subgraph/vault.rs:19-37
Timestamp: 2025-05-09T05:21:40.234Z
Learning: In the rain.orderbook project, the developer prefers to use tuple structs for WASM wrappers (like VaultCalldataResult, GetVaultsResult) rather than structs with named fields.

Applied to files:

  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-10-13T12:57:05.900Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2198
File: crates/common/src/raindex_client/local_db/query/fetch_store_addresses/mod.rs:7-8
Timestamp: 2025-10-13T12:57:05.900Z
Learning: In the rain.orderbook repository, using unqualified serde helper names (e.g., `#[serde(with = "serde_address")]`) that rely on glob imports is acceptable and does not need to be changed to fully qualified paths.

Applied to files:

  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-06-18T18:24:32.049Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1938
File: crates/settings/src/yaml/orderbook.rs:180-199
Timestamp: 2025-06-18T18:24:32.049Z
Learning: In crates/settings/src/yaml/orderbook.rs, the user prefers to avoid refactoring duplicate search logic between get_orderbook_by_address and get_orderbook_by_network_key when there are only 2 functions, indicating they would consider it if more similar functions are added in the future.

Applied to files:

  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-07-23T10:51:12.278Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2012
File: crates/js_api/src/registry.rs:233-252
Timestamp: 2025-07-23T10:51:12.278Z
Learning: In the rainlanguage/rain.orderbook codebase, findolor considers the pattern of creating a partially initialized struct instance within a constructor and then populating it through async operations to be acceptable, as long as the partial state is never exposed to users and the constructor returns Result<T, E> with proper error propagation using the ? operator.

Applied to files:

  • crates/common/src/raindex_client/orders.rs
  • crates/common/src/raindex_client/mod.rs
📚 Learning: 2025-06-18T19:24:40.518Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1938
File: crates/settings/src/yaml/orderbook.rs:185-199
Timestamp: 2025-06-18T19:24:40.518Z
Learning: In crates/settings/src/yaml/orderbook.rs, the user prefers not to refactor get_orderbook_by_network_key to handle multiple orderbooks per network key since their current architecture maintains a one-to-one mapping between orderbooks and networks. They would consider the refactoring if the system evolves to support multiple orderbooks per network in the future.

Applied to files:

  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-05-19T11:40:45.864Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1858
File: crates/subgraph/src/orderbook_client/order.rs:94-108
Timestamp: 2025-05-19T11:40:45.864Z
Learning: Order hashes are unique in the subgraph data model, so a query by hash (`order_detail_by_hash`) will never return multiple orders with the same hash.

Applied to files:

  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-06-18T18:18:44.330Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1938
File: crates/js_api/src/raindex/mod.rs:92-99
Timestamp: 2025-06-18T18:18:44.330Z
Learning: In crates/js_api/src/raindex/mod.rs, the get_subgraph_url_for_chain method and get_multi_subgraph_args method intentionally duplicate lookup logic because they serve different purposes: get_subgraph_url_for_chain returns only the URL string, while get_multi_subgraph_args returns MultiSubgraphArgs structures containing both URL and network information (name/label). This duplication is acceptable and by design.

Applied to files:

  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-07-31T19:34:11.716Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2044
File: crates/common/src/raindex_client/vaults_list.rs:363-423
Timestamp: 2025-07-31T19:34:11.716Z
Learning: In the rainlanguage/rain.orderbook project, for WASM-exposed functionality like VaultsList, the team prefers to keep comprehensive tests in the non-WASM environment due to the complexity of recreating objects like RaindexVaults in WASM. WASM tests focus on basic functionality and error cases since the WASM code reuses the already-tested non-WASM implementation.

Applied to files:

  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-06-17T16:21:24.384Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1903
File: crates/settings/src/yaml/orderbook.rs:371-377
Timestamp: 2025-06-17T16:21:24.384Z
Learning: In crates/settings/src/yaml/orderbook.rs tests, the user findolor considers RPC ordering in Vec<Url> assertions to be intentional and not a test brittleness issue. The ordering of RPCs in tests should be preserved as specified.

Applied to files:

  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-04-29T06:19:15.446Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1706
File: crates/quote/src/js_api/mod.rs:57-61
Timestamp: 2025-04-29T06:19:15.446Z
Learning: In the rain.orderbook codebase, the `get_id` function is designed to use `U256::from_str()` rather than `U256::from_hex()` for parsing order hashes, despite the potential for hex string inputs.

Applied to files:

  • crates/common/src/raindex_client/local_db/orders.rs
📚 Learning: 2025-07-30T07:41:39.271Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2012
File: crates/js_api/src/registry.rs:485-512
Timestamp: 2025-07-30T07:41:39.271Z
Learning: In crates/js_api/src/registry.rs, findolor considers the current concurrent fetching of order files using futures::future::join_all without concurrency limits to be acceptable, preferring the simple approach over adding concurrency limiting mechanisms for the DotrainRegistry implementation.

Applied to files:

  • crates/common/src/raindex_client/local_db/orders.rs
📚 Learning: 2025-10-06T14:12:05.824Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2155
File: crates/common/src/raindex_client/local_db/query/fetch_order_trades/query.sql:86-108
Timestamp: 2025-10-06T14:12:05.824Z
Learning: CTEs (Common Table Expressions) are not supported in the local DB SQL implementation used in the rain.orderbook codebase.

Applied to files:

  • crates/common/src/raindex_client/mod.rs
📚 Learning: 2025-10-06T13:03:35.337Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2146
File: crates/cli/src/commands/local_db/README.md:22-106
Timestamp: 2025-10-06T13:03:35.337Z
Learning: In the rain.orderbook repository, `cargo run` commands work without the `--` separator (e.g., `cargo run local-db fetch-events` works directly). Do not suggest adding `--` before CLI arguments in cargo run examples for this repository.

Applied to files:

  • crates/common/src/raindex_client/mod.rs
📚 Learning: 2025-06-17T16:49:55.915Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1903
File: crates/common/src/erc20.rs:42-48
Timestamp: 2025-06-17T16:49:55.915Z
Learning: In the rain.orderbook codebase, the team prefers not to cache ReadableClientHttp instances or URL strings in ERC20 struct methods, even when there might be repeated allocations. The current simple approach of recreating clients on each call is acceptable.

Applied to files:

  • crates/common/src/raindex_client/mod.rs
📚 Learning: 2025-07-16T05:52:05.576Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1994
File: crates/common/src/raindex_client/vaults.rs:59-59
Timestamp: 2025-07-16T05:52:05.576Z
Learning: User findolor prefers to handle documentation updates for getter methods in batch via dedicated PRs rather than addressing them individually during feature development, as mentioned for the formatted amount string fields in crates/common/src/raindex_client/vaults.rs.

Applied to files:

  • crates/common/src/raindex_client/vaults.rs
📚 Learning: 2025-07-04T10:26:24.289Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1956
File: crates/common/src/raindex_client/mod.rs:116-135
Timestamp: 2025-07-04T10:26:24.289Z
Learning: In crates/common/src/raindex_client/mod.rs, the get_multi_subgraph_args method intentionally treats Some(empty vector) the same as None for chain_ids parameter. Both cases should return all networks to support UI behavior where no selection or empty selection means "show all networks". Only when specific chain IDs are provided should the results be filtered.

Applied to files:

  • crates/common/src/raindex_client/vaults.rs
🧬 Code graph analysis (4)
crates/common/src/raindex_client/trades.rs (4)
crates/common/src/raindex_client/mod.rs (1)
  • local_db (228-230)
crates/common/src/raindex_client/orders.rs (2)
  • order_hash (178-180)
  • order_hash (246-248)
crates/common/src/raindex_client/local_db/query/fetch_order_trades.rs (1)
  • fetch_order_trades (7-16)
crates/common/src/raindex_client/local_db/query/fetch_order_trades_count.rs (1)
  • fetch_order_trades_count (7-17)
crates/common/src/raindex_client/local_db/pipeline/runner/scheduler.rs (1)
crates/common/src/raindex_client/local_db/mod.rs (4)
  • new (43-81)
  • new (142-144)
  • new (237-243)
  • from_js_callback (83-85)
crates/common/src/raindex_client/mod.rs (1)
crates/common/src/raindex_client/local_db/mod.rs (4)
  • new (43-81)
  • new (142-144)
  • new (237-243)
  • from_js_callback (83-85)
crates/common/src/raindex_client/vaults.rs (4)
crates/common/src/raindex_client/mod.rs (8)
  • local_db (228-230)
  • from (247-251)
  • from (329-331)
  • from (335-337)
  • from (341-343)
  • from (462-464)
  • from (468-473)
  • new (115-137)
crates/common/src/raindex_client/local_db/query/fetch_vaults.rs (1)
  • from (30-32)
crates/common/src/raindex_client/local_db/query/fetch_vault_balance_changes.rs (1)
  • fetch_vault_balance_changes (7-15)
crates/common/src/local_db/mod.rs (2)
  • new (344-349)
  • is_chain_supported_local_db (352-354)
🪛 Gitleaks (8.29.1)
crates/common/src/raindex_client/orders.rs

[high] 1675-1675: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (18)
  • GitHub Check: git-clean
  • GitHub Check: test
  • GitHub Check: test
  • GitHub Check: standard-tests (ubuntu-latest, test-js-bindings)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-legal)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-wasm-browser-test)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-rs-static)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-rs-artifacts, true)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-test)
  • GitHub Check: standard-tests (ubuntu-latest, ob-rs-test, true)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-wasm-artifacts)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-wasm-test)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-static)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-artifacts)
  • GitHub Check: test
  • GitHub Check: Deploy-Docs-Preview
  • GitHub Check: Deploy-Preview-Push
  • GitHub Check: build-tauri (ubuntu-22.04, true)
🔇 Additional comments (15)
crates/common/src/raindex_client/trades.rs (1)

141-149: LocalDb-based trades fast path wiring looks correct and preserves fallback behavior

Both get_trades_list and get_trade_count now obtain an optional LocalDb from the client, gate it by is_chain_supported_local_db, and pass &local_db into the typed query helpers. When local_db is absent or the chain isn’t supported, the code falls back to the existing subgraph calls, so behavior is preserved with a cleaner executor abstraction.

Also applies to: 255-266

crates/common/src/raindex_client/mod.rs (1)

2-2: RaindexClient local DB handle refactor is consistent and self-contained

Storing LocalDb inside Rc<RefCell<Option<_>>>, initializing it to None in new, and having set_local_db_callback construct LocalDb via from_js_callback gives a clear, typed abstraction instead of a raw JS callback. The private local_db() accessor cleanly exposes an Option<LocalDb> to internal callers without affecting the public API other than the existing setDbCallback entry point.

Also applies to: 85-90, 132-137, 139-151, 228-230

crates/common/src/raindex_client/local_db/orders.rs (1)

1-23: LocalDbOrders data-source implementation correctly mirrors existing semantics

LocalDbOrders<'_> cleanly wraps &LocalDb and an Rc<RaindexClient>, with:

  • parse_io_vaults robustly handling None, empty strings, and nullable entries, then ordering by ioIndex.
  • list constructing FetchOrdersArgs from GetOrdersFilters, only overriding chain_ids when a non-empty list is provided, and using LocalDb as the executor.
  • get_by_hash narrowing by chain, orderbook, and hash and converting the first result via RaindexOrder::from_local_db_order.

The ignored _page parameter is consistent with the existing design where local DB fast paths return all records without pagination. Based on learnings, this matches the intended behavior for local DB-backed queries.

Also applies to: 33-55, 57-89, 91-115

crates/common/src/raindex_client/local_db/mod.rs (1)

159-197: Scheduler and JS-callback integration with LocalDb are wired correctly

start_local_db_scheduler now:

  • Reads self.local_db, errors with a clear "Local DB not set" RaindexError::JsError when missing.
  • Stops any existing scheduler handle before starting a new one.
  • Passes the configured LocalDb instance into scheduler::start, and stores the returned SchedulerHandle back into local_db_scheduler.

The wasm tests around local_db_from_js_callback_executes_queries and local_db_from_js_callback_surfaces_errors demonstrate that:

  • set_local_db_callback correctly builds a LocalDb from a JS callback.
  • LocalDb delegates query_json/query_text through JsCallbackExecutor, returning decoded rows and surfacing database errors as LocalDbQueryError::Database.

This end-to-end path from JS callback → LocalDb → scheduler looks coherent and well-covered by tests.

Also applies to: 295-311, 343-355, 386-400, 402-424, 426-523

crates/common/src/raindex_client/vaults.rs (1)

1-1: Vaults local DB integration and chain ID routing look correct and well-covered by tests

  • RaindexVault::get_balance_changes now cleanly prefers LocalDb when the chain is supported and a local DB is configured, using OrderbookIdentifier and vault/token identifiers consistent with the query helpers, and falls back to subgraph when there are no local rows, preserving existing behavior.
  • RaindexClient::get_vaults:
    • Treats chain_ids: None and Some(ChainIds([])) as “all networks” via the get_vaults_sg(None, ...) fallback, matching the documented semantics where empty selection means “all networks”.
    • Splits IDs into local-DB-supported vs subgraph-only, folds unsupported-local chains back into the subgraph set when no local DB is configured, and queries both sources (local via get_vaults_local_db, remote via get_vaults_sg) before merging results.
  • get_vaults_local_db’s switch to a concrete LocalDb executor and get_vault’s preference for get_vault_local_db(&local_db, ...) keep the data-flow consistent with the new LocalDb abstraction used elsewhere.
  • The added WASM tests exercise the local DB paths end-to-end (vault listing, single vault fetch, balance changes, and filters), including SQL generation and parameter binding, providing good coverage for the refactor.

Overall, the vault-related LocalDb refactor is coherent and maintains expected behavior.

Also applies to: 12-12, 308-351, 1083-1147, 1203-1239, 1351-1416, 1615-1917

crates/common/src/raindex_client/orders.rs (6)

37-60: Well-structured data source abstraction.

The SubgraphOrders wrapper and OrdersDataSource trait provide clean separation for different data sources. Using #[async_trait(?Send)] is appropriate for WASM compatibility.


803-803: Deriving Default for GetOrdersFilters enables cleaner API usage.

This is a good addition that enables unwrap_or_default() at line 593.


971-998: Test helper StaticJsonExec is well-designed.

The mock executor implementation properly implements LocalDbQueryExecutor trait for testing purposes, allowing controlled JSON responses for unit tests.


1671-1753: Comprehensive test coverage for local DB orders parsing.

The local_db_orders_parse_ios test validates the full flow of parsing local DB orders with inputs/outputs. The static analysis hint on line 1675 about "Generic API Key" is a false positive - 0x0987654321098765432109876543210987654321 is an Ethereum address format, not an API key.


1784-1857: Good test for mixed local/subgraph routing.

The get_orders_routes_between_local_and_subgraph test properly validates that orders from both sources are combined correctly when chain IDs span local DB-supported and non-supported chains.


723-731: > Likely an incorrect or invalid review comment.

crates/common/src/raindex_client/local_db/pipeline/runner/scheduler.rs (4)

33-47: Trait signature correctly updated to use &LocalDb.

The SchedulerRunner trait and its implementation for DefaultClientRunner properly use &LocalDb reference for database operations. This aligns with the broader refactoring replacing direct callback usage.


64-76: API visibility appropriately narrowed to pub(crate).

The start function is now pub(crate) and accepts LocalDb by value. Since LocalDb is Clone and internally uses Rc, passing by value is efficient.


150-152: Test helper noop_local_db properly creates mock LocalDb.

This leverages LocalDb::from_js_callback with a no-op JS function, providing an appropriate test double for the scheduler tests.


176-196: RecordingRunner test mock correctly updated.

The mock runner properly accepts &LocalDb (unused in tests as expected) while maintaining the outcome-based test behavior.

Comment thread crates/common/src/raindex_client/local_db/mod.rs
Comment thread crates/common/src/raindex_client/orders.rs Outdated
Comment thread crates/common/src/raindex_client/orders.rs
Base automatically changed from local-db-orders-query to main December 1, 2025 16:04
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
crates/common/src/raindex_client/orders.rs (1)

794-803: Addresses prior review feedback on error semantics.

The use of RaindexError::OrderNotFound instead of OrderbookNotFound correctly distinguishes between a missing order and a missing orderbook, improving error clarity for callers.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6ce4749 and be3b624.

📒 Files selected for processing (5)
  • crates/common/src/raindex_client/local_db/mod.rs (8 hunks)
  • crates/common/src/raindex_client/local_db/pipeline/runner/mod.rs (2 hunks)
  • crates/common/src/raindex_client/mod.rs (8 hunks)
  • crates/common/src/raindex_client/orders.rs (11 hunks)
  • crates/common/src/raindex_client/vaults.rs (6 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
crates/**/*.rs

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

crates/**/*.rs: For Rust crates in crates/*, run lints using nix develop -c cargo clippy --workspace --all-targets --all-features -D warnings
For Rust crates in crates/*, run tests using nix develop -c cargo test --workspace or --package <crate>

Files:

  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/local_db/pipeline/runner/mod.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/vaults.rs
  • crates/common/src/raindex_client/orders.rs
**/crates/**

📄 CodeRabbit inference engine (AGENTS.md)

Rust workspace organized as crates/* with subdirectories: cli, common, bindings, js_api, quote, subgraph, settings, math, integration_tests

Files:

  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/local_db/pipeline/runner/mod.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/vaults.rs
  • crates/common/src/raindex_client/orders.rs
**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

**/*.rs: Rust: format code with nix develop -c cargo fmt --all
Rust: lint with nix develop -c rainix-rs-static (preconfigured flags included)
Rust: crates and modules use snake_case; types use PascalCase

Files:

  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/local_db/pipeline/runner/mod.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/vaults.rs
  • crates/common/src/raindex_client/orders.rs
🧠 Learnings (62)
📓 Common learnings
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2145
File: crates/common/src/raindex_client/local_db/query/create_tables/query.sql:71-72
Timestamp: 2025-10-06T11:44:07.888Z
Learning: The local DB feature in the rain.orderbook codebase is not live yet (as of PR #2145), so schema migrations for existing databases are not required when modifying table structures in `crates/common/src/raindex_client/local_db/query/create_tables/query.sql`.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1956
File: crates/common/src/fuzz/mod.rs:64-64
Timestamp: 2025-07-04T09:02:57.301Z
Learning: In rainlanguage/rain.orderbook, user findolor prefers to limit type consistency changes to only the parts directly related to the current work scope. For example, when updating chain_id fields from u64 to u32 in fuzz-related code, unrelated files like tauri-app wallet commands can remain as u64 if they serve different purposes and aren't part of the current changes.
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2117
File: crates/js_api/src/gui/select_tokens.rs:421-424
Timestamp: 2025-09-02T08:04:34.729Z
Learning: User findolor in the rainlanguage/rain.orderbook codebase prefers not to change test code when tests are already passing, even if there appear to be type mismatches or potential issues. Working tests should be left alone unless there are actual errors.
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2237
File: crates/common/src/raindex_client/local_db/sync.rs:79-89
Timestamp: 2025-10-18T10:38:41.273Z
Learning: In `crates/common/src/raindex_client/local_db/sync.rs`, the sync_database method currently only supports indexing a single orderbook per chain ID, which is why `.first()` is used to select the orderbook configuration. Multi-orderbook support per chain ID is planned for future PRs.
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1938
File: crates/js_api/src/raindex/orders.rs:1-11
Timestamp: 2025-06-18T12:54:47.807Z
Learning: In the rain.orderbook repository, findolor prefers to keep unused imports in place when they will be used in upcoming follow-up PRs, rather than removing and re-adding them during incremental development.
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1994
File: crates/common/src/raindex_client/vaults.rs:282-292
Timestamp: 2025-07-15T08:01:38.534Z
Learning: In the rainlanguage/rain.orderbook codebase, findolor prefers to avoid concurrency optimizations like using `futures::future::try_join_all` for parallel processing of balance changes, considering such optimizations "not that critical at the moment" when the performance impact is minimal.
📚 Learning: 2025-10-14T07:51:55.148Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2202
File: crates/common/src/raindex_client/local_db/sync.rs:33-34
Timestamp: 2025-10-14T07:51:55.148Z
Learning: In `crates/common/src/raindex_client/local_db/sync.rs`, the hard-coded `DEFAULT_SYNC_CHAIN_ID` constant (set to `SUPPORTED_LOCAL_DB_CHAINS[0]`) will be replaced with proper chain ID handling in downstream PRs as part of the multi-network/orderbook implementation.

Applied to files:

  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/local_db/pipeline/runner/mod.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/vaults.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-10-06T11:13:29.956Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2123
File: crates/common/src/raindex_client/local_db/mod.rs:23-29
Timestamp: 2025-10-06T11:13:29.956Z
Learning: In `crates/common/src/raindex_client/local_db/mod.rs`, the `Default` implementation for `LocalDb` that creates an RPC client pointing to `http://localhost:4444` is acceptable because the RPC client must be explicitly configured before actual usage in production scenarios.

Applied to files:

  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/vaults.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-10-06T11:44:07.888Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2145
File: crates/common/src/raindex_client/local_db/query/create_tables/query.sql:71-72
Timestamp: 2025-10-06T11:44:07.888Z
Learning: The local DB feature in the rain.orderbook codebase is not live yet (as of PR #2145), so schema migrations for existing databases are not required when modifying table structures in `crates/common/src/raindex_client/local_db/query/create_tables/query.sql`.

Applied to files:

  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/vaults.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-10-18T10:38:41.273Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2237
File: crates/common/src/raindex_client/local_db/sync.rs:79-89
Timestamp: 2025-10-18T10:38:41.273Z
Learning: In `crates/common/src/raindex_client/local_db/sync.rs`, the sync_database method currently only supports indexing a single orderbook per chain ID, which is why `.first()` is used to select the orderbook configuration. Multi-orderbook support per chain ID is planned for future PRs.

Applied to files:

  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/local_db/pipeline/runner/mod.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/vaults.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-10-06T14:13:18.531Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2155
File: crates/common/src/raindex_client/trades.rs:133-152
Timestamp: 2025-10-06T14:13:18.531Z
Learning: In the rain.orderbook codebase, the `page` parameter in `RaindexOrder::get_trades_list` method (in crates/common/src/raindex_client/trades.rs) is kept for backwards compatibility with subgraph logic, but the LocalDb fast-path intentionally returns all trades without implementing pagination.

Applied to files:

  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/vaults.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-07-16T10:40:05.717Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2000
File: crates/common/src/raindex_client/vaults.rs:183-183
Timestamp: 2025-07-16T10:40:05.717Z
Learning: In the rainlanguage/rain.orderbook codebase, user findolor considers breaking changes from Option<U256> to U256 for required fields like decimals in RaindexVaultToken to be acceptable and safe, even when they affect multiple usage sites across the codebase.

Applied to files:

  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/vaults.rs
📚 Learning: 2025-06-24T13:36:28.797Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1950
File: crates/common/src/raindex_client/orders.rs:301-301
Timestamp: 2025-06-24T13:36:28.797Z
Learning: In the RaindexClient codebase, when Arc::new(RwLock::new(self.clone())) is used (e.g., in get_orders and get_order_by_hash methods), this creates new Arc/RwLock wrappers around a cloned RaindexClient, but the underlying client data is functionally the same. This pattern is used to provide the correct Arc<RwLock<RaindexClient>> type expected by RaindexOrder::try_from_sg_order() method.

Applied to files:

  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-08-01T07:44:53.910Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2036
File: crates/js_api/src/filters/raindex_filter_store.rs:319-336
Timestamp: 2025-08-01T07:44:53.910Z
Learning: In the rainlanguage/rain.orderbook project's RaindexFilterStore (crates/js_api/src/filters/raindex_filter_store.rs), the team chose a simplified monolithic approach with hard-coded keys and default auto-save behavior over configurable stores. The update_vaults method intentionally auto-saves to both localStorage and URL after each update as the default behavior, following a design evolution from a previous configurable approach.

Applied to files:

  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/vaults.rs
📚 Learning: 2025-07-21T16:34:31.193Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1911
File: crates/subgraph/src/types/impls.rs:7-15
Timestamp: 2025-07-21T16:34:31.193Z
Learning: In the rainlanguage/rain.orderbook codebase, user 0xgleb considers breaking changes that remove unsafe default behaviors to be intentional and acceptable. Specifically, the get_decimals() method in crates/subgraph/src/types/impls.rs was intentionally changed to return MissingDecimals error instead of defaulting to 18 decimals, as defaulting to 18 is considered unsafe and should never have been done.

Applied to files:

  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-10-06T11:28:30.692Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2145
File: crates/common/src/raindex_client/local_db/query/fetch_orders/query.sql:6-7
Timestamp: 2025-10-06T11:28:30.692Z
Learning: In `crates/common/src/raindex_client/local_db/query/fetch_orders/query.sql`, the orderbook_address is currently hardcoded to '0x2f209e5b67A33B8fE96E28f24628dF6Da301c8eB' because the system only supports a single orderbook at the moment. Multiorderbook logic is not yet implemented and will be added in the future.

Applied to files:

  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-10-06T14:12:05.824Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2155
File: crates/common/src/raindex_client/local_db/query/fetch_order_trades/query.sql:86-108
Timestamp: 2025-10-06T14:12:05.824Z
Learning: CTEs (Common Table Expressions) are not supported in the local DB SQL implementation used in the rain.orderbook codebase.

Applied to files:

  • crates/common/src/raindex_client/mod.rs
📚 Learning: 2025-10-06T14:41:41.909Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2159
File: crates/cli/src/commands/local_db/sync/runner/mod.rs:52-113
Timestamp: 2025-10-06T14:41:41.909Z
Learning: The local DB sync CLI command (crates/cli/src/commands/local_db/sync/) is designed for CI-only usage, and simple println! statements are preferred over structured logging for status messages.

Applied to files:

  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/local_db/pipeline/runner/mod.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/vaults.rs
📚 Learning: 2025-10-02T19:17:20.332Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2163
File: crates/common/src/raindex_client/orders.rs:738-741
Timestamp: 2025-10-02T19:17:20.332Z
Learning: In crates/common/src/raindex_client/orders.rs, fetch_dotrain_source() is intentionally called in try_from_sg_order for every order conversion because the dotrain source information is needed immediately. A future optimization with local DB logic is planned to eliminate the network round-trip concern.

Applied to files:

  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-10-06T13:03:35.337Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2146
File: crates/cli/src/commands/local_db/README.md:22-106
Timestamp: 2025-10-06T13:03:35.337Z
Learning: In the rain.orderbook repository, `cargo run` commands work without the `--` separator (e.g., `cargo run local-db fetch-events` works directly). Do not suggest adding `--` before CLI arguments in cargo run examples for this repository.

Applied to files:

  • crates/common/src/raindex_client/mod.rs
📚 Learning: 2025-08-26T14:52:37.000Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2099
File: crates/common/src/hyper_rpc.rs:3-7
Timestamp: 2025-08-26T14:52:37.000Z
Learning: In the rain.orderbook codebase, creating new reqwest::Client instances per request in HyperRpcClient is not considered an issue by the maintainers, despite potential performance benefits of client reuse.

Applied to files:

  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-06-20T07:51:08.790Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1941
File: crates/js_api/src/raindex/vaults.rs:175-181
Timestamp: 2025-06-20T07:51:08.790Z
Learning: In the RaindexClient vault methods, `&self` parameters are intentionally kept for API consistency to make all vault operations instance methods, even when the methods don't use client state. This is a design preference for maintaining a uniform interface.

Applied to files:

  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/vaults.rs
📚 Learning: 2025-06-17T16:49:55.915Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1903
File: crates/common/src/erc20.rs:42-48
Timestamp: 2025-06-17T16:49:55.915Z
Learning: In the rain.orderbook codebase, the team prefers not to cache ReadableClientHttp instances or URL strings in ERC20 struct methods, even when there might be repeated allocations. The current simple approach of recreating clients on each call is acceptable.

Applied to files:

  • crates/common/src/raindex_client/mod.rs
📚 Learning: 2025-06-17T16:32:04.554Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1903
File: crates/js_api/src/gui/order_operations.rs:124-134
Timestamp: 2025-06-17T16:32:04.554Z
Learning: In the rain.orderbook codebase, RPC lists are typically small (2 items maximum), so performance optimizations around cloning and converting small Vec<Url> collections are generally unnecessary.

Applied to files:

  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-07-15T08:01:38.534Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1994
File: crates/common/src/raindex_client/vaults.rs:282-292
Timestamp: 2025-07-15T08:01:38.534Z
Learning: In the rainlanguage/rain.orderbook codebase, findolor prefers to avoid concurrency optimizations like using `futures::future::try_join_all` for parallel processing of balance changes, considering such optimizations "not that critical at the moment" when the performance impact is minimal.

Applied to files:

  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-07-23T10:51:12.278Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2012
File: crates/js_api/src/registry.rs:233-252
Timestamp: 2025-07-23T10:51:12.278Z
Learning: In the rainlanguage/rain.orderbook codebase, findolor considers the pattern of creating a partially initialized struct instance within a constructor and then populating it through async operations to be acceptable, as long as the partial state is never exposed to users and the constructor returns Result<T, E> with proper error propagation using the ? operator.

Applied to files:

  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-05-09T05:28:22.089Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1744
File: crates/js_api/src/subgraph/order.rs:109-114
Timestamp: 2025-05-09T05:28:22.089Z
Learning: In the rain.orderbook project, SubgraphError contains or converts from OrderbookSubgraphClientError, so using OrderbookSubgraphClientError in error creation followed by a conversion to SubgraphError (via ? operator) is acceptable.

Applied to files:

  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-06-17T16:46:19.035Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1903
File: crates/cli/src/commands/order/calldata.rs:47-57
Timestamp: 2025-06-17T16:46:19.035Z
Learning: In the CLI command `crates/cli/src/commands/order/calldata.rs`, the user prefers to let lower-level errors from `try_into_call()` bubble up when the RPCs list is empty, rather than adding early validation checks with custom error messages.

Applied to files:

  • crates/common/src/raindex_client/mod.rs
📚 Learning: 2025-08-01T07:35:13.418Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2036
File: crates/js_api/src/filters/errors.rs:39-46
Timestamp: 2025-08-01T07:35:13.418Z
Learning: In the Rain Orderbook project's PersistentFilterStoreError (crates/js_api/src/filters/errors.rs), the Display implementation already provides user-friendly error messages, so using err.to_string() for both msg and readable_msg in the WasmEncodedError conversion is appropriate and doesn't require separate readable message handling.

Applied to files:

  • crates/common/src/raindex_client/mod.rs
📚 Learning: 2025-04-29T06:19:15.446Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1706
File: crates/quote/src/js_api/mod.rs:57-61
Timestamp: 2025-04-29T06:19:15.446Z
Learning: In the rain.orderbook codebase, the `get_id` function is designed to use `U256::from_str()` rather than `U256::from_hex()` for parsing order hashes, despite the potential for hex string inputs.

Applied to files:

  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-05-14T05:51:50.277Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1715
File: crates/js_api/src/common/mod.rs:55-59
Timestamp: 2025-05-14T05:51:50.277Z
Learning: In the Rain Orderbook project, the error handling for WASM exported functions uses WasmEncodedError which includes both the original error message and a human-readable version, making direct modification of the JsValue conversion unnecessary.

Applied to files:

  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/local_db/mod.rs
📚 Learning: 2025-10-13T12:57:05.900Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2198
File: crates/common/src/raindex_client/local_db/query/fetch_store_addresses/mod.rs:7-8
Timestamp: 2025-10-13T12:57:05.900Z
Learning: In the rain.orderbook repository, using unqualified serde helper names (e.g., `#[serde(with = "serde_address")]`) that rely on glob imports is acceptable and does not need to be changed to fully qualified paths.

Applied to files:

  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-07-04T10:27:22.544Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1956
File: crates/common/src/raindex_client/orders.rs:609-609
Timestamp: 2025-07-04T10:27:22.544Z
Learning: In the rainlanguage/rain.orderbook codebase, user findolor prefers not to implement overflow protection for trades count casting (usize to u16) at this time, considering it unnecessary for the current scope since the practical risk of orders having 65,535+ trades is extremely low.

Applied to files:

  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-10-06T14:39:36.425Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2159
File: crates/cli/src/commands/local_db/sync/cli.rs:37-78
Timestamp: 2025-10-06T14:39:36.425Z
Learning: In the SyncLocalDb CLI command (crates/cli/src/commands/local_db/sync/cli.rs), block range validation (e.g., start_block <= end_block) is handled internally by the sync runner, not at the CLI entry point.

Applied to files:

  • crates/common/src/raindex_client/local_db/pipeline/runner/mod.rs
  • crates/common/src/raindex_client/local_db/mod.rs
📚 Learning: 2025-08-02T02:34:32.237Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2036
File: crates/js_api/src/filters/raindex_filter_store.rs:446-533
Timestamp: 2025-08-02T02:34:32.237Z
Learning: In the rainlanguage/rain.orderbook project's RaindexFilterStore WASM tests (crates/js_api/src/filters/raindex_filter_store.rs), brusherru decided to focus on testing only methods without side effects (that don't use web_sys) due to difficulties with mocking localStorage and window APIs in the WASM test environment. This pragmatic approach tests pure logic separately from browser integration.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-05-27T06:16:35.738Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1874
File: tauri-app/src-tauri/src/transaction_status.rs:69-127
Timestamp: 2025-05-27T06:16:35.738Z
Learning: In tauri-app/src-tauri/src/transaction_status.rs, directly accessing internal RwLock state in tests using `notice.0.read().unwrap()` is acceptable and does not require encapsulation through public getter methods.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
📚 Learning: 2025-05-20T10:20:08.206Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1859
File: crates/quote/src/quote_debug.rs:472-492
Timestamp: 2025-05-20T10:20:08.206Z
Learning: In the Rain Orderbook codebase, the `#[tokio::test(flavor = "multi_thread")]` annotation is specifically needed for tests that use `LocalEvm`, not just for consistency across all async tests.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-07-18T10:31:05.498Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2008
File: crates/common/src/raindex_client/add_orders.rs:85-86
Timestamp: 2025-07-18T10:31:05.498Z
Learning: In the rainlanguage/rain.orderbook codebase, cfg-guarded imports like `#[cfg(not(target_family = "wasm"))] use super::*;` in test modules are sometimes needed to fix compiler warnings, even when similar imports exist in nested sub-modules. These should not be removed as they serve a specific purpose in the compilation process.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-05-19T13:40:56.080Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1858
File: crates/subgraph/src/orderbook_client/mod.rs:54-58
Timestamp: 2025-05-19T13:40:56.080Z
Learning: The `wasm_bindgen_utils` crate in the Rain Orderbook project handles conditional compilation for `JsValue` and `JsError` internally, allowing `impl From<Error> for JsValue` to work on non-WASM targets without explicit cfg guards.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
📚 Learning: 2025-08-01T09:07:20.383Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2044
File: packages/orderbook/README.md:186-189
Timestamp: 2025-08-01T09:07:20.383Z
Learning: In the rainlanguage/rain.orderbook project, Rust methods on structs like RaindexVaultsList are exported as JavaScript getters in WASM bindings using #[wasm_bindgen(getter)]. This means while the Rust code uses method calls like items(), the JavaScript/WASM API exposes them as property access like .items. The README.md correctly documents the JavaScript API surface, not the Rust implementation details.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/vaults.rs
📚 Learning: 2025-10-21T05:15:50.518Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2256
File: crates/common/src/raindex_client/local_db/query/fetch_tables.rs:7-7
Timestamp: 2025-10-21T05:15:50.518Z
Learning: In Rust 2021+ editions, passing a reference to a temporary into an async function within the same expression (e.g., `exec.query_json(&fetch_tables_stmt()).await`) is safe and idiomatic. The temporary lifetime is extended across the await point, so this pattern should not be flagged as an issue.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-04-30T09:28:36.960Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1715
File: crates/js_api/src/common/mod.rs:111-118
Timestamp: 2025-04-30T09:28:36.960Z
Learning: In the rain.orderbook repository, the WASM tests are already properly configured with conditional compilation using `#[cfg(target_family = "wasm")]` and `#[cfg(not(target_family = "wasm"))]`, and don't require additional `wasm_bindgen_test_configure!(run_in_browser)` directives.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-11-25T16:50:31.752Z
Learnt from: CR
Repo: rainlanguage/rain.orderbook PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T16:50:31.752Z
Learning: Applies to crates/integration_tests/**/*.rs : Rust: write tests using `cargo test`; integration tests live in `crates/integration_tests`. Prefer `insta` snapshots and `proptest` where helpful

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
📚 Learning: 2025-10-06T10:23:57.479Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2111
File: packages/webapp/src/routes/db-playground/+page.svelte:149-153
Timestamp: 2025-10-06T10:23:57.479Z
Learning: The db-playground page at packages/webapp/src/routes/db-playground/+page.svelte is used for testing purposes, and production-level concerns (such as invalid RPC tokens) are acceptable in this context.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
📚 Learning: 2025-10-21T05:16:07.124Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2256
File: crates/common/src/raindex_client/local_db/query/fetch_tables.rs:46-52
Timestamp: 2025-10-21T05:16:07.124Z
Learning: In Rust projects using wasm_bindgen_utils, the glob import `use wasm_bindgen_utils::prelude::*;` re-exports `Closure` from wasm_bindgen, so `Closure::wrap` can be used without explicitly importing `use wasm_bindgen::prelude::Closure;`.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
📚 Learning: 2025-06-24T13:30:02.968Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1950
File: crates/common/src/raindex_client/transactions.rs:34-38
Timestamp: 2025-06-24T13:30:02.968Z
Learning: When using #[wasm_bindgen] on an impl block, all methods within that block must have wasm_bindgen attributes, even if they are conditionally compiled for non-WASM targets using #[cfg(not(target_family = "wasm"))]. Removing these attributes causes compiler errors because the wasm_bindgen macro expansion processes the entire impl block and expects consistent attribute usage across all methods.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
📚 Learning: 2025-10-19T15:52:58.239Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2245
File: crates/common/src/raindex_client/local_db/executor.rs:17-46
Timestamp: 2025-10-19T15:52:58.239Z
Learning: When formatting JsValue errors in Rust wasm code using `{:?}`, the Debug output is sufficiently informative and does not produce unhelpful "[object Object]" strings in practice.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
📚 Learning: 2025-05-14T04:49:14.621Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1710
File: crates/quote/Cargo.toml:30-30
Timestamp: 2025-05-14T04:49:14.621Z
Learning: In the rain.orderbook repository, wasm-bindgen-utils is intentionally used as an unconditional dependency because non-wasm targets (like tests) sometimes need to use it.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-05-14T05:13:59.713Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1744
File: crates/subgraph/src/orderbook_client.rs:44-46
Timestamp: 2025-05-14T05:13:59.713Z
Learning: In the rain.orderbook project, WASM dependencies are intentionally made available in non-WASM targets to facilitate testing of WASM-related functionality, so conditional compilation guards like `#[cfg(target_family = "wasm")]` should not be added to imports or implementations that may be needed for tests.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-08-02T03:55:25.215Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2036
File: packages/orderbook/test/js_api/filters.test.ts:19-36
Timestamp: 2025-08-02T03:55:25.215Z
Learning: In the rainlanguage/rain.orderbook project's WASM tests, the pattern of chaining `.value!` calls on WASM result types (like from VaultsFilterBuilder methods) is the established and preferred approach for handling WASM results, and should not be refactored into intermediate variables as it would add unnecessary verbosity without improving the code.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-06-17T16:54:43.176Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1903
File: crates/common/src/deposit.rs:63-64
Timestamp: 2025-06-17T16:54:43.176Z
Learning: In the rain.orderbook codebase, the maintainer findolor prefers to keep the current implementation that clones the rpcs vector when calling ReadableClient::new_from_urls rather than optimizing it to avoid the clone or adding early validation for empty rpcs. Performance micro-optimizations like avoiding vector clones in this context are not a priority.

Applied to files:

  • crates/common/src/raindex_client/local_db/mod.rs
📚 Learning: 2025-07-16T05:52:05.576Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1994
File: crates/common/src/raindex_client/vaults.rs:59-59
Timestamp: 2025-07-16T05:52:05.576Z
Learning: User findolor prefers to handle documentation updates for getter methods in batch via dedicated PRs rather than addressing them individually during feature development, as mentioned for the formatted amount string fields in crates/common/src/raindex_client/vaults.rs.

Applied to files:

  • crates/common/src/raindex_client/vaults.rs
📚 Learning: 2025-06-24T08:46:03.368Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1947
File: crates/common/src/raindex_client/orders.rs:98-125
Timestamp: 2025-06-24T08:46:03.368Z
Learning: In the vault merging logic in crates/common/src/raindex_client/orders.rs, optimization isn't necessary because the maximum list items are usually around 5 items. For such small datasets, the simple three-loop approach is preferred over HashMap-based optimization due to clarity and minimal performance impact.

Applied to files:

  • crates/common/src/raindex_client/vaults.rs
  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-06-06T16:38:04.182Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1913
File: Cargo.toml:55-55
Timestamp: 2025-06-06T16:38:04.182Z
Learning: In rain.orderbook repository, during PR chains involving dependency updates, wasm-bindgen-utils may temporarily point to git commits that don't contain the full required functionality, with the understanding that subsequent PRs in the chain will update it to the correct commit.

Applied to files:

  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-07-04T10:26:24.289Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1956
File: crates/common/src/raindex_client/mod.rs:116-135
Timestamp: 2025-07-04T10:26:24.289Z
Learning: In crates/common/src/raindex_client/mod.rs, the get_multi_subgraph_args method intentionally treats Some(empty vector) the same as None for chain_ids parameter. Both cases should return all networks to support UI behavior where no selection or empty selection means "show all networks". Only when specific chain IDs are provided should the results be filtered.

Applied to files:

  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-04-08T12:56:03.272Z
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1512
File: packages/ui-components/src/__tests__/OrderDetail.test.ts:125-143
Timestamp: 2025-04-08T12:56:03.272Z
Learning: The OrderDetail component in the Rain orderbook UI doesn't currently have error handling tests, but issue #1605 has been created to address this in the future.

Applied to files:

  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-06-18T18:24:32.049Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1938
File: crates/settings/src/yaml/orderbook.rs:180-199
Timestamp: 2025-06-18T18:24:32.049Z
Learning: In crates/settings/src/yaml/orderbook.rs, the user prefers to avoid refactoring duplicate search logic between get_orderbook_by_address and get_orderbook_by_network_key when there are only 2 functions, indicating they would consider it if more similar functions are added in the future.

Applied to files:

  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-06-17T16:21:24.384Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1903
File: crates/settings/src/yaml/orderbook.rs:371-377
Timestamp: 2025-06-17T16:21:24.384Z
Learning: In crates/settings/src/yaml/orderbook.rs tests, the user findolor considers RPC ordering in Vec<Url> assertions to be intentional and not a test brittleness issue. The ordering of RPCs in tests should be preserved as specified.

Applied to files:

  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-06-18T12:56:44.290Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1938
File: crates/js_api/src/raindex/mod.rs:102-118
Timestamp: 2025-06-18T12:56:44.290Z
Learning: In the rainlanguage/rain.orderbook codebase, it's acceptable to scaffold unused enum variants in initial implementation PRs when they will be implemented in future PRs, as confirmed by findolor.

Applied to files:

  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-07-21T16:34:04.947Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1911
File: crates/common/src/raindex_client/orders.rs:720-720
Timestamp: 2025-07-21T16:34:04.947Z
Learning: In the rainlanguage/rain.orderbook codebase, user 0xgleb prefers using `.unwrap()` in test code rather than `.expect()` with descriptive messages, considering the direct unwrap approach acceptable for test contexts where failures should be fast and clear.

Applied to files:

  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-06-18T19:23:33.747Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1938
File: crates/settings/src/yaml/mod.rs:176-178
Timestamp: 2025-06-18T19:23:33.747Z
Learning: In crates/settings/src/yaml/mod.rs, the YamlError enum has two distinct error variants: `KeyNotFound(String)` for when a specific YAML key is not found in a hash/map, and `NotFound(String)` for when other types of entities (like networks, orderbooks, etc.) are not found in the configuration. These serve different purposes and should not be consolidated.

Applied to files:

  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-05-09T05:21:40.234Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1744
File: crates/js_api/src/subgraph/vault.rs:19-37
Timestamp: 2025-05-09T05:21:40.234Z
Learning: In the rain.orderbook project, the developer prefers to use tuple structs for WASM wrappers (like VaultCalldataResult, GetVaultsResult) rather than structs with named fields.

Applied to files:

  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-06-18T19:24:40.518Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1938
File: crates/settings/src/yaml/orderbook.rs:185-199
Timestamp: 2025-06-18T19:24:40.518Z
Learning: In crates/settings/src/yaml/orderbook.rs, the user prefers not to refactor get_orderbook_by_network_key to handle multiple orderbooks per network key since their current architecture maintains a one-to-one mapping between orderbooks and networks. They would consider the refactoring if the system evolves to support multiple orderbooks per network in the future.

Applied to files:

  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-05-19T11:40:45.864Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1858
File: crates/subgraph/src/orderbook_client/order.rs:94-108
Timestamp: 2025-05-19T11:40:45.864Z
Learning: Order hashes are unique in the subgraph data model, so a query by hash (`order_detail_by_hash`) will never return multiple orders with the same hash.

Applied to files:

  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-07-31T19:34:11.716Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2044
File: crates/common/src/raindex_client/vaults_list.rs:363-423
Timestamp: 2025-07-31T19:34:11.716Z
Learning: In the rainlanguage/rain.orderbook project, for WASM-exposed functionality like VaultsList, the team prefers to keep comprehensive tests in the non-WASM environment due to the complexity of recreating objects like RaindexVaults in WASM. WASM tests focus on basic functionality and error cases since the WASM code reuses the already-tested non-WASM implementation.

Applied to files:

  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-07-16T14:33:45.887Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2001
File: crates/common/src/raindex_client/vaults.rs:0-0
Timestamp: 2025-07-16T14:33:45.887Z
Learning: In the rainlanguage/rain.orderbook codebase, findolor considers using Address::random() in tests to be acceptable when the mock server doesn't validate the address parameter and returns a fixed response, making the test deterministic regardless of the address value used.

Applied to files:

  • crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-06-08T18:43:51.842Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1891
File: packages/webapp/src/routes/deploy/[strategyName]/[deploymentKey]/page.test.ts:66-80
Timestamp: 2025-06-08T18:43:51.842Z
Learning: In the rain.orderbook webapp test files, when mocking objects like the transaction manager, it's acceptable to use simple empty objects with ts-expect-error comments rather than providing complete mock implementations with all properties and methods.

Applied to files:

  • crates/common/src/raindex_client/orders.rs
🧬 Code graph analysis (2)
crates/common/src/raindex_client/local_db/mod.rs (1)
crates/common/src/raindex_client/mod.rs (2)
  • local_db (228-230)
  • fmt (239-241)
crates/common/src/raindex_client/orders.rs (2)
crates/common/src/raindex_client/mod.rs (2)
  • local_db (228-230)
  • new (115-137)
crates/common/src/raindex_client/local_db/orders.rs (3)
  • new (20-22)
  • list (59-89)
  • get_by_hash (91-115)
🔇 Additional comments (21)
crates/common/src/raindex_client/local_db/pipeline/runner/mod.rs (1)

90-92: LGTM! Removing Sync bound aligns with LocalDb usage.

The removal of the Sync bound from the DB generic parameter is appropriate since LocalDb (which wraps JS callbacks in WASM) is inherently single-threaded and doesn't implement Sync. This change enables the runner to work with the new LocalDb abstraction while maintaining compatibility with other executors.

Also applies to: 144-150

crates/common/src/raindex_client/vaults.rs (3)

312-331: LGTM! Clean LocalDb integration for balance changes.

The pattern of checking for LocalDb availability and falling back to subgraph queries is well-implemented. The early return when local changes are available avoids unnecessary subgraph calls.


1098-1147: LGTM! Well-structured data source routing.

The refactored get_vaults method cleanly partitions chain IDs between local DB and subgraph sources, handles the case when LocalDb is unavailable by falling back to subgraph, and uses concurrent fetches for local DB queries. The logic is clear and handles edge cases appropriately.


1203-1205: Inconsistent signatures between get_vaults_local_db and get_vault_local_db.

get_vaults_local_db accepts a concrete LocalDb type (line 1205), while get_vault_local_db still uses a generic E: LocalDbQueryExecutor + ?Sized (line 1384). If the intent is to standardize on LocalDb, consider updating get_vault_local_db for consistency. If the generic signature is intentional for flexibility, please verify this is the desired design.

Also applies to: 1384-1386

crates/common/src/raindex_client/mod.rs (3)

87-90: LGTM! Clean abstraction of LocalDb storage.

The replacement of js_sys::Function storage with LocalDb properly encapsulates the JS callback handling. The set_local_db_callback method now creates a LocalDb instance internally, maintaining the same public API while improving internal abstraction.

Also applies to: 134-134, 148-150


228-230: LGTM! Accessor method is appropriate.

The local_db() method correctly clones the Option<LocalDb> to return ownership rather than borrowing from the RefCell. This pattern avoids borrow lifetime issues while keeping the API clean.


298-299: OrderNotFound error variant is properly used.

The new error variant is constructed at line 798 and handled at line 1617 in crates/common/src/raindex_client/orders.rs, confirming it's actively integrated into the data source routing logic as expected.

crates/common/src/raindex_client/orders.rs (7)

38-45: Clean abstraction for subgraph data source.

The SubgraphOrders wrapper with a simple constructor provides a clean way to encapsulate subgraph-specific fetching logic while conforming to the OrdersDataSource trait.


47-61: Well-designed trait for data source abstraction.

The OrdersDataSource trait with #[async_trait(?Send)] correctly supports both WASM and native contexts. The two-method interface (list and get_by_hash) provides a clean contract for different data source implementations.


610-643: Clean routing logic between local DB and subgraph.

The partitioning of chain IDs and conditional delegation to LocalDbOrders vs SubgraphOrders is well-structured. The fallback to subgraph when local_db is None (lines 633-635) ensures graceful degradation.


751-768: Correct handling of empty subgraph results.

The pattern of matching OrderbookSubgraphClientError::Empty and returning Ok(None) (lines 763-764) is the right approach for a get_by_hash that may not find a result, distinguishing "not found" from actual errors.


807-807: Good addition of Default derive.

Adding Default to GetOrdersFilters enables cleaner filter construction and aligns with the unwrap_or_default() usage at line 594.


975-1002: Appropriate test helper for mocking local DB.

StaticJsonExec provides a simple way to inject canned JSON responses for testing local DB paths without requiring actual database infrastructure.


1831-1904: Comprehensive test coverage for routing logic.

The get_orders_routes_between_local_and_subgraph test validates that orders from both local DB (chain 137) and subgraph (chain 1) are correctly retrieved and combined, ensuring the routing logic works as intended.

crates/common/src/raindex_client/local_db/mod.rs (7)

19-39: Clean abstraction using type-erased function pointers.

The LocalDb struct with Rc-wrapped function closures effectively type-erases the concrete executor while remaining Clone. This pattern avoids the need for dyn LocalDbQueryExecutor trait objects while still allowing different executor implementations.


42-80: Correct closure pattern for async execution.

The closures correctly clone both the Rc<exec> and the input parameters (batch, stmt) before moving into the async block. This is necessary because the closures return 'static futures that outlive the function parameters.


99-106: Two-step deserialization enables type erasure.

The pattern of storing QueryJsonFn returning Value and then deserializing to T in the trait impl (lines 103-105) is necessary to type-erase the generic parameter from the stored closure. This is a clean solution.


174-178: Cleaner integration with LocalDb abstraction.

Retrieving LocalDb from the client field and passing it to the scheduler is cleaner than the previous callback-based approach, as it decouples the scheduler from JS-specific types.


228-265: Good test helper design.

RecordingExec using Arc<Mutex<_>> for call tracking provides both thread-safety (satisfying the Sync bound) and the ability to verify delegation behavior in tests.


382-420: Good WASM integration tests.

These tests validate the JS callback integration path, ensuring both successful query execution and proper error propagation through the LocalDb abstraction.


34-40: Past review concern addressed: no more unsafe impl Sync.

The LocalDb struct now uses Rc internally without declaring unsafe impl Sync, correctly limiting its use to single-threaded contexts (appropriate for WASM). The Sync bound at line 44 applies only to the generic executor parameter passed to new(), not to LocalDb itself.

@@ -1,4 +1,4 @@
use super::{local_db::executor::JsCallbackExecutor, *};
use super::*;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Consider using explicit imports instead of wildcard.

The wildcard import use super::*; can obscure dependencies and make the code harder to maintain. Consider listing the specific items imported from the parent module for better clarity.

🤖 Prompt for AI Agents
In crates/common/src/raindex_client/vaults.rs at line 1, the file uses a
wildcard import `use super::*;` which hides exactly which parent-module symbols
are depended on; replace it by explicitly importing only the items actually used
from the parent module (e.g., structs, enums, traits, functions) — inspect this
file to see which identifiers from `super` are referenced, update the `use
super::{...};` list with those identifiers, remove the wildcard import, and run
cargo build/check to ensure no missing imports and adjust names or add any
required `pub(crate)` qualifiers as needed.

@findolor findolor merged commit 9094a0e into main Dec 1, 2025
20 checks passed
@findolor findolor deleted the local-db-query-helper branch December 1, 2025 17:19
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 1, 2025

@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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 1, 2025

Tip

For best results, initiate chat on the files or code changes.

SIZE=L


🧠 Learnings used
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:42.275Z
Learning: For PR #1884, after each commit review, I should provide a new comment with a PR size report in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding irrelevant files such as lock files (package-lock.json, cargo.lock, etc.).

Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:42.275Z
Learning: After each commit in PR #1884, I should provide a new comment with the PR size report in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`. The report should exclude irrelevant files such as lock files (e.g., package-lock.json, cargo.lock).

Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:25:47.873Z
Learning: After each new commit review for rainlanguage/rain.orderbook repository, generate a PR size report in a separate comment with the format: "TOTAL=number ADDITIONS=number DELETIONS=number". This report should exclude irrelevant files such as lock files (e.g., package-lock.json, cargo.lock).

Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:25:47.873Z
Learning: After each new commit review for rainlanguage/rain.orderbook repository, generate a PR size report in a separate comment with the exact format: "TOTAL=number\nADDITIONS=number\nDELETIONS=number". This report should exclude irrelevant files such as lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock).

Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T22:14:22.646Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, I must consistently report the PR size after EVERY new commit in the exact format "TOTAL=number\nADDITIONS=number\nDELETIONS=number" without any formatting blocks. The report must exclude lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock) and can be included either as part of the review or as a separate comment.

Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T22:14:22.646Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, I must consistently report the PR size after EVERY new commit in the exact format "TOTAL=number\nADDITIONS=number\nDELETIONS=number" without any additional text or formatting blocks. The report must exclude lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock) and can be included either as part of the review or as a separate comment.

Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T22:46:08.530Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, the PR size report should be the only content in the comment - no text before it, no text after it, no formatting blocks, just the raw report in the exact format: "TOTAL=number\nADDITIONS=number\nDELETIONS=number". The report must exclude lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock).

Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.

Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.

Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.

Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1971
File: .github/workflows/vercel-docs-prod.yaml:32-34
Timestamp: 2025-07-11T12:30:09.245Z
Learning: findolor prefers not to pin Node versions explicitly in GitHub Actions workflows when using Nix with webapp-shell, considering the current setup sufficient for deterministic builds in the rainlanguage/rain.orderbook project.

Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1971
File: .github/workflows/vercel-docs-prod.yaml:10-14
Timestamp: 2025-07-11T12:29:49.284Z
Learning: In GitHub Actions workflows for the rainlanguage/rain.orderbook project, findolor is comfortable with job names that may seem misleading (like "Deploy-Docs-Preview" in a production workflow) when there's only one job in the workflow, as the context makes it clear enough.

Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2145
File: crates/common/src/raindex_client/local_db/query/create_tables/query.sql:71-72
Timestamp: 2025-10-06T11:44:07.888Z
Learning: The local DB feature in the rain.orderbook codebase is not live yet (as of PR #2145), so schema migrations for existing databases are not required when modifying table structures in `crates/common/src/raindex_client/local_db/query/create_tables/query.sql`.

Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.

Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1956
File: crates/common/src/fuzz/mod.rs:64-64
Timestamp: 2025-07-04T09:02:57.301Z
Learning: In rainlanguage/rain.orderbook, user findolor prefers to limit type consistency changes to only the parts directly related to the current work scope. For example, when updating chain_id fields from u64 to u32 in fuzz-related code, unrelated files like tauri-app wallet commands can remain as u64 if they serve different purposes and aren't part of the current changes.

Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2117
File: crates/js_api/src/gui/select_tokens.rs:421-424
Timestamp: 2025-09-02T08:04:34.729Z
Learning: User findolor in the rainlanguage/rain.orderbook codebase prefers not to change test code when tests are already passing, even if there appear to be type mismatches or potential issues. Working tests should be left alone unless there are actual errors.

Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2237
File: crates/common/src/raindex_client/local_db/sync.rs:79-89
Timestamp: 2025-10-18T10:38:41.273Z
Learning: In `crates/common/src/raindex_client/local_db/sync.rs`, the sync_database method currently only supports indexing a single orderbook per chain ID, which is why `.first()` is used to select the orderbook configuration. Multi-orderbook support per chain ID is planned for future PRs.

Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1938
File: crates/js_api/src/raindex/orders.rs:1-11
Timestamp: 2025-06-18T12:54:47.807Z
Learning: In the rain.orderbook repository, findolor prefers to keep unused imports in place when they will be used in upcoming follow-up PRs, rather than removing and re-adding them during incremental development.

Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1994
File: crates/common/src/raindex_client/vaults.rs:282-292
Timestamp: 2025-07-15T08:01:38.534Z
Learning: In the rainlanguage/rain.orderbook codebase, findolor prefers to avoid concurrency optimizations like using `futures::future::try_join_all` for parallel processing of balance changes, considering such optimizations "not that critical at the moment" when the performance impact is minimal.

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