Skip to content

feat(iota): make split-coin command work with a single gas coin #6647

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

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

Thoralf-M
Copy link
Member

Description of change

Make iota client split-coin work with a single gas coin, by splitting from the gas coin, before this change it would error, as it can't use one coin as gas and as input.

Also increased the min count split amount to 2 as it would otherwise just waste gas

Links to any relevant issues

Fixes #6528

Type of change

  • Enhancement (a non-breaking change which adds functionality)

How the change has been tested

Added test + manual testing

cargo run client split-coin --coin-id 0x14328282ea0476b8fad958fb7763f05d503554d0b34079cc0c5d1861da21a9ee --amounts 1000000000
cargo run client split-coin --coin-id 0x672b2f8b2a73aafabb7a2d37c2d8a847dccf6107871f4af3ca34e9ec3f60b089 --count 3
  • Basic tests (linting, compilation, formatting, unit/integration tests)
  • Patch-specific tests (correctness, functionality coverage)

Change checklist

Tick the boxes that are relevant to your changes, and delete any items that are not.

  • I have followed the contribution guidelines for this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that new and existing unit tests pass locally with my changes

Release Notes

  • Protocol:
  • Nodes (Validators and Full nodes):
  • Indexer:
  • JSON-RPC:
  • GraphQL:
  • CLI: Make iota client split-coin work with a single gas coin
  • Rust SDK:
  • REST API:

@Thoralf-M Thoralf-M requested a review from a team as a code owner April 29, 2025 09:03
Copy link

vercel bot commented Apr 29, 2025

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

Name Status Preview Comments Updated (UTC)
apps-backend ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 21, 2025 1:21pm
apps-ui-kit ✅ Ready (Inspect) Visit Preview May 21, 2025 1:21pm
rebased-explorer ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 21, 2025 1:21pm
wallet-dashboard ✅ Ready (Inspect) Visit Preview May 21, 2025 1:21pm

@iota-ci iota-ci added dev-tools Issues related to the Developer Tools Team sc-platform Issues related to the Smart Contract Platform group. labels Apr 29, 2025
@Thoralf-M Thoralf-M force-pushed the dev-tools/split-gas-coin branch from 6372b83 to 7d1de45 Compare April 29, 2025 09:39
if let Some(amounts) = amounts {
client
.transaction_builder()
.pay_iota_tx_kind(vec![signer; amounts.len()], amounts)?
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we not use the actual split command?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not without breaking change to it, since it uses the provided coin id as input and then you can't use it as gas coin as well

Copy link
Contributor

Choose a reason for hiding this comment

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

We can't change the internal functionality?

Copy link
Member Author

Choose a reason for hiding this comment

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

As far as I know not, as we don't know if the provided object id is also used as gas coin or not

Copy link
Contributor

Choose a reason for hiding this comment

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

Then where is it failing? I'm confused.

Copy link
Member Author

Choose a reason for hiding this comment

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

At this point the transaction is built assuming the provided coin is not the gas object, the gas object is selected later. If the gas object is the same as the provided object it will fail, as it was provided twice as input. Without changing the params to the functions we can't change the assumption, that this object is not used also as gas object

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, but why not change it where it checks for the gas object so that this doesn't fail when you try to call it this way. Otherwise using this method via the SDKs will still fail

Copy link
Member Author

Choose a reason for hiding this comment

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

The gas object is selected after this step, you can't go back and change it then (at least not without super complicated logic to decode it again and replace stuff)

Copy link
Member Author

@Thoralf-M Thoralf-M Apr 29, 2025

Choose a reason for hiding this comment

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

And yes, this method will fail with the SDK if you only have a single gas coin, but I don't think that this is a big issue and also I don't see a way around this without breaking change, but this is not the only method that would fail in such a case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev-tools Issues related to the Developer Tools Team sc-platform Issues related to the Smart Contract Platform group.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

iota client split-coins and others fail when only one coin exists
4 participants