-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
feat: add batch operation for x/nft module #12187
Conversation
Codecov Report
@@ Coverage Diff @@
## main #12187 +/- ##
==========================================
+ Coverage 66.10% 66.12% +0.01%
==========================================
Files 673 674 +1
Lines 71097 71155 +58
==========================================
+ Hits 46999 47051 +52
- Misses 21458 21462 +4
- Partials 2640 2642 +2
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think most of these should use the Mint
, Burn
, Update
, Transfer
from the keeper instead of repeating logic. Did you have a reason not to?
This is indeed the case. I do this now because some logic is repeated, such as class verification, which can reduce gas. Or add some xxxxWithNoCheck (for example: MintWithNoCheck, BatchMintWithNoCheck) methods, the verification logic is implemented by the upper layer, what do you think? |
…batch-for-nft-module
Alright, but the class verification logic is already in The following f.e. has no duplicate class verification, then. // BatchMint defines a method for minting a batch of nfts
func (k Keeper) BatchMint(ctx sdk.Context,
tokens []nft.NFT,
receiver sdk.AccAddress,
) error {
classIDs := make(map[string]bool, len(tokens))
for _, token := range tokens {
if !classIDs[token.ClassId] {
return sdkerrors.Wrap(nft.ErrClassNotExists, token.ClassId)
}
if err := k.Mint(ctx, token, receiver); err != nil {
return err
}
classIDs[token.ClassId] = true
}
return nil
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
I see now what you've meant about the repeating checks, these happen for methods with classID
as argument (BatchTransfer
and BatchBurn
). Maybe a transferWithNoCheck
and burnWithNoCheck
used in Transfer
, BatchTransfer
, Burn
, BatchBurn
do indeed make sense for these, not sure 🤷🏾♂️
Yes, I want to separate the verification logic, and let the upper application decide how to verify (transferWithNoCheck) or use Transfer directly (sdk is responsible for verification). This way the user has more flexibility, now do you think we should add the noCheck method to these methods? If you agree to this, I can continue to modify these |
Thanks @dreamer-zq, one last thing, can we add a changelog? :) |
…batch-for-nft-module
…ai/cosmos-sdk into add-batch-for-nft-module
Alright, because of #12233 your tests are failing 🙉 can you please fix them? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a spec update as well. please update docs prior to merging next time
Sorry, I forgot to check that. @dreamer-zq Could you submit a follow-up PR? |
Ok, Is it the documentation in x/nft/spec ? This change does not modify the relevant state, msg, or event. So what exactly should be changed? Is it adr-043-nft-module ? |
|
Description
Closes: #XXXX
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking change