feat(rpc): implement getTokenSupply RPC method#1239
Open
prestonsn wants to merge 3 commits intoprestonsn/impl-get-token-account-balancefrom
Open
feat(rpc): implement getTokenSupply RPC method#1239prestonsn wants to merge 3 commits intoprestonsn/impl-get-token-account-balancefrom
prestonsn wants to merge 3 commits intoprestonsn/impl-get-token-account-balancefrom
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.
- Add GetTokenSupply endpoint to return total supply of SPL Token mints - Extract getClockTimestamp helper for reusable Clock sysvar access - Support Token-2022 extensions (interest-bearing, scaled UI amounts) - Add request/response serialization tests
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
7016869 to
e6217e2
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 getTokenSupply