Skip to content

Commit

Permalink
Merge pull request #54 from oraichain/add-query-gasless-contract
Browse files Browse the repository at this point in the history
Feat: Add CLI for query gas less contract
  • Loading branch information
ducphamle2 authored Dec 16, 2024
2 parents 03ae1d6 + 692afd6 commit b916208
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions x/wasm/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func GetQueryCmd() *cobra.Command {
GetCmdQueryParams(),
GetCmdBuildAddress(),
GetCmdListContractsByCreator(),
GetCmdQueryGasLessContracts(),
)
return queryCmd
}
Expand Down Expand Up @@ -672,6 +673,40 @@ func GetCmdQueryParams() *cobra.Command {
return cmd
}

func GetCmdQueryGasLessContracts() *cobra.Command {
cmd := &cobra.Command{
Use: "gas-less-contracts",
Short: "Query the gas less contracts",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
pageReq, err := client.ReadPageRequest(cmd.Flags())
if err != nil {
return err
}

queryClient := types.NewQueryClient(clientCtx)
res, err := queryClient.GaslessContracts(
context.Background(),
&types.QueryGaslessContractsRequest{
Pagination: pageReq,
},
)
if err != nil {
return err
}
return clientCtx.PrintProto(res)
},
SilenceUsage: true,
}
flags.AddQueryFlagsToCmd(cmd)
flags.AddPaginationFlagsToCmd(cmd, "gas less contracts")
return cmd
}

// supports a subset of the SDK pagination params for better resource utilization
func addPaginationFlags(cmd *cobra.Command, query string) {
cmd.Flags().String(flags.FlagPageKey, "", fmt.Sprintf("pagination page-key of %s to query for", query))
Expand Down

0 comments on commit b916208

Please sign in to comment.