-
Notifications
You must be signed in to change notification settings - Fork 173
Expand file tree
/
Copy pathgrpc_query.go
More file actions
50 lines (40 loc) · 1.19 KB
/
grpc_query.go
File metadata and controls
50 lines (40 loc) · 1.19 KB
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
package keeper
import (
context "context"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/umee-network/umee/v4/x/uibc"
)
var _ uibc.QueryServer = Querier{}
// Querier implements a QueryServer for the x/uibc module.
type Querier struct {
Keeper
}
func NewQuerier(k Keeper) Querier {
return Querier{Keeper: k}
}
// Params returns params of the x/uibc module.
func (q Querier) Params(goCtx context.Context, req *uibc.QueryParams) (
*uibc.QueryParamsResponse, error,
) {
ctx := sdk.UnwrapSDKContext(goCtx)
params := q.Keeper.GetParams(ctx)
return &uibc.QueryParamsResponse{Params: params}, nil
}
// Quota returns quotas of denoms.
func (q Querier) Quota(goCtx context.Context, req *uibc.QueryQuota) (
*uibc.QueryQuotaResponse, error,
) {
ctx := sdk.UnwrapSDKContext(goCtx)
if len(req.Denom) == 0 {
quotaOfIBCDenoms, err := q.Keeper.GetQuotaOfIBCDenoms(ctx)
if err != nil {
return &uibc.QueryQuotaResponse{}, err
}
return &uibc.QueryQuotaResponse{Quota: quotaOfIBCDenoms}, nil
}
quotaOfIBCDenom, err := q.Keeper.GetQuotaByDenom(ctx, req.Denom)
if err != nil {
return &uibc.QueryQuotaResponse{}, err
}
return &uibc.QueryQuotaResponse{Quota: []uibc.Quota{*quotaOfIBCDenom}}, nil
}