Skip to content

Commit

Permalink
[zksend] fix how coin balances are merged (MystenLabs#15692)
Browse files Browse the repository at this point in the history
## Description 

Describe the changes or additions included in this PR.

## Test Plan 

How did you test the new or updated feature?

---
If your changes are not user-facing and do not break anything, you can
skip the following section. Otherwise, please briefly describe what has
changed under the Release Notes section.

### Type of Change (Check all that apply)

- [ ] protocol change
- [ ] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes
  • Loading branch information
hayes-mysten authored Jan 13, 2024
1 parent 0310242 commit c07aa19
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/brown-buttons-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@mysten/zksend': patch
---

Fix coin merging for sending balances
8 changes: 5 additions & 3 deletions sdk/zksend/src/links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,11 @@ export class ZkSendLinkBuilder {
objectsToTransfer.push(sui);
} else {
const coins = (await this.#getCoinsByType(coinType)).map((coin) => coin.coinObjectId);
const merged =
coins.length > 1 ? txb.mergeCoins(coins[0], coins.slice(1)) : txb.object(coins[0]);
const [split] = txb.splitCoins(merged, [amount]);

if (coins.length > 1) {
txb.mergeCoins(coins[0], coins.slice(1));
}
const [split] = txb.splitCoins(coins[0], [amount]);
objectsToTransfer.push(split);
}
}
Expand Down

0 comments on commit c07aa19

Please sign in to comment.