Skip to content

Conversation

@findolor
Copy link
Collaborator

@findolor findolor commented Dec 5, 2025

Chained PR

Motivation

We have updated the polling mechanism in the SDK on the web app for add orders and remove orders. And now we have to implement the deposits and withdrawals.

Solution

  • Add a new query to fetch a transaction from local db
  • Update get transaction wasm binding in RaindexClient with the two-step polling mechanism
  • Update the web app to fully use SDK polling and remove subgraph polling logic
  • Add and 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

  • New Features

    • Added transaction lookup capability via local database with fallback to subgraph polling
    • Implemented SDK-based transaction indexing for improved efficiency
  • Bug Fixes

    • Clarified timeout error messaging when transaction indexing fails

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

@findolor findolor requested review from 0xgleb and hardyjosh December 5, 2025 10:59
@findolor findolor self-assigned this Dec 5, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 5, 2025

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 is partially related to the changeset; it refers to a real aspect of the changes (polling logic updates) but misses the main point (adding local DB transaction fetching and expanding polling to deposits/withdrawals).
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 2025-12-05-transaction-polling

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

@findolor findolor changed the base branch from main to 2025-12-05-remove-order-polling December 5, 2025 11:00
@findolor
Copy link
Collaborator Author

findolor commented Dec 5, 2025

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 5, 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
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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 16b357c and cb71258.

📒 Files selected for processing (13)
  • crates/common/src/local_db/query/fetch_transaction_by_hash/mod.rs (1 hunks)
  • crates/common/src/local_db/query/fetch_transaction_by_hash/query.sql (1 hunks)
  • crates/common/src/local_db/query/mod.rs (1 hunks)
  • crates/common/src/raindex_client/add_orders.rs (2 hunks)
  • crates/common/src/raindex_client/local_db/mod.rs (1 hunks)
  • crates/common/src/raindex_client/local_db/query/fetch_transaction_by_hash.rs (1 hunks)
  • crates/common/src/raindex_client/local_db/query/mod.rs (1 hunks)
  • crates/common/src/raindex_client/local_db/transactions.rs (1 hunks)
  • crates/common/src/raindex_client/mod.rs (2 hunks)
  • crates/common/src/raindex_client/remove_orders.rs (2 hunks)
  • crates/common/src/raindex_client/transactions.rs (7 hunks)
  • packages/ui-components/src/__tests__/TransactionManager.test.ts (3 hunks)
  • packages/ui-components/src/lib/providers/transactions/TransactionManager.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
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/local_db/query/mod.rs
  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/local_db/query/fetch_transaction_by_hash.rs
  • crates/common/src/raindex_client/add_orders.rs
  • crates/common/src/raindex_client/local_db/transactions.rs
  • crates/common/src/raindex_client/remove_orders.rs
  • crates/common/src/local_db/query/fetch_transaction_by_hash/mod.rs
  • crates/common/src/raindex_client/transactions.rs
  • crates/common/src/raindex_client/local_db/query/mod.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/local_db/query/mod.rs
  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/local_db/query/fetch_transaction_by_hash.rs
  • crates/common/src/raindex_client/add_orders.rs
  • crates/common/src/local_db/query/fetch_transaction_by_hash/query.sql
  • crates/common/src/raindex_client/local_db/transactions.rs
  • crates/common/src/raindex_client/remove_orders.rs
  • crates/common/src/local_db/query/fetch_transaction_by_hash/mod.rs
  • crates/common/src/raindex_client/transactions.rs
  • crates/common/src/raindex_client/local_db/query/mod.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/local_db/query/mod.rs
  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/local_db/mod.rs
  • crates/common/src/raindex_client/local_db/query/fetch_transaction_by_hash.rs
  • crates/common/src/raindex_client/add_orders.rs
  • crates/common/src/raindex_client/local_db/transactions.rs
  • crates/common/src/raindex_client/remove_orders.rs
  • crates/common/src/local_db/query/fetch_transaction_by_hash/mod.rs
  • crates/common/src/raindex_client/transactions.rs
  • crates/common/src/raindex_client/local_db/query/mod.rs
packages/ui-components/**/*.{svelte,ts,tsx,js,jsx}

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

For UI components (packages/ui-components), run lints and format checks using nix develop -c npm run svelte-lint-format-check -w @rainlanguage/ui-components

Files:

  • packages/ui-components/src/__tests__/TransactionManager.test.ts
  • packages/ui-components/src/lib/providers/transactions/TransactionManager.ts
packages/ui-components/**/*.{ts,tsx,js,jsx}

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

For UI components (packages/ui-components), run tests using nix develop -c npm run test -w @rainlanguage/ui-components

Files:

  • packages/ui-components/src/__tests__/TransactionManager.test.ts
  • packages/ui-components/src/lib/providers/transactions/TransactionManager.ts
packages/{webapp,ui-components}/**/*.{svelte,ts,tsx,js,jsx}

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

If you modify frontend code or functionality affecting the frontend, you MUST provide a screenshot of the built webapp reflecting your change.

