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

splitCoins can not iterator #20642

Closed
beykery opened this issue Dec 16, 2024 · 3 comments · Fixed by #20665
Closed

splitCoins can not iterator #20642

beykery opened this issue Dec 16, 2024 · 3 comments · Fixed by #20665
Assignees
Labels

Comments

@beykery
Copy link

beykery commented Dec 16, 2024

const sps = txb.splitCoins(coin, amounts);
for (const item of sps) {
.... ....
}

the 'for' loop can not be ended , why ? 'sps' with unlimited length ?

@hayes-mysten
Copy link
Contributor

The sdk currently returns an infinite iterator for any result type. This is because the result type is shared between commands like splitCoins and the moveCall command. For move calls we don't actually know the number of nested results are unknown until after the transaction executes.

For splitCoins specifically, we should be able to know the number of coins created, but currently we haven't special-cased this, so it returns the same infinite iterator used by the moveCall command.

@beykery
Copy link
Author

beykery commented Dec 18, 2024

the iterator of split return , it's length can be known from the param 'amounts' . so this can be fixed , am i right ?
@hayes-mysten

@hayes-mysten
Copy link
Contributor

Yes, this is something that can be fixed

hayes-mysten added a commit that referenced this issue Dec 19, 2024
…e size (#20665)

## Description 

fixes #20642

## Test plan 

How did you test the new or updated feature?

---

## 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:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants