Some checks failed
CodeQL / Analyze (push) Waiting to run
golangci-lint / lint (push) Waiting to run
Tests / Code Coverage / build (amd64) (push) Waiting to run
Tests / Code Coverage / build (arm64) (push) Waiting to run
Tests / Code Coverage / unit-tests (map[additional-args:-tags="test_e2e" name:e2e path:./e2e]) (push) Waiting to run
Tests / Code Coverage / unit-tests (map[name:08-wasm path:./modules/light-clients/08-wasm]) (push) Waiting to run
Tests / Code Coverage / unit-tests (map[name:ibc-go path:.]) (push) Waiting to run
Docker Build & Push Simapp (main) / docker-build (push) Has been cancelled
80 lines
2.1 KiB
Go
80 lines
2.1 KiB
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"git.cw.tr/mukan-network/mukan-sdk/client"
|
|
"git.cw.tr/mukan-network/mukan-sdk/client/flags"
|
|
"git.cw.tr/mukan-network/mukan-sdk/version"
|
|
|
|
"github.com/cosmos/ibc-go/modules/light-clients/08-wasm/v10/types"
|
|
ibcexported "git.cw.tr/mukan-network/mukan-ibc/modules/core/exported"
|
|
)
|
|
|
|
// getCmdCode defines the command to query wasm code for given checksum.
|
|
func getCmdCode() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "code [checksum]",
|
|
Short: "Query wasm code",
|
|
Long: "Query wasm code for a light client wasm contract with a given checksum",
|
|
Example: fmt.Sprintf("%s query %s wasm code [checksum]", version.AppName, ibcexported.ModuleName),
|
|
Args: cobra.ExactArgs(1),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
clientCtx, err := client.GetClientQueryContext(cmd)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
queryClient := types.NewQueryClient(clientCtx)
|
|
|
|
checksum := args[0]
|
|
req := types.QueryCodeRequest{
|
|
Checksum: checksum,
|
|
}
|
|
|
|
res, err := queryClient.Code(context.Background(), &req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return clientCtx.PrintProto(res)
|
|
},
|
|
}
|
|
|
|
flags.AddQueryFlagsToCmd(cmd)
|
|
|
|
return cmd
|
|
}
|
|
|
|
// getCmdChecksums defines the command to query all wasm checksums.
|
|
func getCmdChecksums() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "checksums",
|
|
Short: "Query all checksums",
|
|
Long: "Query all checksums for all deployed light client wasm contracts",
|
|
Example: fmt.Sprintf("%s query %s wasm checksums", version.AppName, ibcexported.ModuleName),
|
|
Args: cobra.ExactArgs(0),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
clientCtx, err := client.GetClientQueryContext(cmd)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
queryClient := types.NewQueryClient(clientCtx)
|
|
req := types.QueryChecksumsRequest{}
|
|
|
|
res, err := queryClient.Checksums(context.Background(), &req)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return clientCtx.PrintProto(res)
|
|
},
|
|
}
|
|
|
|
flags.AddQueryFlagsToCmd(cmd)
|
|
flags.AddPaginationFlagsToCmd(cmd, "all wasm code")
|
|
|
|
return cmd
|
|
}
|