mirror of https://github.com/certusone/wasmd.git
Implement query list-contract-by-code for the CLI
This commit is contained in:
parent
64d7d04890
commit
bb18c59c5d
|
@ -33,6 +33,7 @@ func GetQueryCmd(cdc *codec.Codec) *cobra.Command {
|
|||
}
|
||||
queryCmd.AddCommand(flags.GetCommands(
|
||||
GetCmdListCode(cdc),
|
||||
GetCmdListContractByCode(cdc),
|
||||
GetCmdQueryCode(cdc),
|
||||
GetCmdGetContractInfo(cdc),
|
||||
GetCmdGetContractState(cdc),
|
||||
|
@ -61,6 +62,32 @@ func GetCmdListCode(cdc *codec.Codec) *cobra.Command {
|
|||
}
|
||||
}
|
||||
|
||||
// GetCmdListContractByCode lists all wasm code uploaded for given code id
|
||||
func GetCmdListContractByCode(cdc *codec.Codec) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "list-contract-by-code [code_id]",
|
||||
Short: "List wasm all bytecode on the chain for given code id",
|
||||
Long: "List wasm all bytecode on the chain for given code id",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
cliCtx := context.NewCLIContext().WithCodec(cdc)
|
||||
|
||||
codeID, err := strconv.ParseUint(args[0], 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
route := fmt.Sprintf("custom/%s/%s/%d", types.QuerierRoute, keeper.QueryListContractByCode, codeID)
|
||||
res, _, err := cliCtx.Query(route)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println(string(res))
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// GetCmdQueryCode returns the bytecode for a given contract
|
||||
func GetCmdQueryCode(cdc *codec.Codec) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
|
|
Loading…
Reference in New Issue