-
Notifications
You must be signed in to change notification settings - Fork 40
/
params.go
52 lines (41 loc) · 1.19 KB
/
params.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
package keeper
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/elys-network/elys/x/commitment/types"
)
// GetParams get all parameters as types.Params
func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) {
store := ctx.KVStore(k.storeKey)
b := store.Get([]byte(types.ParamsKey))
if b == nil {
return
}
k.cdc.MustUnmarshal(b, ¶ms)
return
}
// SetParams set the params
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
store := ctx.KVStore(k.storeKey)
b := k.cdc.MustMarshal(¶ms)
store.Set([]byte(types.ParamsKey), b)
}
// GetVestingDenom returns the vesting denom for the given base denom
func (k Keeper) GetVestingInfo(ctx sdk.Context, baseDenom string) (*types.VestingInfo, int) {
params := k.GetParams(ctx)
for i, vestingInfo := range params.VestingInfos {
if vestingInfo.BaseDenom == baseDenom {
return vestingInfo, i
}
}
return nil, 0
}
// GetLegacyParams get all legacy parameters as types.LegacyParams
func (k Keeper) GetLegacyParams(ctx sdk.Context) (params types.LegacyParams) {
store := ctx.KVStore(k.storeKey)
b := store.Get([]byte(types.ParamsKey))
if b == nil {
return
}
k.cdc.MustUnmarshal(b, ¶ms)
return
}