From 56a4ccc4db55545f05434c21dcf0c48bd72fcb8c Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Tue, 11 Jul 2023 10:45:09 +0900 Subject: [PATCH 1/3] Add burn cmds to x/collection --- x/collection/client/cli/tx.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x/collection/client/cli/tx.go b/x/collection/client/cli/tx.go index 165e6da1df..ad3126ca4c 100644 --- a/x/collection/client/cli/tx.go +++ b/x/collection/client/cli/tx.go @@ -53,6 +53,8 @@ func NewTxCmd() *cobra.Command { NewTxCmdIssueNFT(), NewTxCmdMintFT(), NewTxCmdMintNFT(), + NewTxCmdBurnFT(), + NewTxCmdBurnNFT(), NewTxCmdAttach(), NewTxCmdDetach(), NewTxCmdOperatorAttach(), From c0f0fc62f836694404ccd8a77959340d550659ee Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Tue, 11 Jul 2023 10:47:40 +0900 Subject: [PATCH 2/3] Allow minting tokens of multiple classes --- x/collection/client/cli/tx.go | 17 ++++++++--------- x/collection/client/testutil/suite.go | 4 ++-- x/collection/client/testutil/tx.go | 11 ++++------- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/x/collection/client/cli/tx.go b/x/collection/client/cli/tx.go index ad3126ca4c..925067357a 100644 --- a/x/collection/client/cli/tx.go +++ b/x/collection/client/cli/tx.go @@ -416,11 +416,11 @@ func NewTxCmdIssueNFT() *cobra.Command { func NewTxCmdMintFT() *cobra.Command { cmd := &cobra.Command{ - Use: "mint-ft [contract-id] [operator] [to] [class-id] [amount]", - Args: cobra.ExactArgs(5), + Use: "mint-ft [contract-id] [operator] [to] [amount]", + Args: cobra.ExactArgs(4), Short: "mint fungible tokens", Long: strings.TrimSpace(fmt.Sprintf(` - $ %s tx %s mint-ft [contract-id] [operator] [to] [class-id] [amount]`, version.AppName, collection.ModuleName), + $ %s tx %s mint-ft [contract-id] [operator] [to] [amount]`, version.AppName, collection.ModuleName), ), RunE: func(cmd *cobra.Command, args []string) error { operator := args[1] @@ -433,18 +433,17 @@ func NewTxCmdMintFT() *cobra.Command { return err } - amountStr := args[4] - amount, ok := sdk.NewIntFromString(amountStr) - if !ok { - return sdkerrors.ErrInvalidType.Wrapf("failed to set amount: %s", amountStr) + amountStr := args[3] + amount, err := collection.ParseCoins(amountStr) + if err != nil { + return err } - coins := collection.NewCoins(collection.NewFTCoin(args[3], amount)) msg := collection.MsgMintFT{ ContractId: args[0], From: args[1], To: args[2], - Amount: coins, + Amount: amount, } if err := msg.ValidateBasic(); err != nil { return err diff --git a/x/collection/client/testutil/suite.go b/x/collection/client/testutil/suite.go index 342b967f97..b4538b9664 100644 --- a/x/collection/client/testutil/suite.go +++ b/x/collection/client/testutil/suite.go @@ -219,12 +219,12 @@ func (s *IntegrationTestSuite) createNFTClass(contractID string, operator sdk.Ac func (s *IntegrationTestSuite) mintFT(contractID string, operator, to sdk.AccAddress, classID string, amount sdk.Int) { val := s.network.Validators[0] + amt := collection.NewCoins(collection.NewFTCoin(classID, amount)) args := append([]string{ contractID, operator.String(), to.String(), - classID, - amount.String(), + amt.String(), }, commonArgs...) out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cli.NewTxCmdMintFT(), args) diff --git a/x/collection/client/testutil/tx.go b/x/collection/client/testutil/tx.go index a0aee34cde..616b4df548 100644 --- a/x/collection/client/testutil/tx.go +++ b/x/collection/client/testutil/tx.go @@ -528,6 +528,7 @@ func (s *IntegrationTestSuite) TestNewTxCmdMintFT() { fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), } + amount := collection.NewCoins(collection.NewFTCoin(s.ftClassID, s.balance)) testCases := map[string]struct { args []string valid bool @@ -537,8 +538,7 @@ func (s *IntegrationTestSuite) TestNewTxCmdMintFT() { s.contractID, s.operator.String(), s.customer.String(), - s.ftClassID, - s.balance.String(), + amount.String(), }, true, }, @@ -547,8 +547,7 @@ func (s *IntegrationTestSuite) TestNewTxCmdMintFT() { s.contractID, s.operator.String(), s.customer.String(), - s.ftClassID, - s.balance.String(), + amount.String(), "extra", }, false, @@ -558,7 +557,6 @@ func (s *IntegrationTestSuite) TestNewTxCmdMintFT() { s.contractID, s.operator.String(), s.customer.String(), - s.ftClassID, }, false, }, @@ -567,8 +565,7 @@ func (s *IntegrationTestSuite) TestNewTxCmdMintFT() { "", s.operator.String(), s.customer.String(), - s.ftClassID, - s.balance.String(), + amount.String(), }, false, }, From 7c7f8db436c0fc18a63cef59088c37f29a3a361a Mon Sep 17 00:00:00 2001 From: Youngtaek Yoon Date: Wed, 12 Jul 2023 11:28:59 +0900 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58b5a7f543..9b7034e36e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Features +* (x/collection) [\#1038](https://github.com/Finschia/finschia-sdk/pull/1038) Update x/collection cli for hackwasm2023 + ### Improvements ### Bug Fixes