Add logic to query account balances on RaindexVaultToken#2000
Add logic to query account balances on RaindexVaultToken#2000
Conversation
WalkthroughThis change introduces a new abstraction for retrieving ERC20 token balances, centralizing balance-fetching logic in the backend and exposing it through higher-level methods in the vault abstraction. UI components and tests are refactored to use this new approach, eliminating direct blockchain calls and formatting logic from the frontend. Changes
Sequence Diagram(s)sequenceDiagram
participant UI_Component as UI Component (Deposit/Withdraw Modal)
participant Vault as RaindexVault
participant ERC20 as ERC20 Helper
participant ChainClient as RPC Client
UI_Component->>Vault: getOwnerBalance()
Vault->>ERC20: get_account_balance(owner_address)
ERC20->>ChainClient: readContract(balanceOf, owner_address)
ChainClient-->>ERC20: U256 balance
ERC20-->>Vault: U256 balance
Vault->>Vault: format balance (using decimals)
Vault-->>UI_Component: AccountBalance { balance, formattedBalance }
UI_Component->>UI_Component: Display formattedBalance
Suggested labels
Suggested reviewers
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
npm error Exit handler never called! 🔧 Clippy (1.86.0)error: failed to get Caused by: Caused by: Caused by: Caused by: ✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Caution
Do not merge before #1994
Motivation
See issue: #1968
This PRs improves the usage of user balances in user facing applications by introducing a new wasm binding in RaindexVaultToken to fetch account balance
Solution
Checks
By submitting this for review, I'm confirming I've done the following:
Summary by CodeRabbit
New Features
Refactor
Bug Fixes
Tests