From b330a05208762c9ae4f6ecf4391e5aff053e710b Mon Sep 17 00:00:00 2001 From: harish Date: Mon, 27 Dec 2021 22:18:29 +0530 Subject: [PATCH] fix: fixed cli issues --- client/cli/flags.go | 5 +++-- client/cli/tx.go | 29 ++++++++++++++++++++++------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/client/cli/flags.go b/client/cli/flags.go index d632c5a..7298c0e 100644 --- a/client/cli/flags.go +++ b/client/cli/flags.go @@ -48,8 +48,8 @@ func init() { FsMintONFT.String(FlagDescription, "", "Description of onft") FsMintONFT.String(FlagData, "", "custom data of onft") - FsMintONFT.Bool(FlagTransferable, true, "transferability of onft (true | false)") - FsMintONFT.Bool(FlagExtensible, false, "extensisbility of onft (true | false)") + FsMintONFT.String(FlagTransferable, "yes", "transferability of onft (yes | no)") + FsMintONFT.String(FlagExtensible, "yes", "extensisbility of onft (yes | no)") FsEditONFT.String(FlagMediaURI, "[do-not-modify]", "Media uri of onft") FsEditONFT.String(FlagPreviewURI, "[do-not-modify]", "Preview uri of onft") @@ -57,6 +57,7 @@ func init() { FsEditONFT.String(FlagDescription, "[do-not-modify]", "Description of onft") FsEditONFT.String(FlagTransferable, "[do-not-modify]", "transferability of onft") FsEditONFT.String(FlagData, "[do-not-modify]", "custom data of onft") + FsEditONFT.String(FlagExtensible, "yes", "extensibility of onft (yes | no)") FsTransferONFT.String(FlagRecipient, "", "Receiver of the onft. default value is sender address of transaction") FsQuerySupply.String(FlagOwner, "", "The owner of a nft") diff --git a/client/cli/tx.go b/client/cli/tx.go index 6951ce1..2a4ce12 100644 --- a/client/cli/tx.go +++ b/client/cli/tx.go @@ -102,7 +102,7 @@ func GetCmdMintONFT() *cobra.Command { fmt.Sprintf(`Mint an oNFT. Example: $ %s tx onft mint [denom-id] --type --name --description --media-uri= --preview-uri= ---transferable --extensible --recipient= --from= --chain-id= --fees=`, +--transferable yes --extensible yes --recipient= --from= --chain-id= --fees=`, version.AppName, ), ), @@ -167,15 +167,31 @@ $ %s tx onft mint [denom-id] --type --name --description return err } - transferable, err := cmd.Flags().GetBool(FlagTransferable) + var transferable bool + transferability, err := cmd.Flags().GetString(FlagTransferable) if err != nil { return err } - - extensible, err := cmd.Flags().GetBool(FlagExtensible) + transferability = strings.ToLower(transferability) + if transferability == "false" || transferability == "no" { + transferable = false + } else if transferability == "true" || transferability == "yes" { + transferable = true + } else { + return fmt.Errorf("invalid option for transferable flag , valid options are true|false, yes|no") + } + var extensible bool + extensibility, err := cmd.Flags().GetString(FlagExtensible) if err != nil { return err } + if extensibility == "false" || extensibility == "no" { + extensible = false + } else if extensibility == "true" || extensibility == "yes" { + extensible = true + } else { + return fmt.Errorf("invalid option for extensible flag , valid options are yes|no") + } msg := types.NewMsgMintONFT( denomId, @@ -206,7 +222,7 @@ func GetCmdEditONFT() *cobra.Command { fmt.Sprintf(`Edit the data of an oNFT. Example: $ %s tx onft edit [denom-id] [onft-id] --name= --description= --media-uri= ---preview-uri= --type= --transferable= --from= --chain-id= --fees=`, +--preview-uri= --type= --transferable=yes --extensible=yes --from= --chain-id= --fees=`, version.AppName, ), ), @@ -273,8 +289,7 @@ $ %s tx onft edit [denom-id] [onft-id] --name= --description= 0 && (extensible == "no" || extensible == "yes" || - extensible == types.DoNotModify)) { + if !(len(extensible) > 0 && (extensible == "no" || extensible == "yes" || extensible == types.DoNotModify)) { return fmt.Errorf("invalid option for extensible flag , valid options are yes|no") } msg := types.NewMsgEditONFT(