-
Notifications
You must be signed in to change notification settings - Fork 13
Add token querying capabilities to SDK with OrderbookYaml.getTokens() and DotrainRegistry.getOrderbookYaml()
#2368
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
WalkthroughA new Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant App as Application
participant Registry as DotrainRegistry
participant YAML as OrderbookYaml
participant RemoteAPI as Remote Token API
User->>App: Request tokens
App->>Registry: getOrderbookYaml()
Registry->>YAML: new(settings, None)
YAML-->>Registry: OrderbookYaml instance
Registry-->>App: OrderbookYaml
App->>YAML: getTokens()
alt using-tokens-from configured
YAML->>RemoteAPI: fetch_tokens(urls)
RemoteAPI-->>YAML: remote token configs
YAML->>YAML: merge with local tokens
else local-only
YAML->>YAML: use local tokens
end
YAML->>YAML: assemble TokenInfoExtended[]<br/>(key, address, decimals,<br/>name, symbol, chain_id)
YAML-->>App: Vec<TokenInfoExtended>
App-->>User: Display tokens
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
Motivation
See issues:
The SDK previously lacked a convenient way to query token metadata from YAML configuration. Users needed to work through the GUI layer or manually parse YAML to access token information. Additionally, there was no direct way to access the shared
OrderbookYamlinstance from aDotrainRegistryfor querying networks, tokens, and orderbooks.This PR addresses these gaps by:
TokenInfoExtendedtype that includeschain_idalongside other token metadataOrderbookYaml.getTokens()for fetching all tokens including remote tokens fromusing-tokens-fromURLsDotrainRegistry.getOrderbookYaml()to access the shared settings YAML instanceSolution
New Shared Type:
TokenInfoExtendedIntroduced a new struct in
crates/common/src/erc20.rsthat consolidates token information:key,address,decimals,name,symbol,chain_idTokenInfostruct that was defined in the GUI modulegetTokenInfo,getAllTokenInfos,getAllTokens) and the new YAML methodsNew Method:
OrderbookYaml.getTokens()TokenInfoExtended[]using-tokens-fromURLs if configuredNew Method:
DotrainRegistry.getOrderbookYaml()OrderbookYamlinstance from the registry's shared settingsUI Component Updates
Updated Svelte components to use
TokenInfoExtended:SelectToken.svelteTokenSelectionModal.svelteDeploymentSteps.svelteTokenSelectionModal.test.tsDocumentation
Updated architecture and README documentation to reflect the new APIs.
Checks
By submitting this for review, I'm confirming I've done the following:
Summary by CodeRabbit
New Features
getOrderbookYaml()method on registry to access token configurations.getTokens()method to retrieve all tokens, including support for remote token sources.Documentation
Tests
✏️ Tip: You can customize this high-level summary in your review settings.