0g-chain/migrate/v0_17/kava.go
Derrick Lee f6c55b7015
Add bridge migration (#1214)
* Add bridge migration

* Use NewGenesisState method

* Update migrations with new params

* Use nil for relayer instead of empty address

Both are still valid
2022-04-22 09:22:20 -07:00

58 lines
1.9 KiB
Go

package v0_17
import (
"github.com/cosmos/cosmos-sdk/client"
sdk "github.com/cosmos/cosmos-sdk/types"
authz "github.com/cosmos/cosmos-sdk/x/authz"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
evmtypes "github.com/tharsis/ethermint/x/evm/types"
feemarkettypes "github.com/tharsis/ethermint/x/feemarket/types"
evmutiltypes "github.com/kava-labs/kava/x/evmutil/types"
bridgetypes "github.com/kava-labs/kava-bridge/x/bridge/types"
)
func migrateAppState(appState genutiltypes.AppMap, clientCtx client.Context) {
codec := clientCtx.Codec
// x/emvutil
evmUtilGenState := evmutiltypes.NewGenesisState([]evmutiltypes.Account{})
appState[evmutiltypes.ModuleName] = codec.MustMarshalJSON(evmUtilGenState)
// x/evm
evmGenState := &evmtypes.GenesisState{
Accounts: []evmtypes.GenesisAccount{},
Params: evmtypes.Params{
EvmDenom: "akava",
EnableCreate: true,
EnableCall: true,
ChainConfig: evmtypes.DefaultChainConfig(),
ExtraEIPs: nil,
},
}
appState[evmtypes.ModuleName] = codec.MustMarshalJSON(evmGenState)
// x/bridge
bridgeGenState := bridgetypes.NewGenesisState(
bridgetypes.NewParams(
false, // Bridge disabled
bridgetypes.EnabledERC20Tokens{}, // No bridge ERC20 tokens
nil, // No relayer
bridgetypes.ConversionPairs{}, // No conversion pairs
),
bridgetypes.ERC20BridgePairs{}, // Empty state as there has been no ERC20 contracts deployed
sdk.OneInt(), // NextWithdrawSequence starts at 1
)
appState[bridgetypes.ModuleName] = codec.MustMarshalJSON(&bridgeGenState)
// x/feemarket
feemarketState := feemarkettypes.DefaultGenesisState()
appState[feemarkettypes.ModuleName] = codec.MustMarshalJSON(feemarketState)
// x/authz
authzState := authz.DefaultGenesisState()
appState[authz.ModuleName] = codec.MustMarshalJSON(authzState)
}