Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ts sdk: coin-with-balance intent create zero coin on zero amount #20184

Merged
merged 3 commits into from
Nov 6, 2024

Conversation

kklas
Copy link
Contributor

@kklas kklas commented Nov 5, 2024

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:

@kklas kklas requested a review from a team as a code owner November 5, 2024 22:58
Copy link

vercel bot commented Nov 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 5, 2024 11:58pm
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Nov 5, 2024 11:58pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Nov 5, 2024 11:58pm
sui-typescript-docs ⬜️ Ignored (Inspect) Visit Preview Nov 5, 2024 11:58pm

if (balance === 0n) {
transactionData.replaceCommand(
index,
Commands.MoveCall({ target: '0x2::coin::zero', typeArguments: [type] }),
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't know this was possible, very cool!

@hayes-mysten
Copy link
Contributor

Just missing a changeset, but this seems like a great improvement

@kklas
Copy link
Contributor Author

kklas commented Nov 5, 2024

Added changeset

@kklas kklas temporarily deployed to sui-typescript-aws-kms-test-env November 6, 2024 00:33 — with GitHub Actions Inactive
@hayes-mysten hayes-mysten merged commit e7bc63e into MystenLabs:main Nov 6, 2024
51 checks passed
@kklas kklas deleted the zero-coin-with-balance branch November 6, 2024 16:00
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