Skip to content
This repository has been archived by the owner on Oct 3, 2022. It is now read-only.

Commit

Permalink
implement cli and add proof in packet data
Browse files Browse the repository at this point in the history
  • Loading branch information
Woojinger committed Sep 18, 2022
1 parent ce4e210 commit ac8c175
Show file tree
Hide file tree
Showing 10 changed files with 683 additions and 112 deletions.
51 changes: 44 additions & 7 deletions docs/ibc/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,12 @@

- [QueryResult](#ibc.applications.ibc_query.v1.QueryResult)

- [ibc/applications/ibc_query/v1/packet.proto](#ibc/applications/ibc_query/v1/packet.proto)
- [IBCQueryPacketData](#ibc.applications.ibc_query.v1.IBCQueryPacketData)

- [ibc/applications/ibc_query/v1/query.proto](#ibc/applications/ibc_query/v1/query.proto)
- [QueryCrossChainQuery](#ibc.applications.ibc_query.v1.QueryCrossChainQuery)
- [QueryCrossChainQueryResponse](#ibc.applications.ibc_query.v1.QueryCrossChainQueryResponse)
- [QueryCrossChainQueryResult](#ibc.applications.ibc_query.v1.QueryCrossChainQueryResult)
- [QueryCrossChainQueryResultResponse](#ibc.applications.ibc_query.v1.QueryCrossChainQueryResultResponse)

- [Query](#ibc.applications.ibc_query.v1.Query)

Expand Down Expand Up @@ -1562,16 +1565,50 @@ QueryResult



<a name="ibc/applications/ibc_query/v1/packet.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## ibc/applications/ibc_query/v1/packet.proto



<a name="ibc.applications.ibc_query.v1.IBCQueryPacketData"></a>

### IBCQueryPacketData
IBCQueryPacketData defines a struct for the packet payload


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `id` | [string](#string) | | |
| `path` | [string](#string) | | |
| `query_height` | [uint64](#uint64) | | |
| `proof_specs` | [ics23.ProofSpec](#ics23.ProofSpec) | repeated | TODO Proof specifications used in verifying counterparty state |





<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->

<!-- end services -->



<a name="ibc/applications/ibc_query/v1/query.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## ibc/applications/ibc_query/v1/query.proto



<a name="ibc.applications.ibc_query.v1.QueryCrossChainQuery"></a>
<a name="ibc.applications.ibc_query.v1.QueryCrossChainQueryResult"></a>

### QueryCrossChainQuery
### QueryCrossChainQueryResult
QueryCrossChainQuery


Expand All @@ -1584,9 +1621,9 @@ QueryCrossChainQuery



<a name="ibc.applications.ibc_query.v1.QueryCrossChainQueryResponse"></a>
<a name="ibc.applications.ibc_query.v1.QueryCrossChainQueryResultResponse"></a>

### QueryCrossChainQueryResponse
### QueryCrossChainQueryResultResponse
QueryCrossChainQueryResponse


Expand Down Expand Up @@ -1614,7 +1651,7 @@ Query

| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint |
| ----------- | ------------ | ------------- | ------------| ------- | -------- |
| `CrossChainQuery` | [QueryCrossChainQuery](#ibc.applications.ibc_query.v1.QueryCrossChainQuery) | [QueryCrossChainQueryResponse](#ibc.applications.ibc_query.v1.QueryCrossChainQueryResponse) | query CrossChainQuery | GET|/ibc/apps/ibc-query/v1/{id}|
| `CrossChainQueryResult` | [QueryCrossChainQueryResult](#ibc.applications.ibc_query.v1.QueryCrossChainQueryResult) | [QueryCrossChainQueryResultResponse](#ibc.applications.ibc_query.v1.QueryCrossChainQueryResultResponse) | query CrossChainQueryResult | GET|/ibc/apps/ibc-query/v1/{id}|

<!-- end services -->

Expand Down
4 changes: 2 additions & 2 deletions modules/apps/31-ibc-query/client/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func GetQueryCmd() *cobra.Command {
}

queryCmd.AddCommand(

GetCmdQueryCrossChainQueryResult(),
)

return queryCmd
Expand All @@ -25,7 +25,7 @@ func GetQueryCmd() *cobra.Command {
func NewTxCmd() *cobra.Command {
txCmd := &cobra.Command{
Use: "ibc-query",
Short: "IBC query command",
Short: "Query cross chain query result",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
Expand Down
43 changes: 43 additions & 0 deletions modules/apps/31-ibc-query/client/cli/query.go
Original file line number Diff line number Diff line change
@@ -1 +1,44 @@
package cli

import (
"fmt"
"github.com/cosmos/cosmos-sdk/version"

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

"github.com/cosmos/ibc-go/v4/modules/apps/31-ibc-query/types"
)

// GetCmdQueryCrossChainQueryResult defines the command to query CrossChainQueryResult from store
func GetCmdQueryCrossChainQueryResult() *cobra.Command {
cmd := &cobra.Command{
Use: "query-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),
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)

req := &types.QueryCrossChainQueryResult{
Id: args[0],
}

res, err := queryClient.CrossChainQueryResult(cmd.Context(), req)
if err != nil {
return err
}

return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)
return cmd
}
4 changes: 2 additions & 2 deletions modules/apps/31-ibc-query/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (

var _ types.QueryServer = Keeper{}

// CrossChainQuery implements the Query/CrossChainQuery gRPC method
func (k Keeper) CrossChainQuery(context context.Context, query *types.QueryCrossChainQuery) (*types.QueryCrossChainQueryResponse, error) {
// CrossChainQueryResult implements the Query/CrossChainQueryResult gRPC method
func (k Keeper) CrossChainQueryResult(context context.Context, query *types.QueryCrossChainQueryResult) (*types.QueryCrossChainQueryResultResponse, error) {
// TODO
// get queryResult from private store
return nil, nil
Expand Down
5 changes: 3 additions & 2 deletions modules/apps/31-ibc-query/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/cosmos/ibc-go/v4/modules/apps/31-ibc-query/client/cli"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
Expand Down Expand Up @@ -67,12 +68,12 @@ func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *r

// GetTxCmd implements AppModuleBasic interface
func (AppModuleBasic) GetTxCmd() *cobra.Command {
return nil
return cli.NewTxCmd()
}

// GetQueryCmd implements AppModuleBasic interface
func (AppModuleBasic) GetQueryCmd() *cobra.Command {
return nil
return cli.GetQueryCmd()
}

type AppModule struct {
Expand Down
Loading

0 comments on commit ac8c175

Please sign in to comment.