-
Notifications
You must be signed in to change notification settings - Fork 13
Update token filtering logic in get_orders filters
#2358
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
WalkthroughThis PR refactors token filtering across the codebase to support directional filtering by introducing structured Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 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: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (9)
crates/cli/src/subgraph.rs(3 hunks)crates/common/src/local_db/query/fetch_orders/mod.rs(6 hunks)crates/common/src/local_db/query/fetch_orders/query.sql(1 hunks)crates/common/src/raindex_client/local_db/query/fetch_orders.rs(6 hunks)crates/common/src/raindex_client/orders.rs(5 hunks)crates/subgraph/src/multi_orderbook_client.rs(1 hunks)crates/subgraph/src/orderbook_client/order.rs(14 hunks)crates/subgraph/src/types/common.rs(2 hunks)packages/ui-components/src/lib/components/tables/OrdersListTable.svelte(1 hunks)
🧰 Additional context used
📓 Path-based instructions (8)
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/components/tables/OrdersListTable.svelte
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/components/tables/OrdersListTable.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/components/tables/OrdersListTable.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/components/tables/OrdersListTable.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/tables/OrdersListTable.svelte
**/crates/**
📄 CodeRabbit inference engine (AGENTS.md)
Rust workspace organized as
crates/*with subdirectories: cli, common, bindings, js_api, quote, subgraph, settings, math, integration_tests
Files:
crates/common/src/local_db/query/fetch_orders/query.sqlcrates/subgraph/src/types/common.rscrates/subgraph/src/multi_orderbook_client.rscrates/common/src/local_db/query/fetch_orders/mod.rscrates/cli/src/subgraph.rscrates/common/src/raindex_client/orders.rscrates/common/src/raindex_client/local_db/query/fetch_orders.rscrates/subgraph/src/orderbook_client/order.rs
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/subgraph/src/types/common.rscrates/subgraph/src/multi_orderbook_client.rscrates/common/src/local_db/query/fetch_orders/mod.rscrates/cli/src/subgraph.rscrates/common/src/raindex_client/orders.rscrates/common/src/raindex_client/local_db/query/fetch_orders.rscrates/subgraph/src/orderbook_client/order.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/subgraph/src/types/common.rscrates/subgraph/src/multi_orderbook_client.rscrates/common/src/local_db/query/fetch_orders/mod.rscrates/cli/src/subgraph.rscrates/common/src/raindex_client/orders.rscrates/common/src/raindex_client/local_db/query/fetch_orders.rscrates/subgraph/src/orderbook_client/order.rs
🧠 Learnings (46)
📓 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: findolor
Repo: rainlanguage/rain.orderbook PR: 2001
File: crates/common/src/raindex_client/order_quotes.rs:62-69
Timestamp: 2025-07-16T14:33:13.457Z
Learning: In the rainlanguage/rain.orderbook codebase, findolor considers hardcoded decimal values (18 and 36) in order quote formatting logic to be acceptable for their use case, even when dynamic token decimals could theoretically provide more accurate formatting for different tokens.
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: 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.
📚 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/OrdersListTable.svelte
📚 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:
packages/ui-components/src/lib/components/tables/OrdersListTable.sveltecrates/subgraph/src/types/common.rscrates/subgraph/src/multi_orderbook_client.rscrates/cli/src/subgraph.rscrates/subgraph/src/orderbook_client/order.rs
📚 Learning: 2025-04-10T16:32:51.198Z
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1651
File: packages/ui-components/src/lib/components/TanstackAppTable.svelte:13-13
Timestamp: 2025-04-10T16:32:51.198Z
Learning: In the TanstackAppTable.svelte component, the queryKey prop should be required (type: string) rather than optional (string | undefined) to ensure proper query invalidation.
Applied to files:
packages/ui-components/src/lib/components/tables/OrdersListTable.svelte
📚 Learning: 2025-05-14T05:52:04.270Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1715
File: crates/js_api/src/common/mod.rs:15-22
Timestamp: 2025-05-14T05:52:04.270Z
Learning: The project doesn't require `#[repr(transparent)]` for newtype wrappers in WASM contexts such as `AddOrderCalldata` and `RemoveOrderCalldata` as the current implementation is working as expected without it.
Applied to files:
crates/subgraph/src/types/common.rscrates/common/src/raindex_client/orders.rs
📚 Learning: 2025-07-04T10:26:24.289Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1956
File: crates/common/src/raindex_client/mod.rs:116-135
Timestamp: 2025-07-04T10:26:24.289Z
Learning: In crates/common/src/raindex_client/mod.rs, the get_multi_subgraph_args method intentionally treats Some(empty vector) the same as None for chain_ids parameter. Both cases should return all networks to support UI behavior where no selection or empty selection means "show all networks". Only when specific chain IDs are provided should the results be filtered.
Applied to files:
crates/subgraph/src/types/common.rscrates/subgraph/src/multi_orderbook_client.rscrates/cli/src/subgraph.rs
📚 Learning: 2025-05-14T05:13:59.713Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1744
File: crates/subgraph/src/orderbook_client.rs:44-46
Timestamp: 2025-05-14T05:13:59.713Z
Learning: In the rain.orderbook project, WASM dependencies are intentionally made available in non-WASM targets to facilitate testing of WASM-related functionality, so conditional compilation guards like `#[cfg(target_family = "wasm")]` should not be added to imports or implementations that may be needed for tests.
Applied to files:
crates/subgraph/src/types/common.rscrates/common/src/raindex_client/orders.rs
📚 Learning: 2025-07-16T10:40:05.717Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2000
File: crates/common/src/raindex_client/vaults.rs:183-183
Timestamp: 2025-07-16T10:40:05.717Z
Learning: In the rainlanguage/rain.orderbook codebase, user findolor considers breaking changes from Option<U256> to U256 for required fields like decimals in RaindexVaultToken to be acceptable and safe, even when they affect multiple usage sites across the codebase.
Applied to files:
crates/subgraph/src/multi_orderbook_client.rscrates/cli/src/subgraph.rscrates/common/src/raindex_client/orders.rscrates/common/src/raindex_client/local_db/query/fetch_orders.rscrates/subgraph/src/orderbook_client/order.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/subgraph/src/multi_orderbook_client.rscrates/common/src/raindex_client/orders.rscrates/common/src/raindex_client/local_db/query/fetch_orders.rscrates/subgraph/src/orderbook_client/order.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/multi_orderbook_client.rscrates/common/src/raindex_client/local_db/query/fetch_orders.rscrates/subgraph/src/orderbook_client/order.rs
📚 Learning: 2025-07-21T16:34:31.193Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1911
File: crates/subgraph/src/types/impls.rs:7-15
Timestamp: 2025-07-21T16:34:31.193Z
Learning: In the rainlanguage/rain.orderbook codebase, user 0xgleb considers breaking changes that remove unsafe default behaviors to be intentional and acceptable. Specifically, the get_decimals() method in crates/subgraph/src/types/impls.rs was intentionally changed to return MissingDecimals error instead of defaulting to 18 decimals, as defaulting to 18 is considered unsafe and should never have been done.
Applied to files:
crates/subgraph/src/multi_orderbook_client.rscrates/cli/src/subgraph.rscrates/common/src/raindex_client/orders.rs
📚 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:
crates/subgraph/src/multi_orderbook_client.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/multi_orderbook_client.rscrates/cli/src/subgraph.rscrates/common/src/raindex_client/orders.rscrates/common/src/raindex_client/local_db/query/fetch_orders.rscrates/subgraph/src/orderbook_client/order.rs
📚 Learning: 2025-11-25T14:56:29.762Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2334
File: crates/settings/src/yaml/orderbook.rs:18-18
Timestamp: 2025-11-25T14:56:29.762Z
Learning: In crates/settings/src/yaml/orderbook.rs, the `accounts` section is optional in orderbook YAML. The `AccountCfg::parse_all_from_yaml` method returns an empty HashMap when the `accounts` section is missing rather than throwing a Field(Missing(...)) error, so it doesn't need to be wrapped with `to_yaml_string_missing_check` in the `to_yaml_string` method.
Applied to files:
crates/subgraph/src/multi_orderbook_client.rs
📚 Learning: 2025-06-16T10:49:47.770Z
Learnt from: thedavidmeister
Repo: rainlanguage/rain.orderbook PR: 1926
File: test/concrete/ob/OrderBook.clear.zeroAmount.t.sol:24-32
Timestamp: 2025-06-16T10:49:47.770Z
Learning: LibTestAddOrder.conformConfig() in test/util/lib/LibTestAddOrder.sol automatically constrains OrderConfigV3 to prevent common test failures by ensuring validInputs[0].token != validOutputs[0].token, setting them to address(0) and address(1) respectively if they're equal. This prevents TokenSelfTrade errors in fuzz tests.
Applied to files:
crates/subgraph/src/multi_orderbook_client.rscrates/common/src/raindex_client/local_db/query/fetch_orders.rs
📚 Learning: 2025-12-03T10:40:25.429Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2344
File: crates/common/src/local_db/pipeline/runner/mod.rs:18-31
Timestamp: 2025-12-03T10:40:25.429Z
Learning: In `crates/common/src/local_db/pipeline/runner/mod.rs`, the `TargetSuccess` struct does not need separate `ob_id` or `orderbook_key` fields because the contained `SyncOutcome` already includes orderbook identification information such as chain_id and orderbook_address. This avoids redundant data duplication.
Applied to files:
crates/common/src/local_db/query/fetch_orders/mod.rs
📚 Learning: 2025-10-06T11:28:30.692Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2145
File: crates/common/src/raindex_client/local_db/query/fetch_orders/query.sql:6-7
Timestamp: 2025-10-06T11:28:30.692Z
Learning: In `crates/common/src/raindex_client/local_db/query/fetch_orders/query.sql`, the orderbook_address is currently hardcoded to '0x2f209e5b67A33B8fE96E28f24628dF6Da301c8eB' because the system only supports a single orderbook at the moment. Multiorderbook logic is not yet implemented and will be added in the future.
Applied to files:
crates/common/src/local_db/query/fetch_orders/mod.rscrates/common/src/raindex_client/orders.rscrates/common/src/raindex_client/local_db/query/fetch_orders.rs
📚 Learning: 2025-05-09T05:28:22.089Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1744
File: crates/js_api/src/subgraph/order.rs:109-114
Timestamp: 2025-05-09T05:28:22.089Z
Learning: In the rain.orderbook project, SubgraphError contains or converts from OrderbookSubgraphClientError, so using OrderbookSubgraphClientError in error creation followed by a conversion to SubgraphError (via ? operator) is acceptable.
Applied to files:
crates/cli/src/subgraph.rs
📚 Learning: 2025-07-21T16:37:20.599Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1911
File: crates/subgraph/src/utils/mod.rs:1-1
Timestamp: 2025-07-21T16:37:20.599Z
Learning: In the rainlanguage/rain.orderbook codebase, user 0xgleb prefers explicit module imports over re-exporting symbols at higher levels. Specifically for the float constants in crates/subgraph/src/utils/float.rs, they prefer using `utils::float::*` rather than re-exporting with `pub use float::*` in the utils module, as the explicit import makes it clearer what is being imported and why it's needed.
Applied to files:
crates/cli/src/subgraph.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/cli/src/subgraph.rscrates/common/src/raindex_client/orders.rscrates/common/src/raindex_client/local_db/query/fetch_orders.rs
📚 Learning: 2025-06-18T18:18:44.330Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1938
File: crates/js_api/src/raindex/mod.rs:92-99
Timestamp: 2025-06-18T18:18:44.330Z
Learning: In crates/js_api/src/raindex/mod.rs, the get_subgraph_url_for_chain method and get_multi_subgraph_args method intentionally duplicate lookup logic because they serve different purposes: get_subgraph_url_for_chain returns only the URL string, while get_multi_subgraph_args returns MultiSubgraphArgs structures containing both URL and network information (name/label). This duplication is acceptable and by design.
Applied to files:
crates/cli/src/subgraph.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/subgraph.rs
📚 Learning: 2025-06-17T16:32:04.554Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1903
File: crates/js_api/src/gui/order_operations.rs:124-134
Timestamp: 2025-06-17T16:32:04.554Z
Learning: In the rain.orderbook codebase, RPC lists are typically small (2 items maximum), so performance optimizations around cloning and converting small Vec<Url> collections are generally unnecessary.
Applied to files:
crates/cli/src/subgraph.rscrates/common/src/raindex_client/orders.rs
📚 Learning: 2025-06-24T13:36:28.797Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1950
File: crates/common/src/raindex_client/orders.rs:301-301
Timestamp: 2025-06-24T13:36:28.797Z
Learning: In the RaindexClient codebase, when Arc::new(RwLock::new(self.clone())) is used (e.g., in get_orders and get_order_by_hash methods), this creates new Arc/RwLock wrappers around a cloned RaindexClient, but the underlying client data is functionally the same. This pattern is used to provide the correct Arc<RwLock<RaindexClient>> type expected by RaindexOrder::try_from_sg_order() method.
Applied to files:
crates/cli/src/subgraph.rs
📚 Learning: 2025-05-15T21:22:23.948Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1833
File: crates/cli/src/subgraph.rs:119-129
Timestamp: 2025-05-15T21:22:23.948Z
Learning: In the rain.orderbook project, the `csv` flag in `CliPaginationArgs` is not used in the `From<CliPaginationArgs> for SgPaginationArgs` implementation, so it doesn't need to be tested in the conversion tests. The implementation only maps the `page` and `page_size` fields.
Applied to files:
crates/cli/src/subgraph.rs
📚 Learning: 2025-08-01T09:07:20.383Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2044
File: packages/orderbook/README.md:186-189
Timestamp: 2025-08-01T09:07:20.383Z
Learning: In the rainlanguage/rain.orderbook project, Rust methods on structs like RaindexVaultsList are exported as JavaScript getters in WASM bindings using #[wasm_bindgen(getter)]. This means while the Rust code uses method calls like items(), the JavaScript/WASM API exposes them as property access like .items. The README.md correctly documents the JavaScript API surface, not the Rust implementation details.
Applied to files:
crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-07-04T09:02:57.301Z
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.
Applied to files:
crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-08-01T07:35:13.418Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2036
File: crates/js_api/src/filters/errors.rs:39-46
Timestamp: 2025-08-01T07:35:13.418Z
Learning: In the Rain Orderbook project's PersistentFilterStoreError (crates/js_api/src/filters/errors.rs), the Display implementation already provides user-friendly error messages, so using err.to_string() for both msg and readable_msg in the WasmEncodedError conversion is appropriate and doesn't require separate readable message handling.
Applied to files:
crates/common/src/raindex_client/orders.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/raindex_client/orders.rs
📚 Learning: 2025-10-06T11:13:29.956Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2123
File: crates/common/src/raindex_client/local_db/mod.rs:23-29
Timestamp: 2025-10-06T11:13:29.956Z
Learning: In `crates/common/src/raindex_client/local_db/mod.rs`, the `Default` implementation for `LocalDb` that creates an RPC client pointing to `http://localhost:4444` is acceptable because the RPC client must be explicitly configured before actual usage in production scenarios.
Applied to files:
crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-10-18T10:38:41.273Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2237
File: crates/common/src/raindex_client/local_db/sync.rs:79-89
Timestamp: 2025-10-18T10:38:41.273Z
Learning: In `crates/common/src/raindex_client/local_db/sync.rs`, the sync_database method currently only supports indexing a single orderbook per chain ID, which is why `.first()` is used to select the orderbook configuration. Multi-orderbook support per chain ID is planned for future PRs.
Applied to files:
crates/common/src/raindex_client/orders.rscrates/common/src/raindex_client/local_db/query/fetch_orders.rs
📚 Learning: 2025-10-13T12:57:05.900Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2198
File: crates/common/src/raindex_client/local_db/query/fetch_store_addresses/mod.rs:7-8
Timestamp: 2025-10-13T12:57:05.900Z
Learning: In the rain.orderbook repository, using unqualified serde helper names (e.g., `#[serde(with = "serde_address")]`) that rely on glob imports is acceptable and does not need to be changed to fully qualified paths.
Applied to files:
crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-08-26T14:52:37.000Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2099
File: crates/common/src/hyper_rpc.rs:3-7
Timestamp: 2025-08-26T14:52:37.000Z
Learning: In the rain.orderbook codebase, creating new reqwest::Client instances per request in HyperRpcClient is not considered an issue by the maintainers, despite potential performance benefits of client reuse.
Applied to files:
crates/common/src/raindex_client/orders.rs
📚 Learning: 2025-07-16T14:33:45.887Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2001
File: crates/common/src/raindex_client/vaults.rs:0-0
Timestamp: 2025-07-16T14:33:45.887Z
Learning: In the rainlanguage/rain.orderbook codebase, findolor considers using Address::random() in tests to be acceptable when the mock server doesn't validate the address parameter and returns a fixed response, making the test deterministic regardless of the address value used.
Applied to files:
crates/common/src/raindex_client/orders.rscrates/common/src/raindex_client/local_db/query/fetch_orders.rs
📚 Learning: 2025-10-02T19:17:20.332Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2163
File: crates/common/src/raindex_client/orders.rs:738-741
Timestamp: 2025-10-02T19:17:20.332Z
Learning: In crates/common/src/raindex_client/orders.rs, fetch_dotrain_source() is intentionally called in try_from_sg_order for every order conversion because the dotrain source information is needed immediately. A future optimization with local DB logic is planned to eliminate the network round-trip concern.
Applied to files:
crates/common/src/raindex_client/local_db/query/fetch_orders.rs
📚 Learning: 2025-05-20T10:20:08.206Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1859
File: crates/quote/src/quote_debug.rs:472-492
Timestamp: 2025-05-20T10:20:08.206Z
Learning: In the Rain Orderbook codebase, the `#[tokio::test(flavor = "multi_thread")]` annotation is specifically needed for tests that use `LocalEvm`, not just for consistency across all async tests.
Applied to files:
crates/common/src/raindex_client/local_db/query/fetch_orders.rscrates/subgraph/src/orderbook_client/order.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/common/src/raindex_client/local_db/query/fetch_orders.rscrates/subgraph/src/orderbook_client/order.rs
📚 Learning: 2025-11-25T16:50:31.752Z
Learnt from: CR
Repo: rainlanguage/rain.orderbook PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T16:50:31.752Z
Learning: Applies to crates/integration_tests/**/*.rs : Rust: write tests using `cargo test`; integration tests live in `crates/integration_tests`. Prefer `insta` snapshots and `proptest` where helpful
Applied to files:
crates/common/src/raindex_client/local_db/query/fetch_orders.rscrates/subgraph/src/orderbook_client/order.rs
📚 Learning: 2025-07-21T16:34:04.947Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1911
File: crates/common/src/raindex_client/orders.rs:720-720
Timestamp: 2025-07-21T16:34:04.947Z
Learning: In the rainlanguage/rain.orderbook codebase, user 0xgleb prefers using `.unwrap()` in test code rather than `.expect()` with descriptive messages, considering the direct unwrap approach acceptable for test contexts where failures should be fast and clear.
Applied to files:
crates/common/src/raindex_client/local_db/query/fetch_orders.rscrates/subgraph/src/orderbook_client/order.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_orders.rs
📚 Learning: 2025-07-31T19:34:11.716Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2044
File: crates/common/src/raindex_client/vaults_list.rs:363-423
Timestamp: 2025-07-31T19:34:11.716Z
Learning: In the rainlanguage/rain.orderbook project, for WASM-exposed functionality like VaultsList, the team prefers to keep comprehensive tests in the non-WASM environment due to the complexity of recreating objects like RaindexVaults in WASM. WASM tests focus on basic functionality and error cases since the WASM code reuses the already-tested non-WASM implementation.
Applied to files:
crates/common/src/raindex_client/local_db/query/fetch_orders.rs
📚 Learning: 2025-05-01T14:39:53.795Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1721
File: crates/js_api/src/bindings/mod.rs:1-131
Timestamp: 2025-05-01T14:39:53.795Z
Learning: Empty input validation for functions like `keccak256` and `get_order_hash` in the WebAssembly bindings is not required as empty inputs are considered valid in this context.
Applied to files:
crates/common/src/raindex_client/local_db/query/fetch_orders.rs
📚 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:
crates/subgraph/src/orderbook_client/order.rs
📚 Learning: 2025-04-07T07:50:17.023Z
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1575
File: packages/webapp/src/routes/deploy/layout.test.ts:28-37
Timestamp: 2025-04-07T07:50:17.023Z
Learning: In the rain.orderbook repository, the team considers it acceptable to use type assertions (like `as any`) for complex types in test files. This is preferred over creating detailed type definitions that would only be used for testing.
Applied to files:
crates/subgraph/src/orderbook_client/order.rs
📚 Learning: 2025-07-21T16:33:12.129Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1911
File: crates/common/src/erc20.rs:336-350
Timestamp: 2025-07-21T16:33:12.129Z
Learning: In the rainlanguage/rain.orderbook codebase, user 0xgleb considers both LocalEvm-based tests and mocked tests to be "unit tests" - they don't distinguish between them as "unit" vs "integration" tests based on their implementation approach.
Applied to files:
crates/subgraph/src/orderbook_client/order.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/order.rs
🧬 Code graph analysis (1)
crates/common/src/raindex_client/local_db/query/fetch_orders.rs (1)
crates/common/src/local_db/query/fetch_orders/mod.rs (1)
build_fetch_orders_stmt(91-203)
🪛 Gitleaks (8.30.0)
crates/subgraph/src/orderbook_client/order.rs
[high] 719-719: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
[high] 754-754: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
🔇 Additional comments (15)
packages/ui-components/src/lib/components/tables/OrdersListTable.svelte (1)
82-85: Provide a screenshot showing the token filtering behavior.This change modifies the token filtering functionality in the orders list, which affects frontend behavior. Per the coding guidelines: "If you modify frontend code or functionality affecting the frontend, you MUST provide a screenshot of the built webapp reflecting your change."
Please provide a screenshot demonstrating the updated token filtering in action.
As per coding guidelines, screenshots are required for frontend functionality changes.
crates/subgraph/src/multi_orderbook_client.rs (1)
167-174: Default orders filter correctly updated for optional tokensUsing
tokens: Noneindefault_filter_args()aligns with the newOption<SgOrdersTokensFilterArgs>API and preserves the previous “no token filter” behavior in all existing tests.crates/subgraph/src/types/common.rs (1)
5-12: Directional token filter type is well-shaped and consistent
SgOrdersTokensFilterArgs { inputs, outputs }plustokens: Option<SgOrdersTokensFilterArgs>onSgOrdersListFilterArgscleanly models directional filters while allowing tokens to be omitted entirely. TS/WASM metadata (Tsify,impl_wasm_traits!,tsify(optional)) is consistent with the rest of the module.Also applies to: 27-28
crates/common/src/local_db/query/fetch_orders/query.sql (1)
290-299: New input/output token clauses are placed and named correctlyAdding
/*INPUT_TOKENS_CLAUSE*/and/*OUTPUT_TOKENS_CLAUSE*/in the WHERE section keeps token filtering orthogonal to grouping/ordering and matches the Rust constants used bybind_list_clause. The separateio2alias scopes these filters without touching the outeriosJSON aggregation.crates/common/src/raindex_client/local_db/query/fetch_orders.rs (2)
2-4: Local DB token filter mapping matches new directional model
From<GetOrdersFilters> for FetchOrdersArgsnow builds aFetchOrdersTokensFilterby unwrappinginputs/outputswithunwrap_or_default()and defaulting the whole filter whenfilters.tokensisNone. This ensures:
- No tokens → both
inputsandoutputsempty.- Inputs-only or outputs-only set → only that side populated.
Semantics line up with the subgraph conversion and keep “no selection” equivalent to “no token filter”.Also applies to: 15-28
44-75: Tests correctly assert directional tokens->args mapping and SQL usageThe unit test
from_get_orders_filters_builds_argsand WASM testwrapper_uses_builder_sql_exactlynow:
- Use
GetOrdersTokenFilterto populate onlyinputs.- Assert
args.tokens.inputscontains the lowercased address andargs.tokens.outputsis empty.- Verify that the wrapper delegates exactly to
build_fetch_orders_stmt.
These tests cover the new shape and avoid regressions in builder wiring.Also applies to: 101-133
crates/cli/src/subgraph.rs (1)
4-6: CLI mapping to directional token filters preserves previous semantics
CliFilterArgs.tokens: Vec<String>now maps totokens: Some(SgOrdersTokensFilterArgs { inputs, outputs })when non-empty, andNoneotherwise, with inputs/outputs both set to the same list. This keeps the existing “match either side against these tokens” behavior while conforming to the new directional filter API. The updated test correctly asserts bothinputsandoutputscontain the CLI tokens.Also applies to: 96-113, 168-172
crates/common/src/local_db/query/fetch_orders/mod.rs (3)
17-21: New FetchOrdersTokensFilter cleanly extends FetchOrdersArgsIntroducing
FetchOrdersTokensFilter { inputs, outputs }and embedding it inFetchOrdersArgsas a non-optional field keeps the external API simple while allowing the builder to treat “no tokens” as both vectors empty. This mirrors how other filters (owners, chain_ids) are modeled and keeps the caller code straightforward.Also applies to: 24-31
60-65: Directional EXISTS clauses are wired correctly in the SQL builderThe builder now:
- Sorts and deduplicates
args.tokens.inputs/outputs.- Binds
INPUT_TOKENS_CLAUSE/OUTPUT_TOKENS_CLAUSEwith EXISTS subqueries constrained bylower(io2.io_type) = 'input'/'output'andio2.token IN ({list}).Given existing
bind_list_clausebehavior (also used for owners/chain IDs), empty lists remove the markers without injecting invalidIN (), while non-empty lists generate the expected filter. This yields:
- Input-only filters → only the input EXISTS clause.
- Output-only filters → only the output EXISTS clause.
- Both → both clauses chained with AND, expressing “match this input set AND this output set”.
Also applies to: 183-200
211-223: Tests adequately cover presence/absence of directional token clausesThe updated tests:
- Extend existing assertions to confirm
INPUT_TOKENS_CLAUSE/OUTPUT_TOKENS_CLAUSEmarkers are removed when no tokens are provided.- Add three focused tests verifying:
- Only input clause appears when only inputs are non-empty.
- Only output clause appears when only outputs are non-empty.
- Both clauses, and two
io2.token INsections, appear when both sides are populated.This gives good coverage over the new SQL fragments and helps catch template or binding regressions.
Also applies to: 240-247, 265-314
crates/subgraph/src/orderbook_client/order.rs (3)
41-49: orders_list correctly composes basic and directional token filtersThe refactored
orders_list:
- Detects “basic” filters (owners/active/order_hash) separately from token filters.
- Computes
has_input_tokens/has_output_tokensofffilter_args.tokens.as_ref().- Only populates
inputs_/outputs_inSgOrdersListQueryFilterswhen the respective side has tokens.- Always wraps filters in a single-element
SgOrdersListQueryAnyFiltersorvector when any filter is present.This cleanly supports:
- No tokens (filters = None when no other filters).
- Input-only, output-only, or both-direction token filters.
Also applies to: 50-73
96-104: orders_list_all default filter correctly omits tokensUsing
tokens: Noneinorders_list_all’s call toorders_listpreserves the “fetch all orders” behavior under the new optional token filter structure.
141-143: Tests validate new token-filter wiring against GraphQL requestsThe added/updated tests:
- Instantiate
SgOrdersListFilterArgswithtokens: Nonefor no-token scenarios.- Cover input-only, output-only, both-input-and-output, and combined (owners + active + input token) filters using
SgOrdersTokensFilterArgs.- Use
httpmockbody matchers to assert the generated GraphQL includes the correctinputs_/outputs_blocks andtoken_inarrays, while preserving existing owner/active predicates.This gives strong end-to-end coverage that the subgraph client emits the expected query shapes for the new directional token semantics.
Also applies to: 458-468, 491-501, 523-532, 549-557, 715-859
crates/common/src/raindex_client/orders.rs (2)
21-23: New GetOrdersTokenFilter and conversion logic correctly model directional tokens
GetOrdersTokenFilterintroducesinputs/outputsasOption<Vec<Address>>with appropriate TS metadata, andGetOrdersFilters.tokensnow wraps this. TheTryFrom<GetOrdersFilters> for SgOrdersListFilterArgsimplementation:
- Unwraps
inputs/outputswithunwrap_or_default().- Normalizes all addresses to lowercase strings before building
SgOrdersTokensFilterArgs.- Returns
tokens: Nonewhenever both sides are empty or filters.tokens isNone, via theOption<Option<_>>+flatten()pattern.This yields sensible, minimal filters for the subgraph while preserving backwards-compatibility for callers that previously omitted tokens.
Also applies to: 800-823, 824-855
972-1052: Unit tests confirm directional token mapping and empty-drop behaviorThe new tests:
try_from_get_orders_filters_maps_directional_tokenschecks that a non-empty inputs/outputs pair producestokens.inputsandtokens.outputswith the expected lowercased hex.try_from_get_orders_filters_drops_empty_token_listsasserts that providing explicitly empty lists on both sides results inargs.tokens.is_none().These directly exercise the edge-cases of the conversion logic and should prevent subtle regressions in token filter handling.
Motivation
See issues:
With the new take orders functionality we needed a way to only get orders with a specific pair. For that we needed to update the filtering logic to be more granular.
Solution
Checks
By submitting this for review, I'm confirming I've done the following:
fix #2354
Summary by CodeRabbit
New Features
Changes
✏️ Tip: You can customize this high-level summary in your review settings.