Skip to content

Commit

Permalink
fix: reject modifying NFT class with token index filled in MsgModify (#…
Browse files Browse the repository at this point in the history
…1102)

* Reject modifying NFT class with token index filled

* Update the corresponding unit test

* Update CHANGELOG.md

* Update CHANGELOG.md of other PRs

* Update CHANGELOG.md
  • Loading branch information
0Tech authored Aug 30, 2023
1 parent 3eddfec commit c95052c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
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

0 comments on commit c95052c

Please sign in to comment.