token dropdown loading issues in Orders/Vaults list pages#2428
Open
token dropdown loading issues in Orders/Vaults list pages#2428
Conversation
- Add camelCase aliases to fetch_all_tokens SQL query to match LocalDbToken struct's serde rename_all configuration - Simplify get_all_vault_tokens to use local DB first (consistent with get_vaults), fixing empty token list when no network selected
Contributor
WalkthroughToken query changed to emit camelCase aliases and deterministic ORDER BY. Vault token retrieval was simplified to use a single-source fallback: return local DB results when available, otherwise query the subgraph. Added tests verifying SQL aliases and wasm tests for local-db short-circuiting. Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant Vaults as RaindexClient::Vaults
participant LocalDB as LocalDbVaults
participant Subgraph as SubgraphVaults
Caller->>Vaults: get_all_vault_tokens(chain_ids)
Vaults-->>Vaults: compute ids from chain_ids
alt local DB available
Vaults->>LocalDB: tokens_list(ids)
LocalDB-->>Vaults: tokens
Vaults-->>Caller: return tokens
else local DB not available
Vaults->>Subgraph: tokens_list(ids)
Subgraph-->>Vaults: tokens
Vaults-->>Caller: return tokens
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
See issues:
The token selection dropdown in Orders and Vaults list pages had two issues:
Deserialization error when a network was selected: Selecting a network then opening the token dropdown produced the error: "Cannot load tokens list: There was an error querying the local database: Deserialization failed: missing field
chainId"Empty token list when no network selected: When no network filter was applied, the token dropdown showed no tokens because the code defaulted to querying only the subgraph (which returned nothing) instead of the local database.
Solution
SQL Query Fix: Added camelCase column aliases to the
fetch_all_tokensSQL query to match theLocalDbTokenstruct's#[serde(rename_all = "camelCase")]attribute. The SQL was returning snake_case column names (chain_id,orderbook_address,token_address) but serde expected camelCase (chainId,orderbookAddress,tokenAddress).Data Source Logic Fix: Simplified
get_all_vault_tokensto follow the same pattern asget_vaultsandget_orders- check local DB first, fall back to subgraph. The previous implementation had complex logic that defaulted to subgraph when no chain IDs were provided, even when local DB was available.Checks
By submitting this for review, I'm confirming I've done the following:
fix #2425
Summary by CodeRabbit