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

fix: reject modifying NFT class with token index filled in MsgModify #1102

Merged
merged 5 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Bug Fixes
* (ledger) [\#1040](https://github.com/Finschia/finschia-sdk/pull/1040) Fix a bug(unable to connect nano S plus ledger on ubuntu)
* (x/foundation) [\#1053](https://github.com/Finschia/finschia-sdk/pull/1053) Make x/foundation MsgExec propagate events
* (baseapp) [\#1091](https://github.com/cosmos/cosmos-sdk/pull/1091) Add `events.GetAttributes` and `event.GetAttribute` methods to simplify the retrieval of an attribute from event(s) (backport #1075)
* (baseapp) [\#1092](https://github.com/cosmos/cosmos-sdk/pull/1092) Do not add `module` attribute in case of ibc messages (backport #1079)
* (baseapp) [\#1091](https://github.com/finschia/finschia-sdk/pull/1091) Add `events.GetAttributes` and `event.GetAttribute` methods to simplify the retrieval of an attribute from event(s) (backport #1075)
* (baseapp) [\#1092](https://github.com/finschia/finschia-sdk/pull/1092) Do not add `module` attribute in case of ibc messages (backport #1079)
* (x/collection) [\#1102](https://github.com/finschia/finschia-sdk/pull/1102) Reject modifying NFT class with token index filled in MsgModify
zemyblue marked this conversation as resolved.
Show resolved Hide resolved

### Removed

Expand Down
4 changes: 4 additions & 0 deletions x/collection/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,10 @@ func (m MsgModify) ValidateBasic() error {
if err := ValidateTokenID(tokenID); err != nil {
return ErrInvalidTokenIndex.Wrap(err.Error())
}
// reject modifying nft class with token index filled (daphne compat.)
if ValidateLegacyNFTID(tokenID) == nil && ValidateFTID(tokenID) == nil {
return ErrInvalidTokenIndex.Wrap("cannot modify nft class with index filled")
}
}

validator := validateTokenClassChange
Expand Down
8 changes: 8 additions & 0 deletions x/collection/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,14 @@ func TestMsgModify(t *testing.T) {
owner: addrs[0],
changes: changes,
},
"invalid nft class modification": {
contractID: "deadbeef",
tokenType: "deadbeef",
tokenIndex: "00000000",
owner: addrs[0],
changes: changes,
err: collection.ErrInvalidTokenIndex,
},
"valid nft modification": {
contractID: "deadbeef",
tokenType: "deadbeef",
Expand Down
Loading