Skip to content
This repository was archived by the owner on Oct 3, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion modules/apps/31-ibc-query/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cli

import (
"fmt"

"github.com/cosmos/cosmos-sdk/version"

"github.com/cosmos/cosmos-sdk/client"
Expand All @@ -14,7 +15,7 @@ import (
// GetCmdQueryCrossChainQueryResult defines the command to query CrossChainQueryResult from store
func GetCmdQueryCrossChainQueryResult() *cobra.Command {
cmd := &cobra.Command{
Use: "query-ibc-query-result [query id]",
Use: "ibc-query-result [query id]",
Short: "query cross chain query result with query id",
Long: "query cross chain query result with query id",
Example: fmt.Sprintf("%s query ibc-query query-ibc-query-result 3", version.AppName),
Expand Down
36 changes: 16 additions & 20 deletions modules/apps/31-ibc-query/client/cli/tx.go
Original file line number Diff line number Diff line change
@@ -1,64 +1,60 @@
package cli

import (
"strconv"
"strings"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/spf13/cast"
"github.com/spf13/cobra"

"github.com/cosmos/ibc-go/v4/modules/apps/31-ibc-query/client/utils"
"github.com/cosmos/ibc-go/v4/modules/apps/31-ibc-query/types"
clienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types"
)

const (
flagPacketTimeoutHeight = "packet-timeout-height"
flagPacketTimeoutTimestamp = "packet-timeout-timestamp"
flagAbsoluteTimeouts = "absolute-timeouts"
)

func NewMsgCrossChainQueryCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "cross-chain-query [src-port] [src-channel] [query-path] [query-height]",
Short: "Request ibc query on a given channel.",
Long: strings.TrimSpace(`Register a payee address on a given channel.`),
Args: cobra.ExactArgs(3),
Use: "ibc-query [src-port] [src-channel] [query-path] [query-height] [timeout-timeheight] [timeout-timestamp]",
Short: "submit an ibc query",
Long: strings.TrimSpace(`submit an ibc query to queried chain.
Timeout height and the timeout stamp are the local timeoutHeight and the local timeoutstamp, respectively,
which are used to validate the query result`),
Args: cobra.ExactArgs(6),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

creator := clientCtx.GetFromAddress().String()
queryId, err := utils.GetQueryIdentifier()
if err != nil {
return err
}

srcPort := args[0]
srcChannel := args[1]
path := args[2]
queryHeight, _ := strconv.ParseUint(args[2], 10, 64)
queryHeight, err := cast.ToUint64E(args[3])
if err != nil {
return err
}

timeoutHeightStr, err := cmd.Flags().GetString(flagPacketTimeoutHeight)
queryId, err := utils.GetQueryIdentifier()
if err != nil {
return err
}
timeoutHeight, err := clienttypes.ParseHeight(timeoutHeightStr)

timeoutHeight, err := clienttypes.ParseHeight( args[4])
if err != nil {
return err
}

timeoutTimestamp, err := cmd.Flags().GetUint64(flagPacketTimeoutTimestamp)
timeoutTimestamp, err := cast.ToUint64E(args[5])
if err != nil {
return err
}


msg := types.NewMsgSubmitCrossChainQuery(queryId, path, timeoutHeight, timeoutTimestamp, queryHeight, creator, srcPort, srcChannel)

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}
Expand Down
1 change: 1 addition & 0 deletions modules/apps/31-ibc-query/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
registry.RegisterImplementations(
(*sdk.Msg)(nil),
&MsgSubmitCrossChainQuery{},
&MsgSubmitCrossChainQueryResult{},
)

msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
Expand Down