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 all 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,8 @@ 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)

### Removed

Expand All @@ -63,6 +63,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (refactor) [\#1090](https://github.com/Finschia/finschia-sdk/pull/1090) Automate EventTypeMessage inclusion in every message execution (backport #1063)
* (x/bank) [#1093](https://github.com/Finschia/finschia-sdk/pull/1093) Remove message events including `sender` attribute whose information is already present in the relevant events (backport #1066)
* (ostracon) [\#1099](https://github.com/Finschia/finschia-sdk/pull/1099) feat!: remove libsodium vrf library.
* (x/collection) [\#1102](https://github.com/finschia/finschia-sdk/pull/1102) Reject modifying NFT class with token index filled in MsgModify

### Build, CI
* (build,ci) [\#1043](https://github.com/Finschia/finschia-sdk/pull/1043) Update golang version to 1.20
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