-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
841 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
syntax = "proto3"; | ||
package stride.interchainquery.v1; | ||
|
||
import "stride/interchainquery/v1/genesis.proto"; | ||
import "google/api/annotations.proto"; | ||
import "gogoproto/gogo.proto"; | ||
|
||
option go_package = "github.com/Stride-Labs/stride/v4/x/interchainquery/types"; | ||
|
||
service QueryService { | ||
rpc PendingQueries(QueryPendingQueriesRequest) | ||
returns (QueryPendingQueriesResponse) { | ||
option (google.api.http).get = | ||
"/Stride-Labs/stride/interchainquery/pending_queries"; | ||
} | ||
} | ||
|
||
message QueryPendingQueriesRequest {} | ||
message QueryPendingQueriesResponse { | ||
repeated Query pending_queries = 1 [ (gogoproto.nullable) = false ]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package cli | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
|
||
"github.com/cosmos/cosmos-sdk/client/flags" | ||
"github.com/cosmos/cosmos-sdk/version" | ||
|
||
"github.com/Stride-Labs/stride/v4/x/interchainquery/types" | ||
) | ||
|
||
// GetQueryCmd returns the cli query commands for this module. | ||
func GetQueryCmd() *cobra.Command { | ||
// Group lockup queries under a subcommand | ||
cmd := &cobra.Command{ | ||
Use: types.ModuleName, | ||
Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), | ||
DisableFlagParsing: true, | ||
SuggestionsMinimumDistance: 2, | ||
RunE: client.ValidateCmd, | ||
} | ||
|
||
cmd.AddCommand( | ||
GetCmdListPendingQueries(), | ||
) | ||
|
||
return cmd | ||
} | ||
|
||
// GetCmdQueries provides a list of all pending queries | ||
// (queries that have not have been requested but have not received a response) | ||
func GetCmdListPendingQueries() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "list-pending-queries", | ||
Short: "Query all pending queries", | ||
Example: strings.TrimSpace( | ||
fmt.Sprintf(`$ %s query interchainquery list-pending-queries`, | ||
version.AppName, | ||
), | ||
), | ||
Args: cobra.NoArgs, | ||
RunE: func(cmd *cobra.Command, _ []string) error { | ||
clientCtx, err := client.GetClientQueryContext(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
queryClient := types.NewQueryServiceClient(clientCtx) | ||
|
||
req := &types.QueryPendingQueriesRequest{} | ||
|
||
res, err := queryClient.PendingQueries(context.Background(), req) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return clientCtx.PrintProto(res) | ||
}, | ||
} | ||
|
||
flags.AddQueryFlagsToCmd(cmd) | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package keeper | ||
|
||
import ( | ||
"context" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/Stride-Labs/stride/v4/x/interchainquery/types" | ||
) | ||
|
||
var _ types.QueryServiceServer = Keeper{} | ||
|
||
// Queries all queries that have been requested but have not received a response | ||
func (k Keeper) PendingQueries(c context.Context, req *types.QueryPendingQueriesRequest) (*types.QueryPendingQueriesResponse, error) { | ||
ctx := sdk.UnwrapSDKContext(c) | ||
|
||
pendingQueries := []types.Query{} | ||
for _, query := range k.AllQueries(ctx) { | ||
if query.RequestSent { | ||
pendingQueries = append(pendingQueries, query) | ||
} | ||
} | ||
|
||
return &types.QueryPendingQueriesResponse{PendingQueries: pendingQueries}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.