-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ts sdk: coin-with-balance intent create zero coin on zero amount (#20184
) ## Description Change the `coinWithBalance` intent so that it creates a zero coin instead of splitting when amount is 0. This fixes the edge case where the user doesn't have a coin of required type in the wallet but the amount is 0 anyways, thus avoids throwing the `Not enough coins of type ${coinType} to satisfy requested balance` error in this situation cc @hayes-mysten ## Test plan Added e2e tests --- ## Release notes Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required. For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates. - [ ] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] Indexer: - [ ] JSON-RPC: - [ ] GraphQL: - [ ] CLI: - [ ] Rust SDK: - [ ] REST API: --------- Co-authored-by: hayes-mysten <[email protected]>
- Loading branch information
1 parent
27098db
commit e7bc63e
Showing
4 changed files
with
209 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@mysten/sui': patch | ||
--- | ||
|
||
Allow 0 amounts with `coinWithBalance` intent when the wallet has no coin objects of the required type. |
This file contains 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
This file contains 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
24 changes: 24 additions & 0 deletions
24
sdk/typescript/test/e2e/data/coin_metadata/sources/coin_metadata_zero.move
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
module coin_metadata::test_zero; | ||
|
||
use sui::coin; | ||
use sui::url; | ||
|
||
public struct TEST_ZERO has drop {} | ||
|
||
fun init(witness: TEST_ZERO, ctx: &mut TxContext) { | ||
let (treasury_cap, metadata) = coin::create_currency<TEST_ZERO>( | ||
witness, | ||
2, | ||
b"TEST", | ||
b"Test Coin", | ||
b"Test coin metadata", | ||
option::some(url::new_unsafe_from_bytes(b"http://sui.io")), | ||
ctx, | ||
); | ||
|
||
transfer::public_share_object(metadata); | ||
transfer::public_share_object(treasury_cap) | ||
} |