2022-12-16 09:48:38 +00:00
|
|
|
// Copyright 2021 Evmos Foundation
|
|
|
|
// This file is part of Evmos' Ethermint library.
|
|
|
|
//
|
|
|
|
// The Ethermint library is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// The Ethermint library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with the Ethermint library. If not, see https://github.com/evmos/ethermint/blob/main/LICENSE
|
2020-09-02 19:41:05 +00:00
|
|
|
package keeper
|
|
|
|
|
|
|
|
import (
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
|
2022-09-07 06:36:11 +00:00
|
|
|
"github.com/cerc-io/laconicd/x/evm/types"
|
2020-09-02 19:41:05 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// GetParams returns the total set of evm parameters.
|
|
|
|
func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) {
|
2023-01-23 19:01:28 +00:00
|
|
|
store := ctx.KVStore(k.storeKey)
|
|
|
|
bz := store.Get(types.KeyPrefixParams)
|
|
|
|
if len(bz) == 0 {
|
|
|
|
return k.GetLegacyParams(ctx)
|
2022-10-10 10:38:33 +00:00
|
|
|
}
|
2023-01-23 19:01:28 +00:00
|
|
|
k.cdc.MustUnmarshal(bz, ¶ms)
|
|
|
|
return
|
2022-10-19 16:21:59 +00:00
|
|
|
}
|
|
|
|
|
2023-01-04 14:28:45 +00:00
|
|
|
// 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
|
2022-07-19 15:00:43 +00:00
|
|
|
}
|
2022-10-19 16:21:59 +00:00
|
|
|
|
2023-01-23 19:01:28 +00:00
|
|
|
store := ctx.KVStore(k.storeKey)
|
|
|
|
bz, err := k.cdc.Marshal(¶ms)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2022-10-19 16:21:59 +00:00
|
|
|
|
2023-01-23 19:01:28 +00:00
|
|
|
store.Set(types.KeyPrefixParams, bz)
|
2023-01-04 14:28:45 +00:00
|
|
|
return nil
|
2022-10-19 16:21:59 +00:00
|
|
|
}
|
|
|
|
|
2023-01-12 08:52:55 +00:00
|
|
|
// 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
|
2022-10-19 16:21:59 +00:00
|
|
|
}
|