diff --git a/CHANGELOG.md b/CHANGELOG.md index 06b33ccaea..d1392470c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/foundation) [\#772](https://github.com/line/lbm-sdk/pull/772) export x/foundation pool * (baseapp) [\#781](https://github.com/line/lbm-sdk/pull/781) implement method `SetOption()` in baseapp * (global) [\#782](https://github.com/line/lbm-sdk/pull/782) add unhandled return error handling +* (x/collection,x/token) [\#798](https://github.com/line/lbm-sdk/pull/798) Fix x/collection ModifyContract ### Breaking Changes * (cli) [\#773](https://github.com/line/lbm-sdk/pull/773) guide users to use generate-only in messages for x/foundation authority diff --git a/x/collection/keeper/supply.go b/x/collection/keeper/supply.go index ca02e5a285..245518245c 100644 --- a/x/collection/keeper/supply.go +++ b/x/collection/keeper/supply.go @@ -322,7 +322,7 @@ func (k Keeper) ModifyContract(ctx sdk.Context, contractID string, operator sdk. contract.Name = name }, collection.AttributeKeyBaseImgURI.String(): func(uri string) { - contract.Name = uri + contract.BaseImgUri = uri }, collection.AttributeKeyMeta.String(): func(meta string) { contract.Meta = meta diff --git a/x/collection/keeper/supply_test.go b/x/collection/keeper/supply_test.go index 6691ac9e1b..004bc9177e 100644 --- a/x/collection/keeper/supply_test.go +++ b/x/collection/keeper/supply_test.go @@ -199,11 +199,18 @@ func (s *KeeperTestSuite) TestModifyContract() { ctx, _ := s.ctx.CacheContext() err := s.keeper.ModifyContract(ctx, contractID, s.vendor, changes) - if contractID == s.contractID { - s.Require().NoError(err) - } else { + if contractID != s.contractID { s.Require().Error(err) + return } + s.Require().NoError(err) + + contract, err := s.keeper.GetContract(ctx, contractID) + s.Require().NoError(err) + + s.Require().Equal(changes[0].Value, contract.Name) + s.Require().Equal(changes[1].Value, contract.BaseImgUri) + s.Require().Equal(changes[2].Value, contract.Meta) }) } } @@ -229,11 +236,20 @@ func (s *KeeperTestSuite) TestModifyTokenClass() { ctx, _ := s.ctx.CacheContext() err := s.keeper.ModifyTokenClass(ctx, contractID, classID, s.vendor, changes) - if contractID == s.contractID && classID == s.nftClassID { - s.Require().NoError(err) - } else { + if contractID != s.contractID || classID != s.nftClassID { s.Require().Error(err) + return } + s.Require().NoError(err) + + class, err := s.keeper.GetTokenClass(ctx, contractID, classID) + s.Require().NoError(err) + + nftClass, ok := class.(*collection.NFTClass) + s.Require().True(ok) + + s.Require().Equal(changes[0].Value, nftClass.Name) + s.Require().Equal(changes[1].Value, nftClass.Meta) }) } } @@ -261,11 +277,17 @@ func (s *KeeperTestSuite) TestModifyNFT() { ctx, _ := s.ctx.CacheContext() err := s.keeper.ModifyNFT(ctx, contractID, tokenID, s.vendor, changes) - if contractID == s.contractID && tokenID == validTokenID { - s.Require().NoError(err) - } else { + if contractID != s.contractID || tokenID != validTokenID { s.Require().Error(err) + return } + s.Require().NoError(err) + + nft, err := s.keeper.GetNFT(ctx, contractID, tokenID) + s.Require().NoError(err) + + s.Require().Equal(changes[0].Value, nft.Name) + s.Require().Equal(changes[1].Value, nft.Meta) }) } } diff --git a/x/token/keeper/supply_test.go b/x/token/keeper/supply_test.go index a5d77cb55d..9600f8fa85 100644 --- a/x/token/keeper/supply_test.go +++ b/x/token/keeper/supply_test.go @@ -151,11 +151,18 @@ func (s *KeeperTestSuite) TestModify() { ctx, _ := s.ctx.CacheContext() err := s.keeper.Modify(ctx, contractID, grantee, changes) - if contractID == s.contractID { - s.Require().NoError(err) - } else { + if contractID != s.contractID { s.Require().Error(err) + return } + s.Require().NoError(err) + + class, err := s.keeper.GetClass(ctx, contractID) + s.Require().NoError(err) + + s.Require().Equal(changes[0].Value, class.Name) + s.Require().Equal(changes[1].Value, class.ImageUri) + s.Require().Equal(changes[2].Value, class.Meta) }) } }