Skip to content

feat(rpc): implement getTokenSupply RPC method#1239

Open
prestonsn wants to merge 3 commits intoprestonsn/impl-get-token-account-balancefrom
prestonsn/impl-get-token-supply
Open

feat(rpc): implement getTokenSupply RPC method#1239
prestonsn wants to merge 3 commits intoprestonsn/impl-get-token-account-balancefrom
prestonsn/impl-get-token-supply

Conversation

@prestonsn
Copy link
Contributor

Implements getTokenSupply

  • 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

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
@github-project-automation github-project-automation bot moved this to 🏗 In progress in Sig Feb 19, 2026
@prestonsn prestonsn self-assigned this Feb 19, 2026
@codecov
Copy link

codecov bot commented Feb 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/rpc/account_decoder/lib.zig 73.82% <ø> (ø)
src/rpc/methods.zig 78.68% <100.00%> (ø)
src/rpc/test_serialize.zig 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@prestonsn prestonsn force-pushed the prestonsn/impl-get-token-account-balance branch 3 times, most recently from 7016869 to e6217e2 Compare March 2, 2026 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🏗 In progress

Development

Successfully merging this pull request may close these issues.

1 participant