X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=cmd%2Fbytomcli%2Fcommands%2Fasset.go;h=16cc2c3f1f4b49c3e3d3ce4e203de67e6d94a6d3;hb=475ae99f8cde2a45b5042ee8bf51edf6dde0cede;hp=5a4a056c77fd1d79268d2853ad0b7217051baea6;hpb=15ef4985c87c5cae96bef39d4baf1371b31670f4;p=bytom%2Fbytom.git diff --git a/cmd/bytomcli/commands/asset.go b/cmd/bytomcli/commands/asset.go index 5a4a056c..16cc2c3f 100644 --- a/cmd/bytomcli/commands/asset.go +++ b/cmd/bytomcli/commands/asset.go @@ -7,6 +7,7 @@ import ( "github.com/spf13/cobra" jww "github.com/spf13/jwalterweatherman" + "encoding/hex" "github.com/bytom/crypto/ed25519/chainkd" "github.com/bytom/util" ) @@ -14,8 +15,8 @@ import ( func init() { createAssetCmd.PersistentFlags().IntVarP(&assetQuorum, "quorom", "q", 1, "quorum must be greater than 0 and less than or equal to the number of signers") createAssetCmd.PersistentFlags().StringVarP(&assetToken, "access", "a", "", "access token") - createAssetCmd.PersistentFlags().StringVarP(&assetTags, "tags", "t", "", "tags") createAssetCmd.PersistentFlags().StringVarP(&assetDefiniton, "definition", "d", "", "definition for the asset") + createAssetCmd.PersistentFlags().StringVarP(&issuanceProgram, "issueprogram", "i", "", "issue program for the asset") listAssetsCmd.PersistentFlags().StringVar(&assetID, "id", "", "ID of asset") } @@ -24,14 +25,14 @@ var ( assetID = "" assetQuorum = 1 assetToken = "" - assetTags = "" assetDefiniton = "" + issuanceProgram = "" ) var createAssetCmd = &cobra.Command{ Use: "create-asset ", Short: "Create an asset", - Args: cobra.MinimumNArgs(2), + Args: cobra.RangeArgs(1, 5), Run: func(cmd *cobra.Command, args []string) { var ins assetIns @@ -58,6 +59,15 @@ var createAssetCmd = &cobra.Command{ ins.Definition = map[string]interface{}{definition[0]: definition[1]} } + if issuanceProgram != "" { + issueProg, err := hex.DecodeString(issuanceProgram) + if err != nil { + jww.ERROR.Println(err) + os.Exit(util.ErrLocalExe) + } + ins.IssuanceProgram = issueProg + } + data, exitCode := util.ClientCall("/create-asset", &ins) if exitCode != util.Success { os.Exit(exitCode) @@ -67,6 +77,24 @@ var createAssetCmd = &cobra.Command{ }, } +var getAssetCmd = &cobra.Command{ + Use: "get-asset ", + Short: "get asset by assetID", + Args: cobra.ExactArgs(1), + Run: func(cmd *cobra.Command, args []string) { + filter := struct { + ID string `json:"id"` + }{ID: args[0]} + + data, exitCode := util.ClientCall("/get-asset", &filter) + if exitCode != util.Success { + os.Exit(exitCode) + } + + printJSON(data) + }, +} + var listAssetsCmd = &cobra.Command{ Use: "list-assets", Short: "List the existing assets", @@ -86,14 +114,14 @@ var listAssetsCmd = &cobra.Command{ } var updateAssetAliasCmd = &cobra.Command{ - Use: "update-asset-alias ", + Use: "update-asset-alias ", Short: "Update the asset alias", Args: cobra.ExactArgs(2), Run: func(cmd *cobra.Command, args []string) { var updateAlias = struct { - OldAlias string `json:"old_alias"` - NewAlias string `json:"new_alias"` - }{OldAlias: args[0], NewAlias: args[1]} + ID string `json:"id"` + NewAlias string `json:"alias"` + }{ID: args[0], NewAlias: args[1]} if _, exitCode := util.ClientCall("/update-asset-alias", &updateAlias); exitCode != util.Success { os.Exit(exitCode)