Files:

  • packages/ui-components/src/__tests__/TransactionManager.test.ts
  • packages/ui-components/src/lib/providers/transactions/TransactionManager.ts
packages/**/*.{js,ts,svelte}

📄 CodeRabbit inference engine (AGENTS.md)

JavaScript/Svelte organized as packages/* including webapp, ui-components, and orderbook (wasm wrapper published to npm)

Files:

  • packages/ui-components/src/__tests__/TransactionManager.test.ts
  • packages/ui-components/src/lib/providers/transactions/TransactionManager.ts
**/*.{ts,tsx,svelte}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,svelte}: TypeScript/Svelte: format with nix develop -c npm run format
TypeScript/Svelte: lint with nix develop -c npm run lint
TypeScript/Svelte: type-check with nix develop -c npm run check

Files:

  • packages/ui-components/src/__tests__/TransactionManager.test.ts
  • packages/ui-components/src/lib/providers/transactions/TransactionManager.ts
**/*.{test,spec}.ts

📄 CodeRabbit inference engine (AGENTS.md)

TypeScript/Svelte: run tests with nix develop -c npm run test (Vitest). Name test files *.test.ts or *.spec.ts

Files:

  • packages/ui-components/src/__tests__/TransactionManager.test.ts
🧠 Learnings (45)
📓 Common learnings
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2044
File: tauri-app/src/routes/orders/[chainId]-[orderbook]-[orderHash]/+page.svelte:76-78
Timestamp: 2025-07-31T19:03:56.594Z
Learning: In the rainlanguage/rain.orderbook project, when the Tauri app has issues preventing proper testing, the team prefers to defer Tauri-specific implementations to separate PRs rather than including untested code, especially for financial operations like withdrawals.
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1504
File: tauri-app/src/routes/orders/[network]-[orderHash]/+page.svelte:33-37
Timestamp: 2025-04-08T16:35:15.127Z
Learning: In the Rain OrderBook project, the onDeposit and onWithdraw functions in page components are kept simple (just calling modal handlers and revalidating queries) because error handling for deposit and withdraw actions (including user cancellations and failed transactions) is handled within the modal components themselves.
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: 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: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: 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: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).
📚 Learning: 2025-04-11T08:46:36.365Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1654
File: packages/ui-components/src/lib/stores/transactionStore.ts:195-198
Timestamp: 2025-04-11T08:46:36.365Z
Learning: In the transactionStore, specific functions like `awaitRemoveOrderIndexing` need custom timeout messages that differ from the generic `TransactionErrorMessage.TIMEOUT` message to provide context-specific guidance to users.

Applied to files:

  • crates/common/src/raindex_client/mod.rs
  • crates/common/src/raindex_client/add_orders.rs
  • crates/common/src/raindex_client/remove_orders.rs
  • packages/ui-components/src/__tests__/TransactionManager.test.ts
📚 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/add_orders.rs
  • crates/common/src/raindex_client/remove_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/mod.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/local_db/mod.rs
  • crates/common/src/raindex_client/local_db/transactions.rs
  • crates/common/src/local_db/query/fetch_transaction_by_hash/mod.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/local_db/mod.rs
  • crates/common/src/raindex_client/local_db/transactions.rs
  • crates/common/src/raindex_client/transactions.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/local_db/mod.rs
  • crates/common/src/raindex_client/local_db/transactions.rs
  • crates/common/src/local_db/query/fetch_transaction_by_hash/mod.rs
  • crates/common/src/raindex_client/transactions.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/local_db/query/fetch_transaction_by_hash.rs
  • crates/common/src/raindex_client/add_orders.rs
  • crates/common/src/raindex_client/local_db/transactions.rs
  • crates/common/src/local_db/query/fetch_transaction_by_hash/mod.rs
  • crates/common/src/raindex_client/transactions.rs
  • crates/common/src/raindex_client/local_db/query/mod.rs
📚 Learning: 2025-05-19T18:24:17.608Z
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1860
File: packages/ui-components/src/lib/stores/transactionStore.ts:130-136
Timestamp: 2025-05-19T18:24:17.608Z
Learning: In the `rain.orderbook` project, the `getTransaction` function (and related entity fetch functions) use `wasmEncodedResult` to validate the returned data, ensuring that only valid data is returned. This makes a simple truthiness check (`!!data`) sufficient for the `isSuccess` predicate in `awaitSubgraphIndexing`.

Applied to files:

  • crates/common/src/raindex_client/local_db/query/fetch_transaction_by_hash.rs
  • crates/common/src/raindex_client/local_db/transactions.rs
  • packages/ui-components/src/__tests__/TransactionManager.test.ts
  • crates/common/src/raindex_client/transactions.rs
  • packages/ui-components/src/lib/providers/transactions/TransactionManager.ts
📚 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/query/fetch_transaction_by_hash.rs
  • crates/common/src/raindex_client/local_db/transactions.rs
  • crates/common/src/raindex_client/transactions.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/local_db/query/fetch_transaction_by_hash.rs
  • crates/common/src/raindex_client/local_db/transactions.rs
  • packages/ui-components/src/lib/providers/transactions/TransactionManager.ts
📚 Learning: 2025-05-27T06:16:12.195Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1874
File: tauri-app/src-tauri/src/transaction_status.rs:87-114
Timestamp: 2025-05-27T06:16:12.195Z
Learning: In tauri-app/src-tauri/src/transaction_status.rs, testing one WriteTransactionStatus variant (like PendingPrepare) is sufficient for the update_status_and_emit method since all variants follow the same code path through the From<WriteTransactionStatus<T>> implementation.

Applied to files:

  • crates/common/src/raindex_client/local_db/query/fetch_transaction_by_hash.rs
  • crates/common/src/raindex_client/remove_orders.rs
  • crates/common/src/raindex_client/transactions.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/query/fetch_transaction_by_hash.rs
  • crates/common/src/raindex_client/local_db/transactions.rs
  • crates/common/src/local_db/query/fetch_transaction_by_hash/mod.rs
  • crates/common/src/raindex_client/transactions.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/query/fetch_transaction_by_hash.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/add_orders.rs
  • crates/common/src/raindex_client/remove_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/add_orders.rs
  • crates/common/src/raindex_client/remove_orders.rs
📚 Learning: 2025-05-19T18:41:27.521Z
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1860
File: packages/ui-components/src/lib/services/awaitTransactionIndexing.ts:117-152
Timestamp: 2025-05-19T18:41:27.521Z
Learning: In the Rain Orderbook system, transaction indexing polling should continue running until completion (success or timeout) regardless of UI component state, as the transaction listener depends on this behavior to properly track transaction confirmations.

Applied to files:

  • crates/common/src/raindex_client/add_orders.rs
  • crates/common/src/raindex_client/remove_orders.rs
  • crates/common/src/raindex_client/transactions.rs
  • packages/ui-components/src/lib/providers/transactions/TransactionManager.ts
📚 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/local_db/transactions.rs
  • crates/common/src/raindex_client/remove_orders.rs
  • crates/common/src/raindex_client/transactions.rs
📚 Learning: 2025-12-03T10:40:25.429Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2344
File: crates/common/src/local_db/pipeline/runner/mod.rs:18-31
Timestamp: 2025-12-03T10:40:25.429Z
Learning: In `crates/common/src/local_db/pipeline/runner/mod.rs`, the `TargetSuccess` struct does not need separate `ob_id` or `orderbook_key` fields because the contained `SyncOutcome` already includes orderbook identification information such as chain_id and orderbook_address. This avoids redundant data duplication.

Applied to files:

  • crates/common/src/raindex_client/local_db/transactions.rs
  • crates/common/src/raindex_client/remove_orders.rs
  • crates/common/src/local_db/query/fetch_transaction_by_hash/mod.rs
  • crates/common/src/raindex_client/transactions.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/transactions.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/local_db/query/fetch_transaction_by_hash/mod.rs
  • crates/common/src/raindex_client/transactions.rs
📚 Learning: 2025-05-20T12:08:13.760Z
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1870
File: packages/webapp/src/__tests__/WithdrawModal.test.ts:74-97
Timestamp: 2025-05-20T12:08:13.760Z
Learning: In the WithdrawModal test suite, testing that transactions are correctly passed to the transactionStore is considered sufficient coverage, without needing explicit tests for callback execution.

Applied to files:

  • packages/ui-components/src/__tests__/TransactionManager.test.ts
📚 Learning: 2025-06-04T10:21:01.388Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1907
File: packages/orderbook/test/common/test.test.ts:75-77
Timestamp: 2025-06-04T10:21:01.388Z
Learning: The DotrainOrder.create API in packages/orderbook/test/common/test.test.ts is internal and not used directly in consumer applications, so API changes here don't require external breaking change documentation.

Applied to files:

  • packages/ui-components/src/__tests__/TransactionManager.test.ts
  • packages/ui-components/src/lib/providers/transactions/TransactionManager.ts
📚 Learning: 2025-09-02T08:04:44.814Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2117
File: packages/ui-components/src/__tests__/VaultIdInformation.test.ts:9-13
Timestamp: 2025-09-02T08:04:44.814Z
Learning: In packages/ui-components/src/__tests__/VaultIdInformation.test.ts and similar test files in the rain.orderbook project, the passthrough vi.mock('rainlanguage/orderbook', async (importOriginal) => { return { ...(await importOriginal()) }; }); block is required for tests to run properly, even when not overriding any exports. This is needed due to the specific Vitest configuration or test environment setup in the project.

Applied to files:

  • packages/ui-components/src/__tests__/TransactionManager.test.ts
📚 Learning: 2025-05-19T17:16:54.732Z
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1831
File: packages/ui-components/src/__tests__/transactionStore.test.ts:3-5
Timestamp: 2025-05-19T17:16:54.732Z
Learning: In the rain.orderbook project, there is an ongoing migration of transaction handling from the legacy transactionStore to a new TransactionManager. TransactionStatusMessage has been moved to lib/types/transaction.ts, while TransactionErrorMessage is still in transactionStore but will be moved once other transactions are migrated.

Applied to files:

  • packages/ui-components/src/__tests__/TransactionManager.test.ts
  • packages/ui-components/src/lib/providers/transactions/TransactionManager.ts
📚 Learning: 2025-07-09T12:35:45.699Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1974
File: packages/ui-components/src/__tests__/DeploymentSteps.test.ts:123-126
Timestamp: 2025-07-09T12:35:45.699Z
Learning: In packages/ui-components/src/__tests__/DeploymentSteps.test.ts, findolor prefers to keep mock initializations (like setSelectToken) in individual test cases rather than consolidating them into shared beforeEach blocks, even when it results in duplication.

Applied to files:

  • packages/ui-components/src/__tests__/TransactionManager.test.ts
📚 Learning: 2025-05-27T12:20:52.644Z
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1831
File: packages/webapp/src/routes/orders/[network]-[orderHash]/+page.svelte:24-35
Timestamp: 2025-05-27T12:20:52.644Z
Learning: In the new TransactionManager architecture introduced in PR #1831, errors are automatically surfaced by the TransactionManager through errToast calls in the error callbacks. Additional try-catch error handling around transaction manager methods like handleRemoveOrder is unnecessary since the manager handles error reporting internally.

Applied to files:

  • packages/ui-components/src/__tests__/TransactionManager.test.ts
  • packages/ui-components/src/lib/providers/transactions/TransactionManager.ts
📚 Learning: 2025-06-05T12:21:33.969Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1831
File: packages/ui-components/src/lib/types/transaction.ts:76-84
Timestamp: 2025-06-05T12:21:33.969Z
Learning: In packages/ui-components/src/lib/types/transaction.ts, the `queryKey` property is intentionally declared in both `InternalTransactionArgs` and `TransactionArgs` types. This duplication should be kept as per the project's design preferences.

Applied to files:

  • packages/ui-components/src/__tests__/TransactionManager.test.ts
  • packages/ui-components/src/lib/providers/transactions/TransactionManager.ts
📚 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:

  • packages/ui-components/src/__tests__/TransactionManager.test.ts
  • crates/common/src/raindex_client/transactions.rs
📚 Learning: 2025-05-19T18:24:17.608Z
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1860
File: packages/ui-components/src/lib/stores/transactionStore.ts:130-136
Timestamp: 2025-05-19T18:24:17.608Z
Learning: In the `rain.orderbook` project, the `awaitSubgraphIndexing` function has a two-step validation process: it first checks that `data.value` from `WasmEncodedResult` exists, and only then applies the `isSuccess` predicate. This makes a simple truthiness check (`!!data`) sufficient in the `isSuccess` predicate since the value has already been pre-validated.

Applied to files:

  • packages/ui-components/src/__tests__/TransactionManager.test.ts
  • packages/ui-components/src/lib/providers/transactions/TransactionManager.ts
📚 Learning: 2025-06-30T14:17:16.626Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1926
File: packages/ui-components/src/lib/__mocks__/stores.ts:13-17
Timestamp: 2025-06-30T14:17:16.626Z
Learning: User findolor reports that vi.mock(import('rainlanguage/orderbook'), async (importOriginal) => { ... }) syntax works in their testing environment, despite official Vitest documentation indicating the first argument should be a string. This suggests there may be specific Vitest versions or configurations that support dynamic import() as the first argument to vi.mock().

Applied to files:

  • packages/ui-components/src/__tests__/TransactionManager.test.ts
📚 Learning: 2025-05-19T15:07:45.148Z
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1831
File: packages/ui-components/src/__tests__/Transaction.test.ts:32-194
Timestamp: 2025-05-19T15:07:45.148Z
Learning: The TransactionStore always requires a subgraphUrl property and will always attempt to perform subgraph indexing. It may throw an error if the URL is invalid or fails to fetch, but it doesn't skip indexing when subgraphUrl is present.

Applied to files:

  • packages/ui-components/src/__tests__/TransactionManager.test.ts
  • packages/ui-components/src/lib/providers/transactions/TransactionManager.ts
📚 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/transactions.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/transactions.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/transactions.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/transactions.rs
📚 Learning: 2025-05-21T07:31:33.048Z
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1831
File: packages/ui-components/src/lib/types/transaction.ts:58-66
Timestamp: 2025-05-21T07:31:33.048Z
Learning: In the transaction handling system for rain.orderbook, the chainId parameter is intentionally kept separate from the wagmi config in transaction argument types, as they come from different sources - chainId from YAML configuration and config from wagmi.

Applied to files:

  • crates/common/src/raindex_client/transactions.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/transactions.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/transactions.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/transactions.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/transactions.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/transactions.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/transactions.rs
📚 Learning: 2025-06-09T11:14:12.358Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1891
File: packages/webapp/src/lib/services/handleAddOrder.ts:94-94
Timestamp: 2025-06-09T11:14:12.358Z
Learning: In the handleAddOrder function in packages/webapp/src/lib/services/handleAddOrder.ts, using an empty string fallback for undefined subgraphUrl is acceptable. When subgraphUrl is missing/empty, transaction indexing cannot be shown to the user, but the deployment functionality still works and users can manually navigate to the order page to view their deployed orders. This graceful degradation approach is preferred over making subgraphUrl required.

Applied to files:

  • packages/ui-components/src/lib/providers/transactions/TransactionManager.ts
📚 Learning: 2025-05-19T10:39:19.157Z
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1831
File: packages/ui-components/src/lib/types/transaction.ts:71-77
Timestamp: 2025-05-19T10:39:19.157Z
Learning: In the Rain Orderbook project, `orderHash` is intentionally typed as `string` (not `Hex`) in the `InternalTransactionArgs` interface because it matches the return type of the `getRemoveOrderCalldata` WASM function which returns `Promise<string>`. String operations like `.slice()` are performed on `orderHash` in the code. Meanwhile, `txHash` is typed as `Hex` for blockchain transaction hashes.

Applied to files:

  • packages/ui-components/src/lib/providers/transactions/TransactionManager.ts
🧬 Code graph analysis (7)
crates/common/src/local_db/query/mod.rs (1)
crates/common/src/raindex_client/local_db/query/fetch_transaction_by_hash.rs (1)
  • fetch_transaction_by_hash (8-15)
crates/common/src/raindex_client/local_db/query/fetch_transaction_by_hash.rs (3)
crates/common/src/local_db/query/fetch_transaction_by_hash/mod.rs (1)
  • build_fetch_transaction_by_hash_stmt (22-34)
crates/common/src/raindex_client/local_db/executor.rs (2)
  • create_sql_capturing_callback (170-193)
  • from_ref (25-27)
crates/common/src/local_db/query/sql_statement.rs (1)
  • sql (99-101)
crates/common/src/raindex_client/local_db/transactions.rs (3)
crates/common/src/local_db/query/fetch_transaction_by_hash/mod.rs (1)
  • build_fetch_transaction_by_hash_stmt (22-34)
crates/common/src/raindex_client/local_db/mod.rs (4)
  • new (44-82)
  • new (143-145)
  • new (238-244)
  • exec (73-73)
crates/common/src/raindex_client/transactions.rs (3)
  • from_local_parts (82-94)
  • id (47-49)
  • id (67-69)
crates/common/src/raindex_client/remove_orders.rs (1)
crates/common/src/local_db/pipeline/engine.rs (1)
  • tx_hash (376-380)
crates/common/src/local_db/query/fetch_transaction_by_hash/mod.rs (1)
crates/common/src/local_db/query/sql_statement.rs (3)
  • new_with_params (87-97)
  • sql (99-101)
  • params (103-105)
packages/ui-components/src/__tests__/TransactionManager.test.ts (2)
packages/ui-components/src/lib/types/transaction.ts (1)
  • IndexingContext (11-20)
packages/ui-components/src/lib/index.ts (2)
  • TransactionStatusMessage (76-76)
  • TransactionStoreErrorMessage (77-77)
crates/common/src/raindex_client/local_db/query/mod.rs (1)
crates/common/src/raindex_client/local_db/query/fetch_transaction_by_hash.rs (1)
  • fetch_transaction_by_hash (8-15)
🔇 Additional comments (25)
packages/ui-components/src/__tests__/TransactionManager.test.ts (3)

421-460: LGTM! Well-structured test for withdraw SDK-based indexing.

The test properly verifies:

  • awaitIndexingFn is defined and callable
  • The SDK method getTransaction is called with correct arguments (chainId, orderbook, txHash)
  • Success callback is invoked on valid response

744-819: LGTM! Comprehensive test coverage for deposit SDK-based indexing.

Both success and timeout scenarios are well covered. The timeout error message format ("Timeout waiting for transaction...") aligns with the updated SDK error format.


1070-1073: LGTM! Timeout error message updated to match SDK format.

The updated message format "Timeout waiting for transaction 0x123abc to be indexed after 10 attempts." correctly reflects the new SDK TransactionIndexingTimeout error format, which differs from the previous subgraph-specific wording.

packages/ui-components/src/lib/providers/transactions/TransactionManager.ts (3)

224-227: LGTM! SDK-based indexing for withdraw transactions.

The implementation correctly uses createSdkIndexingFn with raindexClient.getTransaction. The !!tx success predicate is appropriate here—based on learnings, the WasmEncodedResult validation ensures only valid data is returned, making a simple truthiness check sufficient.


286-289: LGTM! Consistent implementation for multi-vault withdrawal.

Follows the same SDK-based indexing pattern as createWithdrawTransaction, maintaining consistency across the codebase.


405-408: LGTM! SDK-based indexing for deposit transactions.

Consistent with the withdraw implementations. The pattern change from subgraph-based to SDK-based indexing is applied uniformly across deposit and withdraw flows.

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

264-265: TransactionIndexingTimeout variant and message look consistent

The new TransactionIndexingTimeout { tx_hash, attempts } variant and its readable message line up with the two-phase (local DB + subgraph) polling semantics, and the payload types match the call sites.

Also applies to: 368-371

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

18-18: New transactions submodule wiring is appropriate

Exporting pub mod transactions; cleanly exposes the new local-DB transaction helper surface from the raindex_client::local_db module.

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

15-15: Wiring fetch_transaction_by_hash into the local_db query surface is correct

Adding pub mod fetch_transaction_by_hash; here keeps the query API consistent with other fetch_* modules and enables reuse by higher-level clients.

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

10-10: Raindex client query module export is aligned

Exposing fetch_transaction_by_hash from the raindex_client-local_db query namespace matches the core local_db query structure and enables the new helper wrapper.

crates/common/src/local_db/query/fetch_transaction_by_hash/query.sql (1)

1-39: SQL template correctly unifies deposits/withdrawals by transaction hash

The params CTE, UNION ALL over deposits and withdrawals, and the final camelCase projection with ORDER BY log_index ASC LIMIT 1 all match the intended “first event for this (chain, orderbook, tx_hash)” semantics and align with LocalDbTransaction’s shape. Just ensure the table/column names stay in sync with the local DB schema.

If you haven’t already, please run the existing local DB SQL tests (or add one) that executes this query against a test DB with both deposits and withdrawals to confirm the shape and column names match the Rust LocalDbTransaction type.

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

170-171: Timeout error rename for remove-orders flow is consistent and covered by tests

get_remove_orders_for_transaction now returns RaindexError::TransactionIndexingTimeout { tx_hash, attempts } on exhausted polling, and the timeout test asserts the attempts value, keeping behavior the same while aligning terminology with transaction-level indexing.

Also applies to: 684-687

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

166-167: Add-orders polling now uses the unified TransactionIndexingTimeout variant

The add-orders polling path correctly returns RaindexError::TransactionIndexingTimeout { tx_hash, attempts } when no results are found after all attempts, and the updated test validates the attempt count, keeping behavior aligned with the remove-orders flow.

Also applies to: 578-581

crates/common/src/raindex_client/local_db/query/fetch_transaction_by_hash.rs (1)

8-15: Wrapper around build_fetch_transaction_by_hash_stmt is minimal and correct

The fetch_transaction_by_hash helper cleanly delegates to the shared SQL builder and LocalDbQueryExecutor::query_json, returning Vec<LocalDbTransaction> as expected from the LIMIT 1 query.

crates/common/src/local_db/query/fetch_transaction_by_hash/mod.rs (3)

1-18: LGTM! Well-structured module with appropriate imports and data types.

The LocalDbTransaction struct is properly defined with clear field types matching the expected database schema. The use of #[serde(rename_all = "camelCase")] ensures proper JSON serialization alignment with the query results.


22-34: Function implementation looks correct.

The builder correctly constructs a SqlStatement using new_with_params with the three required parameters (chain_id, orderbook_address, tx_hash) in the expected order. This aligns with the relevant code snippet showing how SqlStatement::new_with_params works.


41-54: Consider accessing fields via accessor methods instead of direct struct field access.

The test accesses stmt.sql and stmt.params directly. Based on the relevant code snippets, SqlStatement provides sql() and params() accessor methods. Using accessors is more idiomatic and respects encapsulation.

         let stmt = build_fetch_transaction_by_hash_stmt(&ob_id, tx_hash);

-        assert!(stmt.sql.contains("SELECT"));
-        assert!(stmt.sql.contains("FROM deposits"));
-        assert!(stmt.sql.contains("FROM withdrawals"));
-        assert!(stmt.sql.contains("transaction_hash"));
-        assert_eq!(stmt.params.len(), 3);
+        assert!(stmt.sql().contains("SELECT"));
+        assert!(stmt.sql().contains("FROM deposits"));
+        assert!(stmt.sql().contains("FROM withdrawals"));
+        assert!(stmt.sql().contains("transaction_hash"));
+        assert_eq!(stmt.params().len(), 3);
⛔ Skipped due to learnings
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.
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.
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1713
File: crates/settings/src/remote/chains/mod.rs:43-226
Timestamp: 2025-05-13T20:06:22.602Z
Learning: When writing tests for collections of complex objects in Rust, prefer item-by-item comparison over direct vector comparison to get more specific error messages that pinpoint exactly which item and field has a mismatch.
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1874
File: tauri-app/src-tauri/src/transaction_status.rs:87-114
Timestamp: 2025-05-27T06:16:12.195Z
Learning: In tauri-app/src-tauri/src/transaction_status.rs, testing one WriteTransactionStatus variant (like PendingPrepare) is sufficient for the update_status_and_emit method since all variants follow the same code path through the From<WriteTransactionStatus<T>> implementation.
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2186
File: crates/common/src/raindex_client/local_db/query/update_last_synced_block/query.sql:4-5
Timestamp: 2025-10-10T05:16:12.250Z
Learning: In the rain.orderbook codebase, SQL templates use string replacement rather than parameterized queries. Placeholders that represent string values (like `?orderbook_address`) should remain quoted in the SQL template (e.g., `'?orderbook_address'`) because the implementation escapes and replaces these placeholders directly, resulting in properly quoted SQL values after replacement.
crates/common/src/raindex_client/transactions.rs (4)

20-32: LGTM! Well-designed cross-platform sleep helper.

The polling constants and sleep_ms helper functions provide clean abstractions for both WASM and non-WASM targets. The WASM implementation correctly caps the delay to u32::MAX to avoid overflow when converting from u64.


175-195: Two-phase polling with full local DB window is well-designed.

The approach of giving the local DB the full polling window before falling back to subgraph is a good design choice that maximizes the chance of local DB success while maintaining predictable timing.

One consideration: if local DB is available but the chain isn't supported (is_chain_supported_local_db returns false), the code correctly skips Phase 1 and proceeds to Phase 2. However, verify that this is the intended behavior for unsupported chains.


197-216: Subgraph polling fallback correctly handles errors and timeout.

The error handling differentiates between:

  • OrderbookSubgraphClientError::Empty → retry on next attempt
  • Other errors → propagate immediately

The TransactionIndexingTimeout error is correctly returned after exhausting all attempts. The loop bounds are correct (1..=attempts ensures exactly attempts iterations).


306-381: Good test coverage for polling success and timeout scenarios.

The tests effectively cover:

  1. test_get_transaction - basic successful fetch
  2. test_get_transaction_with_polling_success - polling with custom parameters
  3. test_get_transaction_timeout - timeout behavior verification

The use of short intervals (10ms) in tests is appropriate for fast test execution.

crates/common/src/raindex_client/local_db/transactions.rs (4)

11-18: Clean struct design with appropriate lifetime bounds.

The LocalDbTransactions<'a> struct correctly uses a lifetime parameter to borrow LocalDb, avoiding unnecessary cloning. The pub(crate) visibility on both the field and constructor is appropriate for internal use.


22-41: LGTM! Implementation correctly handles both found and not-found cases.

The method:

  1. Builds the statement using the shared builder function
  2. Executes the query via query_json
  3. Returns the first result (if any) converted to RaindexTransaction
  4. Returns None when no results are found

This aligns with the relevant code snippet showing the fetch_transaction_by_hash function's expected behavior.


59-77: Well-crafted mock callback for WASM testing.

The create_mock_callback function creates a properly structured WasmEncodedResult::Success response that mimics the actual callback behavior. This isolates the test from browser APIs, which aligns with the learning about testing pure logic separately from browser integration.


79-126: Good WASM test coverage for success and not-found scenarios.

The tests verify:

  1. test_get_by_tx_hash_returns_transaction_when_found - successful retrieval with proper field mapping
  2. test_get_by_tx_hash_returns_none_when_not_found - empty result handling

Based on the learnings, WASM tests focus on basic functionality while comprehensive tests remain in the non-WASM environment.

Comment on lines +17 to +84
#[cfg(all(test, target_family = "wasm"))]
mod wasm_tests {
use super::*;
use crate::raindex_client::local_db::executor::tests::create_sql_capturing_callback;
use crate::raindex_client::local_db::executor::JsCallbackExecutor;
use alloy::primitives::{address, b256, Address};
use std::cell::RefCell;
use std::rc::Rc;
use wasm_bindgen_test::*;
use wasm_bindgen_utils::prelude::*;

#[wasm_bindgen_test]
async fn wrapper_uses_builder_sql_exactly() {
let tx_hash = b256!("0x0000000000000000000000000000000000000000000000000000000000000abc");
let orderbook = Address::from([0x51; 20]);
let expected_stmt =
build_fetch_transaction_by_hash_stmt(&OrderbookIdentifier::new(1, orderbook), tx_hash);

let store = Rc::new(RefCell::new((String::new(), JsValue::UNDEFINED)));
let callback = create_sql_capturing_callback("[]", store.clone());
let exec = JsCallbackExecutor::from_ref(&callback);

let res = super::fetch_transaction_by_hash(
&exec,
&OrderbookIdentifier::new(1, orderbook),
tx_hash,
)
.await;
assert!(res.is_ok());
assert_eq!(store.borrow().clone().0, expected_stmt.sql);
}

#[wasm_bindgen_test]
async fn wrapper_returns_rows_when_present() {
let tx_hash = b256!("0x0000000000000000000000000000000000000000000000000000000000000abc");
let orderbook = address!("0x5151515151515151515151515151515151515151");
let sender = address!("0x1111111111111111111111111111111111111111");
let expected_stmt =
build_fetch_transaction_by_hash_stmt(&OrderbookIdentifier::new(1, orderbook), tx_hash);

let row_json = format!(
r#"[{{
"transactionHash":"{}",
"blockNumber":100,
"blockTimestamp":999,
"sender":"{}"
}}]"#,
tx_hash, sender
);

let store = Rc::new(RefCell::new((
String::new(),
wasm_bindgen::JsValue::UNDEFINED,
)));
let callback = create_sql_capturing_callback(&row_json, store.clone());
let exec = JsCallbackExecutor::from_ref(&callback);

let res = super::fetch_transaction_by_hash(
&exec,
&OrderbookIdentifier::new(1, orderbook),
tx_hash,
)
.await;
assert!(res.is_ok());
let rows = res.unwrap();
assert_eq!(rows.len(), 1);
assert_eq!(store.borrow().clone().0, expected_stmt.sql);
}
Copy link
Contributor

@coderabbitai coderabbitai bot Dec 5, 2025

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

WASM tests exercise both SQL wiring and row deserialization effectively

The two wasm tests confirm that:

  • The exact SQL emitted by build_fetch_transaction_by_hash_stmt is what the wrapper sends, and
  • A correctly shaped JSON row round-trips into LocalDbTransaction.

This gives good coverage of the wrapper without over-reaching into implementation details; the only minor consideration is that depending on executor::tests::create_sql_capturing_callback couples these tests to another module’s test helpers, which is fine but could be brittle if those helpers are refactored. If that becomes an issue, consider moving the helper into a non-test-only module or re-exporting it at a stable path.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it's fine as it is

Copy link
Contributor

Choose a reason for hiding this comment

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

@findolor, sounds good! The current implementation works well for your use case.

(\ /)
( •.•)
/ > 🔍 noted


🧠 Learnings used
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1860
File: packages/ui-components/src/lib/stores/transactionStore.ts:130-136
Timestamp: 2025-05-19T18:24:17.608Z
Learning: In the `rain.orderbook` project, the `getTransaction` function (and related entity fetch functions) use `wasmEncodedResult` to validate the returned data, ensuring that only valid data is returned. This makes a simple truthiness check (`!!data`) sufficient for the `isSuccess` predicate in `awaitSubgraphIndexing`.

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.

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.

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: 1874
File: tauri-app/src-tauri/src/transaction_status.rs:87-114
Timestamp: 2025-05-27T06:16:12.195Z
Learning: In tauri-app/src-tauri/src/transaction_status.rs, testing one WriteTransactionStatus variant (like PendingPrepare) is sufficient for the update_status_and_emit method since all variants follow the same code path through the From<WriteTransactionStatus<T>> implementation.

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.

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.

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.

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.

Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1831
File: packages/ui-components/src/lib/types/transaction.ts:71-77
Timestamp: 2025-05-19T10:39:19.157Z
Learning: In the Rain Orderbook project, `orderHash` is intentionally typed as `string` (not `Hex`) in the `InternalTransactionArgs` interface because it matches the return type of the `getRemoveOrderCalldata` WASM function which returns `Promise<string>`. String operations like `.slice()` are performed on `orderHash` in the code. Meanwhile, `txHash` is typed as `Hex` for blockchain transaction hashes.

Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1715
File: crates/js_api/src/common/mod.rs:15-22
Timestamp: 2025-05-14T05:52:04.270Z
Learning: The project doesn't require `#[repr(transparent)]` for newtype wrappers in WASM contexts such as `AddOrderCalldata` and `RemoveOrderCalldata` as the current implementation is working as expected without it.

Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1870
File: packages/webapp/src/__tests__/WithdrawModal.test.ts:74-97
Timestamp: 2025-05-20T12:08:13.760Z
Learning: In the WithdrawModal test suite, testing that transactions are correctly passed to the transactionStore is considered sufficient coverage, without needing explicit tests for callback execution.

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.

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.

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: brusherru
Repo: rainlanguage/rain.orderbook PR: 2044
File: tauri-app/src/routes/orders/[chainId]-[orderbook]-[orderHash]/+page.svelte:76-78
Timestamp: 2025-07-31T19:03:56.594Z
Learning: In the rainlanguage/rain.orderbook project, when the Tauri app has issues preventing proper testing, the team prefers to defer Tauri-specific implementations to separate PRs rather than including untested code, especially for financial operations like withdrawals.

Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1504
File: tauri-app/src/routes/orders/[network]-[orderHash]/+page.svelte:33-37
Timestamp: 2025-04-08T16:35:15.127Z
Learning: In the Rain OrderBook project, the onDeposit and onWithdraw functions in page components are kept simple (just calling modal handlers and revalidating queries) because error handling for deposit and withdraw actions (including user cancellations and failed transactions) is handled within the modal components themselves.

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: 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: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: 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:26:31.566Z
Learning: For PR #1884 and future PRs in rainlanguage/rain.orderbook repository, provide PR size reports in a separate comment with ONLY the exact format "TOTAL=number\nADDITIONS=number\nDELETIONS=number", without any additional text or explanation. Reports should exclude irrelevant files such as lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock).

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.

2 participants