forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 10
/
grpc_query.go
35 lines (26 loc) · 886 Bytes
/
grpc_query.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package keeper
import (
"context"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
sdk "github.com/shapeshift/cosmos-sdk/types"
"github.com/shapeshift/cosmos-sdk/x/consensus/types"
)
var _ types.QueryServer = Querier{}
// Querier is used as Keeper will have duplicate methods if used directly, and gRPC names take precedence over keeper
type Querier struct {
Keeper
}
// NewQuerier constructor for the Querier struct
func NewQuerier(keeper Keeper) Querier {
return Querier{Keeper: keeper}
}
// Params queries params of consensus module
func (k Querier) Params(ctx context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
sdkCtx := sdk.UnwrapSDKContext(ctx)
params, err := k.Keeper.Get(sdkCtx)
if err != nil {
return nil, status.Error(codes.Internal, err.Error())
}
return &types.QueryParamsResponse{Params: params}, nil
}