diff --git a/testutil/keeper/fungible.go b/testutil/keeper/fungible.go index 047c9c5eb3..cc7c4d4f4c 100644 --- a/testutil/keeper/fungible.go +++ b/testutil/keeper/fungible.go @@ -8,17 +8,15 @@ import ( "github.com/cosmos/cosmos-sdk/store" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - authkeeper2 "github.com/cosmos/cosmos-sdk/x/auth/keeper" - bankkeeper2 "github.com/cosmos/cosmos-sdk/x/bank/keeper" typesparams "github.com/cosmos/cosmos-sdk/x/params/types" - evmkeeper "github.com/evmos/ethermint/x/evm/keeper" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmdb "github.com/tendermint/tm-db" + + fungiblemocks "github.com/zeta-chain/zetacore/testutil/keeper/mocks/fungible" "github.com/zeta-chain/zetacore/x/fungible/keeper" "github.com/zeta-chain/zetacore/x/fungible/types" - zetaObserverModuleKeeper "github.com/zeta-chain/zetacore/x/observer/keeper" ) func FungibleKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { @@ -41,21 +39,23 @@ func FungibleKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { "FungibleParams", ) - bankkeeper := bankkeeper2.BaseKeeper{} - authkeeper := authkeeper2.AccountKeeper{} - evmKeeper := &evmkeeper.Keeper{} - zetaObserverKeeper := zetaObserverModuleKeeper.Keeper{} - keeper := keeper.NewKeeper( + // Initialize mocks from expected keeper interfaces + bankKeeper := fungiblemocks.NewFungibleBankKeeper(t) + authKeeper := fungiblemocks.NewFungibleAccountKeeper(t) + observerKeeper := fungiblemocks.NewFungibleObserverKeeper(t) + evmKeeper := fungiblemocks.NewFungibleEVMKeeper(t) + + k := keeper.NewKeeper( codec.NewProtoCodec(registry), storeKey, memStoreKey, paramsSubspace, - authkeeper, + authKeeper, evmKeeper, - bankkeeper, - zetaObserverKeeper, + bankKeeper, + observerKeeper, ) ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) - return keeper, ctx + return k, ctx } diff --git a/testutil/keeper/mocks.go b/testutil/keeper/mocks.go new file mode 100644 index 0000000000..96bdaa71dd --- /dev/null +++ b/testutil/keeper/mocks.go @@ -0,0 +1,25 @@ +package keeper + +import ( + fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" +) + +//go:generate mockery --name FungibleAccountKeeper --filename account.go --case underscore --output ./mocks/fungible +type FungibleAccountKeeper interface { + fungibletypes.AccountKeeper +} + +//go:generate mockery --name FungibleBankKeeper --filename fungible.go --case underscore --output ./mocks/fungible +type FungibleBankKeeper interface { + fungibletypes.BankKeeper +} + +//go:generate mockery --name FungibleObserverKeeper --filename observer.go --case underscore --output ./mocks/fungible +type FungibleObserverKeeper interface { + fungibletypes.ObserverKeeper +} + +//go:generate mockery --name FungibleEVMKeeper --filename evm.go --case underscore --output ./mocks/fungible +type FungibleEVMKeeper interface { + fungibletypes.EVMKeeper +} diff --git a/testutil/keeper/mocks/fungible/account.go b/testutil/keeper/mocks/fungible/account.go new file mode 100644 index 0000000000..da987d7db2 --- /dev/null +++ b/testutil/keeper/mocks/fungible/account.go @@ -0,0 +1,86 @@ +// Code generated by mockery v2.32.3. DO NOT EDIT. + +package mocks + +import ( + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + + mock "github.com/stretchr/testify/mock" + + types "github.com/cosmos/cosmos-sdk/types" +) + +// FungibleAccountKeeper is an autogenerated mock type for the FungibleAccountKeeper type +type FungibleAccountKeeper struct { + mock.Mock +} + +// GetAccount provides a mock function with given fields: ctx, addr +func (_m *FungibleAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) authtypes.AccountI { + ret := _m.Called(ctx, addr) + + var r0 authtypes.AccountI + if rf, ok := ret.Get(0).(func(types.Context, types.AccAddress) authtypes.AccountI); ok { + r0 = rf(ctx, addr) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(authtypes.AccountI) + } + } + + return r0 +} + +// GetModuleAccount provides a mock function with given fields: ctx, name +func (_m *FungibleAccountKeeper) GetModuleAccount(ctx types.Context, name string) authtypes.ModuleAccountI { + ret := _m.Called(ctx, name) + + var r0 authtypes.ModuleAccountI + if rf, ok := ret.Get(0).(func(types.Context, string) authtypes.ModuleAccountI); ok { + r0 = rf(ctx, name) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(authtypes.ModuleAccountI) + } + } + + return r0 +} + +// GetSequence provides a mock function with given fields: ctx, addr +func (_m *FungibleAccountKeeper) GetSequence(ctx types.Context, addr types.AccAddress) (uint64, error) { + ret := _m.Called(ctx, addr) + + var r0 uint64 + var r1 error + if rf, ok := ret.Get(0).(func(types.Context, types.AccAddress) (uint64, error)); ok { + return rf(ctx, addr) + } + if rf, ok := ret.Get(0).(func(types.Context, types.AccAddress) uint64); ok { + r0 = rf(ctx, addr) + } else { + r0 = ret.Get(0).(uint64) + } + + if rf, ok := ret.Get(1).(func(types.Context, types.AccAddress) error); ok { + r1 = rf(ctx, addr) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// NewFungibleAccountKeeper creates a new instance of FungibleAccountKeeper. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewFungibleAccountKeeper(t interface { + mock.TestingT + Cleanup(func()) +}) *FungibleAccountKeeper { + mock := &FungibleAccountKeeper{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/testutil/keeper/mocks/fungible/evm.go b/testutil/keeper/mocks/fungible/evm.go new file mode 100644 index 0000000000..e05034a958 --- /dev/null +++ b/testutil/keeper/mocks/fungible/evm.go @@ -0,0 +1,150 @@ +// Code generated by mockery v2.32.3. DO NOT EDIT. + +package mocks + +import ( + context "context" + big "math/big" + + core "github.com/ethereum/go-ethereum/core" + + evmtypes "github.com/evmos/ethermint/x/evm/types" + + mock "github.com/stretchr/testify/mock" + + types "github.com/cosmos/cosmos-sdk/types" + + vm "github.com/ethereum/go-ethereum/core/vm" +) + +// FungibleEVMKeeper is an autogenerated mock type for the FungibleEVMKeeper type +type FungibleEVMKeeper struct { + mock.Mock +} + +// ApplyMessage provides a mock function with given fields: ctx, msg, tracer, commit +func (_m *FungibleEVMKeeper) ApplyMessage(ctx types.Context, msg core.Message, tracer vm.EVMLogger, commit bool) (*evmtypes.MsgEthereumTxResponse, error) { + ret := _m.Called(ctx, msg, tracer, commit) + + var r0 *evmtypes.MsgEthereumTxResponse + var r1 error + if rf, ok := ret.Get(0).(func(types.Context, core.Message, vm.EVMLogger, bool) (*evmtypes.MsgEthereumTxResponse, error)); ok { + return rf(ctx, msg, tracer, commit) + } + if rf, ok := ret.Get(0).(func(types.Context, core.Message, vm.EVMLogger, bool) *evmtypes.MsgEthereumTxResponse); ok { + r0 = rf(ctx, msg, tracer, commit) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*evmtypes.MsgEthereumTxResponse) + } + } + + if rf, ok := ret.Get(1).(func(types.Context, core.Message, vm.EVMLogger, bool) error); ok { + r1 = rf(ctx, msg, tracer, commit) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// ChainID provides a mock function with given fields: +func (_m *FungibleEVMKeeper) ChainID() *big.Int { + ret := _m.Called() + + var r0 *big.Int + if rf, ok := ret.Get(0).(func() *big.Int); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*big.Int) + } + } + + return r0 +} + +// EstimateGas provides a mock function with given fields: c, req +func (_m *FungibleEVMKeeper) EstimateGas(c context.Context, req *evmtypes.EthCallRequest) (*evmtypes.EstimateGasResponse, error) { + ret := _m.Called(c, req) + + var r0 *evmtypes.EstimateGasResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *evmtypes.EthCallRequest) (*evmtypes.EstimateGasResponse, error)); ok { + return rf(c, req) + } + if rf, ok := ret.Get(0).(func(context.Context, *evmtypes.EthCallRequest) *evmtypes.EstimateGasResponse); ok { + r0 = rf(c, req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*evmtypes.EstimateGasResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *evmtypes.EthCallRequest) error); ok { + r1 = rf(c, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetBlockBloomTransient provides a mock function with given fields: ctx +func (_m *FungibleEVMKeeper) GetBlockBloomTransient(ctx types.Context) *big.Int { + ret := _m.Called(ctx) + + var r0 *big.Int + if rf, ok := ret.Get(0).(func(types.Context) *big.Int); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*big.Int) + } + } + + return r0 +} + +// GetLogSizeTransient provides a mock function with given fields: ctx +func (_m *FungibleEVMKeeper) GetLogSizeTransient(ctx types.Context) uint64 { + ret := _m.Called(ctx) + + var r0 uint64 + if rf, ok := ret.Get(0).(func(types.Context) uint64); ok { + r0 = rf(ctx) + } else { + r0 = ret.Get(0).(uint64) + } + + return r0 +} + +// SetBlockBloomTransient provides a mock function with given fields: ctx, bloom +func (_m *FungibleEVMKeeper) SetBlockBloomTransient(ctx types.Context, bloom *big.Int) { + _m.Called(ctx, bloom) +} + +// SetLogSizeTransient provides a mock function with given fields: ctx, logSize +func (_m *FungibleEVMKeeper) SetLogSizeTransient(ctx types.Context, logSize uint64) { + _m.Called(ctx, logSize) +} + +// WithChainID provides a mock function with given fields: ctx +func (_m *FungibleEVMKeeper) WithChainID(ctx types.Context) { + _m.Called(ctx) +} + +// NewFungibleEVMKeeper creates a new instance of FungibleEVMKeeper. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewFungibleEVMKeeper(t interface { + mock.TestingT + Cleanup(func()) +}) *FungibleEVMKeeper { + mock := &FungibleEVMKeeper{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/testutil/keeper/mocks/fungible/fungible.go b/testutil/keeper/mocks/fungible/fungible.go new file mode 100644 index 0000000000..dbbb384d3e --- /dev/null +++ b/testutil/keeper/mocks/fungible/fungible.go @@ -0,0 +1,171 @@ +// Code generated by mockery v2.32.3. DO NOT EDIT. + +package mocks + +import ( + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + + mock "github.com/stretchr/testify/mock" + + types "github.com/cosmos/cosmos-sdk/types" +) + +// FungibleBankKeeper is an autogenerated mock type for the FungibleBankKeeper type +type FungibleBankKeeper struct { + mock.Mock +} + +// BlockedAddr provides a mock function with given fields: addr +func (_m *FungibleBankKeeper) BlockedAddr(addr types.AccAddress) bool { + ret := _m.Called(addr) + + var r0 bool + if rf, ok := ret.Get(0).(func(types.AccAddress) bool); ok { + r0 = rf(addr) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// BurnCoins provides a mock function with given fields: ctx, moduleName, amt +func (_m *FungibleBankKeeper) BurnCoins(ctx types.Context, moduleName string, amt types.Coins) error { + ret := _m.Called(ctx, moduleName, amt) + + var r0 error + if rf, ok := ret.Get(0).(func(types.Context, string, types.Coins) error); ok { + r0 = rf(ctx, moduleName, amt) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// GetBalance provides a mock function with given fields: ctx, addr, denom +func (_m *FungibleBankKeeper) GetBalance(ctx types.Context, addr types.AccAddress, denom string) types.Coin { + ret := _m.Called(ctx, addr, denom) + + var r0 types.Coin + if rf, ok := ret.Get(0).(func(types.Context, types.AccAddress, string) types.Coin); ok { + r0 = rf(ctx, addr, denom) + } else { + r0 = ret.Get(0).(types.Coin) + } + + return r0 +} + +// GetDenomMetaData provides a mock function with given fields: ctx, denom +func (_m *FungibleBankKeeper) GetDenomMetaData(ctx types.Context, denom string) (banktypes.Metadata, bool) { + ret := _m.Called(ctx, denom) + + var r0 banktypes.Metadata + var r1 bool + if rf, ok := ret.Get(0).(func(types.Context, string) (banktypes.Metadata, bool)); ok { + return rf(ctx, denom) + } + if rf, ok := ret.Get(0).(func(types.Context, string) banktypes.Metadata); ok { + r0 = rf(ctx, denom) + } else { + r0 = ret.Get(0).(banktypes.Metadata) + } + + if rf, ok := ret.Get(1).(func(types.Context, string) bool); ok { + r1 = rf(ctx, denom) + } else { + r1 = ret.Get(1).(bool) + } + + return r0, r1 +} + +// HasSupply provides a mock function with given fields: ctx, denom +func (_m *FungibleBankKeeper) HasSupply(ctx types.Context, denom string) bool { + ret := _m.Called(ctx, denom) + + var r0 bool + if rf, ok := ret.Get(0).(func(types.Context, string) bool); ok { + r0 = rf(ctx, denom) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// IsSendEnabledCoin provides a mock function with given fields: ctx, coin +func (_m *FungibleBankKeeper) IsSendEnabledCoin(ctx types.Context, coin types.Coin) bool { + ret := _m.Called(ctx, coin) + + var r0 bool + if rf, ok := ret.Get(0).(func(types.Context, types.Coin) bool); ok { + r0 = rf(ctx, coin) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// MintCoins provides a mock function with given fields: ctx, moduleName, amt +func (_m *FungibleBankKeeper) MintCoins(ctx types.Context, moduleName string, amt types.Coins) error { + ret := _m.Called(ctx, moduleName, amt) + + var r0 error + if rf, ok := ret.Get(0).(func(types.Context, string, types.Coins) error); ok { + r0 = rf(ctx, moduleName, amt) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SendCoinsFromAccountToModule provides a mock function with given fields: ctx, senderAddr, recipientModule, amt +func (_m *FungibleBankKeeper) SendCoinsFromAccountToModule(ctx types.Context, senderAddr types.AccAddress, recipientModule string, amt types.Coins) error { + ret := _m.Called(ctx, senderAddr, recipientModule, amt) + + var r0 error + if rf, ok := ret.Get(0).(func(types.Context, types.AccAddress, string, types.Coins) error); ok { + r0 = rf(ctx, senderAddr, recipientModule, amt) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SendCoinsFromModuleToAccount provides a mock function with given fields: ctx, senderModule, recipientAddr, amt +func (_m *FungibleBankKeeper) SendCoinsFromModuleToAccount(ctx types.Context, senderModule string, recipientAddr types.AccAddress, amt types.Coins) error { + ret := _m.Called(ctx, senderModule, recipientAddr, amt) + + var r0 error + if rf, ok := ret.Get(0).(func(types.Context, string, types.AccAddress, types.Coins) error); ok { + r0 = rf(ctx, senderModule, recipientAddr, amt) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SetDenomMetaData provides a mock function with given fields: ctx, denomMetaData +func (_m *FungibleBankKeeper) SetDenomMetaData(ctx types.Context, denomMetaData banktypes.Metadata) { + _m.Called(ctx, denomMetaData) +} + +// NewFungibleBankKeeper creates a new instance of FungibleBankKeeper. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewFungibleBankKeeper(t interface { + mock.TestingT + Cleanup(func()) +}) *FungibleBankKeeper { + mock := &FungibleBankKeeper{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/testutil/keeper/mocks/fungible/observer.go b/testutil/keeper/mocks/fungible/observer.go new file mode 100644 index 0000000000..7d8248a6ae --- /dev/null +++ b/testutil/keeper/mocks/fungible/observer.go @@ -0,0 +1,162 @@ +// Code generated by mockery v2.32.3. DO NOT EDIT. + +package mocks + +import ( + common "github.com/zeta-chain/zetacore/common" + + mock "github.com/stretchr/testify/mock" + + observertypes "github.com/zeta-chain/zetacore/x/observer/types" + + types "github.com/cosmos/cosmos-sdk/types" +) + +// FungibleObserverKeeper is an autogenerated mock type for the FungibleObserverKeeper type +type FungibleObserverKeeper struct { + mock.Mock +} + +// GetAllBallots provides a mock function with given fields: ctx +func (_m *FungibleObserverKeeper) GetAllBallots(ctx types.Context) []*observertypes.Ballot { + ret := _m.Called(ctx) + + var r0 []*observertypes.Ballot + if rf, ok := ret.Get(0).(func(types.Context) []*observertypes.Ballot); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*observertypes.Ballot) + } + } + + return r0 +} + +// GetAllObserverMappers provides a mock function with given fields: ctx +func (_m *FungibleObserverKeeper) GetAllObserverMappers(ctx types.Context) []*observertypes.ObserverMapper { + ret := _m.Called(ctx) + + var r0 []*observertypes.ObserverMapper + if rf, ok := ret.Get(0).(func(types.Context) []*observertypes.ObserverMapper); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*observertypes.ObserverMapper) + } + } + + return r0 +} + +// GetBallot provides a mock function with given fields: ctx, index +func (_m *FungibleObserverKeeper) GetBallot(ctx types.Context, index string) (observertypes.Ballot, bool) { + ret := _m.Called(ctx, index) + + var r0 observertypes.Ballot + var r1 bool + if rf, ok := ret.Get(0).(func(types.Context, string) (observertypes.Ballot, bool)); ok { + return rf(ctx, index) + } + if rf, ok := ret.Get(0).(func(types.Context, string) observertypes.Ballot); ok { + r0 = rf(ctx, index) + } else { + r0 = ret.Get(0).(observertypes.Ballot) + } + + if rf, ok := ret.Get(1).(func(types.Context, string) bool); ok { + r1 = rf(ctx, index) + } else { + r1 = ret.Get(1).(bool) + } + + return r0, r1 +} + +// GetCoreParamsByChainID provides a mock function with given fields: ctx, chainID +func (_m *FungibleObserverKeeper) GetCoreParamsByChainID(ctx types.Context, chainID int64) (*observertypes.CoreParams, bool) { + ret := _m.Called(ctx, chainID) + + var r0 *observertypes.CoreParams + var r1 bool + if rf, ok := ret.Get(0).(func(types.Context, int64) (*observertypes.CoreParams, bool)); ok { + return rf(ctx, chainID) + } + if rf, ok := ret.Get(0).(func(types.Context, int64) *observertypes.CoreParams); ok { + r0 = rf(ctx, chainID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*observertypes.CoreParams) + } + } + + if rf, ok := ret.Get(1).(func(types.Context, int64) bool); ok { + r1 = rf(ctx, chainID) + } else { + r1 = ret.Get(1).(bool) + } + + return r0, r1 +} + +// GetObserverMapper provides a mock function with given fields: ctx, chain +func (_m *FungibleObserverKeeper) GetObserverMapper(ctx types.Context, chain *common.Chain) (observertypes.ObserverMapper, bool) { + ret := _m.Called(ctx, chain) + + var r0 observertypes.ObserverMapper + var r1 bool + if rf, ok := ret.Get(0).(func(types.Context, *common.Chain) (observertypes.ObserverMapper, bool)); ok { + return rf(ctx, chain) + } + if rf, ok := ret.Get(0).(func(types.Context, *common.Chain) observertypes.ObserverMapper); ok { + r0 = rf(ctx, chain) + } else { + r0 = ret.Get(0).(observertypes.ObserverMapper) + } + + if rf, ok := ret.Get(1).(func(types.Context, *common.Chain) bool); ok { + r1 = rf(ctx, chain) + } else { + r1 = ret.Get(1).(bool) + } + + return r0, r1 +} + +// GetParams provides a mock function with given fields: ctx +func (_m *FungibleObserverKeeper) GetParams(ctx types.Context) observertypes.Params { + ret := _m.Called(ctx) + + var r0 observertypes.Params + if rf, ok := ret.Get(0).(func(types.Context) observertypes.Params); ok { + r0 = rf(ctx) + } else { + r0 = ret.Get(0).(observertypes.Params) + } + + return r0 +} + +// SetBallot provides a mock function with given fields: ctx, ballot +func (_m *FungibleObserverKeeper) SetBallot(ctx types.Context, ballot *observertypes.Ballot) { + _m.Called(ctx, ballot) +} + +// SetObserverMapper provides a mock function with given fields: ctx, om +func (_m *FungibleObserverKeeper) SetObserverMapper(ctx types.Context, om *observertypes.ObserverMapper) { + _m.Called(ctx, om) +} + +// NewFungibleObserverKeeper creates a new instance of FungibleObserverKeeper. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewFungibleObserverKeeper(t interface { + mock.TestingT + Cleanup(func()) +}) *FungibleObserverKeeper { + mock := &FungibleObserverKeeper{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/x/fungible/keeper/begin_blocker_deploy_system_contracts_privnet.go b/x/fungible/keeper/begin_blocker_deploy_system_contracts_privnet.go index 361ea09926..f11aaddf89 100644 --- a/x/fungible/keeper/begin_blocker_deploy_system_contracts_privnet.go +++ b/x/fungible/keeper/begin_blocker_deploy_system_contracts_privnet.go @@ -130,7 +130,7 @@ func (k Keeper) TestUpdateSystemContractAddress(goCtx context.Context) error { if err != nil { return sdkerrors.Wrapf(err, "failed to DeploySystemContract") } - creator := k.zetaobserverKeeper.GetParams(ctx).GetAdminPolicyAccount(observertypes.Policy_Type_deploy_fungible_coin) + creator := k.observerKeeper.GetParams(ctx).GetAdminPolicyAccount(observertypes.Policy_Type_deploy_fungible_coin) msg := types.NewMessageUpdateSystemContract(creator, SystemContractAddress.Hex()) _, err = k.UpdateSystemContract(ctx, msg) return err @@ -140,7 +140,7 @@ func (k Keeper) TestUpdateZRC20WithdrawFee(goCtx context.Context) error { ctx := sdk.UnwrapSDKContext(goCtx) foreignCoins := k.GetAllForeignCoins(ctx) - creator := k.zetaobserverKeeper.GetParams(ctx).GetAdminPolicyAccount(observertypes.Policy_Type_deploy_fungible_coin) + creator := k.observerKeeper.GetParams(ctx).GetAdminPolicyAccount(observertypes.Policy_Type_deploy_fungible_coin) for _, foreignCoin := range foreignCoins { msg := types.NewMsgUpdateZRC20WithdrawFee(creator, foreignCoin.Zrc20ContractAddress, sdk.NewUint(uint64(foreignCoin.ForeignChainId))) diff --git a/x/fungible/keeper/evm.go b/x/fungible/keeper/evm.go index 1ff2af09ba..30e0c2cb0b 100644 --- a/x/fungible/keeper/evm.go +++ b/x/fungible/keeper/evm.go @@ -54,7 +54,7 @@ func (k Keeper) DeployZRC20Contract( gasLimit *big.Int, ) (common.Address, error) { chainName := zetacommon.ParseChainName(chainStr) - chain := k.zetaobserverKeeper.GetParams(ctx).GetChainFromChainName(chainName) + chain := k.observerKeeper.GetParams(ctx).GetChainFromChainName(chainName) if chain == nil { return common.Address{}, sdkerrors.Wrapf(zetaObserverTypes.ErrSupportedChains, "chain %s not found", chainStr) } diff --git a/x/fungible/keeper/gas_coin_and_pool.go b/x/fungible/keeper/gas_coin_and_pool.go index 2c629352a7..9d84cf73de 100644 --- a/x/fungible/keeper/gas_coin_and_pool.go +++ b/x/fungible/keeper/gas_coin_and_pool.go @@ -21,7 +21,7 @@ import ( func (k Keeper) setupChainGasCoinAndPool(ctx sdk.Context, c string, gasAssetName string, symbol string, decimals uint8) (ethcommon.Address, error) { name := fmt.Sprintf("%s-%s", gasAssetName, c) chainName := common.ParseChainName(c) - chain := k.zetaobserverKeeper.GetParams(ctx).GetChainFromChainName(chainName) + chain := k.observerKeeper.GetParams(ctx).GetChainFromChainName(chainName) if chain == nil { return ethcommon.Address{}, zetaObserverTypes.ErrSupportedChains } diff --git a/x/fungible/keeper/keeper.go b/x/fungible/keeper/keeper.go index bb1b75664a..99fc899c10 100644 --- a/x/fungible/keeper/keeper.go +++ b/x/fungible/keeper/keeper.go @@ -14,14 +14,14 @@ import ( type ( Keeper struct { - cdc codec.BinaryCodec - storeKey storetypes.StoreKey - memKey storetypes.StoreKey - paramstore paramtypes.Subspace - authKeeper types.AccountKeeper - evmKeeper types.EVMKeeper - bankKeeper types.BankKeeper - zetaobserverKeeper types.ZetaObserverKeeper + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + memKey storetypes.StoreKey + paramstore paramtypes.Subspace + authKeeper types.AccountKeeper + evmKeeper types.EVMKeeper + bankKeeper types.BankKeeper + observerKeeper types.ObserverKeeper } ) @@ -33,7 +33,7 @@ func NewKeeper( authKeeper types.AccountKeeper, evmKeeper types.EVMKeeper, bankKeeper types.BankKeeper, - zetacobservKeeper types.ZetaObserverKeeper, + observerKeeper types.ObserverKeeper, ) *Keeper { // set KeyTable if it has not already been set if !ps.HasKeyTable() { @@ -41,14 +41,14 @@ func NewKeeper( } return &Keeper{ - cdc: cdc, - storeKey: storeKey, - memKey: memKey, - paramstore: ps, - authKeeper: authKeeper, - evmKeeper: evmKeeper, - bankKeeper: bankKeeper, - zetaobserverKeeper: zetacobservKeeper, + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + paramstore: ps, + authKeeper: authKeeper, + evmKeeper: evmKeeper, + bankKeeper: bankKeeper, + observerKeeper: observerKeeper, } } diff --git a/x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20.go b/x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20.go index fcf5c5a1f8..d44b71afc4 100644 --- a/x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20.go +++ b/x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20.go @@ -31,7 +31,7 @@ import ( // Only the admin policy account is authorized to broadcast this message. func (k msgServer) DeployFungibleCoinZRC20(goCtx context.Context, msg *types.MsgDeployFungibleCoinZRC20) (*types.MsgDeployFungibleCoinZRC20Response, error) { ctx := sdk.UnwrapSDKContext(goCtx) - if msg.Creator != k.zetaobserverKeeper.GetParams(ctx).GetAdminPolicyAccount(zetaObserverTypes.Policy_Type_deploy_fungible_coin) { + if msg.Creator != k.observerKeeper.GetParams(ctx).GetAdminPolicyAccount(zetaObserverTypes.Policy_Type_deploy_fungible_coin) { return nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Deploy can only be executed by the correct policy account") } if msg.Decimals > 255 { diff --git a/x/fungible/keeper/msg_server_remove_foreign_coin.go b/x/fungible/keeper/msg_server_remove_foreign_coin.go index 995bcb6705..0a9dc3b7b6 100644 --- a/x/fungible/keeper/msg_server_remove_foreign_coin.go +++ b/x/fungible/keeper/msg_server_remove_foreign_coin.go @@ -14,7 +14,7 @@ import ( // Only the admin policy account is authorized to broadcast this message. func (k msgServer) RemoveForeignCoin(goCtx context.Context, msg *types.MsgRemoveForeignCoin) (*types.MsgRemoveForeignCoinResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - if msg.Creator != k.zetaobserverKeeper.GetParams(ctx).GetAdminPolicyAccount(zetaObserverTypes.Policy_Type_deploy_fungible_coin) { + if msg.Creator != k.observerKeeper.GetParams(ctx).GetAdminPolicyAccount(zetaObserverTypes.Policy_Type_deploy_fungible_coin) { return nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Removal can only be executed by the correct policy account") } index := msg.Name diff --git a/x/fungible/keeper/msg_server_update_system_contract.go b/x/fungible/keeper/msg_server_update_system_contract.go index a586819d2e..d88a52c554 100644 --- a/x/fungible/keeper/msg_server_update_system_contract.go +++ b/x/fungible/keeper/msg_server_update_system_contract.go @@ -16,7 +16,7 @@ import ( func (k Keeper) UpdateSystemContract(goCtx context.Context, msg *types.MsgUpdateSystemContract) (*types.MsgUpdateSystemContractResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - if msg.Creator != k.zetaobserverKeeper.GetParams(ctx).GetAdminPolicyAccount(zetaObserverTypes.Policy_Type_deploy_fungible_coin) { + if msg.Creator != k.observerKeeper.GetParams(ctx).GetAdminPolicyAccount(zetaObserverTypes.Policy_Type_deploy_fungible_coin) { return nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Deploy can only be executed by the correct policy account") } newSystemContractAddr := ethcommon.HexToAddress(msg.NewSystemContractAddress) diff --git a/x/fungible/keeper/msg_server_update_zrc20_withdraw_fee.go b/x/fungible/keeper/msg_server_update_zrc20_withdraw_fee.go index 0d85cb917a..8bb7fa4181 100644 --- a/x/fungible/keeper/msg_server_update_zrc20_withdraw_fee.go +++ b/x/fungible/keeper/msg_server_update_zrc20_withdraw_fee.go @@ -14,7 +14,7 @@ import ( func (k Keeper) UpdateZRC20WithdrawFee(goCtx context.Context, msg *types.MsgUpdateZRC20WithdrawFee) (*types.MsgUpdateZRC20WithdrawFeeResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - if msg.Creator != k.zetaobserverKeeper.GetParams(ctx).GetAdminPolicyAccount(zetaObserverTypes.Policy_Type_deploy_fungible_coin) { + if msg.Creator != k.observerKeeper.GetParams(ctx).GetAdminPolicyAccount(zetaObserverTypes.Policy_Type_deploy_fungible_coin) { return nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Deploy can only be executed by the correct policy account") } zrc20Addr := ethcommon.HexToAddress(msg.Zrc20Address) diff --git a/x/fungible/types/expected_keepers.go b/x/fungible/types/expected_keepers.go index a5bac6ea0a..5b9785041d 100644 --- a/x/fungible/types/expected_keepers.go +++ b/x/fungible/types/expected_keepers.go @@ -12,7 +12,7 @@ import ( evmtypes "github.com/evmos/ethermint/x/evm/types" "github.com/zeta-chain/zetacore/common" - zetaObserverTypes "github.com/zeta-chain/zetacore/x/observer/types" + observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) // AccountKeeper defines the expected account keeper used for simulations (noalias) @@ -35,15 +35,15 @@ type BankKeeper interface { GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin } -type ZetaObserverKeeper interface { - SetObserverMapper(ctx sdk.Context, om *zetaObserverTypes.ObserverMapper) - GetObserverMapper(ctx sdk.Context, chain *common.Chain) (val zetaObserverTypes.ObserverMapper, found bool) - GetAllObserverMappers(ctx sdk.Context) (mappers []*zetaObserverTypes.ObserverMapper) - SetBallot(ctx sdk.Context, ballot *zetaObserverTypes.Ballot) - GetBallot(ctx sdk.Context, index string) (val zetaObserverTypes.Ballot, found bool) - GetAllBallots(ctx sdk.Context) (voters []*zetaObserverTypes.Ballot) - GetParams(ctx sdk.Context) (params zetaObserverTypes.Params) - GetCoreParamsByChainID(ctx sdk.Context, chainID int64) (params *zetaObserverTypes.CoreParams, found bool) +type ObserverKeeper interface { + SetObserverMapper(ctx sdk.Context, om *observertypes.ObserverMapper) + GetObserverMapper(ctx sdk.Context, chain *common.Chain) (val observertypes.ObserverMapper, found bool) + GetAllObserverMappers(ctx sdk.Context) (mappers []*observertypes.ObserverMapper) + SetBallot(ctx sdk.Context, ballot *observertypes.Ballot) + GetBallot(ctx sdk.Context, index string) (val observertypes.Ballot, found bool) + GetAllBallots(ctx sdk.Context) (voters []*observertypes.Ballot) + GetParams(ctx sdk.Context) (params observertypes.Params) + GetCoreParamsByChainID(ctx sdk.Context, chainID int64) (params *observertypes.CoreParams, found bool) } type EVMKeeper interface {