-
Notifications
You must be signed in to change notification settings - Fork 28
/
params.go
50 lines (40 loc) · 1.15 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
package keeper
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/irisnet/irismod/modules/farm/types"
)
// CreatePoolFee returns the create pool fee
func (k Keeper) CreatePoolFee(ctx sdk.Context) sdk.Coin {
return k.GetParams(ctx).PoolCreationFee
}
// MaxRewardCategories returns the maxRewardCategories
func (k Keeper) MaxRewardCategories(ctx sdk.Context) uint32 {
return k.GetParams(ctx).MaxRewardCategories
}
// MaxRewardCategories returns the maxRewardCategories
func (k Keeper) TaxRate(ctx sdk.Context) sdk.Dec {
return k.GetParams(ctx).TaxRate
}
// GetParams sets the farm module parameters.
func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) {
store := ctx.KVStore(k.storeKey)
bz := store.Get([]byte(types.ParamsKey))
if bz == nil {
return params
}
k.cdc.MustUnmarshal(bz, ¶ms)
return params
}
// SetParams sets the farm module parameters.
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error {
if err := params.Validate(); err != nil {
return err
}
store := ctx.KVStore(k.storeKey)
bz, err := k.cdc.Marshal(¶ms)
if err != nil {
return err
}
store.Set(types.ParamsKey, bz)
return nil
}