mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-27 08:45:19 +00:00
2b123bf007
* add eip712 ante * minor cleanup * eip712 integration test with bridge conversion * fix issues * update bridge module * merge bridge module convert logic * update eip712 tests & update deps * remove v17 migrations * remove v17 migrations * fix genesis test * fix erc20 to coin tx * remove eth check * clean up imports * remove * fix evmutil cli * remove bridge comments * address feedback * rename mint method * add transfer checks for locking & unlocking funds * fix gas * increase gas even more * fix amount check Co-authored-by: Ruaridh <rhuairahrighairidh@users.noreply.github.com> Co-authored-by: Ruaridh <rhuairahrighairidh@users.noreply.github.com>
52 lines
1.4 KiB
Go
52 lines
1.4 KiB
Go
package keeper
|
|
|
|
import (
|
|
"bytes"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
|
|
|
"github.com/kava-labs/kava/x/evmutil/types"
|
|
)
|
|
|
|
// GetParams returns the total set of evm parameters.
|
|
func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) {
|
|
k.paramSubspace.GetParamSet(ctx, ¶ms)
|
|
return params
|
|
}
|
|
|
|
// SetParams sets the evm parameters to the param space.
|
|
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
|
|
k.paramSubspace.SetParamSet(ctx, ¶ms)
|
|
}
|
|
|
|
// GetEnabledConversionPairFromERC20Address returns an ConversionPair from the internal contract address.
|
|
func (k Keeper) GetEnabledConversionPairFromERC20Address(
|
|
ctx sdk.Context,
|
|
address types.InternalEVMAddress,
|
|
) (types.ConversionPair, error) {
|
|
params := k.GetParams(ctx)
|
|
for _, pair := range params.EnabledConversionPairs {
|
|
if bytes.Equal(pair.KavaERC20Address, address.Bytes()) {
|
|
return pair, nil
|
|
}
|
|
}
|
|
|
|
return types.ConversionPair{}, sdkerrors.Wrap(types.ErrConversionNotEnabled, address.String())
|
|
}
|
|
|
|
// GetEnabledConversionPairFromDenom returns an ConversionPair from the sdk.Coin denom.
|
|
func (k Keeper) GetEnabledConversionPairFromDenom(
|
|
ctx sdk.Context,
|
|
denom string,
|
|
) (types.ConversionPair, error) {
|
|
params := k.GetParams(ctx)
|
|
for _, pair := range params.EnabledConversionPairs {
|
|
if pair.Denom == denom {
|
|
return pair, nil
|
|
}
|
|
}
|
|
|
|
return types.ConversionPair{}, sdkerrors.Wrap(types.ErrConversionNotEnabled, denom)
|
|
}
|