Add token operations: balance queries, transfers, and token list support#6
Merged
Quantumlyy merged 6 commits intomainfrom Mar 29, 2026
Merged
Conversation
Add Token/TokenList types matching the btkn-info schema used by btknlist.org registry. Implement ArkType schema validation for token lists and a fetchTokenList utility that fetches and validates token list JSON from URLs. Co-authored-by: Claude <noreply@anthropic.com> Signed-off-by: Claude <noreply@anthropic.com>
Generic token amount formatting/parsing that respects per-token decimals, analogous to existing formatSats/parseSats but parameterized by decimals. Co-authored-by: Claude <noreply@anthropic.com> Signed-off-by: Claude <noreply@anthropic.com>
…rface Add optional getTokenBalance and sendToken methods to the connector interface. Implement them in the sparkSdk connector using the Spark SDK's getBalance (tokenBalances) and transferTokens APIs. Add mock implementations in the test connector. Co-authored-by: Claude <noreply@anthropic.com> Signed-off-by: Claude <noreply@anthropic.com>
Core actions for querying token balances and sending tokens on Spark. Follow the same connector-delegation pattern as getBalance/sendPayment. Co-authored-by: Claude <noreply@anthropic.com> Signed-off-by: Claude <noreply@anthropic.com>
React hooks for token operations: - useTokenList: fetches and validates a token list from a URL (query) - useTokenBalance: queries token balances via the connector (query) - useSendToken: sends tokens to a Spark address (mutation) Also re-exports new token types and utilities from @mbga/core. Co-authored-by: Claude <noreply@anthropic.com> Signed-off-by: Claude <noreply@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com> Signed-off-by: Claude <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary
This PR adds comprehensive token operation support to the MBGA SDK, including fetching token balances, sending tokens, and managing token lists from the btkn-info registry.
Key Changes
Core Actions
getTokenBalance: Query token balances for the current connection, with optional filtering by token identifiersendToken: Transfer tokens to a Spark address with amount specified in raw unitsToken List Management
validateTokenList: ArkType schema validation for btkn-info token list formatfetchTokenList: Fetch and validate token lists from URLs with proper error handlingTokenandTokenListtypes: Full TypeScript support matching the btkn-info schema specificationToken Amount Utilities
formatTokenAmount: Convert raw bigint amounts to human-readable decimal strings, respecting per-token decimalsparseTokenAmount: Parse decimal strings back to raw bigint amounts with validationReact Hooks
useTokenBalance: Query hook for fetching token balances with loading/error states and optional enable flaguseSendToken: Mutation hook for sending tokens with async and callback variantsuseTokenList: Query hook for fetching and validating token lists from URLsConnector Integration
sparkSdkconnector withgetTokenBalanceandsendTokenimplementationsgetTokenBalanceandsendTokenoptional methods to connector interfaceTesting
Implementation Details
bigintfor precision without floating-point errorshttps://claude.ai/code/session_017mN5apo7AtGo2LJwKNUQrn