forked from evmos/evmos
-
Notifications
You must be signed in to change notification settings - Fork 3
/
grpc_query.go
81 lines (67 loc) · 2.49 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package keeper
import (
"context"
"github.com/EscanBE/evermint/v12/x/inflation/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
var _ types.QueryServer = Keeper{}
// Period returns the current period of the inflation module.
func (k Keeper) Period(
c context.Context,
_ *types.QueryPeriodRequest,
) (*types.QueryPeriodResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
period := k.GetPeriod(ctx)
return &types.QueryPeriodResponse{Period: period}, nil
}
// EpochMintProvision returns the EpochMintProvision of the inflation module.
func (k Keeper) EpochMintProvision(
c context.Context,
_ *types.QueryEpochMintProvisionRequest,
) (*types.QueryEpochMintProvisionResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
epochMintProvision := k.GetEpochMintProvision(ctx)
mintDenom := k.GetParams(ctx).MintDenom
coin := sdk.NewDecCoinFromDec(mintDenom, epochMintProvision)
return &types.QueryEpochMintProvisionResponse{EpochMintProvision: coin}, nil
}
// SkippedEpochs returns the number of skipped Epochs of the inflation module.
func (k Keeper) SkippedEpochs(
c context.Context,
_ *types.QuerySkippedEpochsRequest,
) (*types.QuerySkippedEpochsResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
skippedEpochs := k.GetSkippedEpochs(ctx)
return &types.QuerySkippedEpochsResponse{SkippedEpochs: skippedEpochs}, nil
}
// InflationRate returns the inflation rate for the current period.
func (k Keeper) InflationRate(
c context.Context,
_ *types.QueryInflationRateRequest,
) (*types.QueryInflationRateResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
mintDenom := k.GetParams(ctx).MintDenom
inflationRate := k.GetInflationRate(ctx, mintDenom)
return &types.QueryInflationRateResponse{InflationRate: inflationRate}, nil
}
// CirculatingSupply returns the total supply in circulation excluding the team
// allocation in the first year
func (k Keeper) CirculatingSupply(
c context.Context,
_ *types.QueryCirculatingSupplyRequest,
) (*types.QueryCirculatingSupplyResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
mintDenom := k.GetParams(ctx).MintDenom
circulatingSupply := k.GetCirculatingSupply(ctx, mintDenom)
coin := sdk.NewDecCoinFromDec(mintDenom, circulatingSupply)
return &types.QueryCirculatingSupplyResponse{CirculatingSupply: coin}, nil
}
// Params returns params of the mint module.
func (k Keeper) Params(
c context.Context,
_ *types.QueryParamsRequest,
) (*types.QueryParamsResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
params := k.GetParams(ctx)
return &types.QueryParamsResponse{Params: params}, nil
}