From ecf227e1eebf9ec8db59a18574006fe04b350bbc Mon Sep 17 00:00:00 2001 From: Shogo Hyodo Date: Mon, 18 Mar 2024 15:48:35 +0900 Subject: [PATCH 1/2] add nft id validation --- x/collection/msgs.go | 2 +- x/collection/msgs_test.go | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/x/collection/msgs.go b/x/collection/msgs.go index 71f3c2ec9e..4c416335f0 100644 --- a/x/collection/msgs.go +++ b/x/collection/msgs.go @@ -340,7 +340,7 @@ func (m MsgSendNFT) ValidateBasic() error { return ErrEmptyField.Wrap("token ids cannot be empty") } for _, id := range m.TokenIds { - if err := ValidateTokenID(id); err != nil { + if err := ValidateNFTID(id); err != nil { return err } } diff --git a/x/collection/msgs_test.go b/x/collection/msgs_test.go index 9f8ebba60d..236629d1ab 100644 --- a/x/collection/msgs_test.go +++ b/x/collection/msgs_test.go @@ -259,6 +259,13 @@ func TestMsgSendNFT(t *testing.T) { ids: []string{""}, err: collection.ErrInvalidTokenID, }, + "FT ids": { + contractID: "deadbeef", + from: addrs[0], + to: addrs[1], + ids: []string{collection.NewFTID("deadbeef")}, + err: sdkerrors.ErrInvalidRequest.Wrapf("invalid id: %s", collection.NewFTID("deadbeef")), + }, } for name, tc := range testCases { From 5b479669fbc691c505a4436b8cb41fffe7f06991 Mon Sep 17 00:00:00 2001 From: Shogo Hyodo Date: Mon, 18 Mar 2024 15:50:18 +0900 Subject: [PATCH 2/2] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b35b7835a2..d14bde6448 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/crisis) [#1167](https://github.com/Finschia/finschia-sdk/pull/1167) Use `CacheContext()` in `AssertInvariants()` * (chore) [\#1168](https://github.com/Finschia/finschia-sdk/pull/1168) Replace `ExactArgs(0)` with `NoArgs()` in `x/upgrade` module * (server) [\#1175](https://github.com/Finschia/finschia-sdk/pull/1175) Use go embed for swagger +* (x/collection) [\#1287](https://github.com/Finschia/finschia-sdk/pull/1287) add nft id validation to MsgSendNFT ### Bug Fixes * chore(deps) [\#1141](https://github.com/Finschia/finschia-sdk/pull/1141) Bump github.com/cosmos/ledger-cosmos-go from 0.12.2 to 0.13.2 to fix ledger signing issue