Skip to content

feat(sdk-coin-sui): add fundsInAddressBalance to WalrusStakingBuilder#9340

Draft
bitgo-ai-agent-dev[bot] wants to merge 1 commit into
masterfrom
SI-1062-walrus-staking-funds-in-address-balance
Draft

feat(sdk-coin-sui): add fundsInAddressBalance to WalrusStakingBuilder#9340
bitgo-ai-agent-dev[bot] wants to merge 1 commit into
masterfrom
SI-1062-walrus-staking-funds-in-address-balance

Conversation

@bitgo-ai-agent-dev

Copy link
Copy Markdown

What

  • WalrusStakingBuilder exposes fundsInAddressBalance(amount: string) setter (default 0 = existing behavior unchanged)
  • WAL coin type helper built from walrusConfig (WAL_PKG_ID::wal::WAL)
  • Validation relaxed: require inputObjects.length > 0 OR fundsInAddressBalance > 0 (addr-bal-only is now valid)
  • When fundsInAddressBalance > 0, PTB inserts redeem_funds(Coin<WAL>) before merge/split/stake_with_pool
  • Residual Coin<WAL> is always transferred back to sender when addr-bal is used (no-drop safety — WAL cannot be merged into the SUI gas coin)
  • WalrusStakingTransaction.toJson() emits fundsInAddressBalance and expiration; getTxData() handles BalanceWithdrawal inputs (mirrors StakingTransaction)
  • initBuilder() restores fundsInAddressBalance from the BalanceWithdrawal PTB input
  • getInputObjectsFromTx now scans all transactions (not just [0]) so mixed and addr-bal-only PTB layouts are handled correctly
  • Unit tests: mixed (objects + addr-bal), addr-bal-only exact, addr-bal partial/residual, round-trip serialize → initBuilder restore, default unchanged, fail when neither source provided

Why

  • Walrus wallets that hold WAL only in address balance (no Coin<WAL> objects) could not stake to Walrus validators — staking required at least one inputObjects entry
  • WAL principal must be sourceable from coin objects, address balance, or a mix, analogous to the token-transfer addr-bal pattern and SI-1053 for native SUI staking

Test plan

  • Run walrusStakingBuilder unit tests — new fundsInAddressBalance suite passes
  • Confirm existing Walrus stake tests still pass with default (no addr-bal) behavior
  • Confirm native SUI staking tests from SI-1053 remain green

Ticket: SI-1062

@linear-code

linear-code Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

SI-1062

@bitgo-ai-agent-dev
bitgo-ai-agent-dev Bot force-pushed the SI-1062-walrus-staking-funds-in-address-balance branch 5 times, most recently from 0a70969 to 86e89e1 Compare July 23, 2026 10:38

@benkelcher-bitgo benkelcher-bitgo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think that function is unused, unless i missed something - we should remove it if so

Comment thread modules/sdk-coin-sui/src/lib/walrusStakingBuilder.ts
Comment thread modules/sdk-coin-sui/src/lib/walrusStakingBuilder.ts Outdated
Add address-balance funding path for WAL staking, analogous to the
addr-bal support added to SUI StakingBuilder in SI-1053.

What changed:
- WalrusStakingBuilder: adds fundsInAddressBalance(amount) setter
  (default 0 = existing behavior); validation relaxed to require
  inputObjects OR fundsInAddressBalance (addr-bal-only now allowed);
  buildSuiTransaction() emits redeem_funds(Coin<WAL>) before
  merge/split/stake_with_pool when addr-bal > 0; residual Coin<WAL>
  is transferred back to sender (no-drop safety); expiration and
  fundsInAddressBalance are propagated on the returned SuiTransaction;
  initBuilder() restores fundsInAddressBalance from BalanceWithdrawal
- WalrusStakingTransaction: getTxData() passes BalanceWithdrawal inputs
  through unchanged; toJson() emits fundsInAddressBalance and expiration;
  getInputObjectsFromTx() now scans all transactions (not just [0]) so
  it handles the addr-bal-only and mixed PTB layouts correctly
- Unit tests: mixed (objects + addr-bal), addr-bal-only exact, addr-bal
  partial/residual, round-trip restore, default unchanged, fail when
  neither source provided

Why: Walrus wallets that hold WAL only in address balance (no Coin<WAL>
objects) were unable to stake to Walrus validators. WAL principal must
be sourced from coin objects, address balance, or a mix, identical to
the token-transfer addr-bal pattern and SI-1053 for native SUI staking.

Ticket: SI-1062
Session-Id: aca9f2f3-fd6e-4d57-b9c7-d625685c9134
Task-Id: 64820ae1-489e-41cb-9c47-958063a67a0c
@bitgo-ai-agent-dev
bitgo-ai-agent-dev Bot force-pushed the SI-1062-walrus-staking-funds-in-address-balance branch 2 times, most recently from ae93acc to 41f7988 Compare July 23, 2026 12:27

@benkelcher-bitgo benkelcher-bitgo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants