-
Notifications
You must be signed in to change notification settings - Fork 13
Add vault balance change type filtering #2370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughAdds optional type-based filtering for vault balance changes across stack: new kinds/filters and mappings, dynamic IN-clause SQL binding, subgraph client typename filtering, propagation through raindex APIs and UI, plus related types, conversions, fixtures, and tests. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant UI as VaultBalanceChangeTypeFilter
participant Table as VaultBalanceChangesTable
participant Raindex as Raindex API
participant Subgraph as Subgraph Client
participant LocalDB as Local DB
rect rgba(200,230,255,0.35)
User->>UI: select filter types
UI->>Table: emit selected filterTypes
Table->>Raindex: get_balance_changes(vault_id, pagination?, filter_types)
end
par Local DB path
Raindex->>LocalDB: fetch_vault_balance_changes(vault_id, token, owner, filter_kinds)
LocalDB->>LocalDB: build SQL with CHANGE_TYPES IN-clause
LocalDB-->>Raindex: return filtered local results
and Subgraph path
Raindex->>Subgraph: vault_balance_changes_list(..., filter_typenames)
Subgraph->>Subgraph: apply client-side typename filter (if provided)
Subgraph-->>Raindex: return filtered subgraph results
end
Raindex-->>Table: merge and return results
Table->>User: render updated rows
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this 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: Organization UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (13)
crates/cli/src/commands/vault/list_balance_changes.rscrates/common/src/local_db/query/fetch_vault_balance_changes/mod.rscrates/common/src/local_db/query/fetch_vault_balance_changes/query.sqlcrates/common/src/raindex_client/local_db/query/fetch_vault_balance_changes.rscrates/common/src/raindex_client/vaults.rscrates/subgraph/src/orderbook_client/vault.rspackages/ui-components/src/__tests__/DropdownCheckbox.test.tspackages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.tspackages/ui-components/src/__tests__/VaultBalanceChangesTable.test.tspackages/ui-components/src/lib/components/VaultBalanceChangeTypeFilter.sveltepackages/ui-components/src/lib/components/dropdown/DropdownCheckbox.sveltepackages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.sveltepackages/ui-components/src/lib/index.ts
🧰 Additional context used
📓 Path-based instructions (10)
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 usingnix develop -c npm run svelte-lint-format-check -w @rainlanguage/ui-components
Files:
packages/ui-components/src/lib/index.tspackages/ui-components/src/lib/components/VaultBalanceChangeTypeFilter.sveltepackages/ui-components/src/__tests__/VaultBalanceChangesTable.test.tspackages/ui-components/src/__tests__/DropdownCheckbox.test.tspackages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.sveltepackages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.tspackages/ui-components/src/lib/components/dropdown/DropdownCheckbox.svelte
packages/ui-components/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
For UI components (
packages/ui-components), run tests usingnix develop -c npm run test -w @rainlanguage/ui-components
Files:
packages/ui-components/src/lib/index.tspackages/ui-components/src/__tests__/VaultBalanceChangesTable.test.tspackages/ui-components/src/__tests__/DropdownCheckbox.test.tspackages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.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/lib/index.tspackages/ui-components/src/lib/components/VaultBalanceChangeTypeFilter.sveltepackages/ui-components/src/__tests__/VaultBalanceChangesTable.test.tspackages/ui-components/src/__tests__/DropdownCheckbox.test.tspackages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.sveltepackages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.tspackages/ui-components/src/lib/components/dropdown/DropdownCheckbox.svelte
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/lib/index.tspackages/ui-components/src/lib/components/VaultBalanceChangeTypeFilter.sveltepackages/ui-components/src/__tests__/VaultBalanceChangesTable.test.tspackages/ui-components/src/__tests__/DropdownCheckbox.test.tspackages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.sveltepackages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.tspackages/ui-components/src/lib/components/dropdown/DropdownCheckbox.svelte
**/*.{ts,tsx,svelte}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx,svelte}: TypeScript/Svelte: format withnix develop -c npm run format
TypeScript/Svelte: lint withnix develop -c npm run lint
TypeScript/Svelte: type-check withnix develop -c npm run check
Files:
packages/ui-components/src/lib/index.tspackages/ui-components/src/lib/components/VaultBalanceChangeTypeFilter.sveltepackages/ui-components/src/__tests__/VaultBalanceChangesTable.test.tspackages/ui-components/src/__tests__/DropdownCheckbox.test.tspackages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.sveltepackages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.tspackages/ui-components/src/lib/components/dropdown/DropdownCheckbox.svelte
**/*.svelte
📄 CodeRabbit inference engine (AGENTS.md)
Svelte components should use
PascalCase.sveltenaming convention; other files use kebab or snake case as appropriate
Files:
packages/ui-components/src/lib/components/VaultBalanceChangeTypeFilter.sveltepackages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.sveltepackages/ui-components/src/lib/components/dropdown/DropdownCheckbox.svelte
**/*.{test,spec}.ts
📄 CodeRabbit inference engine (AGENTS.md)
TypeScript/Svelte: run tests with
nix develop -c npm run test(Vitest). Name test files*.test.tsor*.spec.ts
Files:
packages/ui-components/src/__tests__/VaultBalanceChangesTable.test.tspackages/ui-components/src/__tests__/DropdownCheckbox.test.tspackages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.ts
crates/**/*.rs
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
crates/**/*.rs: For Rust crates incrates/*, run lints usingnix develop -c cargo clippy --workspace --all-targets --all-features -D warnings
For Rust crates incrates/*, run tests usingnix develop -c cargo test --workspaceor--package <crate>
Files:
crates/common/src/raindex_client/local_db/query/fetch_vault_balance_changes.rscrates/common/src/local_db/query/fetch_vault_balance_changes/mod.rscrates/subgraph/src/orderbook_client/vault.rscrates/cli/src/commands/vault/list_balance_changes.rscrates/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/local_db/query/fetch_vault_balance_changes.rscrates/common/src/local_db/query/fetch_vault_balance_changes/mod.rscrates/subgraph/src/orderbook_client/vault.rscrates/cli/src/commands/vault/list_balance_changes.rscrates/common/src/local_db/query/fetch_vault_balance_changes/query.sqlcrates/common/src/raindex_client/vaults.rs
**/*.rs
📄 CodeRabbit inference engine (AGENTS.md)
**/*.rs: Rust: format code withnix develop -c cargo fmt --all
Rust: lint withnix develop -c rainix-rs-static(preconfigured flags included)
Rust: crates and modules usesnake_case; types usePascalCase
Files:
crates/common/src/raindex_client/local_db/query/fetch_vault_balance_changes.rscrates/common/src/local_db/query/fetch_vault_balance_changes/mod.rscrates/subgraph/src/orderbook_client/vault.rscrates/cli/src/commands/vault/list_balance_changes.rscrates/common/src/raindex_client/vaults.rs
🧠 Learnings (50)
📓 Common learnings
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: 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: 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: 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.
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: 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: 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.
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1744
File: packages/webapp/src/lib/components/DepositOrWithdrawModal.svelte:73-76
Timestamp: 2025-05-09T05:30:02.520Z
Learning: In Rain.orderbook, `VaultCalldataResult` is a wrapper type that contains both `error` and `value` properties. When using this in the `DepositOrWithdrawModal` component, only the inner `value` field is passed to the `handleTransaction` function, not the complete wrapper.
📚 Learning: 2025-07-17T10:36:02.846Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1996
File: packages/ui-components/src/__tests__/VaultIdInformation.test.ts:6-6
Timestamp: 2025-07-17T10:36:02.846Z
Learning: In packages/ui-components/src/__tests__/VaultIdInformation.test.ts, findolor prefers to keep exported type aliases like `VaultIdInformationComponentProps` in test files, even when static analysis tools flag this as discouraged practice.
Applied to files:
packages/ui-components/src/lib/index.tspackages/ui-components/src/lib/components/VaultBalanceChangeTypeFilter.sveltepackages/ui-components/src/__tests__/VaultBalanceChangesTable.test.tspackages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.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/lib/index.tspackages/ui-components/src/__tests__/VaultBalanceChangesTable.test.tspackages/ui-components/src/__tests__/DropdownCheckbox.test.tspackages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.ts
📚 Learning: 2025-12-11T07:46:32.817Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2358
File: packages/ui-components/src/lib/components/tables/OrdersListTable.svelte:82-85
Timestamp: 2025-12-11T07:46:32.817Z
Learning: In packages/ui-components/src/lib/components/tables/OrdersListTable.svelte, the token filter intentionally sets both inputs and outputs to the same selectedTokens array (lines 82-85) to achieve OR filtering behavior. This is by design: the single UI token filter should match orders containing the selected token(s) in either inputs OR outputs, not pair-specific filtering. Even though the API supports more granular directional filtering, the UI uses the same tokens in both fields for broader matching.
Applied to files:
packages/ui-components/src/lib/index.tspackages/ui-components/src/lib/components/VaultBalanceChangeTypeFilter.sveltepackages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.svelte
📚 Learning: 2025-07-29T12:30:44.350Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2045
File: packages/ui-components/src/lib/components/deployment/TokenSelectionModal.svelte:52-59
Timestamp: 2025-07-29T12:30:44.350Z
Learning: In packages/ui-components/src/lib/components/deployment/TokenSelectionModal.svelte, the bind:this approach doesn't work for auto-focusing the Flowbite Input component when the modal opens, requiring the use of document.querySelector('.token-search-input') instead as a working solution.
Applied to files:
packages/ui-components/src/lib/index.ts
📚 Learning: 2025-03-31T14:01:19.067Z
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1493
File: packages/ui-components/src/lib/components/deployment/DeployButton.svelte:0-0
Timestamp: 2025-03-31T14:01:19.067Z
Learning: The DeployButton component in packages/ui-components/src/lib/components/deployment/DeployButton.svelte is designed to be generic, dispatching clickDeploy events to be handled at the page level, where validation of event details (result, networkKey, subgraphUrl) occurs.
Applied to files:
packages/ui-components/src/lib/index.ts
📚 Learning: 2025-06-18T16:44:14.948Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1925
File: packages/ui-components/src/lib/components/deployment/SelectToken.svelte:137-151
Timestamp: 2025-06-18T16:44:14.948Z
Learning: In the SelectToken.svelte component, the SDK validates addresses before making RPC calls, so calling saveTokenSelection on every keystroke in handleInput doesn't result in network calls until there's a full valid address.
Applied to files:
packages/ui-components/src/lib/index.ts
📚 Learning: 2025-09-02T08:05:07.646Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2117
File: packages/webapp/src/lib/components/DepositModal.svelte:25-28
Timestamp: 2025-09-02T08:05:07.646Z
Learning: In packages/webapp/src/lib/components/DepositModal.svelte, findolor considers the double-cast pattern `as unknown as AccountBalance` safe for initializing userBalance with Float.parse('0').value and formattedBalance: '0'.
Applied to files:
packages/ui-components/src/lib/components/VaultBalanceChangeTypeFilter.sveltepackages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.svelte
📚 Learning: 2025-08-19T04:15:33.633Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2036
File: packages/ui-components/src/lib/components/ListViewVaultFilters.svelte:33-52
Timestamp: 2025-08-19T04:15:33.633Z
Learning: In the ListViewVaultFilters.svelte component, the "Show my items only" filter is intentionally destructive for the owners field. When toggled, it should replace any existing owner filters (including those from URL parameters) rather than being additive. This is by design because the UI doesn't provide capability to filter by other owner addresses or remove specific owners from a list. The toggle serves as both a filter and a way for users to clear URL-based owner filters and switch to filtering by their own address only.
Applied to files:
packages/ui-components/src/lib/components/VaultBalanceChangeTypeFilter.svelte
📚 Learning: 2025-06-07T09:14:33.054Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1882
File: packages/webapp/src/lib/components/DepositModal.svelte:35-35
Timestamp: 2025-06-07T09:14:33.054Z
Learning: When reviewing shared types in TypeScript, it's normal for individual components to only destructure and use a subset of the available properties from the type. Shared types like VaultActionArgs are designed to accommodate the union of all use cases across multiple components, not just a single component's requirements.
Applied to files:
packages/ui-components/src/lib/components/VaultBalanceChangeTypeFilter.svelte
📚 Learning: 2025-05-09T05:30:02.520Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1744
File: packages/webapp/src/lib/components/DepositOrWithdrawModal.svelte:73-76
Timestamp: 2025-05-09T05:30:02.520Z
Learning: In Rain.orderbook, `VaultCalldataResult` is a wrapper type that contains both `error` and `value` properties. When using this in the `DepositOrWithdrawModal` component, only the inner `value` field is passed to the `handleTransaction` function, not the complete wrapper.
Applied to files:
packages/ui-components/src/lib/components/VaultBalanceChangeTypeFilter.sveltepackages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.sveltecrates/common/src/raindex_client/vaults.rs
📚 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__/VaultBalanceChangesTable.test.tspackages/ui-components/src/__tests__/DropdownCheckbox.test.tspackages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.ts
📚 Learning: 2025-08-14T14:16:34.044Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2083
File: packages/ui-components/src/lib/components/tables/VaultsListTable.svelte:205-205
Timestamp: 2025-08-14T14:16:34.044Z
Learning: In the VaultsListTable component, the `matchesAccount` function from the wallet provider may not properly update on wallet connect/disconnect events, making direct comparison with the reactive `$account` variable more reliable for UI visibility checks. The `matchesAccount` function needs future refactoring to handle wallet state changes properly.
Applied to files:
packages/ui-components/src/__tests__/VaultBalanceChangesTable.test.tspackages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.svelte
📚 Learning: 2025-08-04T09:07:00.160Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2048
File: packages/webapp/src/__tests__/WithdrawModal.test.ts:36-37
Timestamp: 2025-08-04T09:07:00.160Z
Learning: In packages/webapp/src/__tests__/WithdrawModal.test.ts and similar test files, findolor considers it acceptable to directly unwrap .value from Float.fromFixedDecimal() and Float.parse() calls without explicit error handling, preferring to keep test fixtures simple rather than adding comprehensive error checking.
Applied to files:
packages/ui-components/src/__tests__/VaultBalanceChangesTable.test.tspackages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.ts
📚 Learning: 2025-03-24T12:27:07.862Z
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1494
File: packages/ui-components/src/__tests__/WalletProvider.test.ts:18-28
Timestamp: 2025-03-24T12:27:07.862Z
Learning: In the WalletProvider tests, verifying that setAccountContext is called with the correct store is sufficient. Additional testing of Svelte's store implementation (like subscribing to verify the store value) is unnecessary as it would just be testing the framework itself.
Applied to files:
packages/ui-components/src/__tests__/VaultBalanceChangesTable.test.tspackages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.ts
📚 Learning: 2025-04-04T11:25:21.518Z
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1559
File: packages/ui-components/src/__tests__/OrderOrVaultHash.test.ts:94-94
Timestamp: 2025-04-04T11:25:21.518Z
Learning: In the rain.orderbook project, minimal test fixtures are preferred over complete mocks that implement the entire interface. Type casting (e.g., `as unknown as SgVault`) is an acceptable approach to maintain both minimal fixtures and TypeScript type compatibility.
Applied to files:
packages/ui-components/src/__tests__/VaultBalanceChangesTable.test.ts
📚 Learning: 2025-03-31T10:16:53.544Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1469
File: packages/ui-components/src/__tests__/CodeMirrorDotrain.test.ts:75-98
Timestamp: 2025-03-31T10:16:53.544Z
Learning: In the rainlanguage/rain.orderbook project, direct manipulation of Svelte's internal state (component.$$.ctx) in tests is an acceptable approach for testing component behavior, as demonstrated in the CodeMirrorDotrain tests.
Applied to files:
packages/ui-components/src/__tests__/VaultBalanceChangesTable.test.tspackages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.svelte
📚 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:
packages/ui-components/src/__tests__/VaultBalanceChangesTable.test.tscrates/common/src/raindex_client/local_db/query/fetch_vault_balance_changes.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:
packages/ui-components/src/__tests__/VaultBalanceChangesTable.test.tscrates/common/src/raindex_client/local_db/query/fetch_vault_balance_changes.rscrates/common/src/raindex_client/vaults.rs
📚 Learning: 2025-08-14T18:29:32.933Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2083
File: packages/ui-components/src/__tests__/VaultsListTable.test.ts:16-19
Timestamp: 2025-08-14T18:29:32.933Z
Learning: In the rain.orderbook project's UI components tests, mocking hooks like useToasts is often required as infrastructure even when not directly asserting on their calls, because components internally depend on these hooks. Removing such mocks would break component rendering in tests and require more complex test setup with providers.
Applied to files:
packages/ui-components/src/__tests__/VaultBalanceChangesTable.test.ts
📚 Learning: 2025-08-15T17:53:36.512Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2083
File: packages/ui-components/src/__tests__/VaultsListTable.test.ts:0-0
Timestamp: 2025-08-15T17:53:36.512Z
Learning: In test files, avoid testing HTML/browser primitives (like whether a disabled checkbox can be clicked). Tests should focus on component logic and behavior rather than browser functionality. For example, test that the component correctly applies the disabled attribute based on business rules, not that disabled checkboxes can't be toggled.
Applied to files:
packages/ui-components/src/__tests__/DropdownCheckbox.test.ts
📚 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 **/*.{test,spec}.ts : TypeScript/Svelte: run tests with `nix develop -c npm run test` (Vitest). Name test files `*.test.ts` or `*.spec.ts`
Applied to files:
packages/ui-components/src/__tests__/DropdownCheckbox.test.tspackages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.ts
📚 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_vault_balance_changes.rscrates/common/src/local_db/query/fetch_vault_balance_changes/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/local_db/query/fetch_vault_balance_changes.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/query/fetch_vault_balance_changes.rspackages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.sveltecrates/subgraph/src/orderbook_client/vault.rscrates/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/local_db/query/fetch_vault_balance_changes.rs
📚 Learning: 2025-05-19T12:09:10.694Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1858
File: crates/subgraph/src/orderbook_client/vault.rs:81-92
Timestamp: 2025-05-19T12:09:10.694Z
Learning: The `vault_balance_changes_list` function in OrderbookSubgraphClient uses a different pagination approach compared to other list methods. It uses hard-coded GraphQL query parameters (first=200, skip=0) while still accepting pagination arguments, and the pagination is handled by special logic inside the `query_paginated` method that properly processes these values.
Applied to files:
crates/common/src/raindex_client/local_db/query/fetch_vault_balance_changes.rspackages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.sveltecrates/subgraph/src/orderbook_client/vault.rscrates/cli/src/commands/vault/list_balance_changes.rscrates/common/src/raindex_client/vaults.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/local_db/query/fetch_vault_balance_changes.rscrates/common/src/local_db/query/fetch_vault_balance_changes/mod.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/local_db/query/fetch_vault_balance_changes.rscrates/common/src/local_db/query/fetch_vault_balance_changes/mod.rscrates/subgraph/src/orderbook_client/vault.rscrates/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/local_db/query/fetch_vault_balance_changes.rscrates/common/src/local_db/query/fetch_vault_balance_changes/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/query/fetch_vault_balance_changes.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/local_db/query/fetch_vault_balance_changes.rspackages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.sveltecrates/common/src/local_db/query/fetch_vault_balance_changes/mod.rscrates/common/src/raindex_client/vaults.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/query/fetch_vault_balance_changes.rspackages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.sveltecrates/common/src/raindex_client/vaults.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/query/fetch_vault_balance_changes.rs
📚 Learning: 2025-07-26T06:56:28.207Z
Learnt from: hardyjosh
Repo: rainlanguage/rain.orderbook PR: 2035
File: packages/ui-components/src/lib/components/tables/OrdersListTable.svelte:167-174
Timestamp: 2025-07-26T06:56:28.207Z
Learning: In OrdersListTable.svelte, maintainer hardyjosh considers keyed each-blocks unnecessary for item.inputs and item.outputs arrays because the entire query result updates at once during refresh, making DOM diffing optimizations negligible when the whole dataset is replaced rather than individual items being modified.
Applied to files:
packages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.svelte
📚 Learning: 2025-06-27T17:34:15.825Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 1957
File: packages/ui-components/src/lib/components/tables/VaultsListTable.svelte:60-60
Timestamp: 2025-06-27T17:34:15.825Z
Learning: In the VaultsListTable.svelte component, the `activeAccounts` store is redundant in query keys when the `owners` variable (derived from `activeAccountsItems`) is already included, as `owners` is what's actually used in the query function while `activeAccounts` is just a transformed version of the same data.
Applied to files:
packages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.svelte
📚 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:
packages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.sveltecrates/common/src/raindex_client/vaults.rs
📚 Learning: 2025-06-05T12:21:16.329Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1831
File: packages/ui-components/src/lib/components/transactions/TransactionList.svelte:10-15
Timestamp: 2025-06-05T12:21:16.329Z
Learning: The transactions array in TransactionList.svelte is expected to remain small, so performance optimizations like derived stores for array reversal are not necessary and simpler code is preferred.
Applied to files:
packages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.svelte
📚 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/local_db/query/fetch_vault_balance_changes/mod.rs
📚 Learning: 2025-05-17T15:32:28.733Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1790
File: tauri-app/src-tauri/src/commands/vault.rs:67-67
Timestamp: 2025-05-17T15:32:28.733Z
Learning: For the PR focused on testing Tauri commands::order module, the generic type parameter R: Runtime was selectively added where needed for the PR scope, applying the changes primarily to order.rs and related files while leaving other modules like vault.rs for potential future refactoring.
Applied to files:
crates/common/src/local_db/query/fetch_vault_balance_changes/mod.rscrates/subgraph/src/orderbook_client/vault.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/local_db/query/fetch_vault_balance_changes/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/local_db/query/fetch_vault_balance_changes/mod.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/local_db/query/fetch_vault_balance_changes/mod.rs
📚 Learning: 2025-10-10T05:16:12.250Z
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.
Applied to files:
crates/common/src/local_db/query/fetch_vault_balance_changes/mod.rs
📚 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/local_db/query/fetch_vault_balance_changes/mod.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/cli/src/commands/vault/list_balance_changes.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 test/**/*.sol : Solidity: write tests with `forge test`; add fuzz and property tests where relevant
Applied to files:
packages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.ts
📚 Learning: 2025-08-15T20:56:15.592Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 1978
File: packages/webapp/src/routes/deploy/[orderName]/[deploymentKey]/fullDeployment.test.ts:22-29
Timestamp: 2025-08-15T20:56:15.592Z
Learning: In packages/webapp/src/routes/deploy/[orderName]/[deploymentKey]/fullDeployment.test.ts, brusherru prefers fail-fast testing approaches where type mismatches cause immediate test failures to alert developers about interface changes, rather than using defensive programming with type guards that might mask API evolution.
Applied to files:
packages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.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__/VaultBalanceChangeTypeFilter.test.ts
📚 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
🧬 Code graph analysis (2)
crates/common/src/raindex_client/local_db/query/fetch_vault_balance_changes.rs (1)
crates/common/src/local_db/query/fetch_vault_balance_changes/mod.rs (1)
build_fetch_balance_changes_stmt(28-60)
crates/common/src/local_db/query/fetch_vault_balance_changes/mod.rs (1)
crates/common/src/local_db/query/sql_statement.rs (2)
sql(99-101)params(103-105)
🔇 Additional comments (23)
crates/subgraph/src/orderbook_client/vault.rs (3)
85-87: LGTM! Clear documentation of client-side filtering limitations.The doc comments appropriately warn that client-side filtering is less efficient than local DB filtering, guiding users toward the optimal path for large datasets.
88-118: Verify filtering behavior for empty filter arrays.The filtering logic short-circuits only when
typenames.is_empty()returns true (line 109). However, iffilter_typenamesisSome(&[])(an empty slice), the code still enters the if block at line 108 but then returns all results at line 117. This is correct, but the double-check pattern could be clearer.Consider documenting or testing the behavior when
Some(&[])is passed. Currently, passingSome(&[])effectively means "no filtering" (returns all results), which is semantically different fromNonebut produces the same outcome. If this is intentional, it's fine—but confirming the contract would help future maintainers.
703-747: LGTM! Comprehensive test coverage for type filtering.The test validates filtering by creating a dataset with mixed types (Deposit, Withdrawal, TradeVaultBalanceChange) and confirms that only "Deposit" items are returned. This properly exercises the new filtering logic.
crates/common/src/local_db/query/fetch_vault_balance_changes/query.sql (1)
27-27: LGTM! Placeholder for dynamic SQL clause.The
/*CHANGE_TYPES_CLAUSE*/comment serves as a placeholder for runtime SQL construction. The position in the JOIN clause is appropriate for filtering by change types.Based on the PR context, this placeholder will be replaced with a dynamic IN clause using
stmt.bind_list_clausein the Rust code, which handles parameterization safely.packages/ui-components/src/lib/index.ts (1)
53-53: LGTM! New component properly exported.The VaultBalanceChangeTypeFilter export is correctly placed alongside related vault components and follows the project's export pattern.
packages/ui-components/src/__tests__/VaultBalanceChangesTable.test.ts (2)
111-126: LGTM! Test validates filter UI rendering.The test correctly verifies that the new filter UI elements are present: the table title, the "Trade Type" label, and the dropdown button.
128-144: LGTM! Test validates initial API call with undefined filter.The test confirms that
getBalanceChangesis called with(1, undefined)on initial render, verifying the default behavior where no filter types are applied.crates/cli/src/commands/vault/list_balance_changes.rs (2)
34-34: LGTM! Updated to match new API signature.The addition of
Noneas the filter parameter is correct—CLI commands should default to showing all balance change types unless explicitly filtered.
46-50: LGTM! Consistent API update.Both pagination paths now correctly pass
Nonefor the filter parameter, maintaining the existing "show all" behavior.packages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.ts (3)
6-11: LGTM! Test validates basic rendering.The test confirms the filter dropdown renders with the correct label and button element.
19-32: LGTM! Test validates all filter options are present.The test correctly verifies all four filter types (Deposit, Withdrawal, Trade, Clear Bounty) are rendered in the dropdown.
40-67: LGTM! Tests validate button text updates correctly.Both tests properly verify that the dropdown button text reflects the selection state: "All types" when all options are selected, and "2 items" when a subset is selected.
packages/ui-components/src/__tests__/DropdownCheckbox.test.ts (1)
1-194: LGTM! Comprehensive test coverage for DropdownCheckbox.The test suite thoroughly covers rendering, interactions, and prop-driven behaviors:
- Rendering tests validate UI states (empty, selected count, all selected, empty message)
- Interaction tests verify toggle behavior and event emission with correct payloads
- Props tests confirm conditional rendering based on
onlyTitleandshowAllLabelThe test structure is clear and follows best practices for component testing.
packages/ui-components/src/lib/components/VaultBalanceChangeTypeFilter.svelte (1)
1-24: LGTM!The component structure is clean. The reactive logic correctly handles the filter state: returning the selected filter types when a subset is chosen, and
undefinedwhen all or none are selected (indicating no filtering).crates/common/src/raindex_client/local_db/query/fetch_vault_balance_changes.rs (2)
9-18: LGTM!The function signature update correctly adds the optional
filter_typesparameter and properly propagates errors from the builder via?. The integration withbuild_fetch_balance_changes_stmtis clean.
117-155: Good test coverage for the new filter functionality.The test properly verifies that:
- The filter types are passed through to the builder
- The generated SQL contains the expected
change_type INclause- The function executes successfully with filters applied
packages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.svelte (2)
18-31: LGTM!The filter integration is well-implemented:
filterTypesis correctly included inqueryKeyto ensure cache invalidation when filters change- The filter is properly passed to
getBalanceChanges(pageParam + 1, filterTypes)- The reactive query will automatically refetch when
filterTypeschanges due to thequeryKeydependency
36-38: LGTM!The filter component is correctly positioned and bound to
filterTypes. The layout withjustify-endaligns well with other filter UIs in the codebase.crates/common/src/local_db/query/fetch_vault_balance_changes/mod.rs (2)
28-60: LGTM!The builder implementation is solid:
- Uses
flat_mapto correctly expand filter types that map to multiple DB types (e.g.,Trade→ 6 internal types)bind_list_clauseproperly handles the dynamic IN clause injection- Returns
Resultfor proper error propagation- Empty filter array correctly results in no IN clause (same as
None)
100-115: Good test for Trade filter expansion.This test correctly validates that the
Tradefilter expands to 6 internal types (TAKE_INPUT,TAKE_OUTPUT,CLEAR_ALICE_INPUT,CLEAR_ALICE_OUTPUT,CLEAR_BOB_INPUT,CLEAR_BOB_OUTPUT), resulting in 11 total parameters (5 base + 6 trade types).crates/common/src/raindex_client/vaults.rs (3)
650-685: LGTM!The
VaultBalanceChangeFilterenum is well-designed:
to_local_db_types()correctly expands composite types (Trade → 6 types, ClearBounty → 2 types)to_subgraph_typename()returns the discriminated union type name used by the GraphQL API- The enum variants align with the UI filter options
633-647: Good extension of type parsing.The
TryFrom<String>implementation correctly handles all the variant strings from both the local DB (TAKE_INPUT,CLEAR_ALICE_BOUNTY, etc.) and subgraph (TradeVaultBalanceChange,ClearBounty, etc.), ensuring consistent type mapping across data sources.
336-391: LGTM!The
get_balance_changesmethod correctly:
- Passes
filter_types.as_deref()to the local DB query- Constructs
subgraph_typenamesfor the subgraph query viato_subgraph_typename()- Falls back to subgraph when local DB has no results
The dual-path filtering logic is clean and maintains consistency between data sources.
packages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.ts
Show resolved
Hide resolved
packages/ui-components/src/lib/components/dropdown/DropdownCheckbox.svelte
Outdated
Show resolved
Hide resolved
packages/ui-components/src/lib/components/VaultBalanceChangeTypeFilter.svelte
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
| let balance_changes = balance_changes | ||
| .into_iter() | ||
| .map(|balance_change| { | ||
| RaindexVaultBalanceChange::try_from_sg_balance_change(self.chain_id, balance_change) | ||
| RaindexVaultBalanceChange::try_from_sg_balance_change_type( | ||
| self.chain_id, | ||
| balance_change, | ||
| ) | ||
| }) | ||
| .collect::<Result<Vec<RaindexVaultBalanceChange>, RaindexError>>()?; | ||
|
|
||
| let balance_changes = if let Some(ref filters) = filter_types { | ||
| let filter_types: Vec<_> = filters.iter().map(|f| f.to_raindex_type()).collect(); | ||
| balance_changes | ||
| .into_iter() | ||
| .filter(|change| filter_types.contains(&change.r#type)) | ||
| .collect() | ||
| } else { | ||
| balance_changes | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Subgraph path: filter is not passed to query, only applied post-fetch.
The subgraph query is called with None for filter_typenames (line 372), and filtering is applied client-side after conversion (lines 386-394). This is inconsistent with the comment on line 87 of vault.rs which suggests the subgraph client accepts filter_typenames.
Consider passing the filter to the subgraph client to leverage client-side filtering there, reducing data transferred before the Raindex type conversion:
🔎 Proposed fix
let balance_changes = client
.vault_balance_changes_list(
Id::new(self.id.to_string()),
SgPaginationArgs {
page: page.unwrap_or(1),
page_size: 1000,
},
- None,
+ filter_types.as_ref().map(|filters| {
+ filters
+ .iter()
+ .flat_map(|f| match f {
+ VaultBalanceChangeFilter::Deposit => vec!["Deposit".to_string()],
+ VaultBalanceChangeFilter::Withdrawal => vec!["Withdrawal".to_string()],
+ VaultBalanceChangeFilter::TakeOrder => vec!["TradeVaultBalanceChange".to_string()],
+ VaultBalanceChangeFilter::Clear => vec!["TradeVaultBalanceChange".to_string()],
+ VaultBalanceChangeFilter::ClearBounty => vec!["ClearBounty".to_string()],
+ })
+ .collect::<Vec<_>>()
+ }),
)
.await?;Note: This optimization may require additional work since TakeOrder/Clear both map to "TradeVaultBalanceChange" at the subgraph level, requiring post-conversion filtering to distinguish them. The current approach works correctly.
Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In crates/common/src/raindex_client/vaults.rs around lines 376 to 394, the code
currently applies filter_types only after fetching and converting balance
changes; instead pass a converted list of subgraph filter_typenames into the
subgraph query at the call site (where filter_typenames is currently None) so
the subgraph does server-side filtering and reduces transferred data, then keep
the existing post-conversion filter as a secondary step to handle ambiguous
mappings (e.g., TakeOrder/Clear both mapping to "TradeVaultBalanceChange" at the
subgraph level) so those are correctly distinguished after try_from conversion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the current approach is fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@findolor, understood! The current approach with client-side filtering after fetching works correctly, and I'll leave it as is. Thank you for the clarification.
🧠 Learnings used
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1858
File: crates/subgraph/src/orderbook_client/vault.rs:81-92
Timestamp: 2025-05-19T12:09:10.694Z
Learning: The `vault_balance_changes_list` function in OrderbookSubgraphClient uses a different pagination approach compared to other list methods. It uses hard-coded GraphQL query parameters (first=200, skip=0) while still accepting pagination arguments, and the pagination is handled by special logic inside the `query_paginated` method that properly processes these values.
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.
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: 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.
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 1957
File: packages/ui-components/src/lib/components/tables/OrdersListTable.svelte:86-94
Timestamp: 2025-06-27T18:41:18.194Z
Learning: In the rain.orderbook UI components, the tokensQuery should use `enabled: true` rather than `Object.keys($activeSubgraphs).length > 0` because tokens are needed for filtering functionality even when no specific subgraphs are selected. The multiSubgraphArgs falls back to default subgraphs from settings, so disabling the query when no subgraphs are active would break the token filtering feature.
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.
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.
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.
packages/ui-components/src/lib/components/dropdown/DropdownCheckbox.svelte
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
♻️ Duplicate comments (1)
crates/common/src/raindex_client/vaults.rs (1)
338-398: Filtering logic is correct, but optimization noted in past review remains.The implementation correctly applies filters via:
- Local DB path: filter passed through at line 354 ✓
- Subgraph path: filter applied client-side at lines 387-395 ✓
There's an existing past review comment (lines 377-395) noting that filters could be passed to the subgraph query (line 373) to reduce data transferred. However, because
TakeOrderandClearboth map to"TradeVaultBalanceChange"at the subgraph level, post-conversion filtering would still be needed to distinguish them, making the current approach reasonable.
📜 Review details
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (13)
crates/cli/src/commands/vault/list_balance_changes.rscrates/common/src/local_db/query/fetch_vault_balance_changes/mod.rscrates/common/src/raindex_client/local_db/query/fetch_vault_balance_changes.rscrates/common/src/raindex_client/vaults.rscrates/common/src/types/mod.rscrates/common/src/types/vault_balance_change_kind.rscrates/subgraph/src/orderbook_client/vault.rspackages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.tspackages/ui-components/src/__tests__/VaultBalanceChangesTable.test.tspackages/ui-components/src/lib/components/VaultBalanceChangeTypeFilter.sveltepackages/ui-components/src/lib/components/dropdown/DropdownCheckbox.sveltepackages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.sveltepackages/ui-components/src/lib/utils/vaultBalanceChangeLabels.ts
🧰 Additional context used
📓 Path-based instructions (10)
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 usingnix develop -c npm run svelte-lint-format-check -w @rainlanguage/ui-components
Files:
packages/ui-components/src/__tests__/VaultBalanceChangesTable.test.tspackages/ui-components/src/lib/components/VaultBalanceChangeTypeFilter.sveltepackages/ui-components/src/lib/utils/vaultBalanceChangeLabels.tspackages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.tspackages/ui-components/src/lib/components/dropdown/DropdownCheckbox.sveltepackages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.svelte
packages/ui-components/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
For UI components (
packages/ui-components), run tests usingnix develop -c npm run test -w @rainlanguage/ui-components
Files:
packages/ui-components/src/__tests__/VaultBalanceChangesTable.test.tspackages/ui-components/src/lib/utils/vaultBalanceChangeLabels.tspackages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.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__/VaultBalanceChangesTable.test.tspackages/ui-components/src/lib/components/VaultBalanceChangeTypeFilter.sveltepackages/ui-components/src/lib/utils/vaultBalanceChangeLabels.tspackages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.tspackages/ui-components/src/lib/components/dropdown/DropdownCheckbox.sveltepackages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.svelte
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__/VaultBalanceChangesTable.test.tspackages/ui-components/src/lib/components/VaultBalanceChangeTypeFilter.sveltepackages/ui-components/src/lib/utils/vaultBalanceChangeLabels.tspackages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.tspackages/ui-components/src/lib/components/dropdown/DropdownCheckbox.sveltepackages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.svelte
**/*.{ts,tsx,svelte}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx,svelte}: TypeScript/Svelte: format withnix develop -c npm run format
TypeScript/Svelte: lint withnix develop -c npm run lint
TypeScript/Svelte: type-check withnix develop -c npm run check
Files:
packages/ui-components/src/__tests__/VaultBalanceChangesTable.test.tspackages/ui-components/src/lib/components/VaultBalanceChangeTypeFilter.sveltepackages/ui-components/src/lib/utils/vaultBalanceChangeLabels.tspackages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.tspackages/ui-components/src/lib/components/dropdown/DropdownCheckbox.sveltepackages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.svelte
**/*.{test,spec}.ts
📄 CodeRabbit inference engine (AGENTS.md)
TypeScript/Svelte: run tests with
nix develop -c npm run test(Vitest). Name test files*.test.tsor*.spec.ts
Files:
packages/ui-components/src/__tests__/VaultBalanceChangesTable.test.tspackages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.ts
**/*.svelte
📄 CodeRabbit inference engine (AGENTS.md)
Svelte components should use
PascalCase.sveltenaming convention; other files use kebab or snake case as appropriate
Files:
packages/ui-components/src/lib/components/VaultBalanceChangeTypeFilter.sveltepackages/ui-components/src/lib/components/dropdown/DropdownCheckbox.sveltepackages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.svelte
crates/**/*.rs
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
crates/**/*.rs: For Rust crates incrates/*, run lints usingnix develop -c cargo clippy --workspace --all-targets --all-features -D warnings
For Rust crates incrates/*, run tests usingnix develop -c cargo test --workspaceor--package <crate>
Files:
crates/common/src/types/vault_balance_change_kind.rscrates/common/src/types/mod.rscrates/cli/src/commands/vault/list_balance_changes.rscrates/common/src/raindex_client/local_db/query/fetch_vault_balance_changes.rscrates/subgraph/src/orderbook_client/vault.rscrates/common/src/local_db/query/fetch_vault_balance_changes/mod.rscrates/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/types/vault_balance_change_kind.rscrates/common/src/types/mod.rscrates/cli/src/commands/vault/list_balance_changes.rscrates/common/src/raindex_client/local_db/query/fetch_vault_balance_changes.rscrates/subgraph/src/orderbook_client/vault.rscrates/common/src/local_db/query/fetch_vault_balance_changes/mod.rscrates/common/src/raindex_client/vaults.rs
**/*.rs
📄 CodeRabbit inference engine (AGENTS.md)
**/*.rs: Rust: format code withnix develop -c cargo fmt --all
Rust: lint withnix develop -c rainix-rs-static(preconfigured flags included)
Rust: crates and modules usesnake_case; types usePascalCase
Files:
crates/common/src/types/vault_balance_change_kind.rscrates/common/src/types/mod.rscrates/cli/src/commands/vault/list_balance_changes.rscrates/common/src/raindex_client/local_db/query/fetch_vault_balance_changes.rscrates/subgraph/src/orderbook_client/vault.rscrates/common/src/local_db/query/fetch_vault_balance_changes/mod.rscrates/common/src/raindex_client/vaults.rs
🧠 Learnings (57)
📓 Common learnings
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: 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.
📚 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__/VaultBalanceChangesTable.test.tspackages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.ts
📚 Learning: 2025-07-17T10:36:02.846Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1996
File: packages/ui-components/src/__tests__/VaultIdInformation.test.ts:6-6
Timestamp: 2025-07-17T10:36:02.846Z
Learning: In packages/ui-components/src/__tests__/VaultIdInformation.test.ts, findolor prefers to keep exported type aliases like `VaultIdInformationComponentProps` in test files, even when static analysis tools flag this as discouraged practice.
Applied to files:
packages/ui-components/src/__tests__/VaultBalanceChangesTable.test.tspackages/ui-components/src/lib/components/VaultBalanceChangeTypeFilter.sveltepackages/ui-components/src/lib/utils/vaultBalanceChangeLabels.tspackages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.ts
📚 Learning: 2025-08-04T09:07:00.160Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2048
File: packages/webapp/src/__tests__/WithdrawModal.test.ts:36-37
Timestamp: 2025-08-04T09:07:00.160Z
Learning: In packages/webapp/src/__tests__/WithdrawModal.test.ts and similar test files, findolor considers it acceptable to directly unwrap .value from Float.fromFixedDecimal() and Float.parse() calls without explicit error handling, preferring to keep test fixtures simple rather than adding comprehensive error checking.
Applied to files:
packages/ui-components/src/__tests__/VaultBalanceChangesTable.test.tspackages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.tscrates/common/src/raindex_client/vaults.rs
📚 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__/VaultBalanceChangesTable.test.tspackages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.ts
📚 Learning: 2025-08-14T14:16:34.044Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2083
File: packages/ui-components/src/lib/components/tables/VaultsListTable.svelte:205-205
Timestamp: 2025-08-14T14:16:34.044Z
Learning: In the VaultsListTable component, the `matchesAccount` function from the wallet provider may not properly update on wallet connect/disconnect events, making direct comparison with the reactive `$account` variable more reliable for UI visibility checks. The `matchesAccount` function needs future refactoring to handle wallet state changes properly.
Applied to files:
packages/ui-components/src/__tests__/VaultBalanceChangesTable.test.tspackages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.tspackages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.svelte
📚 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:
packages/ui-components/src/__tests__/VaultBalanceChangesTable.test.tscrates/common/src/raindex_client/local_db/query/fetch_vault_balance_changes.rscrates/subgraph/src/orderbook_client/vault.rs
📚 Learning: 2025-03-31T10:16:53.544Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1469
File: packages/ui-components/src/__tests__/CodeMirrorDotrain.test.ts:75-98
Timestamp: 2025-03-31T10:16:53.544Z
Learning: In the rainlanguage/rain.orderbook project, direct manipulation of Svelte's internal state (component.$$.ctx) in tests is an acceptable approach for testing component behavior, as demonstrated in the CodeMirrorDotrain tests.
Applied to files:
packages/ui-components/src/__tests__/VaultBalanceChangesTable.test.tspackages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.svelte
📚 Learning: 2025-04-04T11:25:21.518Z
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1559
File: packages/ui-components/src/__tests__/OrderOrVaultHash.test.ts:94-94
Timestamp: 2025-04-04T11:25:21.518Z
Learning: In the rain.orderbook project, minimal test fixtures are preferred over complete mocks that implement the entire interface. Type casting (e.g., `as unknown as SgVault`) is an acceptable approach to maintain both minimal fixtures and TypeScript type compatibility.
Applied to files:
packages/ui-components/src/__tests__/VaultBalanceChangesTable.test.tscrates/subgraph/src/orderbook_client/vault.rs
📚 Learning: 2025-09-02T08:05:07.646Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2117
File: packages/webapp/src/lib/components/DepositModal.svelte:25-28
Timestamp: 2025-09-02T08:05:07.646Z
Learning: In packages/webapp/src/lib/components/DepositModal.svelte, findolor considers the double-cast pattern `as unknown as AccountBalance` safe for initializing userBalance with Float.parse('0').value and formattedBalance: '0'.
Applied to files:
packages/ui-components/src/lib/components/VaultBalanceChangeTypeFilter.sveltepackages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.svelte
📚 Learning: 2025-06-07T09:14:33.054Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1882
File: packages/webapp/src/lib/components/DepositModal.svelte:35-35
Timestamp: 2025-06-07T09:14:33.054Z
Learning: When reviewing shared types in TypeScript, it's normal for individual components to only destructure and use a subset of the available properties from the type. Shared types like VaultActionArgs are designed to accommodate the union of all use cases across multiple components, not just a single component's requirements.
Applied to files:
packages/ui-components/src/lib/components/VaultBalanceChangeTypeFilter.sveltepackages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.ts
📚 Learning: 2025-08-19T04:15:33.633Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2036
File: packages/ui-components/src/lib/components/ListViewVaultFilters.svelte:33-52
Timestamp: 2025-08-19T04:15:33.633Z
Learning: In the ListViewVaultFilters.svelte component, the "Show my items only" filter is intentionally destructive for the owners field. When toggled, it should replace any existing owner filters (including those from URL parameters) rather than being additive. This is by design because the UI doesn't provide capability to filter by other owner addresses or remove specific owners from a list. The toggle serves as both a filter and a way for users to clear URL-based owner filters and switch to filtering by their own address only.
Applied to files:
packages/ui-components/src/lib/components/VaultBalanceChangeTypeFilter.svelte
📚 Learning: 2025-12-11T07:46:32.817Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2358
File: packages/ui-components/src/lib/components/tables/OrdersListTable.svelte:82-85
Timestamp: 2025-12-11T07:46:32.817Z
Learning: In packages/ui-components/src/lib/components/tables/OrdersListTable.svelte, the token filter intentionally sets both inputs and outputs to the same selectedTokens array (lines 82-85) to achieve OR filtering behavior. This is by design: the single UI token filter should match orders containing the selected token(s) in either inputs OR outputs, not pair-specific filtering. Even though the API supports more granular directional filtering, the UI uses the same tokens in both fields for broader matching.
Applied to files:
packages/ui-components/src/lib/components/VaultBalanceChangeTypeFilter.sveltepackages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.svelte
📚 Learning: 2025-05-17T15:32:28.733Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1790
File: tauri-app/src-tauri/src/commands/vault.rs:67-67
Timestamp: 2025-05-17T15:32:28.733Z
Learning: For the PR focused on testing Tauri commands::order module, the generic type parameter R: Runtime was selectively added where needed for the PR scope, applying the changes primarily to order.rs and related files while leaving other modules like vault.rs for potential future refactoring.
Applied to files:
crates/common/src/types/vault_balance_change_kind.rscrates/common/src/types/mod.rscrates/common/src/raindex_client/local_db/query/fetch_vault_balance_changes.rscrates/subgraph/src/orderbook_client/vault.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/types/mod.rscrates/common/src/raindex_client/local_db/query/fetch_vault_balance_changes.rscrates/subgraph/src/orderbook_client/vault.rspackages/ui-components/src/lib/utils/vaultBalanceChangeLabels.tscrates/common/src/local_db/query/fetch_vault_balance_changes/mod.rspackages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.sveltecrates/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/types/mod.rscrates/common/src/raindex_client/local_db/query/fetch_vault_balance_changes.rs
📚 Learning: 2025-05-19T12:09:10.694Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1858
File: crates/subgraph/src/orderbook_client/vault.rs:81-92
Timestamp: 2025-05-19T12:09:10.694Z
Learning: The `vault_balance_changes_list` function in OrderbookSubgraphClient uses a different pagination approach compared to other list methods. It uses hard-coded GraphQL query parameters (first=200, skip=0) while still accepting pagination arguments, and the pagination is handled by special logic inside the `query_paginated` method that properly processes these values.
Applied to files:
crates/cli/src/commands/vault/list_balance_changes.rscrates/common/src/raindex_client/local_db/query/fetch_vault_balance_changes.rscrates/subgraph/src/orderbook_client/vault.rspackages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.sveltecrates/common/src/raindex_client/vaults.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/local_db/query/fetch_vault_balance_changes.rscrates/subgraph/src/orderbook_client/vault.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_vault_balance_changes.rscrates/common/src/local_db/query/fetch_vault_balance_changes/mod.rscrates/common/src/raindex_client/vaults.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/local_db/query/fetch_vault_balance_changes.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/query/fetch_vault_balance_changes.rscrates/common/src/local_db/query/fetch_vault_balance_changes/mod.rspackages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.sveltecrates/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/local_db/query/fetch_vault_balance_changes.rscrates/subgraph/src/orderbook_client/vault.rscrates/common/src/raindex_client/vaults.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/query/fetch_vault_balance_changes.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/subgraph/src/orderbook_client/vault.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/subgraph/src/orderbook_client/vault.rs
📚 Learning: 2025-05-13T20:06:22.602Z
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.
Applied to files:
crates/subgraph/src/orderbook_client/vault.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/subgraph/src/orderbook_client/vault.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/subgraph/src/orderbook_client/vault.rs
📚 Learning: 2025-05-16T17:24:34.724Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1844
File: tauri-app/src-tauri/src/commands/wallet.rs:27-28
Timestamp: 2025-05-16T17:24:34.724Z
Learning: In Rust projects, dependencies listed in the [dependencies] section of Cargo.toml are available for both application code and tests. The tokio crate with the "full" feature set includes the "test" feature needed for `#[tokio::test]` to work properly.
Applied to files:
crates/subgraph/src/orderbook_client/vault.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/subgraph/src/orderbook_client/vault.rs
📚 Learning: 2025-09-25T12:19:33.736Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2099
File: crates/common/src/raindex_client/sqlite_web/fetch.rs:1203-1209
Timestamp: 2025-09-25T12:19:33.736Z
Learning: httpmock json_body_partial expects Into<String> (JSON string), while json_body expects Into<serde_json::Value> (JSON object). Using .to_string() with json_body_partial is the correct usage.
Applied to files:
crates/subgraph/src/orderbook_client/vault.rscrates/common/src/raindex_client/vaults.rs
📚 Learning: 2025-05-09T05:30:02.520Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1744
File: packages/webapp/src/lib/components/DepositOrWithdrawModal.svelte:73-76
Timestamp: 2025-05-09T05:30:02.520Z
Learning: In Rain.orderbook, `VaultCalldataResult` is a wrapper type that contains both `error` and `value` properties. When using this in the `DepositOrWithdrawModal` component, only the inner `value` field is passed to the `handleTransaction` function, not the complete wrapper.
Applied to files:
packages/ui-components/src/lib/utils/vaultBalanceChangeLabels.tspackages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.sveltecrates/common/src/raindex_client/vaults.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:
packages/ui-components/src/lib/utils/vaultBalanceChangeLabels.tspackages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.sveltecrates/common/src/raindex_client/vaults.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 **/*.{test,spec}.ts : TypeScript/Svelte: run tests with `nix develop -c npm run test` (Vitest). Name test files `*.test.ts` or `*.spec.ts`
Applied to files:
packages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.ts
📚 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 test/**/*.sol : Solidity: write tests with `forge test`; add fuzz and property tests where relevant
Applied to files:
packages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.ts
📚 Learning: 2025-11-06T15:31:40.811Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2297
File: tauri-app/src/lib/components/MetricChart.test.ts:68-85
Timestamp: 2025-11-06T15:31:40.811Z
Learning: In tauri-app/src/lib/components/MetricChart.test.ts, findolor considers it acceptable to duplicate Float parsing and formatting logic within test helper functions like buildPlotData, rather than extracting it to shared utilities or reusing production code like decodeRainFloat from chartData.ts.
Applied to files:
packages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.ts
📚 Learning: 2025-07-23T13:03:40.669Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1911
File: crates/subgraph/src/vault_balance_changes_query.rs:133-135
Timestamp: 2025-07-23T13:03:40.669Z
Learning: User 0xgleb prefers not to make changes to test code when tests are already passing, even if the code format could be standardized differently. Working test code should be left alone unless there's a functional issue.
Applied to files:
packages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.ts
📚 Learning: 2025-03-24T12:27:07.862Z
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1494
File: packages/ui-components/src/__tests__/WalletProvider.test.ts:18-28
Timestamp: 2025-03-24T12:27:07.862Z
Learning: In the WalletProvider tests, verifying that setAccountContext is called with the correct store is sufficient. Additional testing of Svelte's store implementation (like subscribing to verify the store value) is unnecessary as it would just be testing the framework itself.
Applied to files:
packages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.ts
📚 Learning: 2025-04-08T11:46:05.879Z
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1575
File: packages/webapp/src/routes/deploy/layout.test.ts:96-99
Timestamp: 2025-04-08T11:46:05.879Z
Learning: In TypeScript tests, seemingly redundant assertions like explicitly checking a property after a full object assertion may be necessary for proper type narrowing, especially when dealing with union types like `string | null`.
Applied to files:
packages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.ts
📚 Learning: 2025-07-10T12:52:47.468Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1925
File: packages/ui-components/src/lib/errors/DeploymentStepsError.ts:16-16
Timestamp: 2025-07-10T12:52:47.468Z
Learning: In packages/ui-components/src/lib/errors/DeploymentStepsError.ts, the error codes NO_SELECT_TOKENS ('Error loading tokens') and NO_AVAILABLE_TOKENS ('Error loading available tokens') represent different failure scenarios in the token loading workflow and should remain as separate error codes.
Applied to files:
packages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.ts
📚 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_vault_balance_changes/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/local_db/query/fetch_vault_balance_changes/mod.rs
📚 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/local_db/query/fetch_vault_balance_changes/mod.rs
📚 Learning: 2025-04-11T06:07:10.456Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1599
File: tauri-app/src/lib/components/modal/ModalScenarioDebug.svelte:10-16
Timestamp: 2025-04-11T06:07:10.456Z
Learning: Empty divs with CSS classes are used intentionally for styling and layout purposes in Svelte components in this codebase, even when they don't contain content.
Applied to files:
packages/ui-components/src/lib/components/dropdown/DropdownCheckbox.svelte
📚 Learning: 2025-07-26T06:56:28.207Z
Learnt from: hardyjosh
Repo: rainlanguage/rain.orderbook PR: 2035
File: packages/ui-components/src/lib/components/tables/OrdersListTable.svelte:167-174
Timestamp: 2025-07-26T06:56:28.207Z
Learning: In OrdersListTable.svelte, maintainer hardyjosh considers keyed each-blocks unnecessary for item.inputs and item.outputs arrays because the entire query result updates at once during refresh, making DOM diffing optimizations negligible when the whole dataset is replaced rather than individual items being modified.
Applied to files:
packages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.svelte
📚 Learning: 2025-06-27T17:34:15.825Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 1957
File: packages/ui-components/src/lib/components/tables/VaultsListTable.svelte:60-60
Timestamp: 2025-06-27T17:34:15.825Z
Learning: In the VaultsListTable.svelte component, the `activeAccounts` store is redundant in query keys when the `owners` variable (derived from `activeAccountsItems`) is already included, as `owners` is what's actually used in the query function while `activeAccounts` is just a transformed version of the same data.
Applied to files:
packages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.svelte
📚 Learning: 2025-07-24T19:31:29.248Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2002
File: packages/ui-components/src/lib/components/tables/VaultsListTable.svelte:63-68
Timestamp: 2025-07-24T19:31:29.248Z
Learning: In Svelte components, functions that depend on reactive state and are used in template rendering (like `isVaultDisabled` in VaultsListTable.svelte) should remain as reactive statements ($:) rather than regular functions, because regular functions won't trigger UI updates when their dependencies change. This is especially important for UI state like disabled/enabled status that needs to update across multiple rendered items when selection state changes.
Applied to files:
packages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.svelte
📚 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:
packages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.svelte
📚 Learning: 2025-06-05T12:21:16.329Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1831
File: packages/ui-components/src/lib/components/transactions/TransactionList.svelte:10-15
Timestamp: 2025-06-05T12:21:16.329Z
Learning: The transactions array in TransactionList.svelte is expected to remain small, so performance optimizations like derived stores for array reversal are not necessary and simpler code is preferred.
Applied to files:
packages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.svelte
📚 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/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
📚 Learning: 2025-06-27T18:41:18.194Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 1957
File: packages/ui-components/src/lib/components/tables/OrdersListTable.svelte:86-94
Timestamp: 2025-06-27T18:41:18.194Z
Learning: In the rain.orderbook UI components, the tokensQuery should use `enabled: true` rather than `Object.keys($activeSubgraphs).length > 0` because tokens are needed for filtering functionality even when no specific subgraphs are selected. The multiSubgraphArgs falls back to default subgraphs from settings, so disabling the query when no subgraphs are active would break the token filtering feature.
Applied to files:
crates/common/src/raindex_client/vaults.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/vaults.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/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/vaults.rs
📚 Learning: 2025-09-30T21:18:01.636Z
Learnt from: hardyjosh
Repo: rainlanguage/rain.orderbook PR: 2167
File: crates/virtual-raindex/src/engine/take.rs:131-138
Timestamp: 2025-09-30T21:18:01.636Z
Learning: In the virtual-raindex take order flow (crates/virtual-raindex/src/engine/take.rs), balance diffs are written from the order's perspective where the taker is the counterparty: the order's input column receives taker_output (what the taker provides to the order) and the order's output column receives taker_input (what the taker requests from the order).
Applied to files:
crates/common/src/raindex_client/vaults.rs
📚 Learning: 2025-12-17T13:17:58.487Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2360
File: crates/common/src/test_helpers.rs:329-367
Timestamp: 2025-12-17T13:17:58.487Z
Learning: In the rainlanguage/rain.orderbook codebase, findolor considers hardcoded values (like decimals) acceptable in test helper functions such as deposit_to_orderbook in crates/common/src/test_helpers.rs, as test infrastructure doesn't need the same level of parameterization as production code.
Applied to files:
crates/common/src/raindex_client/vaults.rs
🧬 Code graph analysis (4)
packages/ui-components/src/__tests__/VaultBalanceChangesTable.test.ts (1)
packages/ui-components/src/lib/utils/vaultBalanceChangeLabels.ts (1)
VAULT_BALANCE_CHANGE_LABELS(6-13)
packages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.ts (1)
packages/ui-components/src/lib/utils/vaultBalanceChangeLabels.ts (1)
VAULT_BALANCE_CHANGE_FILTER_LABELS(15-21)
crates/common/src/local_db/query/fetch_vault_balance_changes/mod.rs (3)
crates/common/src/raindex_client/vaults.rs (3)
new(53-55)new(208-213)from(635-644)crates/common/src/local_db/query/mod.rs (1)
from(68-70)crates/common/src/local_db/query/sql_statement.rs (2)
sql(99-101)params(103-105)
crates/common/src/raindex_client/vaults.rs (1)
crates/common/src/types/vault_balance_change_kind.rs (3)
from_local_db_change_type(27-38)from_subgraph_typename(48-57)from_local_db_trade_kind(40-46)
⏰ 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: standard-tests (ubuntu-latest, rainix-wasm-artifacts)
- GitHub Check: standard-tests (ubuntu-latest, test-js-bindings)
- GitHub Check: standard-tests (ubuntu-latest, rainix-sol-static)
- GitHub Check: standard-tests (ubuntu-latest, rainix-wasm-test)
- 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-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-rs-static)
- GitHub Check: standard-tests (ubuntu-latest, rainix-sol-artifacts)
- GitHub Check: test
- GitHub Check: test
- GitHub Check: test
- GitHub Check: build-tauri (ubuntu-22.04, true)
- GitHub Check: Deploy-Preview-Push
- GitHub Check: Deploy-Docs-Preview
🔇 Additional comments (42)
packages/ui-components/src/lib/utils/vaultBalanceChangeLabels.ts (3)
1-4: LGTM!Type imports are correctly specified and sourced from the appropriate package.
6-13: LGTM!The label mapping is comprehensive and uses consistent title-case formatting. All expected vault balance change types are covered including the fallback 'unknown' type.
23-25: LGTM!The function provides a sensible fallback by returning the input type when no mapping is found.
crates/common/src/types/vault_balance_change_kind.rs (9)
3-13: LGTM!The type mapping arrays correctly categorize all local DB change types according to their semantic meaning. The grouping of CLEAR_ALICE_* and CLEAR_BOB_* variants under CLEAR_TYPES and CLEAR_BOUNTY_TYPES aligns with the PR objectives.
15-24: LGTM!The enum definition is well-designed with appropriate derives and serde configuration for cross-language compatibility.
27-38: LGTM!The conversion logic correctly maps all local DB change types to their corresponding kind variants, with proper handling of multi-variant categories and an Unknown fallback.
40-46: LGTM!The trade kind conversion correctly maps the two trade types (take and clear) to their corresponding balance change kinds.
48-57: LGTM!The subgraph typename conversion correctly handles all expected GraphQL type names with an appropriate Unknown fallback.
59-68: LGTM!The mapping to subgraph typenames correctly handles the dual representation of trade-related changes (TakeOrder and Clear) which can appear as both specific types and as TradeVaultBalanceChange in the subgraph schema.
70-79: LGTM!The display names match the TypeScript label mappings exactly, ensuring consistency across the frontend and backend.
81-90: LGTM!Efficient implementation using static arrays, avoiding allocations and ensuring consistency with the const definitions.
93-232: LGTM!Comprehensive test coverage for all conversion methods and mappings. The tests verify bidirectional conversions and edge cases including the Unknown variant.
crates/common/src/types/mod.rs (1)
8-8: LGTM!The new module is correctly declared and publicly exported following the established pattern in this file.
Also applies to: 17-17
packages/ui-components/src/lib/components/dropdown/DropdownCheckbox.svelte (1)
46-47: LGTM!The layout changes have been correctly implemented with the
flexbase class included and the Label properly positioned within the container. Previous review issues have been addressed.packages/ui-components/src/__tests__/VaultBalanceChangesTable.test.ts (3)
8-8: LGTM!Good use of the shared label constant instead of hardcoded strings. This ensures consistency between the UI display and tests.
Also applies to: 108-110
114-129: LGTM!The test effectively verifies that the new filter UI component is rendered with the expected elements.
131-147: LGTM!The test properly verifies that the balance changes API is initially called without any filter types (undefined), which is the expected default behavior.
packages/ui-components/src/__tests__/VaultBalanceChangeTypeFilter.test.ts (1)
1-68: LGTM!Comprehensive test coverage for the VaultBalanceChangeTypeFilter component. The tests verify:
- Component rendering
- Default state behavior
- All filter options are present
- "All types" selection updates button text correctly
- Partial selection shows item count
The use of
VAULT_BALANCE_CHANGE_FILTER_LABELSensures consistency with the actual UI implementation.crates/cli/src/commands/vault/list_balance_changes.rs (2)
34-34: LGTM!The CLI correctly passes
Nonefor the new filter parameter, which is appropriate since the CLI interface doesn't implement type-based filtering.Also applies to: 49-49
173-173: LGTM!The test fixture correctly adds the required "id" field to match the updated schema.
packages/ui-components/src/lib/components/VaultBalanceChangeTypeFilter.svelte (2)
1-20: LGTM!The component logic correctly implements the filter state management:
- When some (but not all) types are selected, it exports the sorted array of keys
- When none or all are selected, it exports
undefined(representing no filter)This aligns with the expected filter behavior where
undefinedmeans "show all types".
22-28: LGTM!The component template correctly configures the DropdownCheckbox with appropriate props. The "Change Type" label accurately describes the filter's purpose, and
onlyTitle={true}ensures a clean display without showing the keys.crates/common/src/raindex_client/local_db/query/fetch_vault_balance_changes.rs (2)
6-22: LGTM!The filter parameter integration is clean: optional filter_types are mapped to VaultBalanceChangeKind via to_kind(), converted to a slice with as_deref(), and passed to the builder with proper error propagation.
36-119: LGTM!Existing tests correctly updated to pass
Nonefor filter_types, maintaining backward compatibility and verifying the no-filter code path.packages/ui-components/src/lib/components/tables/VaultBalanceChangesTable.svelte (3)
4-19: LGTM!Imports are well-organized and the
filterTypesstate is appropriately typed as optional to support both filtered and unfiltered modes.
21-32: LGTM!Query reactivity is properly set up with
filterTypesin the key, and pagination support is correctly implemented usingDEFAULT_PAGE_SIZE.
37-80: LGTM!UI integration is clean:
- Filter component is appropriately positioned above the table
- Padding typo fix (p-- → p-0) corrects invalid Tailwind class
- Type labels are now human-readable via
labelForVaultBalanceChangeTypecrates/common/src/local_db/query/fetch_vault_balance_changes/mod.rs (4)
1-11: LGTM!New imports and constants appropriately support dynamic IN-clause generation for filtering.
28-58: LGTM! API signature change is intentional.The function now returns
Result<SqlStatement, SqlBuildError>to propagate binding errors. The dynamic IN-clause construction correctly usesflat_mapto expand eachVaultBalanceChangeKindinto its corresponding local DB change type strings (e.g., TakeOrder → ["TAKE_INPUT", "TAKE_OUTPUT"]).
68-81: LGTM!Test correctly verifies the no-filter case, ensuring no IN-clause is generated when
filter_kindsisNone.
83-160: LGTM!Comprehensive test coverage verifies:
- Single and multiple filter types
- Expansion of compound types (TakeOrder → 2 DB types, Clear → 4 DB types)
- Empty filter array correctly treated as no filter
- Parameter counts and IN-clause structure match expectations
crates/subgraph/src/orderbook_client/vault.rs (4)
85-118: LGTM! Performance caveat is appropriately documented.Client-side filtering implementation is straightforward. The doc comment correctly notes that "Subgraph filtering happens client-side after fetching, which is less efficient than local DB filtering" — this is an acceptable trade-off for the subgraph path.
120-148: LGTM!Filter parameter is correctly propagated through all paginated calls, ensuring consistent filtering across pages.
264-293: LGTM!JSON-based test fixture appropriately supports the new
SgVaultBalanceChangeTypedeserialization path.
606-722: LGTM!Test updates correctly pass
Noneto maintain backward compatibility, and the new filter test verifies client-side filtering logic by checking that only matching typenames are returned.crates/common/src/raindex_client/vaults.rs (7)
1-46: LGTM!Import additions align with the new filtering types and updated subgraph type system.
622-660: LGTM!The
RaindexVaultBalanceChangeTypeenum correctly addsTakeOrder,Clear, andClearBountyvariants. TheFrom<VaultBalanceChangeKind>and updatedTryFrom<String>implementations provide clean conversion paths from both local DB and subgraph type systems.
662-697: LGTM!The
VaultBalanceChangeFilterenum provides a clean public API for filtering, with conversion methods (to_kind,to_local_db_types,to_raindex_type) that bridge between filter types and the internal type systems.
810-897: LGTM!The
trade_kindfield addition toLocalTradeBalanceInfoand its usage intry_from_sg_trade_balance_changecorrectly enable type derivation from trade event typenames viaVaultBalanceChangeKind::from_subgraph_typename.
899-976: LGTM!The
try_from_sg_balance_change_typemethod correctly handles allSgVaultBalanceChangeTypevariants:
- Directly maps
Deposit,Withdrawal, andClearBountyto corresponding types- Delegates
TradeVaultBalanceChangeto existing logic that derives type from trade event- Returns error for
Unknownvariant
1016-1070: LGTM!The method now correctly derives
change_typefrombalance.trade_kindviaVaultBalanceChangeKind::from_local_db_trade_kind, enabling proper type classification for local trade events (e.g., "take" →TakeOrder, "clear" →Clear).
1733-2863: LGTM!Test updates comprehensively cover:
- Passing
Nonefor filter parameters to maintain backward compatibility- Adding
trade_kindto test fixtures for new type derivation- Asserting new change types (
TakeOrder,Clear) work correctly- Updated mocks align with new
SgVaultBalanceChangeTypehandling
| export const VAULT_BALANCE_CHANGE_FILTER_LABELS: Record<VaultBalanceChangeFilter, string> = { | ||
| deposit: 'Deposit', | ||
| withdrawal: 'Withdrawal', | ||
| takeOrder: 'Take order', | ||
| clear: 'Clear', | ||
| clearBounty: 'Clear Bounty' | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Consider reducing label duplication.
The labels for deposit, withdrawal, takeOrder, clear, and clearBounty are duplicated between VAULT_BALANCE_CHANGE_LABELS and VAULT_BALANCE_CHANGE_FILTER_LABELS. While this duplication is minor and manageable, you could derive the filter labels from the main mapping to ensure consistency.
🔎 Potential refactor
+export const VAULT_BALANCE_CHANGE_LABELS: Record<RaindexVaultBalanceChangeType, string> = {
+ deposit: 'Deposit',
+ withdrawal: 'Withdrawal',
+ takeOrder: 'Take order',
+ clear: 'Clear',
+ clearBounty: 'Clear Bounty',
+ unknown: 'Unknown'
+};
+
-export const VAULT_BALANCE_CHANGE_FILTER_LABELS: Record<VaultBalanceChangeFilter, string> = {
- deposit: 'Deposit',
- withdrawal: 'Withdrawal',
- takeOrder: 'Take order',
- clear: 'Clear',
- clearBounty: 'Clear Bounty'
-};
+export const VAULT_BALANCE_CHANGE_FILTER_LABELS: Record<VaultBalanceChangeFilter, string> = {
+ deposit: VAULT_BALANCE_CHANGE_LABELS.deposit,
+ withdrawal: VAULT_BALANCE_CHANGE_LABELS.withdrawal,
+ takeOrder: VAULT_BALANCE_CHANGE_LABELS.takeOrder,
+ clear: VAULT_BALANCE_CHANGE_LABELS.clear,
+ clearBounty: VAULT_BALANCE_CHANGE_LABELS.clearBounty
+};Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In packages/ui-components/src/lib/utils/vaultBalanceChangeLabels.ts around lines
15 to 21, the VAULT_BALANCE_CHANGE_FILTER_LABELS object duplicates the same
string values defined in VAULT_BALANCE_CHANGE_LABELS; replace the manual
duplicate by deriving filter labels from the main mapping (e.g., map the keys of
VAULT_BALANCE_CHANGE_FILTER_LABELS to values from VAULT_BALANCE_CHANGE_LABELS)
so the filter labels are produced from the authoritative source, keeping types
intact and retaining the same keys and casing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@findolor, understood! I'll keep the current implementation as-is with the separate label definitions.
🧠 Learnings used
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1744
File: packages/webapp/src/lib/components/DepositOrWithdrawModal.svelte:73-76
Timestamp: 2025-05-09T05:30:02.520Z
Learning: In Rain.orderbook, `VaultCalldataResult` is a wrapper type that contains both `error` and `value` properties. When using this in the `DepositOrWithdrawModal` component, only the inner `value` field is passed to the `handleTransaction` function, not the complete wrapper.
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.
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: 1996
File: packages/ui-components/src/__tests__/VaultIdInformation.test.ts:6-6
Timestamp: 2025-07-17T10:36:02.846Z
Learning: In packages/ui-components/src/__tests__/VaultIdInformation.test.ts, findolor prefers to keep exported type aliases like `VaultIdInformationComponentProps` in test files, even when static analysis tools flag this as discouraged practice.
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 1957
File: packages/ui-components/src/lib/components/tables/VaultsListTable.svelte:60-60
Timestamp: 2025-06-27T17:34:15.825Z
Learning: In the VaultsListTable.svelte component, the `activeAccounts` store is redundant in query keys when the `owners` variable (derived from `activeAccountsItems`) is already included, as `owners` is what's actually used in the query function while `activeAccounts` is just a transformed version of the same data.
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2117
File: packages/webapp/src/lib/components/DepositModal.svelte:25-28
Timestamp: 2025-09-02T08:05:07.646Z
Learning: In packages/webapp/src/lib/components/DepositModal.svelte, findolor considers the double-cast pattern `as unknown as AccountBalance` safe for initializing userBalance with Float.parse('0').value and formattedBalance: '0'.
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2083
File: packages/ui-components/src/lib/components/tables/VaultsListTable.svelte:205-205
Timestamp: 2025-08-14T14:16:34.044Z
Learning: In the VaultsListTable component, the `matchesAccount` function from the wallet provider may not properly update on wallet connect/disconnect events, making direct comparison with the reactive `$account` variable more reliable for UI visibility checks. The `matchesAccount` function needs future refactoring to handle wallet state changes properly.
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.
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.
There was a problem hiding this 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: Organization UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (3)
crates/common/src/raindex_client/local_db/query/fetch_vault_balance_changes.rspackages/orderbook/test/js_api/raindexClient.test.tspackages/ui-components/test-setup.ts
🧰 Additional context used
📓 Path-based instructions (10)
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 usingnix develop -c npm run svelte-lint-format-check -w @rainlanguage/ui-components
Files:
packages/ui-components/test-setup.ts
packages/ui-components/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
For UI components (
packages/ui-components), run tests usingnix develop -c npm run test -w @rainlanguage/ui-components
Files:
packages/ui-components/test-setup.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/test-setup.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/test-setup.tspackages/orderbook/test/js_api/raindexClient.test.ts
**/*.{ts,tsx,svelte}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx,svelte}: TypeScript/Svelte: format withnix develop -c npm run format
TypeScript/Svelte: lint withnix develop -c npm run lint
TypeScript/Svelte: type-check withnix develop -c npm run check
Files:
packages/ui-components/test-setup.tspackages/orderbook/test/js_api/raindexClient.test.ts
packages/orderbook/**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
packages/orderbook/**/*.{ts,tsx,js,jsx}: For Orderbook TypeScript (packages/orderbook), run lints usingnix develop -c npm run check -w @rainlanguage/orderbook
For Orderbook TypeScript (packages/orderbook), run tests usingnix develop -c npm run test -w @rainlanguage/orderbook
Files:
packages/orderbook/test/js_api/raindexClient.test.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.tsor*.spec.ts
Files:
packages/orderbook/test/js_api/raindexClient.test.ts
crates/**/*.rs
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
crates/**/*.rs: For Rust crates incrates/*, run lints usingnix develop -c cargo clippy --workspace --all-targets --all-features -D warnings
For Rust crates incrates/*, run tests usingnix develop -c cargo test --workspaceor--package <crate>
Files:
crates/common/src/raindex_client/local_db/query/fetch_vault_balance_changes.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/local_db/query/fetch_vault_balance_changes.rs
**/*.rs
📄 CodeRabbit inference engine (AGENTS.md)
**/*.rs: Rust: format code withnix develop -c cargo fmt --all
Rust: lint withnix develop -c rainix-rs-static(preconfigured flags included)
Rust: crates and modules usesnake_case; types usePascalCase
Files:
crates/common/src/raindex_client/local_db/query/fetch_vault_balance_changes.rs
🧠 Learnings (33)
📓 Common learnings
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: 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.
📚 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/test-setup.tspackages/orderbook/test/js_api/raindexClient.test.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/test-setup.ts
📚 Learning: 2025-08-14T18:29:32.933Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2083
File: packages/ui-components/src/__tests__/VaultsListTable.test.ts:16-19
Timestamp: 2025-08-14T18:29:32.933Z
Learning: In the rain.orderbook project's UI components tests, mocking hooks like useToasts is often required as infrastructure even when not directly asserting on their calls, because components internally depend on these hooks. Removing such mocks would break component rendering in tests and require more complex test setup with providers.
Applied to files:
packages/ui-components/test-setup.ts
📚 Learning: 2025-04-07T08:18:36.473Z
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1565
File: packages/webapp/src/routes/deploy/layout.test.ts:12-29
Timestamp: 2025-04-07T08:18:36.473Z
Learning: In test files for this project, hardingjam prefers to use custom mocks (such as for localStorage) rather than relying on environment-provided implementations, as this allows for spying on individual methods and having precise control over implementation details for more robust testing.
Applied to files:
packages/ui-components/test-setup.ts
📚 Learning: 2025-07-11T08:46:07.606Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1925
File: packages/ui-components/src/__tests__/DeploymentSteps.test.ts:519-554
Timestamp: 2025-07-11T08:46:07.606Z
Learning: In packages/ui-components/src/__tests__/DeploymentSteps.test.ts, findolor prefers to keep hardcoded timeout values (like 50ms and 100ms) inline in test cases rather than extracting them to named constants, viewing such refactoring as unnecessary for test maintainability.
Applied to files:
packages/ui-components/test-setup.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/test-setup.ts
📚 Learning: 2025-06-17T14:55:22.914Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1936
File: packages/ui-components/vite.config.ts:21-23
Timestamp: 2025-06-17T14:55:22.914Z
Learning: In the rain.orderbook project, the Vite configuration uses `'import.meta.vitest': 'undefined'` (as a string) combined with conditional `if (import.meta.vitest)` checks for in-source testing. The mock files are excluded from test execution using `exclude: ['src/lib/__mocks__/**/*.ts']`. This configuration successfully allows dev builds to work without `vi` undefined errors, despite the theoretical expectation that the string "undefined" would be truthy and cause issues.
Applied to files:
packages/ui-components/test-setup.ts
📚 Learning: 2025-03-31T10:16:53.544Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1469
File: packages/ui-components/src/__tests__/CodeMirrorDotrain.test.ts:75-98
Timestamp: 2025-03-31T10:16:53.544Z
Learning: In the rainlanguage/rain.orderbook project, direct manipulation of Svelte's internal state (component.$$.ctx) in tests is an acceptable approach for testing component behavior, as demonstrated in the CodeMirrorDotrain tests.
Applied to files:
packages/ui-components/test-setup.tspackages/orderbook/test/js_api/raindexClient.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/orderbook/test/js_api/raindexClient.test.ts
📚 Learning: 2025-04-04T11:25:21.518Z
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1559
File: packages/ui-components/src/__tests__/OrderOrVaultHash.test.ts:94-94
Timestamp: 2025-04-04T11:25:21.518Z
Learning: In the rain.orderbook project, minimal test fixtures are preferred over complete mocks that implement the entire interface. Type casting (e.g., `as unknown as SgVault`) is an acceptable approach to maintain both minimal fixtures and TypeScript type compatibility.
Applied to files:
packages/orderbook/test/js_api/raindexClient.test.tscrates/common/src/raindex_client/local_db/query/fetch_vault_balance_changes.rs
📚 Learning: 2025-07-04T09:14:35.748Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1956
File: packages/ui-components/src/__tests__/VaultDetail.test.ts:177-181
Timestamp: 2025-07-04T09:14:35.748Z
Learning: In the rain.orderbook project, maintainer findolor is fine with mutating mock data directly in test files using ts-expect-error comments, preferring this pragmatic approach over immutable patterns like spread operators for test data updates.
Applied to files:
packages/orderbook/test/js_api/raindexClient.test.ts
📚 Learning: 2025-11-25T16:50:11.197Z
Learnt from: CR
Repo: rainlanguage/rain.orderbook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-25T16:50:11.197Z
Learning: Applies to packages/orderbook/**/*.{ts,tsx,js,jsx} : For Orderbook TypeScript (`packages/orderbook`), run tests using `nix develop -c npm run test -w rainlanguage/orderbook`
Applied to files:
packages/orderbook/test/js_api/raindexClient.test.ts
📚 Learning: 2025-04-08T09:18:46.653Z
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1597
File: packages/ui-components/src/__tests__/OrderDetail.test.ts:120-120
Timestamp: 2025-04-08T09:18:46.653Z
Learning: In test files for the Rain Orderbook project, it's acceptable to bypass TypeScript's strict typing using constructs like `as unknown as [Type]` to create simplified mock objects that don't need to implement the entire interface.
Applied to files:
packages/orderbook/test/js_api/raindexClient.test.ts
📚 Learning: 2025-07-01T21:26:42.195Z
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 1955
File: packages/orderbook/package.json:40-40
Timestamp: 2025-07-01T21:26:42.195Z
Learning: In the rain.orderbook project, the team does not require cross-platform compatibility improvements for the TypeScript check script in packages/orderbook/package.json. The current brace expansion syntax "./dist/**/*.{ts,js}" is sufficient for their development environment.
Applied to files:
packages/orderbook/test/js_api/raindexClient.test.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/orderbook/test/js_api/raindexClient.test.ts
📚 Learning: 2025-03-26T16:16:51.943Z
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1515
File: packages/webapp/src/routes/deploy/[strategyName]/[deploymentKey]/layout.test.ts:37-37
Timestamp: 2025-03-26T16:16:51.943Z
Learning: For Rain Orderbook projects, in test files, the preference is to use "as any" type assertions with per-line ESLint disable comments rather than creating dedicated types for test parameters.
Applied to files:
packages/orderbook/test/js_api/raindexClient.test.ts
📚 Learning: 2025-05-09T05:30:02.520Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1744
File: packages/webapp/src/lib/components/DepositOrWithdrawModal.svelte:73-76
Timestamp: 2025-05-09T05:30:02.520Z
Learning: In Rain.orderbook, `VaultCalldataResult` is a wrapper type that contains both `error` and `value` properties. When using this in the `DepositOrWithdrawModal` component, only the inner `value` field is passed to the `handleTransaction` function, not the complete wrapper.
Applied to files:
packages/orderbook/test/js_api/raindexClient.test.ts
📚 Learning: 2025-05-17T15:32:28.733Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1790
File: tauri-app/src-tauri/src/commands/vault.rs:67-67
Timestamp: 2025-05-17T15:32:28.733Z
Learning: For the PR focused on testing Tauri commands::order module, the generic type parameter R: Runtime was selectively added where needed for the PR scope, applying the changes primarily to order.rs and related files while leaving other modules like vault.rs for potential future refactoring.
Applied to files:
crates/common/src/raindex_client/local_db/query/fetch_vault_balance_changes.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/query/fetch_vault_balance_changes.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/query/fetch_vault_balance_changes.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/query/fetch_vault_balance_changes.rs
📚 Learning: 2025-05-13T20:06:22.602Z
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.
Applied to files:
crates/common/src/raindex_client/local_db/query/fetch_vault_balance_changes.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_vault_balance_changes.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/local_db/query/fetch_vault_balance_changes.rs
📚 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_vault_balance_changes.rs
📚 Learning: 2025-09-02T08:04:34.729Z
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.
Applied to files:
crates/common/src/raindex_client/local_db/query/fetch_vault_balance_changes.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_vault_balance_changes.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/local_db/query/fetch_vault_balance_changes.rs
📚 Learning: 2025-05-19T12:09:10.694Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1858
File: crates/subgraph/src/orderbook_client/vault.rs:81-92
Timestamp: 2025-05-19T12:09:10.694Z
Learning: The `vault_balance_changes_list` function in OrderbookSubgraphClient uses a different pagination approach compared to other list methods. It uses hard-coded GraphQL query parameters (first=200, skip=0) while still accepting pagination arguments, and the pagination is handled by special logic inside the `query_paginated` method that properly processes these values.
Applied to files:
crates/common/src/raindex_client/local_db/query/fetch_vault_balance_changes.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/local_db/query/fetch_vault_balance_changes.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/local_db/query/fetch_vault_balance_changes.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/query/fetch_vault_balance_changes.rs
🧬 Code graph analysis (1)
crates/common/src/raindex_client/local_db/query/fetch_vault_balance_changes.rs (1)
crates/common/src/raindex_client/vaults.rs (22)
vaults(1504-1525)vault_id(134-136)vault_id(177-179)vault_id(724-727)vault_id(775-777)token(146-148)token(186-188)token(729-731)token(778-780)token(1089-1091)token(1102-1104)owner(130-132)owner(174-176)from(635-644)address(267-269)address(292-294)orderbook(150-152)orderbook(189-191)orderbook(766-768)orderbook(805-807)new(53-55)new(208-213)
⏰ 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: standard-tests (ubuntu-latest, rainix-wasm-browser-test)
- GitHub Check: standard-tests (ubuntu-latest, rainix-sol-legal)
- GitHub Check: standard-tests (ubuntu-latest, test-js-bindings)
- GitHub Check: standard-tests (ubuntu-latest, rainix-wasm-artifacts)
- GitHub Check: standard-tests (ubuntu-latest, rainix-sol-static)
- GitHub Check: standard-tests (ubuntu-latest, rainix-wasm-test)
- GitHub Check: standard-tests (ubuntu-latest, rainix-sol-artifacts)
- GitHub Check: standard-tests (ubuntu-latest, rainix-rs-static)
- 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-rs-artifacts, true)
- GitHub Check: test
- GitHub Check: git-clean
- GitHub Check: test
- GitHub Check: test
- GitHub Check: build-tauri (ubuntu-22.04, true)
- GitHub Check: Deploy-Preview-Push
- GitHub Check: Deploy-Docs-Preview
🔇 Additional comments (7)
packages/ui-components/test-setup.ts (1)
4-5: LGTM! Standard test environment setup.The
window.scrollTomock is a standard and necessary addition for testing in jsdom environments, which don't natively implement this method. This is likely needed for the new UI components being added in this PR (VaultBalanceChangeTypeFilter, DropdownCheckbox, VaultBalanceChangesTable) which may trigger scrolling behavior.packages/orderbook/test/js_api/raindexClient.test.ts (2)
414-415: LGTM! Test fixtures correctly extended with trade metadata.The addition of
trade: { tradeEvent: { __typename: 'TakeOrder' } }to all trade-related vault balance changes aligns with the new type structure for vault balance change filtering. The consistent application across all trade balance change objects is correct.Also applies to: 445-446, 499-500, 528-529
1576-1576: LGTM! Explicit identifier improves test fixture clarity.Adding the explicit
idfield to the deposit balance change test data makes the fixture more complete and easier to reference in assertions.crates/common/src/raindex_client/local_db/query/fetch_vault_balance_changes.rs (4)
6-7: LGTM: Imports are correct.The new imports for
VaultBalanceChangeFilterandVaultBalanceChangeKindare necessary for the filtering functionality and correctly reference their respective modules.
10-23: LGTM: Filter type conversion logic is correct.The function properly:
- Accepts
Option<&[VaultBalanceChangeFilter]>as the new parameter- Converts each filter to
VaultBalanceChangeKindvia.to_kind()- Uses
.as_deref()to transformOption<Vec<T>>intoOption<&[T]>matching the builder's signature
36-69: LGTM: Existing tests correctly updated.Both existing tests properly pass
Nonefor the newfilter_typesparameter to maintain their original no-filtering behavior.Also applies to: 71-119
121-160: Previous type mismatch issue resolved.The test now correctly:
- Creates
filter_kindsby converting eachVaultBalanceChangeFiltertoVaultBalanceChangeKind(line 131)- Passes
Some(&filter_kinds)to the builder (line 137), matching its expected signature- Passes
Some(&filter_types)to the wrapper function (line 154), matching its expected signatureThe test logic mirrors the production code conversion and includes a good assertion verifying the IN clause is present.
| #[wasm_bindgen_test] | ||
| async fn wrapper_uses_builder_sql_with_filter_types() { | ||
| let vault_id = U256::from(1); | ||
| let token = address!("0x00000000000000000000000000000000000000aa"); | ||
| let orderbook = Address::from([0x51; 20]); | ||
| let owner = address!("0x00000000000000000000000000000000000000f1"); | ||
| let filter_types = vec![ | ||
| VaultBalanceChangeFilter::Deposit, | ||
| VaultBalanceChangeFilter::Withdrawal, | ||
| ]; | ||
| let filter_kinds: Vec<_> = filter_types.iter().map(|f| f.to_kind()).collect(); | ||
| let expected_stmt = build_fetch_balance_changes_stmt( | ||
| &OrderbookIdentifier::new(1, orderbook), | ||
| vault_id, | ||
| token, | ||
| owner, | ||
| Some(&filter_kinds), | ||
| ) | ||
| .unwrap(); | ||
|
|
||
| let store = Rc::new(RefCell::new(( | ||
| String::new(), | ||
| wasm_bindgen::JsValue::UNDEFINED, | ||
| ))); | ||
| let callback = create_sql_capturing_callback("[]", store.clone()); | ||
| let exec = JsCallbackExecutor::from_ref(&callback); | ||
|
|
||
| let res = super::fetch_vault_balance_changes( | ||
| &exec, | ||
| &OrderbookIdentifier::new(1, orderbook), | ||
| vault_id, | ||
| token, | ||
| owner, | ||
| Some(&filter_types), | ||
| ) | ||
| .await; | ||
| assert!(res.is_ok()); | ||
| assert_eq!(store.borrow().clone().0, expected_stmt.sql); | ||
| assert!(expected_stmt.sql.contains("change_type IN")); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
Consider testing the empty filter edge case.
The tests cover None (no filtering) and non-empty filter lists, but don't test Some(&[]) (empty filter list). While unlikely in practice, it would be good defensive programming to verify the behavior when an empty filter list is provided—specifically, how bind_list_clause handles an empty iterator for the IN clause.
Example test structure
#[wasm_bindgen_test]
async fn wrapper_handles_empty_filter_list() {
let vault_id = U256::from(1);
let token = address!("0x00000000000000000000000000000000000000aa");
let orderbook = Address::from([0x51; 20]);
let owner = address!("0x00000000000000000000000000000000000000f1");
let filter_types: Vec<VaultBalanceChangeFilter> = vec![];
let store = Rc::new(RefCell::new((
String::new(),
wasm_bindgen::JsValue::UNDEFINED,
)));
let callback = create_sql_capturing_callback("[]", store.clone());
let exec = JsCallbackExecutor::from_ref(&callback);
let res = super::fetch_vault_balance_changes(
&exec,
&OrderbookIdentifier::new(1, orderbook),
vault_id,
token,
owner,
Some(&filter_types),
)
.await;
assert!(res.is_ok());
}🤖 Prompt for AI Agents
In
crates/common/src/raindex_client/local_db/query/fetch_vault_balance_changes.rs
around lines 121-160, add a new wasm_bindgen_test that covers the edge case
where Some(&[]) (an empty filter slice) is passed to
fetch_vault_balance_changes; create the same vault_id, token, orderbook and
owner fixtures as the existing test, set filter_types to an empty
Vec<VaultBalanceChangeFilter>, build the callback/store and JsCallbackExecutor
the same way, call super::fetch_vault_balance_changes with Some(&filter_types)
and assert the call succeeds (res.is_ok()) and optionally assert the captured
SQL matches the expected build_fetch_balance_changes_stmt for an empty filter
(or at least that it does not contain a malformed IN clause).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@findolor, understood! I'll skip the empty filter test case.
🧠 Learnings used
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: 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: 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.
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: 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.
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.
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: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1790
File: tauri-app/src-tauri/src/commands/vault.rs:67-67
Timestamp: 2025-05-17T15:32:28.733Z
Learning: For the PR focused on testing Tauri commands::order module, the generic type parameter R: Runtime was selectively added where needed for the PR scope, applying the changes primarily to order.rs and related files while leaving other modules like vault.rs for potential future refactoring.
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: 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.
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: 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.
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: 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.
Motivation
See issues:
When viewing vault balance changes, users often want to focus on specific types of transactions (deposits, withdrawals, trades, or clear bounties) rather than scrolling through all activity. This improves the user experience for vault management and analysis by allowing targeted filtering of balance history.
Solution
Added filtering capability for vault balance changes across the full stack:
Rust Changes:
VaultBalanceChangeFilterenum with variants:Deposit,Withdrawal,Trade,ClearBountybuild_fetch_balance_changes_stmtto support dynamic SQLINclause for filtering by change typeRaindexVault::get_balance_changes()to accept optional filter types parametervault_balance_changes_listandvault_balance_changes_list_allRaindexVaultBalanceChangeTypeparsing to properly mapCLEAR_ALICE_*andCLEAR_BOB_*variantsUI Changes:
DropdownCheckboxcomponent for multi-select dropdown functionalityVaultBalanceChangeTypeFiltercomponent that wrapsDropdownCheckboxwith the four filter optionsVaultBalanceChangesTableabove the tablep--→p-0), dynamic filter count logic, and stable query keysTests:
DropdownCheckboxandVaultBalanceChangeTypeFilterChecks
By submitting this for review, I'm confirming I've done the following:
Summary by CodeRabbit
New Features
Tests
Other
✏️ Tip: You can customize this high-level summary in your review settings.