-
Notifications
You must be signed in to change notification settings - Fork 126
/
params.go
41 lines (34 loc) · 996 Bytes
/
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
package keeper
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/haqq-network/haqq/x/evm/types"
)
// GetParams returns the total set of evm parameters.
func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) {
store := ctx.KVStore(k.storeKey)
bz := store.Get(types.KeyPrefixParams)
if len(bz) == 0 {
return k.GetLegacyParams(ctx)
}
k.cdc.MustUnmarshal(bz, ¶ms)
return
}
// SetParams sets the EVM params each in their individual key for better get performance
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.KeyPrefixParams, bz)
return nil
}
// GetLegacyParams returns param set for version before migrate
func (k Keeper) GetLegacyParams(ctx sdk.Context) types.Params {
var params types.Params
k.ss.GetParamSetIfExists(ctx, ¶ms)
return params
}