-
Notifications
You must be signed in to change notification settings - Fork 0
/
grpc_query.go
51 lines (43 loc) · 1.08 KB
/
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package keeper
import (
"context"
"github.com/jinxprotocol/v4-chain/protocol/x/feetiers/types"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
sdk "github.com/cosmos/cosmos-sdk/types"
)
var _ types.QueryServer = Keeper{}
// Params processes a query request/response for the Params from state.
func (k Keeper) PerpetualFeeParams(
c context.Context,
req *types.QueryPerpetualFeeParamsRequest,
) (
*types.QueryPerpetualFeeParamsResponse,
error,
) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}
ctx := sdk.UnwrapSDKContext(c)
params := k.GetPerpetualFeeParams(ctx)
return &types.QueryPerpetualFeeParamsResponse{
Params: params,
}, nil
}
func (k Keeper) UserFeeTier(
c context.Context,
req *types.QueryUserFeeTierRequest,
) (
*types.QueryUserFeeTierResponse,
error,
) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}
ctx := sdk.UnwrapSDKContext(c)
index, tier := k.getUserFeeTier(ctx, req.User)
return &types.QueryUserFeeTierResponse{
Index: index,
Tier: tier,
}, nil
}