feat(sdk-coin-sui): add fundsInAddressBalance support to StakingBuilder (AddStake)#9324
Merged
abhijit0943 merged 1 commit intoJul 23, 2026
Conversation
Contributor
bitgo-ai-agent-dev
Bot
force-pushed
the
SI-1053-add-fundsInAddressBalance-to-staking-builder
branch
3 times, most recently
from
July 22, 2026 10:26
cc4935d to
c41dbb4
Compare
…er (AddStake)
Wallets holding only address-balance SUI (no Coin<SUI> objects) could not
stake because StakingBuilder sourced the stake amount only from gas coin
objects (gasData.payment). This change teaches StakingBuilder the same
address-balance principal funding path as TransferBuilder Path 2c.
Changes:
- stakingBuilder.ts: add _fundsInAddressBalance field and
fundsInAddressBalance(amount) setter; when > 0, insert
redeem_funds(SUI) + mergeCoins(gas, [addrCoin]) before splitCoins +
request_add_stake; return expiration: this._expiration instead of
hardcoded None; restore both _fundsInAddressBalance and _expiration
in initBuilder()
- stakingTransaction.ts: toJson() emits fundsInAddressBalance and uses
tx.expiration ?? { None: null }; getTxData() handles BalanceWithdrawal
inputs and uses tx.expiration ?? { None: null } (fixes ValidDuring
being silently discarded, required for Case 2 / WP addr-bal-only stake)
- utils.ts: getStakeRequests() filters MoveCall targets to
::sui_system::request_add_stake (prevents crash on redeem_funds
MoveCall with no arguments[2]); getWalrusStakeWithPoolRequests()
gets matching filter on ::staking::stake_with_pool for defensive
parity ahead of Walrus addr-bal support
- walrusStakingBuilder.ts: use WalrusStakingTransaction instead of
StakingTransaction so loadInputsAndOutputs calls the correct
getWalrusStakeWithPoolRequests (the getStakeRequests target filter
would otherwise zero out Walrus stake I/O); remove now-unused
StakingTransaction import
- stakingBuilder tests: fundsInAddressBalance suite covering mixed
coin-objects + addr-bal command sequence, round-trip deserialization,
multi-stake, Case 2 (addr-bal-only / empty payment), and unchanged
default behavior
Ticket: SI-1053
Session-Id: 6c1e4b34-b84e-453f-ba38-703340b82bb0
Task-Id: df1f6ba5-a31c-4ff7-9b7d-26fc6422054f
bitgo-ai-agent-dev
Bot
force-pushed
the
SI-1053-add-fundsInAddressBalance-to-staking-builder
branch
2 times, most recently
from
July 22, 2026 10:33
dbcc0d1 to
0f0979b
Compare
benkelcher-bitgo
approved these changes
Jul 22, 2026
abhijit0943
marked this pull request as ready for review
July 23, 2026 05:58
Gautam2305
approved these changes
Jul 23, 2026
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.
What
fundsInAddressBalance(amount: string)method toStakingBuilderso wallets holding only address-balance SUI can stakefundsInAddressBalance > 0, AddStake PTB insertsredeem_funds(SUI)+mergeCoins(gas, [addrCoin])beforesplitCoins+request_add_stakeStakingTransaction.toJson()now emitsfundsInAddressBalance(fromtx.expiration ?? { None: null }andtx.fundsInAddressBalance);getTxData()handlesBalanceWithdrawalinputs and usestx.expiration ?? { None: null }StakingBuilder.initBuilder()restores_fundsInAddressBalancefrom deserializedBalanceWithdrawalinput and restores_expirationifValidDuringStakingBuilder.buildSuiTransaction()passesexpiration: this._expirationthrough to the returnedSuiTransactionutils.getStakeRequests()to only parse MoveCalls ending with::sui_system::request_add_stake, preventing crash onredeem_fundsMoveCall (noarguments[2])utils.getWalrusStakeWithPoolRequests()with same target filter (::staking::stake_with_pool) for defensive parityWalrusStakingBuilderto useWalrusStakingTransactioninstead ofStakingTransaction(fixesloadInputsAndOutputscalling the correctgetWalrusStakeWithPoolRequests)StakingTransactionimport fromwalrusStakingBuilder.tsWhy
Coin<SUI>objects) cannot stake becauseStakingBuildersourced the stake amount exclusively from gas coin objects. This mirrors thefundsInAddressBalancepath inTransferBuilderPath 2c.StakingTransaction.toJson()/getTxData()previously hardcodedexpiration: { None: null }— this would silently discard anyValidDuringexpiration set by WP for Case 2 (addr-bal-only, emptygasData.payment). Fixed to usetx.expiration ?? { None: null }.getStakeRequestsbug would cause a runtime crash when parsing a staking transaction that includes aredeem_fundsMoveCall (noarguments[2]).Test plan
fundsInAddressBalancesuite: mixed coin-objects + addr-bal command sequence, round-trip deserialization, multi-stake, default behavior unchangedfundsInAddressBalance > 0+gasData.payment = [](addr-bal-only stake)getStakeRequeststarget filter)Ticket: SI-1053