36 lines
894 B
Go
36 lines
894 B
Go
package keeper
|
|
|
|
import (
|
|
"context"
|
|
|
|
"google.golang.org/grpc/codes"
|
|
"google.golang.org/grpc/status"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"github.com/cosmos/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 Balance implements the Query/Balance gRPC method
|
|
func (k Querier) Params(ctx context.Context, req *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
|
|
}
|