feat(rpc): impl getTokenAccountBalance RPC #1237
Draft
prestonsn wants to merge 2 commits intoprestonsn/impl-get-account-info-for-db-twofrom
Draft
feat(rpc): impl getTokenAccountBalance RPC #1237prestonsn wants to merge 2 commits intoprestonsn/impl-get-account-info-for-db-twofrom
prestonsn wants to merge 2 commits intoprestonsn/impl-get-account-info-for-db-twofrom
Conversation
Implement the getAccountInfo RPC method with full support for all Solana account encodings: base58, base64, base64+zstd, and jsonParsed. - Add AccountHookContext with getAccountInfo method for reading account data - Support dataSlice parameter for partial account reads - Implement streaming zstd compression for base64+zstd encoding - Fall back to base64 encoding when no jsonParsed parser is available Add comprehensive account parsing for the following program types: - **Vote accounts**: Parse vote state with authorized voters, prior voters, epoch credits, and last timestamp - **Stake accounts**: Parse delegation info, stake activation, and lockup - **Nonce accounts**: Parse authority, blockhash, and fee calculator - **Address Lookup Tables**: Parse lookup table state with addresses - **BPF Upgradeable Loader**: Parse program, programData, and buffer accounts - **Sysvars**: Parse clock, rent, epochSchedule, slotHistory, slotHashes, stakeHistory, epochRewards, fees, recentBlockhashes, and lastRestartSlot - **Config accounts**: Parse validator info and stake config - **SPL Token & Token-2022**: Full token account, mint, and multisig parsing with extension support (transfer fees, interest-bearing, metadata, etc.) - Parse all token extensions including TransferFeeConfig, InterestBearingConfig, TokenMetadata, ConfidentialTransferMint, PermanentDelegate, and more - Support interest-bearing token amount calculations with compound interest - Support scaled UI amounts with multiplier switching - Parse TokenMetadata additional_metadata key-value pairs - Move AccountEncoding enum to common module for reuse - Add SPL_TOKEN_PROGRAM_ID and SPL_TOKEN_2022_PROGRAM_ID to runtime/ids.zig - Move MAX_ENTRIES constant into SlotHistory struct - Fix SlotTracker to avoid use-after-free issues with processed/confirmed counters
- Add getTokenAccountBalance endpoint that returns token balance with - UI amount formatting. Handles SPL Token and Token-2022 accounts, - including interest-bearing and scaled UI amount extension configs.
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 2 files with indirect coverage changes 🚀 New features to boost your workflow:
|
b67e6b1 to
a0a5842
Compare
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.
Implements https://solana.com/docs/rpc/http/gettokenaccountbalance
Sample response from testing (
8KMd8WMacjWd9Md3rZjy7yxx7v7zyZMye4XdrXdV3rHN) :{ "context": { "slot": 389457101, "apiVersion": "0.2.0" }, "value": { "uiAmount": 600013911.6102316, "decimals": 9, "amount": "600013911610231717", "uiAmountString": "600013911.610231717" } }