Skip to content

To remove same type of account owning objects in one transaction #21421

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
markeddolphin opened this issue Mar 5, 2025 · 4 comments
Open
Assignees
Labels

Comments

@markeddolphin
Copy link

Here, I'd like to remove array of account owning objects in one transaction programmatically.

Here is my code.

public struct Receipt has key {
   id: UID
}

public fun burn_receipts(receipts: &mut vector<Receipt>) {
    while(!vectory::is_empty(receipts)) {
        let Receipt { id } = vector::pop_back(receipts);
        id.delete();
    }
}

when I run this code, its returning UnusedvaluewithoutDrop.

Copy link
Contributor

github-actions bot commented Mar 5, 2025

Thank you for opening this issue, a team member will review it shortly. Until then, please do not interact with any users that claim to be from Sui support and do not click on any links!

@stefan-mysten stefan-mysten self-assigned this Mar 5, 2025
@markeddolphin
Copy link
Author

@stefan-mysten I would really love to hear your suggestion on this obstacle. :)

@stefan-mysten
Copy link
Contributor

I believe that the issue is that your Receipt type does not have a drop ability. If you want to keep it like that, you will need to transfer the receipts object (that is passed into burn_receipts function) or somehow burn it/ drop it.

The UnusedValueWithoutDrop tells you while receipts might be empty, as you deleted all its elements, it's still an object, I think. However, I don't do a lot of Move so I might be off. Hope it helps!

@markeddolphin
Copy link
Author

Maybe sui PTB could be solution I think. So instead of taking vector, I might need to create function to take Receipt and burn it in. I can call this function multiple times for the receipts I need to be burned using PTB. so It can be triggered in one transaction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants