Skip to content

Commit

Permalink
fix: fixed cli issues
Browse files Browse the repository at this point in the history
  • Loading branch information
harish551 committed Dec 27, 2021
1 parent 9d72c73 commit b330a05
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
5 changes: 3 additions & 2 deletions client/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,16 @@ 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")
FsEditONFT.String(FlagName, "[do-not-modify]", "Name of nft")
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")
Expand Down
29 changes: 22 additions & 7 deletions client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func GetCmdMintONFT() *cobra.Command {
fmt.Sprintf(`Mint an oNFT.
Example:
$ %s tx onft mint [denom-id] --type <onft-type> --name <onft-name> --description <onft-descritpion> --media-uri=<uri> --preview-uri=<uri>
--transferable --extensible --recipient=<recipient> --from=<key-name> --chain-id=<chain-id> --fees=<fee>`,
--transferable yes --extensible yes --recipient=<recipient> --from=<key-name> --chain-id=<chain-id> --fees=<fee>`,
version.AppName,
),
),
Expand Down Expand Up @@ -167,15 +167,31 @@ $ %s tx onft mint [denom-id] --type <onft-type> --name <onft-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,
Expand Down Expand Up @@ -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=<onft-name> --description=<onft-description> --media-uri=<uri>
--preview-uri=<uri> --type=<onft-type> --transferable=<yes|no> --from=<key-name> --chain-id=<chain-id> --fees=<fee>`,
--preview-uri=<uri> --type=<onft-type> --transferable=yes --extensible=yes --from=<key-name> --chain-id=<chain-id> --fees=<fee>`,
version.AppName,
),
),
Expand Down Expand Up @@ -273,8 +289,7 @@ $ %s tx onft edit [denom-id] [onft-id] --name=<onft-name> --description=<onft-de
if err != nil {
return err
}
if !(len(extensible) > 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(
Expand Down

0 comments on commit b330a05

Please sign in to comment.