Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gRPC queries for controller and host parameters #574

Merged
Merged
Changes from 1 commit
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
Next Next commit
add grpc query for controller and host params
Adds gRPC routes for controller params and host params. Add tests and registers the gRPC gateways on the ica module
colin-axner committed Dec 1, 2021
commit 209b27f3b93fd68a5936fdd459aae0992f628231
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package keeper

import (
"context"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/controller/types"
)

var _ types.QueryServer = Keeper{}

// Params implements the Query/Params gRPC method
func (q Keeper) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
params := q.GetParams(ctx)

return &types.QueryParamsResponse{
Params: &params,
}, nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package keeper_test

import (
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/controller/types"
)

func (suite *KeeperTestSuite) TestQueryParams() {
ctx := sdk.WrapSDKContext(suite.chainA.GetContext())
expParams := types.DefaultParams()
res, _ := suite.chainA.GetSimApp().ICAControllerKeeper.Params(ctx, &types.QueryParamsRequest{})
suite.Require().Equal(&expParams, res.Params)
}
547 changes: 547 additions & 0 deletions modules/apps/27-interchain-accounts/controller/types/query.pb.go

Large diffs are not rendered by default.

148 changes: 148 additions & 0 deletions modules/apps/27-interchain-accounts/controller/types/query.pb.gw.go
19 changes: 19 additions & 0 deletions modules/apps/27-interchain-accounts/host/keeper/grpc_query.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package keeper

import (
"context"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/host/types"
)

var _ types.QueryServer = Keeper{}

// Params implements the Query/Params gRPC method
func (q Keeper) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
params := q.GetParams(ctx)

return &types.QueryParamsResponse{
Params: &params,
}, nil
}
14 changes: 14 additions & 0 deletions modules/apps/27-interchain-accounts/host/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package keeper_test

import (
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/host/types"
)

func (suite *KeeperTestSuite) TestQueryParams() {
ctx := sdk.WrapSDKContext(suite.chainA.GetContext())
expParams := types.DefaultParams()
res, _ := suite.chainA.GetSimApp().ICAHostKeeper.Params(ctx, &types.QueryParamsRequest{})
suite.Require().Equal(&expParams, res.Params)
}
547 changes: 547 additions & 0 deletions modules/apps/27-interchain-accounts/host/types/query.pb.go

Large diffs are not rendered by default.

148 changes: 148 additions & 0 deletions modules/apps/27-interchain-accounts/host/types/query.pb.gw.go
5 changes: 5 additions & 0 deletions modules/apps/27-interchain-accounts/module.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ica

import (
"context"
"encoding/json"
"fmt"

@@ -17,8 +18,10 @@ import (

"github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/controller"
controllerkeeper "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/controller/keeper"
controllertypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/controller/types"
"github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/host"
hostkeeper "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/host/keeper"
hosttypes "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/host/types"
"github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/types"
porttypes "github.com/cosmos/ibc-go/v2/modules/core/05-port/types"
)
@@ -71,6 +74,8 @@ func (AppModuleBasic) RegisterRESTRoutes(ctx client.Context, rtr *mux.Router) {

// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the interchain accounts module.
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
controllertypes.RegisterQueryHandlerClient(context.Background(), mux, controllertypes.NewQueryClient(clientCtx))
hosttypes.RegisterQueryHandlerClient(context.Background(), mux, hosttypes.NewQueryClient(clientCtx))
}

// GetTxCmd implements AppModuleBasic interface
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
syntax = "proto3";

package ibc.applications.interchain_accounts.controller.v1;

option go_package = "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/controller/types";

import "gogoproto/gogo.proto";
import "ibc/applications/interchain_accounts/controller/v1/controller.proto";
import "google/api/annotations.proto";

// Query provides defines the gRPC querier service.
service Query {
// Params queries all parameters of the ICA controller submodule.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/ibc/apps/interchain_accounts/controller/v1/params";
}
}

// QueryParamsRequest is the request type for the Query/Params RPC method.
message QueryParamsRequest {}

// QueryParamsResponse is the response type for the Query/Params RPC method.
message QueryParamsResponse {
// params defines the parameters of the module.
Params params = 1;
}

27 changes: 27 additions & 0 deletions proto/ibc/applications/interchain_accounts/host/v1/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
syntax = "proto3";

package ibc.applications.interchain_accounts.host.v1;

option go_package = "github.com/cosmos/ibc-go/v2/modules/apps/27-interchain-accounts/host/types";

import "google/api/annotations.proto";
import "gogoproto/gogo.proto";
import "ibc/applications/interchain_accounts/host/v1/host.proto";

// Query provides defines the gRPC querier service.
service Query {
// Params queries all parameters of the ICA host submodule.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/ibc/apps/interchain_accounts/host/v1/params";
}
}

// QueryParamsRequest is the request type for the Query/Params RPC method.
message QueryParamsRequest {}

// QueryParamsResponse is the response type for the Query/Params RPC method.
message QueryParamsResponse {
// params defines the parameters of the module.
Params params = 1;
}