Repository navigation
docs(graphql): state units and nullability for Wallet.balance - #512
Merged
Merged
Conversation
Every wallet balance resolves in US cents (FractionalCentAmount), not sats, and external wallets return null. The BTCWallet description claimed a BTC-denominated balance. Descriptions only; no wire type or resolver change. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Do not promise a float for every wallet type: a non-external BTC wallet resolves an unconverted amount object, and UsdtWallet has no external null branch. Point readers to the concrete wallet type instead. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Review fix: the description promised up to 4 decimal places, but the resolver's USDAmount branch returns up to 8. State both cases explicitly and regenerate the SDL files via yarn write-sdl. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Why
Sweep finding Backend 16: every
Wallet.balanceis typedFractionalCentAmount, includingBTCWallet, whose description says "A balance stored in BTC." The generated API reference andguides/examples.md("sats for BTC") imply units the API does not return.What the code does (origin/main
cbd9e26aa)UsdWalletshared/types/object/usd-wallet.tsasCents(8); USDT-backed balances go throughusdtMicrosToUsdCentstype === ExternalUsdtWalletusdt-wallet.tsusdtMicrosToUsdCents)BTCWalletbtc-wallet.tsUSDAmountobject fromgetBalanceForWalletunconverted (see below).type === ExternalNo path returns sats.
getBalanceForWallet→Ibex.getAccountDetails→parseAccountBalanceyieldsUSDAmount.dollars(...)for any currency except USDT.Change
Descriptions only, on
Wallet.balance,BTCWallet.balance,UsdWallet.balanceandUsdtWallet.balance. TheFractionalCentAmountscalar description is shared with inputs, so it is unchanged. There are no type, nullability or resolver changes, soflash-mobileis unaffected (the diff in the regenerated schema files is description lines only).Not changed: needs a decision
A non-external BTC wallet would serialize
balanceas an object ({"money":["12.34","USD"],"currencyCode":"USD"}), not a float. I confirmed this with graphql 16.14.2 default scalar serialization, using a stand-in object shaped likeUSDAmount. On main, account creation only creates Checking wallets forinitialWallets(default["USD","USDT"]) plus the required cash currencies, and BTC wallets are only created throughupsertExternal. So I did not find a live path to this, but I could not check data: the read-only Mongo MCP failed to connect, and I have not queried TEST or PROD. Fixing it would be a behavior change and is out of scope here.Validation (commit 7bde387)
yarn write-sdl: regenerated public, admin and supergraph schemasyarn tsc-check: passyarn eslint-check: passyarn check:sdl: pass🤖 Generated with Claude Code