diff --git a/app/app.go b/app/app.go index d6d58cb6d..345a43817 100644 --- a/app/app.go +++ b/app/app.go @@ -310,7 +310,6 @@ func NewAxelarApp( *GetKeeper[axelarnetKeeper.IBCKeeper](keepers), GetKeeper[nexusKeeper.Keeper](keepers), axelarbankkeeper.NewBankKeeper(GetKeeper[bankkeeper.BaseKeeper](keepers)), - GetKeeper[authkeeper.AccountKeeper](keepers), logger, ), ) @@ -446,12 +445,10 @@ func initMessageRouter(keepers *KeeperCache) nexusTypes.MessageRouter { messageRouter := nexusTypes.NewMessageRouter(). AddRoute(evmTypes.ModuleName, evmKeeper.NewMessageRoute()). AddRoute(axelarnetTypes.ModuleName, axelarnetKeeper.NewMessageRoute( - *GetKeeper[axelarnetKeeper.Keeper](keepers), GetKeeper[axelarnetKeeper.IBCKeeper](keepers), GetKeeper[feegrantkeeper.Keeper](keepers), axelarbankkeeper.NewBankKeeper(GetKeeper[bankkeeper.BaseKeeper](keepers)), GetKeeper[nexusKeeper.Keeper](keepers), - GetKeeper[authkeeper.AccountKeeper](keepers), GetKeeper[stakingkeeper.Keeper](keepers), )) diff --git a/x/axelarnet/handler.go b/x/axelarnet/handler.go index 2f9703862..16cc0f5cb 100644 --- a/x/axelarnet/handler.go +++ b/x/axelarnet/handler.go @@ -20,8 +20,8 @@ import ( ) // NewHandler returns the handler of the Cosmos module -func NewHandler(k keeper.Keeper, n types.Nexus, b types.BankKeeper, a types.AccountKeeper, ibcK keeper.IBCKeeper) sdk.Handler { - server := keeper.NewMsgServerImpl(k, n, b, a, ibcK) +func NewHandler(k keeper.Keeper, n types.Nexus, b types.BankKeeper, ibcK keeper.IBCKeeper) sdk.Handler { + server := keeper.NewMsgServerImpl(k, n, b, ibcK) h := func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { ctx = ctx.WithEventManager(sdk.NewEventManager()) switch msg := msg.(type) { diff --git a/x/axelarnet/keeper/coin.go b/x/axelarnet/keeper/coin.go deleted file mode 100644 index 3c163cadf..000000000 --- a/x/axelarnet/keeper/coin.go +++ /dev/null @@ -1,185 +0,0 @@ -package keeper - -import ( - "fmt" - "strings" - - sdk "github.com/cosmos/cosmos-sdk/types" - ibctypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types" - - "github.com/axelarnetwork/axelar-core/x/axelarnet/exported" - "github.com/axelarnetwork/axelar-core/x/axelarnet/types" - "github.com/axelarnetwork/utils/funcs" -) - -// Coin provides functionality to lock and release coins -type Coin struct { - sdk.Coin - ctx sdk.Context - ibcK IBCKeeper - nexusK types.Nexus - coinType types.CoinType -} - -// NewCoin creates a coin struct, assign a coin type and normalize the denom if it's a ICS20 token -func NewCoin(ctx sdk.Context, ibcK IBCKeeper, nexusK types.Nexus, c sdk.Coin) (Coin, error) { - ct, err := getCoinType(ctx, nexusK, c.Denom) - if err != nil { - return Coin{}, err - } - - c2 := Coin{ - Coin: c, - ctx: ctx, - ibcK: ibcK, - nexusK: nexusK, - coinType: ct, - } - err = c2.normalizeDenom() - - return c2, err -} - -// Lock locks coin from deposit address to escrow address -func (c Coin) Lock(bankK types.BankKeeper, depositAddr sdk.AccAddress) error { - switch c.coinType { - case types.ICS20: - // convert to IBC denom - ics20, err := c.toICS20() - if err != nil { - return err - } - - if bankK.SpendableBalance(c.ctx, depositAddr, ics20.GetDenom()).IsLT(ics20) { - return fmt.Errorf("coin %s to lock is greater than account balance", ics20) - } - - // lock tokens in escrow address - escrowAddress := types.GetEscrowAddress(ics20.GetDenom()) - if err := bankK.SendCoins( - c.ctx, depositAddr, escrowAddress, sdk.NewCoins(ics20), - ); err != nil { - return err - } - case types.Native: - // lock tokens in escrow address - escrowAddress := types.GetEscrowAddress(c.GetDenom()) - if err := bankK.SendCoins( - c.ctx, depositAddr, escrowAddress, sdk.NewCoins(c.Coin), - ); err != nil { - return err - } - case types.External: - // transfer coins from linked address to module account and burn them - if err := bankK.SendCoinsFromAccountToModule( - c.ctx, depositAddr, types.ModuleName, sdk.NewCoins(c.Coin), - ); err != nil { - return err - } - - // NOTE: should not happen as the module account was - // retrieved on the step above, and it has enough balance - // to burn. - funcs.MustNoErr(bankK.BurnCoins(c.ctx, types.ModuleName, sdk.NewCoins(c.Coin))) - default: - return fmt.Errorf("unrecognized coin type %d", c.coinType) - } - - return nil -} - -// GetOriginalDenom returns the coin's original denom -func (c Coin) GetOriginalDenom() (string, error) { - if c.coinType != types.ICS20 { - return c.GetDenom(), nil - } - - // convert back to IBC denom 'ibc/{hash}' - coin, err := c.toICS20() - if err != nil { - return "", err - } - - return coin.GetDenom(), err -} - -// normalizeDenom converts from 'ibc/{hash}' to native asset that recognized by nexus module, -// returns error if trace is not found in IBC transfer store -func (c *Coin) normalizeDenom() error { - if !isIBCDenom(c.GetDenom()) || c.coinType != types.ICS20 { - return nil - } - - // get base denomination and tracing path - denomTrace, err := c.ibcK.ParseIBCDenom(c.ctx, c.Denom) - if err != nil { - return err - } - - // convert denomination from 'ibc/{hash}' to native asset that recognized by nexus module - c.Coin = sdk.NewCoin(denomTrace.GetBaseDenom(), c.Amount) - - return nil -} - -// toICS20 creates an ICS20 token from base denom, returns error if the asset is not registered on Axelarnet -func (c Coin) toICS20() (sdk.Coin, error) { - if c.coinType != types.ICS20 { - return sdk.Coin{}, fmt.Errorf("%s is not ICS20 token", c.GetDenom()) - } - - // check if the asset registered with a path - chain, ok := c.nexusK.GetChainByNativeAsset(c.ctx, c.GetDenom()) - if !ok { - return sdk.Coin{}, fmt.Errorf("asset %s is not linked to a cosmos chain", c.GetDenom()) - } - - path, ok := c.ibcK.GetIBCPath(c.ctx, chain.Name) - if !ok { - return sdk.Coin{}, fmt.Errorf("path not found for chain %s", chain.Name) - } - - trace := ibctypes.DenomTrace{ - Path: path, - BaseDenom: c.GetDenom(), - } - - return sdk.NewCoin(trace.IBCDenom(), c.Amount), nil -} - -func getCoinType(ctx sdk.Context, nexusK types.Nexus, denom string) (types.CoinType, error) { - switch { - // check if the format of token denomination is 'ibc/{hash}' - case isIBCDenom(denom): - return types.ICS20, nil - case isNativeAssetOnAxelarnet(ctx, nexusK, denom): - return types.Native, nil - case nexusK.IsAssetRegistered(ctx, exported.Axelarnet, denom): - return types.External, nil - default: - return types.Unrecognized, fmt.Errorf("unrecognized coin %s", denom) - } -} - -// isIBCDenom validates that the given denomination is a valid ICS token representation (ibc/{hash}) -func isIBCDenom(denom string) bool { - if err := sdk.ValidateDenom(denom); err != nil { - return false - } - - denomSplit := strings.SplitN(denom, "/", 2) - if len(denomSplit) != 2 || denomSplit[0] != ibctypes.DenomPrefix { - return false - } - - if _, err := ibctypes.ParseHexHash(denomSplit[1]); err != nil { - return false - } - - return true -} - -func isNativeAssetOnAxelarnet(ctx sdk.Context, n types.Nexus, denom string) bool { - chain, ok := n.GetChainByNativeAsset(ctx, denom) - return ok && chain.Name.Equals(exported.Axelarnet.Name) -} diff --git a/x/axelarnet/keeper/coin_test.go b/x/axelarnet/keeper/coin_test.go index abfa8fc24..f407035b3 100644 --- a/x/axelarnet/keeper/coin_test.go +++ b/x/axelarnet/keeper/coin_test.go @@ -1,149 +1,147 @@ package keeper_test -import ( - "testing" +// import ( +// "testing" +// sdk "github.com/cosmos/cosmos-sdk/types" +// ibctypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types" +// "github.com/stretchr/testify/assert" +// tmbytes "github.com/tendermint/tendermint/libs/bytes" +// "github.com/axelarnetwork/axelar-core/testutils/rand" +// "github.com/axelarnetwork/axelar-core/x/axelarnet/exported" +// "github.com/axelarnetwork/axelar-core/x/axelarnet/keeper" +// "github.com/axelarnetwork/axelar-core/x/axelarnet/types" +// "github.com/axelarnetwork/axelar-core/x/axelarnet/types/mock" +// "github.com/axelarnetwork/axelar-core/x/axelarnet/types/testutils" +// nexus "github.com/axelarnetwork/axelar-core/x/nexus/exported" +// nexustestutils "github.com/axelarnetwork/axelar-core/x/nexus/exported/testutils" +// "github.com/axelarnetwork/utils/funcs" +// . "github.com/axelarnetwork/utils/test" +// ) - sdk "github.com/cosmos/cosmos-sdk/types" - ibctypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types" - "github.com/stretchr/testify/assert" - tmbytes "github.com/tendermint/tendermint/libs/bytes" +// func TestCoin(t *testing.T) { +// var ( +// ctx sdk.Context +// nexusK *mock.NexusMock +// bankK *mock.BankKeeperMock +// transferK *mock.IBCTransferKeeperMock +// ibcK keeper.IBCKeeper +// chain nexus.Chain +// coin keeper.Coin +// trace ibctypes.DenomTrace +// ) - "github.com/axelarnetwork/axelar-core/testutils/rand" - "github.com/axelarnetwork/axelar-core/x/axelarnet/exported" - "github.com/axelarnetwork/axelar-core/x/axelarnet/keeper" - "github.com/axelarnetwork/axelar-core/x/axelarnet/types" - "github.com/axelarnetwork/axelar-core/x/axelarnet/types/mock" - "github.com/axelarnetwork/axelar-core/x/axelarnet/types/testutils" - nexus "github.com/axelarnetwork/axelar-core/x/nexus/exported" - nexustestutils "github.com/axelarnetwork/axelar-core/x/nexus/exported/testutils" - "github.com/axelarnetwork/utils/funcs" - . "github.com/axelarnetwork/utils/test" -) +// givenAKeeper := Given("a keeper", func() { +// ctx2, k, _, _ := setup() +// ctx = ctx2 +// nexusK = &mock.NexusMock{} +// bankK = &mock.BankKeeperMock{} +// transferK = &mock.IBCTransferKeeperMock{} +// ibcK = keeper.NewIBCKeeper(k, transferK) +// bankK.SendCoinsFromAccountToModuleFunc = func(sdk.Context, sdk.AccAddress, string, sdk.Coins) error { +// return nil +// } +// bankK.BurnCoinsFunc = func(sdk.Context, string, sdk.Coins) error { +// return nil +// } +// bankK.SendCoinsFunc = func(sdk.Context, sdk.AccAddress, sdk.AccAddress, sdk.Coins) error { +// return nil +// } +// bankK.SpendableBalanceFunc = func(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin { +// return coin.Coin +// } +// }) -func TestCoin(t *testing.T) { - var ( - ctx sdk.Context - nexusK *mock.NexusMock - bankK *mock.BankKeeperMock - transferK *mock.IBCTransferKeeperMock - ibcK keeper.IBCKeeper - chain nexus.Chain - coin keeper.Coin - trace ibctypes.DenomTrace - ) +// whenCoinIsNative := When("coin is native", func() { +// nexusK.GetChainByNativeAssetFunc = func(sdk.Context, string) (nexus.Chain, bool) { +// return exported.Axelarnet, true +// } +// coin = funcs.Must(keeper.NewCoin(ctx, ibcK, nexusK, sdk.NewCoin(exported.NativeAsset, sdk.NewInt(rand.PosI64())))) +// }) - givenAKeeper := Given("a keeper", func() { - ctx2, k, _, _ := setup() - ctx = ctx2 - nexusK = &mock.NexusMock{} - bankK = &mock.BankKeeperMock{} - transferK = &mock.IBCTransferKeeperMock{} - ibcK = keeper.NewIBCKeeper(k, transferK) - bankK.SendCoinsFromAccountToModuleFunc = func(sdk.Context, sdk.AccAddress, string, sdk.Coins) error { - return nil - } - bankK.BurnCoinsFunc = func(sdk.Context, string, sdk.Coins) error { - return nil - } - bankK.SendCoinsFunc = func(sdk.Context, sdk.AccAddress, sdk.AccAddress, sdk.Coins) error { - return nil - } - bankK.SpendableBalanceFunc = func(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin { - return coin.Coin - } - }) +// whenCoinIsExternal := When("coin is external", func() { +// nexusK.GetChainByNativeAssetFunc = func(sdk.Context, string) (nexus.Chain, bool) { +// return nexustestutils.RandomChain(), true +// } +// nexusK.IsAssetRegisteredFunc = func(sdk.Context, nexus.Chain, string) bool { +// return true +// } +// coin = funcs.Must(keeper.NewCoin(ctx, ibcK, nexusK, sdk.NewCoin(rand.Denom(5, 10), sdk.NewInt(rand.PosI64())))) +// }) - whenCoinIsNative := When("coin is native", func() { - nexusK.GetChainByNativeAssetFunc = func(sdk.Context, string) (nexus.Chain, bool) { - return exported.Axelarnet, true - } - coin = funcs.Must(keeper.NewCoin(ctx, ibcK, nexusK, sdk.NewCoin(exported.NativeAsset, sdk.NewInt(rand.PosI64())))) - }) +// whenCoinIsICS20 := When("coin is from ICS20", func() { +// // setup +// path := testutils.RandomIBCPath() +// chain = nexustestutils.RandomChain() +// trace = ibctypes.DenomTrace{ +// Path: path, +// BaseDenom: rand.Denom(5, 10), +// } +// transferK.GetDenomTraceFunc = func(ctx sdk.Context, denomTraceHash tmbytes.HexBytes) (ibctypes.DenomTrace, bool) { +// return trace, true +// } - whenCoinIsExternal := When("coin is external", func() { - nexusK.GetChainByNativeAssetFunc = func(sdk.Context, string) (nexus.Chain, bool) { - return nexustestutils.RandomChain(), true - } - nexusK.IsAssetRegisteredFunc = func(sdk.Context, nexus.Chain, string) bool { - return true - } - coin = funcs.Must(keeper.NewCoin(ctx, ibcK, nexusK, sdk.NewCoin(rand.Denom(5, 10), sdk.NewInt(rand.PosI64())))) - }) +// funcs.MustNoErr(ibcK.SetCosmosChain(ctx, types.CosmosChain{ +// Name: chain.Name, +// AddrPrefix: rand.StrBetween(1, 10), +// IBCPath: path, +// })) - whenCoinIsICS20 := When("coin is from ICS20", func() { - // setup - path := testutils.RandomIBCPath() - chain = nexustestutils.RandomChain() - trace = ibctypes.DenomTrace{ - Path: path, - BaseDenom: rand.Denom(5, 10), - } - transferK.GetDenomTraceFunc = func(ctx sdk.Context, denomTraceHash tmbytes.HexBytes) (ibctypes.DenomTrace, bool) { - return trace, true - } +// coin = funcs.Must(keeper.NewCoin(ctx, ibcK, nexusK, sdk.NewCoin(trace.IBCDenom(), sdk.NewInt(rand.PosI64())))) - funcs.MustNoErr(ibcK.SetCosmosChain(ctx, types.CosmosChain{ - Name: chain.Name, - AddrPrefix: rand.StrBetween(1, 10), - IBCPath: path, - })) +// nexusK.GetChainFunc = func(sdk.Context, nexus.ChainName) (nexus.Chain, bool) { +// return chain, true +// } +// nexusK.GetChainByNativeAssetFunc = func(sdk.Context, string) (nexus.Chain, bool) { +// return chain, true +// } +// }) - coin = funcs.Must(keeper.NewCoin(ctx, ibcK, nexusK, sdk.NewCoin(trace.IBCDenom(), sdk.NewInt(rand.PosI64())))) - - nexusK.GetChainFunc = func(sdk.Context, nexus.ChainName) (nexus.Chain, bool) { - return chain, true - } - nexusK.GetChainByNativeAssetFunc = func(sdk.Context, string) (nexus.Chain, bool) { - return chain, true - } - }) - - givenAKeeper. - Branch( - whenCoinIsNative. - Then("should Lock native coin in escrow account", func(t *testing.T) { - err := coin.Lock(bankK, rand.AccAddr()) - assert.NoError(t, err) - assert.Len(t, bankK.SendCoinsCalls(), 1) - }), - whenCoinIsExternal. - Then("should burn external token", func(t *testing.T) { - err := coin.Lock(bankK, rand.AccAddr()) - assert.NoError(t, err) - assert.Len(t, bankK.SendCoinsFromAccountToModuleCalls(), 1) - assert.Len(t, bankK.BurnCoinsCalls(), 1) - }), - whenCoinIsICS20. - When("coin is greater than bank balance", func() { - bankK.SpendableBalanceFunc = func(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin { - return sdk.NewCoin(trace.IBCDenom(), coin.Amount.Sub(sdk.OneInt())) - } - }). - Then("should return error", func(t *testing.T) { - err := coin.Lock(bankK, rand.AccAddr()) - assert.ErrorContains(t, err, "is greater than account balance") - }), - whenCoinIsICS20. - When("coin equals to bank balance", func() { - bankK.SpendableBalanceFunc = func(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin { - return sdk.NewCoin(trace.IBCDenom(), coin.Amount) - } - }). - Then("should Lock ICS20 coin in escrow account", func(t *testing.T) { - err := coin.Lock(bankK, rand.AccAddr()) - assert.NoError(t, err) - assert.Len(t, bankK.SendCoinsCalls(), 1) - }), - whenCoinIsICS20. - When("coin is less than bank balance", func() { - bankK.SpendableBalanceFunc = func(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin { - return sdk.NewCoin(trace.IBCDenom(), coin.Amount.Add(sdk.OneInt())) - } - }). - Then("should Lock ICS20 coin in escrow account", func(t *testing.T) { - err := coin.Lock(bankK, rand.AccAddr()) - assert.NoError(t, err) - assert.Len(t, bankK.SendCoinsCalls(), 1) - }), - ).Run(t) -} +// givenAKeeper. +// Branch( +// whenCoinIsNative. +// Then("should Lock native coin in escrow account", func(t *testing.T) { +// err := coin.Lock(bankK, rand.AccAddr()) +// assert.NoError(t, err) +// assert.Len(t, bankK.SendCoinsCalls(), 1) +// }), +// whenCoinIsExternal. +// Then("should burn external token", func(t *testing.T) { +// err := coin.Lock(bankK, rand.AccAddr()) +// assert.NoError(t, err) +// assert.Len(t, bankK.SendCoinsFromAccountToModuleCalls(), 1) +// assert.Len(t, bankK.BurnCoinsCalls(), 1) +// }), +// whenCoinIsICS20. +// When("coin is greater than bank balance", func() { +// bankK.SpendableBalanceFunc = func(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin { +// return sdk.NewCoin(trace.IBCDenom(), coin.Amount.Sub(sdk.OneInt())) +// } +// }). +// Then("should return error", func(t *testing.T) { +// err := coin.Lock(bankK, rand.AccAddr()) +// assert.ErrorContains(t, err, "is greater than account balance") +// }), +// whenCoinIsICS20. +// When("coin equals to bank balance", func() { +// bankK.SpendableBalanceFunc = func(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin { +// return sdk.NewCoin(trace.IBCDenom(), coin.Amount) +// } +// }). +// Then("should Lock ICS20 coin in escrow account", func(t *testing.T) { +// err := coin.Lock(bankK, rand.AccAddr()) +// assert.NoError(t, err) +// assert.Len(t, bankK.SendCoinsCalls(), 1) +// }), +// whenCoinIsICS20. +// When("coin is less than bank balance", func() { +// bankK.SpendableBalanceFunc = func(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin { +// return sdk.NewCoin(trace.IBCDenom(), coin.Amount.Add(sdk.OneInt())) +// } +// }). +// Then("should Lock ICS20 coin in escrow account", func(t *testing.T) { +// err := coin.Lock(bankK, rand.AccAddr()) +// assert.NoError(t, err) +// assert.Len(t, bankK.SendCoinsCalls(), 1) +// }), +// ).Run(t) +// } diff --git a/x/axelarnet/keeper/message_route.go b/x/axelarnet/keeper/message_route.go index 8018cb18f..fc496ad73 100644 --- a/x/axelarnet/keeper/message_route.go +++ b/x/axelarnet/keeper/message_route.go @@ -9,6 +9,7 @@ import ( "github.com/axelarnetwork/axelar-core/x/axelarnet/types" nexus "github.com/axelarnetwork/axelar-core/x/nexus/exported" + nexustypes "github.com/axelarnetwork/axelar-core/x/nexus/types" ) // for IBC execution @@ -16,12 +17,10 @@ const gasCost = storetypes.Gas(1000000) // NewMessageRoute creates a new message route func NewMessageRoute( - keeper Keeper, ibcK types.IBCKeeper, feegrantK types.FeegrantKeeper, bankK types.BankKeeper, nexusK types.Nexus, - accountK types.AccountKeeper, stakingK types.StakingKeeper, ) nexus.MessageRoute { return func(ctx sdk.Context, routingCtx nexus.RoutingContext, msg nexus.GeneralMessage) error { @@ -34,7 +33,7 @@ func NewMessageRoute( return sdkerrors.Wrap(err, "invalid payload") } - asset, err := escrowAssetToMessageSender(ctx, keeper, feegrantK, bankK, nexusK, accountK, stakingK, routingCtx, msg) + asset, err := escrowAssetToMessageSender(ctx, feegrantK, bankK, nexusK, ibcK, stakingK, routingCtx, msg) if err != nil { return err } @@ -49,11 +48,10 @@ func NewMessageRoute( // escrowAssetToMessageSender sends the asset to general msg sender account func escrowAssetToMessageSender( ctx sdk.Context, - keeper Keeper, feegrantK types.FeegrantKeeper, bankK types.BankKeeper, nexusK types.Nexus, - accountK types.AccountKeeper, + ibcK types.IBCKeeper, stakingK types.StakingKeeper, routingCtx nexus.RoutingContext, msg nexus.GeneralMessage, @@ -80,13 +78,12 @@ func escrowAssetToMessageSender( return asset, bankK.SendCoins(ctx, sender, types.AxelarGMPAccount, sdk.NewCoins(asset)) case nexus.TypeGeneralMessageWithToken: - // general message with token, get token from corresponding account - asset, sender, err := prepareTransfer(ctx, keeper, nexusK, bankK, accountK, *msg.Asset) + coin, err := nexustypes.NewCoin(ctx, nexusK, ibcK, bankK, *msg.Asset) if err != nil { return sdk.Coin{}, err } - return asset, bankK.SendCoins(ctx, sender, types.AxelarGMPAccount, sdk.NewCoins(asset)) + return coin.GetOriginalCoin(ctx), coin.Unlock(ctx, types.AxelarGMPAccount) default: return sdk.Coin{}, fmt.Errorf("unrecognized message type") } diff --git a/x/axelarnet/keeper/msg_server.go b/x/axelarnet/keeper/msg_server.go index 99bb342b0..3b0fa43da 100644 --- a/x/axelarnet/keeper/msg_server.go +++ b/x/axelarnet/keeper/msg_server.go @@ -9,7 +9,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/query" - ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types" "github.com/ethereum/go-ethereum/crypto" "github.com/axelarnetwork/axelar-core/utils" @@ -17,6 +16,7 @@ import ( "github.com/axelarnetwork/axelar-core/x/axelarnet/exported" "github.com/axelarnetwork/axelar-core/x/axelarnet/types" nexus "github.com/axelarnetwork/axelar-core/x/nexus/exported" + nexustypes "github.com/axelarnetwork/axelar-core/x/nexus/types" tss "github.com/axelarnetwork/axelar-core/x/tss/exported" "github.com/axelarnetwork/utils/funcs" ) @@ -25,20 +25,18 @@ var _ types.MsgServiceServer = msgServer{} type msgServer struct { Keeper - nexus types.Nexus - bank types.BankKeeper - account types.AccountKeeper - ibcK IBCKeeper + nexus types.Nexus + bank types.BankKeeper + ibcK IBCKeeper } // NewMsgServerImpl returns an implementation of the axelarnet MsgServiceServer interface for the provided Keeper. -func NewMsgServerImpl(k Keeper, n types.Nexus, b types.BankKeeper, a types.AccountKeeper, ibcK IBCKeeper) types.MsgServiceServer { +func NewMsgServerImpl(k Keeper, n types.Nexus, b types.BankKeeper, ibcK IBCKeeper) types.MsgServiceServer { return msgServer{ - Keeper: k, - nexus: n, - bank: b, - account: a, - ibcK: ibcK, + Keeper: k, + nexus: n, + bank: b, + ibcK: ibcK, } } @@ -82,7 +80,7 @@ func (s msgServer) CallContract(c context.Context, req *types.CallContractReques }) if req.Fee != nil { - token, err := NewCoin(ctx, s.ibcK, s.nexus, req.Fee.Amount) + normalizedCoin, err := nexustypes.NewCoin(ctx, s.nexus, s.ibcK, s.bank, req.Fee.Amount) if err != nil { return nil, sdkerrors.Wrap(err, "unrecognized fee denom") } @@ -96,7 +94,7 @@ func (s msgServer) CallContract(c context.Context, req *types.CallContractReques MessageID: msgID, Recipient: req.Fee.Recipient, Fee: req.Fee.Amount, - Asset: token.GetDenom(), + Asset: normalizedCoin.GetDenom(), } if req.Fee.RefundRecipient != nil { feePaidEvent.RefundRecipient = req.Fee.RefundRecipient.String() @@ -188,12 +186,12 @@ func (s msgServer) ConfirmDeposit(c context.Context, req *types.ConfirmDepositRe return nil, fmt.Errorf("recipient chain '%s' is not activated", recipient.Chain.Name) } - normalizedCoin, err := NewCoin(ctx, s.ibcK, s.nexus, coin) + normalizedCoin, err := nexustypes.NewCoin(ctx, s.nexus, s.ibcK, s.bank, coin) if err != nil { return nil, err } - if err := normalizedCoin.Lock(s.bank, req.DepositAddress); err != nil { + if err := normalizedCoin.Lock(ctx, req.DepositAddress); err != nil { return nil, err } @@ -263,7 +261,7 @@ func (s msgServer) ExecutePendingTransfers(c context.Context, _ *types.ExecutePe continue } - if err = transfer(ctx, s.Keeper, s.nexus, s.bank, s.account, recipient, pendingTransfer.Asset); err != nil { + if err = transfer(ctx, s.Keeper, s.nexus, s.bank, s.ibcK, recipient, pendingTransfer.Asset); err != nil { s.Logger(ctx).Error("failed to transfer asset to axelarnet", "err", err) continue } @@ -282,7 +280,7 @@ func (s msgServer) ExecutePendingTransfers(c context.Context, _ *types.ExecutePe // release transfer fees if collector, ok := s.GetFeeCollector(ctx); ok { for _, fee := range s.nexus.GetTransferFees(ctx) { - if err := transfer(ctx, s.Keeper, s.nexus, s.bank, s.account, collector, fee); err != nil { + if err := transfer(ctx, s.Keeper, s.nexus, s.bank, s.ibcK, collector, fee); err != nil { s.Logger(ctx).Error("failed to collect fees", "err", err) continue } @@ -406,13 +404,18 @@ func (s msgServer) RouteIBCTransfers(c context.Context, _ *types.RouteIBCTransfe return nil, err } for _, p := range pendingTransfers { - token, sender, err := prepareTransfer(ctx, s.Keeper, s.nexus, s.bank, s.account, p.Asset) + coin, err := nexustypes.NewCoin(ctx, s.nexus, s.ibcK, s.bank, p.Asset) if err != nil { - s.Logger(ctx).Error(fmt.Sprintf("failed to prepare transfer %s: %s", p.String(), err)) + s.Logger(ctx).Error(fmt.Sprintf("failed to route IBC transfer %s: %s", p.String(), err)) continue } - funcs.MustNoErr(s.EnqueueIBCTransfer(ctx, types.NewIBCTransfer(sender, p.Recipient.Address, token, portID, channelID, p.ID))) + if err := coin.Unlock(ctx, types.AxelarGMPAccount); err != nil { + s.Logger(ctx).Error(fmt.Sprintf("failed to route IBC transfer %s: %s", p.String(), err)) + continue + } + + funcs.MustNoErr(s.EnqueueIBCTransfer(ctx, types.NewIBCTransfer(types.AxelarGMPAccount, p.Recipient.Address, coin.GetOriginalCoin(ctx), portID, channelID, p.ID))) s.nexus.ArchivePendingTransfer(ctx, p) } } @@ -496,71 +499,17 @@ func (s msgServer) RouteMessage(c context.Context, req *types.RouteMessageReques return &types.RouteMessageResponse{}, nil } -// toICS20 converts a cross chain transfer to ICS20 token -func toICS20(ctx sdk.Context, k Keeper, n types.Nexus, coin sdk.Coin) sdk.Coin { - // if chain or path not found, it will create coin with base denom - chain, _ := n.GetChainByNativeAsset(ctx, coin.GetDenom()) - path, _ := k.GetIBCPath(ctx, chain.Name) - - prefixedDenom := types.NewIBCPath(path, coin.Denom) - // construct the denomination trace from the full raw denomination - denomTrace := ibctransfertypes.ParseDenomTrace(prefixedDenom) - return sdk.NewCoin(denomTrace.IBCDenom(), coin.Amount) -} - -// isFromExternalCosmosChain returns true if the asset origins from cosmos chains -func isFromExternalCosmosChain(ctx sdk.Context, k Keeper, n types.Nexus, coin sdk.Coin) bool { - chain, ok := n.GetChainByNativeAsset(ctx, coin.GetDenom()) - if !ok { - return false - } - - if _, ok = k.GetCosmosChainByName(ctx, chain.Name); !ok { - return false - } - - _, ok = k.GetIBCPath(ctx, chain.Name) - return ok -} - -func transfer(ctx sdk.Context, k Keeper, n types.Nexus, b types.BankKeeper, a types.AccountKeeper, recipient sdk.AccAddress, coin sdk.Coin) error { - coin, escrowAddress, err := prepareTransfer(ctx, k, n, b, a, coin) +func transfer(ctx sdk.Context, k Keeper, n types.Nexus, b types.BankKeeper, ibc types.IBCKeeper, recipient sdk.AccAddress, coin sdk.Coin) error { + c, err := nexustypes.NewCoin(ctx, n, ibc, b, coin) if err != nil { - return fmt.Errorf("failed to prepare transfer %s: %s", coin, err) + return err } - if err = b.SendCoins( - ctx, escrowAddress, recipient, sdk.NewCoins(coin), - ); err != nil { - return fmt.Errorf("failed to send %s from %s to %s: %s", coin, escrowAddress, recipient, err) + if err := c.Unlock(ctx, recipient); err != nil { + return err } - k.Logger(ctx).Debug(fmt.Sprintf("successfully sent %s from %s to %s", coin, escrowAddress, recipient)) - - return nil -} -func prepareTransfer(ctx sdk.Context, k Keeper, n types.Nexus, b types.BankKeeper, a types.AccountKeeper, coin sdk.Coin) (sdk.Coin, sdk.AccAddress, error) { - var sender sdk.AccAddress - // pending transfer can be either of cosmos chains assets, Axelarnet native asset, assets from supported chain - switch { - // asset origins from cosmos chains, it will be converted to ICS20 token - case isFromExternalCosmosChain(ctx, k, n, coin): - coin = toICS20(ctx, k, n, coin) - sender = types.GetEscrowAddress(coin.GetDenom()) - case isNativeAssetOnAxelarnet(ctx, n, coin.Denom): - sender = types.GetEscrowAddress(coin.Denom) - case n.IsAssetRegistered(ctx, exported.Axelarnet, coin.Denom): - if err := b.MintCoins( - ctx, types.ModuleName, sdk.NewCoins(coin), - ); err != nil { - return sdk.Coin{}, nil, err - } + k.Logger(ctx).Debug(fmt.Sprintf("successfully sent %s to %s", coin, recipient)) - sender = a.GetModuleAddress(types.ModuleName) - default: - // should not reach here - panic(fmt.Sprintf("unrecognized %s token", coin.Denom)) - } - - return coin, sender, nil + return nil } diff --git a/x/axelarnet/message_handler.go b/x/axelarnet/message_handler.go index 8c92bde01..7050aed99 100644 --- a/x/axelarnet/message_handler.go +++ b/x/axelarnet/message_handler.go @@ -19,6 +19,7 @@ import ( "github.com/axelarnetwork/axelar-core/x/axelarnet/keeper" "github.com/axelarnetwork/axelar-core/x/axelarnet/types" nexus "github.com/axelarnetwork/axelar-core/x/nexus/exported" + nexustypes "github.com/axelarnetwork/axelar-core/x/nexus/types" tss "github.com/axelarnetwork/axelar-core/x/tss/exported" "github.com/axelarnetwork/utils/funcs" ) @@ -127,7 +128,7 @@ func OnRecvMessage(ctx sdk.Context, k keeper.Keeper, ibcK keeper.IBCKeeper, n ty } // extract token from packet - token, err := extractTokenFromPacketData(ctx, ibcK, n, packet) + token, err := extractTokenFromPacketData(ctx, ibcK, n, b, packet) if err != nil { return channeltypes.NewErrorAcknowledgement(err) } @@ -184,7 +185,7 @@ func OnRecvMessage(ctx sdk.Context, k keeper.Keeper, ibcK keeper.IBCKeeper, n ty return ack } -func validateMessage(ctx sdk.Context, ibcK keeper.IBCKeeper, n types.Nexus, ibcPath string, msg Message, token keeper.Coin) error { +func validateMessage(ctx sdk.Context, ibcK keeper.IBCKeeper, n types.Nexus, ibcPath string, msg Message, token nexustypes.Coin) error { // validate source chain srcChainName, srcChainFound := ibcK.GetChainNameByIBCPath(ctx, ibcPath) if !srcChainFound { @@ -243,7 +244,7 @@ func validateMessage(ctx sdk.Context, ibcK keeper.IBCKeeper, n types.Nexus, ibcP } } -func handleMessage(ctx sdk.Context, n types.Nexus, b types.BankKeeper, sourceAddress nexus.CrossChainAddress, msg Message, token keeper.Coin) error { +func handleMessage(ctx sdk.Context, n types.Nexus, b types.BankKeeper, sourceAddress nexus.CrossChainAddress, msg Message, token nexustypes.Coin) error { id, txID, nonce := n.GenerateMessageID(ctx) // ignore token for call contract @@ -284,7 +285,7 @@ func handleMessage(ctx sdk.Context, n types.Nexus, b types.BankKeeper, sourceAdd return n.SetNewMessage(ctx, m) } -func handleMessageWithToken(ctx sdk.Context, n types.Nexus, b types.BankKeeper, sourceAddress nexus.CrossChainAddress, msg Message, token keeper.Coin) error { +func handleMessageWithToken(ctx sdk.Context, n types.Nexus, b types.BankKeeper, sourceAddress nexus.CrossChainAddress, msg Message, token nexustypes.Coin) error { id, txID, nonce := n.GenerateMessageID(ctx) token, err := deductFee(ctx, b, msg.Fee, token, id) @@ -292,7 +293,7 @@ func handleMessageWithToken(ctx sdk.Context, n types.Nexus, b types.BankKeeper, return err } - if err = token.Lock(b, types.AxelarGMPAccount); err != nil { + if err = token.Lock(ctx, types.AxelarGMPAccount); err != nil { return err } @@ -322,11 +323,11 @@ func handleMessageWithToken(ctx sdk.Context, n types.Nexus, b types.BankKeeper, return n.SetNewMessage(ctx, m) } -func handleTokenSent(ctx sdk.Context, n types.Nexus, b types.BankKeeper, sourceAddress nexus.CrossChainAddress, msg Message, token keeper.Coin) error { +func handleTokenSent(ctx sdk.Context, n types.Nexus, b types.BankKeeper, sourceAddress nexus.CrossChainAddress, msg Message, token nexustypes.Coin) error { destChain := funcs.MustOk(n.GetChain(ctx, nexus.ChainName(msg.DestinationChain))) crossChainAddr := nexus.CrossChainAddress{Chain: destChain, Address: msg.DestinationAddress} - if err := token.Lock(b, types.AxelarGMPAccount); err != nil { + if err := token.Lock(ctx, types.AxelarGMPAccount); err != nil { return err } @@ -350,7 +351,7 @@ func handleTokenSent(ctx sdk.Context, n types.Nexus, b types.BankKeeper, sourceA // extractTokenFromPacketData get normalized token from ICS20 packet // panic if unable to unmarshal packet data -func extractTokenFromPacketData(ctx sdk.Context, ibcK keeper.IBCKeeper, n types.Nexus, packet ibcexported.PacketI) (keeper.Coin, error) { +func extractTokenFromPacketData(ctx sdk.Context, ibcK keeper.IBCKeeper, n types.Nexus, b types.BankKeeper, packet ibcexported.PacketI) (nexustypes.Coin, error) { data := funcs.Must(types.ToICS20Packet(packet)) // parse the transfer amount @@ -388,17 +389,17 @@ func extractTokenFromPacketData(ctx sdk.Context, ibcK keeper.IBCKeeper, n types. denom = denomTrace.IBCDenom() } - return keeper.NewCoin(ctx, ibcK, n, sdk.NewCoin(denom, amount)) + return nexustypes.NewCoin(ctx, n, ibcK, b, sdk.NewCoin(denom, amount)) } // deductFee pays the fee and returns the updated transfer amount with the fee deducted -func deductFee(ctx sdk.Context, b types.BankKeeper, fee *Fee, token keeper.Coin, msgID string) (keeper.Coin, error) { +func deductFee(ctx sdk.Context, b types.BankKeeper, fee *Fee, token nexustypes.Coin, msgID string) (nexustypes.Coin, error) { if fee == nil { return token, nil } feeAmount := funcs.MustOk(sdk.NewIntFromString(fee.Amount)) - coin := sdk.NewCoin(funcs.Must(token.GetOriginalDenom()), feeAmount) + coin := sdk.NewCoin(token.GetOriginalCoin(ctx).Denom, feeAmount) recipient := funcs.Must(sdk.AccAddressFromBech32(fee.Recipient)) feePaidEvent := types.FeePaid{ diff --git a/x/axelarnet/module.go b/x/axelarnet/module.go index 0690fb8ea..3202c1917 100644 --- a/x/axelarnet/module.go +++ b/x/axelarnet/module.go @@ -29,6 +29,7 @@ import ( "github.com/axelarnetwork/axelar-core/x/axelarnet/keeper" "github.com/axelarnetwork/axelar-core/x/axelarnet/types" nexus "github.com/axelarnetwork/axelar-core/x/nexus/exported" + nexustypes "github.com/axelarnetwork/axelar-core/x/nexus/types" "github.com/axelarnetwork/utils/funcs" ) @@ -96,16 +97,15 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command { // AppModule implements module.AppModule type AppModule struct { AppModuleBasic - logger log.Logger - ibcK keeper.IBCKeeper - keeper keeper.Keeper - nexus types.Nexus - bank types.BankKeeper - account types.AccountKeeper + logger log.Logger + ibcK keeper.IBCKeeper + keeper keeper.Keeper + nexus types.Nexus + bank types.BankKeeper } // NewAppModule creates a new AppModule object -func NewAppModule(ibcK keeper.IBCKeeper, nexus types.Nexus, bank types.BankKeeper, account types.AccountKeeper, logger log.Logger) AppModule { +func NewAppModule(ibcK keeper.IBCKeeper, nexus types.Nexus, bank types.BankKeeper, logger log.Logger) AppModule { return AppModule{ AppModuleBasic: AppModuleBasic{}, logger: logger, @@ -113,7 +113,6 @@ func NewAppModule(ibcK keeper.IBCKeeper, nexus types.Nexus, bank types.BankKeepe keeper: ibcK.Keeper, nexus: nexus, bank: bank, - account: account, } } @@ -141,7 +140,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw // Route returns the module's route func (am AppModule) Route() sdk.Route { - return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper, am.nexus, am.bank, am.account, am.ibcK)) + return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper, am.nexus, am.bank, am.ibcK)) } // QuerierRoute returns this module's query route @@ -157,7 +156,7 @@ func (am AppModule) LegacyQuerierHandler(*codec.LegacyAmino) sdk.Querier { // RegisterServices registers a GRPC query service to respond to the // module-specific GRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { - msgServer := keeper.NewMsgServerImpl(am.keeper, am.nexus, am.bank, am.account, am.ibcK) + msgServer := keeper.NewMsgServerImpl(am.keeper, am.nexus, am.bank, am.ibcK) types.RegisterMsgServiceServer(grpc.ServerWithSDKErrors{Server: cfg.MsgServer(), Err: types.ErrAxelarnet, Logger: am.keeper.Logger}, msgServer) types.RegisterQueryServiceServer(cfg.QueryServer(), keeper.NewGRPCQuerier(am.keeper, am.nexus)) @@ -344,6 +343,17 @@ func (m AxelarnetIBCModule) setRoutedPacketFailed(ctx sdk.Context, packet channe // check if the packet is Axelar routed cross chain transfer transferID, ok := getSeqIDMapping(ctx, m.keeper, port, channel, sequence) if ok { + transfer := funcs.MustOk(m.keeper.GetTransfer(ctx, transferID)) + coin, err := nexustypes.NewCoin(ctx, m.nexus, m.ibcK, m.bank, transfer.Token) + if err != nil { + return err + } + + err = coin.Lock(ctx, types.AxelarGMPAccount) + if err != nil { + return err + } + events.Emit(ctx, &types.IBCTransferFailed{ ID: transferID, @@ -360,12 +370,12 @@ func (m AxelarnetIBCModule) setRoutedPacketFailed(ctx sdk.Context, packet channe // check if the packet is Axelar routed general message messageID, ok := getSeqMessageIDMapping(ctx, m.keeper, port, channel, sequence) if ok { - coin, err := keeper.NewCoin(ctx, m.ibcK, m.nexus, extractTokenFromAckOrTimeoutPacket(packet)) + coin, err := nexustypes.NewCoin(ctx, m.nexus, m.ibcK, m.bank, extractTokenFromAckOrTimeoutPacket(packet)) if err != nil { return err } - err = coin.Lock(m.bank, types.AxelarGMPAccount) + err = coin.Lock(ctx, types.AxelarGMPAccount) if err != nil { return err } diff --git a/x/axelarnet/types/expected_keepers.go b/x/axelarnet/types/expected_keepers.go index 509939888..8d3fcf469 100644 --- a/x/axelarnet/types/expected_keepers.go +++ b/x/axelarnet/types/expected_keepers.go @@ -6,7 +6,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" - "github.com/cosmos/cosmos-sdk/x/auth/types" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" ibctypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types" @@ -18,6 +17,7 @@ import ( "github.com/axelarnetwork/axelar-core/utils" nexus "github.com/axelarnetwork/axelar-core/x/nexus/exported" + nexustypes "github.com/axelarnetwork/axelar-core/x/nexus/types" ) //go:generate moq -out ./mock/expected_keepers.go -pkg mock . BaseKeeper Nexus BankKeeper IBCTransferKeeper ChannelKeeper AccountKeeper PortKeeper GovKeeper StakingKeeper FeegrantKeeper IBCKeeper @@ -41,29 +41,51 @@ type BaseKeeper interface { // Nexus provides functionality to manage cross-chain transfers type Nexus interface { + Logger(ctx sdk.Context) log.Logger + + InitGenesis(ctx sdk.Context, genState *nexustypes.GenesisState) + ExportGenesis(ctx sdk.Context) *nexustypes.GenesisState + + SetParams(ctx sdk.Context, p nexustypes.Params) + GetParams(ctx sdk.Context) nexustypes.Params + + ActivateWasmConnection(ctx sdk.Context) + DeactivateWasmConnection(ctx sdk.Context) + IsWasmConnectionActivated(ctx sdk.Context) bool + IsChainActivated(ctx sdk.Context, chain nexus.Chain) bool + ActivateChain(ctx sdk.Context, chain nexus.Chain) + GetChains(ctx sdk.Context) []nexus.Chain + GetChain(ctx sdk.Context, chain nexus.ChainName) (nexus.Chain, bool) + IsChainMaintainer(ctx sdk.Context, chain nexus.Chain, maintainer sdk.ValAddress) bool + AddChainMaintainer(ctx sdk.Context, chain nexus.Chain, validator sdk.ValAddress) error + RemoveChainMaintainer(ctx sdk.Context, chain nexus.Chain, validator sdk.ValAddress) error + GetChainMaintainers(ctx sdk.Context, chain nexus.Chain) []sdk.ValAddress + GetChainMaintainerStates(ctx sdk.Context, chain nexus.Chain) []nexus.MaintainerState + LinkAddresses(ctx sdk.Context, sender nexus.CrossChainAddress, recipient nexus.CrossChainAddress) error + DeactivateChain(ctx sdk.Context, chain nexus.Chain) + RegisterFee(ctx sdk.Context, chain nexus.Chain, feeInfo nexus.FeeInfo) error + GetFeeInfo(ctx sdk.Context, chain nexus.Chain, asset string) nexus.FeeInfo + SetRateLimit(ctx sdk.Context, chainName nexus.ChainName, limit sdk.Coin, window time.Duration) error + RateLimitTransfer(ctx sdk.Context, chain nexus.ChainName, asset sdk.Coin, direction nexus.TransferDirection) error + SetNewMessage(ctx sdk.Context, msg nexus.GeneralMessage) error + GetMessage(ctx sdk.Context, id string) (nexus.GeneralMessage, bool) + SetMessageExecuted(ctx sdk.Context, id string) error + RouteMessage(ctx sdk.Context, id string, routingCtx ...nexus.RoutingContext) error + DequeueRouteMessage(ctx sdk.Context) (nexus.GeneralMessage, bool) + IsAssetRegistered(ctx sdk.Context, chain nexus.Chain, denom string) bool + GetChainByNativeAsset(ctx sdk.Context, asset string) (chain nexus.Chain, ok bool) EnqueueForTransfer(ctx sdk.Context, sender nexus.CrossChainAddress, amount sdk.Coin) (nexus.TransferID, error) EnqueueTransfer(ctx sdk.Context, senderChain nexus.Chain, recipient nexus.CrossChainAddress, asset sdk.Coin) (nexus.TransferID, error) GetTransfersForChainPaginated(ctx sdk.Context, chain nexus.Chain, state nexus.TransferState, pageRequest *query.PageRequest) ([]nexus.CrossChainTransfer, *query.PageResponse, error) ArchivePendingTransfer(ctx sdk.Context, transfer nexus.CrossChainTransfer) - GetChain(ctx sdk.Context, chain nexus.ChainName) (nexus.Chain, bool) - LinkAddresses(ctx sdk.Context, sender nexus.CrossChainAddress, recipient nexus.CrossChainAddress) error - IsAssetRegistered(ctx sdk.Context, chain nexus.Chain, denom string) bool RegisterAsset(ctx sdk.Context, chain nexus.Chain, asset nexus.Asset, limit sdk.Uint, window time.Duration) error GetRecipient(ctx sdk.Context, sender nexus.CrossChainAddress) (nexus.CrossChainAddress, bool) SetChain(ctx sdk.Context, chain nexus.Chain) GetTransferFees(ctx sdk.Context) sdk.Coins SubTransferFee(ctx sdk.Context, coin sdk.Coin) - ActivateChain(ctx sdk.Context, chain nexus.Chain) - GetChainByNativeAsset(ctx sdk.Context, asset string) (nexus.Chain, bool) - IsChainActivated(ctx sdk.Context, chain nexus.Chain) bool - RateLimitTransfer(ctx sdk.Context, chain nexus.ChainName, asset sdk.Coin, direction nexus.TransferDirection) error - GetMessage(ctx sdk.Context, id string) (m nexus.GeneralMessage, found bool) - SetNewMessage(ctx sdk.Context, m nexus.GeneralMessage) error - SetMessageExecuted(ctx sdk.Context, id string) error SetMessageFailed(ctx sdk.Context, id string) error GenerateMessageID(ctx sdk.Context) (string, []byte, uint64) ValidateAddress(ctx sdk.Context, address nexus.CrossChainAddress) error - RouteMessage(ctx sdk.Context, id string, routingCtx ...nexus.RoutingContext) error } // BankKeeper defines the expected interface contract the vesting module requires @@ -107,8 +129,6 @@ type ChannelKeeper interface { // creating a x/bank keeper. type AccountKeeper interface { GetModuleAddress(moduleName string) sdk.AccAddress - - GetModuleAccount(ctx sdk.Context, moduleName string) types.ModuleAccountI // used in module_test } // CosmosChainGetter exposes GetCosmosChainByName @@ -137,4 +157,6 @@ type FeegrantKeeper interface { // IBCKeeper defines the expected IBC keeper type IBCKeeper interface { SendMessage(c context.Context, recipient nexus.CrossChainAddress, asset sdk.Coin, payload string, id string) error + ParseIBCDenom(ctx sdk.Context, ibcDenom string) (ibctypes.DenomTrace, error) + GetIBCPath(ctx sdk.Context, chain nexus.ChainName) (string, bool) } diff --git a/x/axelarnet/types/mock/expected_keepers.go b/x/axelarnet/types/mock/expected_keepers.go index c47a2c5f9..21acd9ecc 100644 --- a/x/axelarnet/types/mock/expected_keepers.go +++ b/x/axelarnet/types/mock/expected_keepers.go @@ -8,9 +8,9 @@ import ( utils "github.com/axelarnetwork/axelar-core/utils" axelarnettypes "github.com/axelarnetwork/axelar-core/x/axelarnet/types" github_com_axelarnetwork_axelar_core_x_nexus_exported "github.com/axelarnetwork/axelar-core/x/nexus/exported" + nexustypes "github.com/axelarnetwork/axelar-core/x/nexus/types" cosmossdktypes "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" - "github.com/cosmos/cosmos-sdk/x/auth/types" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" gov "github.com/cosmos/cosmos-sdk/x/gov/types" ibctransfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types" @@ -666,15 +666,33 @@ var _ axelarnettypes.Nexus = &NexusMock{} // ActivateChainFunc: func(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain) { // panic("mock out the ActivateChain method") // }, +// ActivateWasmConnectionFunc: func(ctx cosmossdktypes.Context) { +// panic("mock out the ActivateWasmConnection method") +// }, +// AddChainMaintainerFunc: func(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain, validator cosmossdktypes.ValAddress) error { +// panic("mock out the AddChainMaintainer method") +// }, // ArchivePendingTransferFunc: func(ctx cosmossdktypes.Context, transfer github_com_axelarnetwork_axelar_core_x_nexus_exported.CrossChainTransfer) { // panic("mock out the ArchivePendingTransfer method") // }, +// DeactivateChainFunc: func(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain) { +// panic("mock out the DeactivateChain method") +// }, +// DeactivateWasmConnectionFunc: func(ctx cosmossdktypes.Context) { +// panic("mock out the DeactivateWasmConnection method") +// }, +// DequeueRouteMessageFunc: func(ctx cosmossdktypes.Context) (github_com_axelarnetwork_axelar_core_x_nexus_exported.GeneralMessage, bool) { +// panic("mock out the DequeueRouteMessage method") +// }, // EnqueueForTransferFunc: func(ctx cosmossdktypes.Context, sender github_com_axelarnetwork_axelar_core_x_nexus_exported.CrossChainAddress, amount cosmossdktypes.Coin) (github_com_axelarnetwork_axelar_core_x_nexus_exported.TransferID, error) { // panic("mock out the EnqueueForTransfer method") // }, // EnqueueTransferFunc: func(ctx cosmossdktypes.Context, senderChain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain, recipient github_com_axelarnetwork_axelar_core_x_nexus_exported.CrossChainAddress, asset cosmossdktypes.Coin) (github_com_axelarnetwork_axelar_core_x_nexus_exported.TransferID, error) { // panic("mock out the EnqueueTransfer method") // }, +// ExportGenesisFunc: func(ctx cosmossdktypes.Context) *nexustypes.GenesisState { +// panic("mock out the ExportGenesis method") +// }, // GenerateMessageIDFunc: func(ctx cosmossdktypes.Context) (string, []byte, uint64) { // panic("mock out the GenerateMessageID method") // }, @@ -684,9 +702,24 @@ var _ axelarnettypes.Nexus = &NexusMock{} // GetChainByNativeAssetFunc: func(ctx cosmossdktypes.Context, asset string) (github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain, bool) { // panic("mock out the GetChainByNativeAsset method") // }, +// GetChainMaintainerStatesFunc: func(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain) []github_com_axelarnetwork_axelar_core_x_nexus_exported.MaintainerState { +// panic("mock out the GetChainMaintainerStates method") +// }, +// GetChainMaintainersFunc: func(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain) []cosmossdktypes.ValAddress { +// panic("mock out the GetChainMaintainers method") +// }, +// GetChainsFunc: func(ctx cosmossdktypes.Context) []github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain { +// panic("mock out the GetChains method") +// }, +// GetFeeInfoFunc: func(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain, asset string) github_com_axelarnetwork_axelar_core_x_nexus_exported.FeeInfo { +// panic("mock out the GetFeeInfo method") +// }, // GetMessageFunc: func(ctx cosmossdktypes.Context, id string) (github_com_axelarnetwork_axelar_core_x_nexus_exported.GeneralMessage, bool) { // panic("mock out the GetMessage method") // }, +// GetParamsFunc: func(ctx cosmossdktypes.Context) nexustypes.Params { +// panic("mock out the GetParams method") +// }, // GetRecipientFunc: func(ctx cosmossdktypes.Context, sender github_com_axelarnetwork_axelar_core_x_nexus_exported.CrossChainAddress) (github_com_axelarnetwork_axelar_core_x_nexus_exported.CrossChainAddress, bool) { // panic("mock out the GetRecipient method") // }, @@ -696,21 +729,39 @@ var _ axelarnettypes.Nexus = &NexusMock{} // GetTransfersForChainPaginatedFunc: func(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain, state github_com_axelarnetwork_axelar_core_x_nexus_exported.TransferState, pageRequest *query.PageRequest) ([]github_com_axelarnetwork_axelar_core_x_nexus_exported.CrossChainTransfer, *query.PageResponse, error) { // panic("mock out the GetTransfersForChainPaginated method") // }, +// InitGenesisFunc: func(ctx cosmossdktypes.Context, genState *nexustypes.GenesisState) { +// panic("mock out the InitGenesis method") +// }, // IsAssetRegisteredFunc: func(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain, denom string) bool { // panic("mock out the IsAssetRegistered method") // }, // IsChainActivatedFunc: func(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain) bool { // panic("mock out the IsChainActivated method") // }, +// IsChainMaintainerFunc: func(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain, maintainer cosmossdktypes.ValAddress) bool { +// panic("mock out the IsChainMaintainer method") +// }, +// IsWasmConnectionActivatedFunc: func(ctx cosmossdktypes.Context) bool { +// panic("mock out the IsWasmConnectionActivated method") +// }, // LinkAddressesFunc: func(ctx cosmossdktypes.Context, sender github_com_axelarnetwork_axelar_core_x_nexus_exported.CrossChainAddress, recipient github_com_axelarnetwork_axelar_core_x_nexus_exported.CrossChainAddress) error { // panic("mock out the LinkAddresses method") // }, +// LoggerFunc: func(ctx cosmossdktypes.Context) log.Logger { +// panic("mock out the Logger method") +// }, // RateLimitTransferFunc: func(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.ChainName, asset cosmossdktypes.Coin, direction github_com_axelarnetwork_axelar_core_x_nexus_exported.TransferDirection) error { // panic("mock out the RateLimitTransfer method") // }, // RegisterAssetFunc: func(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain, asset github_com_axelarnetwork_axelar_core_x_nexus_exported.Asset, limit cosmossdktypes.Uint, window time.Duration) error { // panic("mock out the RegisterAsset method") // }, +// RegisterFeeFunc: func(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain, feeInfo github_com_axelarnetwork_axelar_core_x_nexus_exported.FeeInfo) error { +// panic("mock out the RegisterFee method") +// }, +// RemoveChainMaintainerFunc: func(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain, validator cosmossdktypes.ValAddress) error { +// panic("mock out the RemoveChainMaintainer method") +// }, // RouteMessageFunc: func(ctx cosmossdktypes.Context, id string, routingCtx ...github_com_axelarnetwork_axelar_core_x_nexus_exported.RoutingContext) error { // panic("mock out the RouteMessage method") // }, @@ -723,9 +774,15 @@ var _ axelarnettypes.Nexus = &NexusMock{} // SetMessageFailedFunc: func(ctx cosmossdktypes.Context, id string) error { // panic("mock out the SetMessageFailed method") // }, -// SetNewMessageFunc: func(ctx cosmossdktypes.Context, m github_com_axelarnetwork_axelar_core_x_nexus_exported.GeneralMessage) error { +// SetNewMessageFunc: func(ctx cosmossdktypes.Context, msg github_com_axelarnetwork_axelar_core_x_nexus_exported.GeneralMessage) error { // panic("mock out the SetNewMessage method") // }, +// SetParamsFunc: func(ctx cosmossdktypes.Context, p nexustypes.Params) { +// panic("mock out the SetParams method") +// }, +// SetRateLimitFunc: func(ctx cosmossdktypes.Context, chainName github_com_axelarnetwork_axelar_core_x_nexus_exported.ChainName, limit cosmossdktypes.Coin, window time.Duration) error { +// panic("mock out the SetRateLimit method") +// }, // SubTransferFeeFunc: func(ctx cosmossdktypes.Context, coin cosmossdktypes.Coin) { // panic("mock out the SubTransferFee method") // }, @@ -742,15 +799,33 @@ type NexusMock struct { // ActivateChainFunc mocks the ActivateChain method. ActivateChainFunc func(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain) + // ActivateWasmConnectionFunc mocks the ActivateWasmConnection method. + ActivateWasmConnectionFunc func(ctx cosmossdktypes.Context) + + // AddChainMaintainerFunc mocks the AddChainMaintainer method. + AddChainMaintainerFunc func(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain, validator cosmossdktypes.ValAddress) error + // ArchivePendingTransferFunc mocks the ArchivePendingTransfer method. ArchivePendingTransferFunc func(ctx cosmossdktypes.Context, transfer github_com_axelarnetwork_axelar_core_x_nexus_exported.CrossChainTransfer) + // DeactivateChainFunc mocks the DeactivateChain method. + DeactivateChainFunc func(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain) + + // DeactivateWasmConnectionFunc mocks the DeactivateWasmConnection method. + DeactivateWasmConnectionFunc func(ctx cosmossdktypes.Context) + + // DequeueRouteMessageFunc mocks the DequeueRouteMessage method. + DequeueRouteMessageFunc func(ctx cosmossdktypes.Context) (github_com_axelarnetwork_axelar_core_x_nexus_exported.GeneralMessage, bool) + // EnqueueForTransferFunc mocks the EnqueueForTransfer method. EnqueueForTransferFunc func(ctx cosmossdktypes.Context, sender github_com_axelarnetwork_axelar_core_x_nexus_exported.CrossChainAddress, amount cosmossdktypes.Coin) (github_com_axelarnetwork_axelar_core_x_nexus_exported.TransferID, error) // EnqueueTransferFunc mocks the EnqueueTransfer method. EnqueueTransferFunc func(ctx cosmossdktypes.Context, senderChain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain, recipient github_com_axelarnetwork_axelar_core_x_nexus_exported.CrossChainAddress, asset cosmossdktypes.Coin) (github_com_axelarnetwork_axelar_core_x_nexus_exported.TransferID, error) + // ExportGenesisFunc mocks the ExportGenesis method. + ExportGenesisFunc func(ctx cosmossdktypes.Context) *nexustypes.GenesisState + // GenerateMessageIDFunc mocks the GenerateMessageID method. GenerateMessageIDFunc func(ctx cosmossdktypes.Context) (string, []byte, uint64) @@ -760,9 +835,24 @@ type NexusMock struct { // GetChainByNativeAssetFunc mocks the GetChainByNativeAsset method. GetChainByNativeAssetFunc func(ctx cosmossdktypes.Context, asset string) (github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain, bool) + // GetChainMaintainerStatesFunc mocks the GetChainMaintainerStates method. + GetChainMaintainerStatesFunc func(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain) []github_com_axelarnetwork_axelar_core_x_nexus_exported.MaintainerState + + // GetChainMaintainersFunc mocks the GetChainMaintainers method. + GetChainMaintainersFunc func(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain) []cosmossdktypes.ValAddress + + // GetChainsFunc mocks the GetChains method. + GetChainsFunc func(ctx cosmossdktypes.Context) []github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain + + // GetFeeInfoFunc mocks the GetFeeInfo method. + GetFeeInfoFunc func(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain, asset string) github_com_axelarnetwork_axelar_core_x_nexus_exported.FeeInfo + // GetMessageFunc mocks the GetMessage method. GetMessageFunc func(ctx cosmossdktypes.Context, id string) (github_com_axelarnetwork_axelar_core_x_nexus_exported.GeneralMessage, bool) + // GetParamsFunc mocks the GetParams method. + GetParamsFunc func(ctx cosmossdktypes.Context) nexustypes.Params + // GetRecipientFunc mocks the GetRecipient method. GetRecipientFunc func(ctx cosmossdktypes.Context, sender github_com_axelarnetwork_axelar_core_x_nexus_exported.CrossChainAddress) (github_com_axelarnetwork_axelar_core_x_nexus_exported.CrossChainAddress, bool) @@ -772,21 +862,39 @@ type NexusMock struct { // GetTransfersForChainPaginatedFunc mocks the GetTransfersForChainPaginated method. GetTransfersForChainPaginatedFunc func(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain, state github_com_axelarnetwork_axelar_core_x_nexus_exported.TransferState, pageRequest *query.PageRequest) ([]github_com_axelarnetwork_axelar_core_x_nexus_exported.CrossChainTransfer, *query.PageResponse, error) + // InitGenesisFunc mocks the InitGenesis method. + InitGenesisFunc func(ctx cosmossdktypes.Context, genState *nexustypes.GenesisState) + // IsAssetRegisteredFunc mocks the IsAssetRegistered method. IsAssetRegisteredFunc func(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain, denom string) bool // IsChainActivatedFunc mocks the IsChainActivated method. IsChainActivatedFunc func(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain) bool + // IsChainMaintainerFunc mocks the IsChainMaintainer method. + IsChainMaintainerFunc func(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain, maintainer cosmossdktypes.ValAddress) bool + + // IsWasmConnectionActivatedFunc mocks the IsWasmConnectionActivated method. + IsWasmConnectionActivatedFunc func(ctx cosmossdktypes.Context) bool + // LinkAddressesFunc mocks the LinkAddresses method. LinkAddressesFunc func(ctx cosmossdktypes.Context, sender github_com_axelarnetwork_axelar_core_x_nexus_exported.CrossChainAddress, recipient github_com_axelarnetwork_axelar_core_x_nexus_exported.CrossChainAddress) error + // LoggerFunc mocks the Logger method. + LoggerFunc func(ctx cosmossdktypes.Context) log.Logger + // RateLimitTransferFunc mocks the RateLimitTransfer method. RateLimitTransferFunc func(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.ChainName, asset cosmossdktypes.Coin, direction github_com_axelarnetwork_axelar_core_x_nexus_exported.TransferDirection) error // RegisterAssetFunc mocks the RegisterAsset method. RegisterAssetFunc func(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain, asset github_com_axelarnetwork_axelar_core_x_nexus_exported.Asset, limit cosmossdktypes.Uint, window time.Duration) error + // RegisterFeeFunc mocks the RegisterFee method. + RegisterFeeFunc func(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain, feeInfo github_com_axelarnetwork_axelar_core_x_nexus_exported.FeeInfo) error + + // RemoveChainMaintainerFunc mocks the RemoveChainMaintainer method. + RemoveChainMaintainerFunc func(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain, validator cosmossdktypes.ValAddress) error + // RouteMessageFunc mocks the RouteMessage method. RouteMessageFunc func(ctx cosmossdktypes.Context, id string, routingCtx ...github_com_axelarnetwork_axelar_core_x_nexus_exported.RoutingContext) error @@ -800,7 +908,13 @@ type NexusMock struct { SetMessageFailedFunc func(ctx cosmossdktypes.Context, id string) error // SetNewMessageFunc mocks the SetNewMessage method. - SetNewMessageFunc func(ctx cosmossdktypes.Context, m github_com_axelarnetwork_axelar_core_x_nexus_exported.GeneralMessage) error + SetNewMessageFunc func(ctx cosmossdktypes.Context, msg github_com_axelarnetwork_axelar_core_x_nexus_exported.GeneralMessage) error + + // SetParamsFunc mocks the SetParams method. + SetParamsFunc func(ctx cosmossdktypes.Context, p nexustypes.Params) + + // SetRateLimitFunc mocks the SetRateLimit method. + SetRateLimitFunc func(ctx cosmossdktypes.Context, chainName github_com_axelarnetwork_axelar_core_x_nexus_exported.ChainName, limit cosmossdktypes.Coin, window time.Duration) error // SubTransferFeeFunc mocks the SubTransferFee method. SubTransferFeeFunc func(ctx cosmossdktypes.Context, coin cosmossdktypes.Coin) @@ -817,6 +931,20 @@ type NexusMock struct { // Chain is the chain argument value. Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain } + // ActivateWasmConnection holds details about calls to the ActivateWasmConnection method. + ActivateWasmConnection []struct { + // Ctx is the ctx argument value. + Ctx cosmossdktypes.Context + } + // AddChainMaintainer holds details about calls to the AddChainMaintainer method. + AddChainMaintainer []struct { + // Ctx is the ctx argument value. + Ctx cosmossdktypes.Context + // Chain is the chain argument value. + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain + // Validator is the validator argument value. + Validator cosmossdktypes.ValAddress + } // ArchivePendingTransfer holds details about calls to the ArchivePendingTransfer method. ArchivePendingTransfer []struct { // Ctx is the ctx argument value. @@ -824,6 +952,23 @@ type NexusMock struct { // Transfer is the transfer argument value. Transfer github_com_axelarnetwork_axelar_core_x_nexus_exported.CrossChainTransfer } + // DeactivateChain holds details about calls to the DeactivateChain method. + DeactivateChain []struct { + // Ctx is the ctx argument value. + Ctx cosmossdktypes.Context + // Chain is the chain argument value. + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain + } + // DeactivateWasmConnection holds details about calls to the DeactivateWasmConnection method. + DeactivateWasmConnection []struct { + // Ctx is the ctx argument value. + Ctx cosmossdktypes.Context + } + // DequeueRouteMessage holds details about calls to the DequeueRouteMessage method. + DequeueRouteMessage []struct { + // Ctx is the ctx argument value. + Ctx cosmossdktypes.Context + } // EnqueueForTransfer holds details about calls to the EnqueueForTransfer method. EnqueueForTransfer []struct { // Ctx is the ctx argument value. @@ -844,6 +989,11 @@ type NexusMock struct { // Asset is the asset argument value. Asset cosmossdktypes.Coin } + // ExportGenesis holds details about calls to the ExportGenesis method. + ExportGenesis []struct { + // Ctx is the ctx argument value. + Ctx cosmossdktypes.Context + } // GenerateMessageID holds details about calls to the GenerateMessageID method. GenerateMessageID []struct { // Ctx is the ctx argument value. @@ -863,6 +1013,34 @@ type NexusMock struct { // Asset is the asset argument value. Asset string } + // GetChainMaintainerStates holds details about calls to the GetChainMaintainerStates method. + GetChainMaintainerStates []struct { + // Ctx is the ctx argument value. + Ctx cosmossdktypes.Context + // Chain is the chain argument value. + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain + } + // GetChainMaintainers holds details about calls to the GetChainMaintainers method. + GetChainMaintainers []struct { + // Ctx is the ctx argument value. + Ctx cosmossdktypes.Context + // Chain is the chain argument value. + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain + } + // GetChains holds details about calls to the GetChains method. + GetChains []struct { + // Ctx is the ctx argument value. + Ctx cosmossdktypes.Context + } + // GetFeeInfo holds details about calls to the GetFeeInfo method. + GetFeeInfo []struct { + // Ctx is the ctx argument value. + Ctx cosmossdktypes.Context + // Chain is the chain argument value. + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain + // Asset is the asset argument value. + Asset string + } // GetMessage holds details about calls to the GetMessage method. GetMessage []struct { // Ctx is the ctx argument value. @@ -870,6 +1048,11 @@ type NexusMock struct { // ID is the id argument value. ID string } + // GetParams holds details about calls to the GetParams method. + GetParams []struct { + // Ctx is the ctx argument value. + Ctx cosmossdktypes.Context + } // GetRecipient holds details about calls to the GetRecipient method. GetRecipient []struct { // Ctx is the ctx argument value. @@ -893,6 +1076,13 @@ type NexusMock struct { // PageRequest is the pageRequest argument value. PageRequest *query.PageRequest } + // InitGenesis holds details about calls to the InitGenesis method. + InitGenesis []struct { + // Ctx is the ctx argument value. + Ctx cosmossdktypes.Context + // GenState is the genState argument value. + GenState *nexustypes.GenesisState + } // IsAssetRegistered holds details about calls to the IsAssetRegistered method. IsAssetRegistered []struct { // Ctx is the ctx argument value. @@ -909,6 +1099,20 @@ type NexusMock struct { // Chain is the chain argument value. Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain } + // IsChainMaintainer holds details about calls to the IsChainMaintainer method. + IsChainMaintainer []struct { + // Ctx is the ctx argument value. + Ctx cosmossdktypes.Context + // Chain is the chain argument value. + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain + // Maintainer is the maintainer argument value. + Maintainer cosmossdktypes.ValAddress + } + // IsWasmConnectionActivated holds details about calls to the IsWasmConnectionActivated method. + IsWasmConnectionActivated []struct { + // Ctx is the ctx argument value. + Ctx cosmossdktypes.Context + } // LinkAddresses holds details about calls to the LinkAddresses method. LinkAddresses []struct { // Ctx is the ctx argument value. @@ -918,6 +1122,11 @@ type NexusMock struct { // Recipient is the recipient argument value. Recipient github_com_axelarnetwork_axelar_core_x_nexus_exported.CrossChainAddress } + // Logger holds details about calls to the Logger method. + Logger []struct { + // Ctx is the ctx argument value. + Ctx cosmossdktypes.Context + } // RateLimitTransfer holds details about calls to the RateLimitTransfer method. RateLimitTransfer []struct { // Ctx is the ctx argument value. @@ -942,6 +1151,24 @@ type NexusMock struct { // Window is the window argument value. Window time.Duration } + // RegisterFee holds details about calls to the RegisterFee method. + RegisterFee []struct { + // Ctx is the ctx argument value. + Ctx cosmossdktypes.Context + // Chain is the chain argument value. + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain + // FeeInfo is the feeInfo argument value. + FeeInfo github_com_axelarnetwork_axelar_core_x_nexus_exported.FeeInfo + } + // RemoveChainMaintainer holds details about calls to the RemoveChainMaintainer method. + RemoveChainMaintainer []struct { + // Ctx is the ctx argument value. + Ctx cosmossdktypes.Context + // Chain is the chain argument value. + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain + // Validator is the validator argument value. + Validator cosmossdktypes.ValAddress + } // RouteMessage holds details about calls to the RouteMessage method. RouteMessage []struct { // Ctx is the ctx argument value. @@ -976,8 +1203,26 @@ type NexusMock struct { SetNewMessage []struct { // Ctx is the ctx argument value. Ctx cosmossdktypes.Context - // M is the m argument value. - M github_com_axelarnetwork_axelar_core_x_nexus_exported.GeneralMessage + // Msg is the msg argument value. + Msg github_com_axelarnetwork_axelar_core_x_nexus_exported.GeneralMessage + } + // SetParams holds details about calls to the SetParams method. + SetParams []struct { + // Ctx is the ctx argument value. + Ctx cosmossdktypes.Context + // P is the p argument value. + P nexustypes.Params + } + // SetRateLimit holds details about calls to the SetRateLimit method. + SetRateLimit []struct { + // Ctx is the ctx argument value. + Ctx cosmossdktypes.Context + // ChainName is the chainName argument value. + ChainName github_com_axelarnetwork_axelar_core_x_nexus_exported.ChainName + // Limit is the limit argument value. + Limit cosmossdktypes.Coin + // Window is the window argument value. + Window time.Duration } // SubTransferFee holds details about calls to the SubTransferFee method. SubTransferFee []struct { @@ -995,26 +1240,45 @@ type NexusMock struct { } } lockActivateChain sync.RWMutex + lockActivateWasmConnection sync.RWMutex + lockAddChainMaintainer sync.RWMutex lockArchivePendingTransfer sync.RWMutex + lockDeactivateChain sync.RWMutex + lockDeactivateWasmConnection sync.RWMutex + lockDequeueRouteMessage sync.RWMutex lockEnqueueForTransfer sync.RWMutex lockEnqueueTransfer sync.RWMutex + lockExportGenesis sync.RWMutex lockGenerateMessageID sync.RWMutex lockGetChain sync.RWMutex lockGetChainByNativeAsset sync.RWMutex + lockGetChainMaintainerStates sync.RWMutex + lockGetChainMaintainers sync.RWMutex + lockGetChains sync.RWMutex + lockGetFeeInfo sync.RWMutex lockGetMessage sync.RWMutex + lockGetParams sync.RWMutex lockGetRecipient sync.RWMutex lockGetTransferFees sync.RWMutex lockGetTransfersForChainPaginated sync.RWMutex + lockInitGenesis sync.RWMutex lockIsAssetRegistered sync.RWMutex lockIsChainActivated sync.RWMutex + lockIsChainMaintainer sync.RWMutex + lockIsWasmConnectionActivated sync.RWMutex lockLinkAddresses sync.RWMutex + lockLogger sync.RWMutex lockRateLimitTransfer sync.RWMutex lockRegisterAsset sync.RWMutex + lockRegisterFee sync.RWMutex + lockRemoveChainMaintainer sync.RWMutex lockRouteMessage sync.RWMutex lockSetChain sync.RWMutex lockSetMessageExecuted sync.RWMutex lockSetMessageFailed sync.RWMutex lockSetNewMessage sync.RWMutex + lockSetParams sync.RWMutex + lockSetRateLimit sync.RWMutex lockSubTransferFee sync.RWMutex lockValidateAddress sync.RWMutex } @@ -1055,6 +1319,78 @@ func (mock *NexusMock) ActivateChainCalls() []struct { return calls } +// ActivateWasmConnection calls ActivateWasmConnectionFunc. +func (mock *NexusMock) ActivateWasmConnection(ctx cosmossdktypes.Context) { + if mock.ActivateWasmConnectionFunc == nil { + panic("NexusMock.ActivateWasmConnectionFunc: method is nil but Nexus.ActivateWasmConnection was just called") + } + callInfo := struct { + Ctx cosmossdktypes.Context + }{ + Ctx: ctx, + } + mock.lockActivateWasmConnection.Lock() + mock.calls.ActivateWasmConnection = append(mock.calls.ActivateWasmConnection, callInfo) + mock.lockActivateWasmConnection.Unlock() + mock.ActivateWasmConnectionFunc(ctx) +} + +// ActivateWasmConnectionCalls gets all the calls that were made to ActivateWasmConnection. +// Check the length with: +// +// len(mockedNexus.ActivateWasmConnectionCalls()) +func (mock *NexusMock) ActivateWasmConnectionCalls() []struct { + Ctx cosmossdktypes.Context +} { + var calls []struct { + Ctx cosmossdktypes.Context + } + mock.lockActivateWasmConnection.RLock() + calls = mock.calls.ActivateWasmConnection + mock.lockActivateWasmConnection.RUnlock() + return calls +} + +// AddChainMaintainer calls AddChainMaintainerFunc. +func (mock *NexusMock) AddChainMaintainer(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain, validator cosmossdktypes.ValAddress) error { + if mock.AddChainMaintainerFunc == nil { + panic("NexusMock.AddChainMaintainerFunc: method is nil but Nexus.AddChainMaintainer was just called") + } + callInfo := struct { + Ctx cosmossdktypes.Context + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain + Validator cosmossdktypes.ValAddress + }{ + Ctx: ctx, + Chain: chain, + Validator: validator, + } + mock.lockAddChainMaintainer.Lock() + mock.calls.AddChainMaintainer = append(mock.calls.AddChainMaintainer, callInfo) + mock.lockAddChainMaintainer.Unlock() + return mock.AddChainMaintainerFunc(ctx, chain, validator) +} + +// AddChainMaintainerCalls gets all the calls that were made to AddChainMaintainer. +// Check the length with: +// +// len(mockedNexus.AddChainMaintainerCalls()) +func (mock *NexusMock) AddChainMaintainerCalls() []struct { + Ctx cosmossdktypes.Context + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain + Validator cosmossdktypes.ValAddress +} { + var calls []struct { + Ctx cosmossdktypes.Context + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain + Validator cosmossdktypes.ValAddress + } + mock.lockAddChainMaintainer.RLock() + calls = mock.calls.AddChainMaintainer + mock.lockAddChainMaintainer.RUnlock() + return calls +} + // ArchivePendingTransfer calls ArchivePendingTransferFunc. func (mock *NexusMock) ArchivePendingTransfer(ctx cosmossdktypes.Context, transfer github_com_axelarnetwork_axelar_core_x_nexus_exported.CrossChainTransfer) { if mock.ArchivePendingTransferFunc == nil { @@ -1091,6 +1427,106 @@ func (mock *NexusMock) ArchivePendingTransferCalls() []struct { return calls } +// DeactivateChain calls DeactivateChainFunc. +func (mock *NexusMock) DeactivateChain(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain) { + if mock.DeactivateChainFunc == nil { + panic("NexusMock.DeactivateChainFunc: method is nil but Nexus.DeactivateChain was just called") + } + callInfo := struct { + Ctx cosmossdktypes.Context + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain + }{ + Ctx: ctx, + Chain: chain, + } + mock.lockDeactivateChain.Lock() + mock.calls.DeactivateChain = append(mock.calls.DeactivateChain, callInfo) + mock.lockDeactivateChain.Unlock() + mock.DeactivateChainFunc(ctx, chain) +} + +// DeactivateChainCalls gets all the calls that were made to DeactivateChain. +// Check the length with: +// +// len(mockedNexus.DeactivateChainCalls()) +func (mock *NexusMock) DeactivateChainCalls() []struct { + Ctx cosmossdktypes.Context + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain +} { + var calls []struct { + Ctx cosmossdktypes.Context + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain + } + mock.lockDeactivateChain.RLock() + calls = mock.calls.DeactivateChain + mock.lockDeactivateChain.RUnlock() + return calls +} + +// DeactivateWasmConnection calls DeactivateWasmConnectionFunc. +func (mock *NexusMock) DeactivateWasmConnection(ctx cosmossdktypes.Context) { + if mock.DeactivateWasmConnectionFunc == nil { + panic("NexusMock.DeactivateWasmConnectionFunc: method is nil but Nexus.DeactivateWasmConnection was just called") + } + callInfo := struct { + Ctx cosmossdktypes.Context + }{ + Ctx: ctx, + } + mock.lockDeactivateWasmConnection.Lock() + mock.calls.DeactivateWasmConnection = append(mock.calls.DeactivateWasmConnection, callInfo) + mock.lockDeactivateWasmConnection.Unlock() + mock.DeactivateWasmConnectionFunc(ctx) +} + +// DeactivateWasmConnectionCalls gets all the calls that were made to DeactivateWasmConnection. +// Check the length with: +// +// len(mockedNexus.DeactivateWasmConnectionCalls()) +func (mock *NexusMock) DeactivateWasmConnectionCalls() []struct { + Ctx cosmossdktypes.Context +} { + var calls []struct { + Ctx cosmossdktypes.Context + } + mock.lockDeactivateWasmConnection.RLock() + calls = mock.calls.DeactivateWasmConnection + mock.lockDeactivateWasmConnection.RUnlock() + return calls +} + +// DequeueRouteMessage calls DequeueRouteMessageFunc. +func (mock *NexusMock) DequeueRouteMessage(ctx cosmossdktypes.Context) (github_com_axelarnetwork_axelar_core_x_nexus_exported.GeneralMessage, bool) { + if mock.DequeueRouteMessageFunc == nil { + panic("NexusMock.DequeueRouteMessageFunc: method is nil but Nexus.DequeueRouteMessage was just called") + } + callInfo := struct { + Ctx cosmossdktypes.Context + }{ + Ctx: ctx, + } + mock.lockDequeueRouteMessage.Lock() + mock.calls.DequeueRouteMessage = append(mock.calls.DequeueRouteMessage, callInfo) + mock.lockDequeueRouteMessage.Unlock() + return mock.DequeueRouteMessageFunc(ctx) +} + +// DequeueRouteMessageCalls gets all the calls that were made to DequeueRouteMessage. +// Check the length with: +// +// len(mockedNexus.DequeueRouteMessageCalls()) +func (mock *NexusMock) DequeueRouteMessageCalls() []struct { + Ctx cosmossdktypes.Context +} { + var calls []struct { + Ctx cosmossdktypes.Context + } + mock.lockDequeueRouteMessage.RLock() + calls = mock.calls.DequeueRouteMessage + mock.lockDequeueRouteMessage.RUnlock() + return calls +} + // EnqueueForTransfer calls EnqueueForTransferFunc. func (mock *NexusMock) EnqueueForTransfer(ctx cosmossdktypes.Context, sender github_com_axelarnetwork_axelar_core_x_nexus_exported.CrossChainAddress, amount cosmossdktypes.Coin) (github_com_axelarnetwork_axelar_core_x_nexus_exported.TransferID, error) { if mock.EnqueueForTransferFunc == nil { @@ -1175,6 +1611,38 @@ func (mock *NexusMock) EnqueueTransferCalls() []struct { return calls } +// ExportGenesis calls ExportGenesisFunc. +func (mock *NexusMock) ExportGenesis(ctx cosmossdktypes.Context) *nexustypes.GenesisState { + if mock.ExportGenesisFunc == nil { + panic("NexusMock.ExportGenesisFunc: method is nil but Nexus.ExportGenesis was just called") + } + callInfo := struct { + Ctx cosmossdktypes.Context + }{ + Ctx: ctx, + } + mock.lockExportGenesis.Lock() + mock.calls.ExportGenesis = append(mock.calls.ExportGenesis, callInfo) + mock.lockExportGenesis.Unlock() + return mock.ExportGenesisFunc(ctx) +} + +// ExportGenesisCalls gets all the calls that were made to ExportGenesis. +// Check the length with: +// +// len(mockedNexus.ExportGenesisCalls()) +func (mock *NexusMock) ExportGenesisCalls() []struct { + Ctx cosmossdktypes.Context +} { + var calls []struct { + Ctx cosmossdktypes.Context + } + mock.lockExportGenesis.RLock() + calls = mock.calls.ExportGenesis + mock.lockExportGenesis.RUnlock() + return calls +} + // GenerateMessageID calls GenerateMessageIDFunc. func (mock *NexusMock) GenerateMessageID(ctx cosmossdktypes.Context) (string, []byte, uint64) { if mock.GenerateMessageIDFunc == nil { @@ -1279,6 +1747,150 @@ func (mock *NexusMock) GetChainByNativeAssetCalls() []struct { return calls } +// GetChainMaintainerStates calls GetChainMaintainerStatesFunc. +func (mock *NexusMock) GetChainMaintainerStates(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain) []github_com_axelarnetwork_axelar_core_x_nexus_exported.MaintainerState { + if mock.GetChainMaintainerStatesFunc == nil { + panic("NexusMock.GetChainMaintainerStatesFunc: method is nil but Nexus.GetChainMaintainerStates was just called") + } + callInfo := struct { + Ctx cosmossdktypes.Context + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain + }{ + Ctx: ctx, + Chain: chain, + } + mock.lockGetChainMaintainerStates.Lock() + mock.calls.GetChainMaintainerStates = append(mock.calls.GetChainMaintainerStates, callInfo) + mock.lockGetChainMaintainerStates.Unlock() + return mock.GetChainMaintainerStatesFunc(ctx, chain) +} + +// GetChainMaintainerStatesCalls gets all the calls that were made to GetChainMaintainerStates. +// Check the length with: +// +// len(mockedNexus.GetChainMaintainerStatesCalls()) +func (mock *NexusMock) GetChainMaintainerStatesCalls() []struct { + Ctx cosmossdktypes.Context + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain +} { + var calls []struct { + Ctx cosmossdktypes.Context + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain + } + mock.lockGetChainMaintainerStates.RLock() + calls = mock.calls.GetChainMaintainerStates + mock.lockGetChainMaintainerStates.RUnlock() + return calls +} + +// GetChainMaintainers calls GetChainMaintainersFunc. +func (mock *NexusMock) GetChainMaintainers(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain) []cosmossdktypes.ValAddress { + if mock.GetChainMaintainersFunc == nil { + panic("NexusMock.GetChainMaintainersFunc: method is nil but Nexus.GetChainMaintainers was just called") + } + callInfo := struct { + Ctx cosmossdktypes.Context + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain + }{ + Ctx: ctx, + Chain: chain, + } + mock.lockGetChainMaintainers.Lock() + mock.calls.GetChainMaintainers = append(mock.calls.GetChainMaintainers, callInfo) + mock.lockGetChainMaintainers.Unlock() + return mock.GetChainMaintainersFunc(ctx, chain) +} + +// GetChainMaintainersCalls gets all the calls that were made to GetChainMaintainers. +// Check the length with: +// +// len(mockedNexus.GetChainMaintainersCalls()) +func (mock *NexusMock) GetChainMaintainersCalls() []struct { + Ctx cosmossdktypes.Context + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain +} { + var calls []struct { + Ctx cosmossdktypes.Context + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain + } + mock.lockGetChainMaintainers.RLock() + calls = mock.calls.GetChainMaintainers + mock.lockGetChainMaintainers.RUnlock() + return calls +} + +// GetChains calls GetChainsFunc. +func (mock *NexusMock) GetChains(ctx cosmossdktypes.Context) []github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain { + if mock.GetChainsFunc == nil { + panic("NexusMock.GetChainsFunc: method is nil but Nexus.GetChains was just called") + } + callInfo := struct { + Ctx cosmossdktypes.Context + }{ + Ctx: ctx, + } + mock.lockGetChains.Lock() + mock.calls.GetChains = append(mock.calls.GetChains, callInfo) + mock.lockGetChains.Unlock() + return mock.GetChainsFunc(ctx) +} + +// GetChainsCalls gets all the calls that were made to GetChains. +// Check the length with: +// +// len(mockedNexus.GetChainsCalls()) +func (mock *NexusMock) GetChainsCalls() []struct { + Ctx cosmossdktypes.Context +} { + var calls []struct { + Ctx cosmossdktypes.Context + } + mock.lockGetChains.RLock() + calls = mock.calls.GetChains + mock.lockGetChains.RUnlock() + return calls +} + +// GetFeeInfo calls GetFeeInfoFunc. +func (mock *NexusMock) GetFeeInfo(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain, asset string) github_com_axelarnetwork_axelar_core_x_nexus_exported.FeeInfo { + if mock.GetFeeInfoFunc == nil { + panic("NexusMock.GetFeeInfoFunc: method is nil but Nexus.GetFeeInfo was just called") + } + callInfo := struct { + Ctx cosmossdktypes.Context + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain + Asset string + }{ + Ctx: ctx, + Chain: chain, + Asset: asset, + } + mock.lockGetFeeInfo.Lock() + mock.calls.GetFeeInfo = append(mock.calls.GetFeeInfo, callInfo) + mock.lockGetFeeInfo.Unlock() + return mock.GetFeeInfoFunc(ctx, chain, asset) +} + +// GetFeeInfoCalls gets all the calls that were made to GetFeeInfo. +// Check the length with: +// +// len(mockedNexus.GetFeeInfoCalls()) +func (mock *NexusMock) GetFeeInfoCalls() []struct { + Ctx cosmossdktypes.Context + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain + Asset string +} { + var calls []struct { + Ctx cosmossdktypes.Context + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain + Asset string + } + mock.lockGetFeeInfo.RLock() + calls = mock.calls.GetFeeInfo + mock.lockGetFeeInfo.RUnlock() + return calls +} + // GetMessage calls GetMessageFunc. func (mock *NexusMock) GetMessage(ctx cosmossdktypes.Context, id string) (github_com_axelarnetwork_axelar_core_x_nexus_exported.GeneralMessage, bool) { if mock.GetMessageFunc == nil { @@ -1315,6 +1927,38 @@ func (mock *NexusMock) GetMessageCalls() []struct { return calls } +// GetParams calls GetParamsFunc. +func (mock *NexusMock) GetParams(ctx cosmossdktypes.Context) nexustypes.Params { + if mock.GetParamsFunc == nil { + panic("NexusMock.GetParamsFunc: method is nil but Nexus.GetParams was just called") + } + callInfo := struct { + Ctx cosmossdktypes.Context + }{ + Ctx: ctx, + } + mock.lockGetParams.Lock() + mock.calls.GetParams = append(mock.calls.GetParams, callInfo) + mock.lockGetParams.Unlock() + return mock.GetParamsFunc(ctx) +} + +// GetParamsCalls gets all the calls that were made to GetParams. +// Check the length with: +// +// len(mockedNexus.GetParamsCalls()) +func (mock *NexusMock) GetParamsCalls() []struct { + Ctx cosmossdktypes.Context +} { + var calls []struct { + Ctx cosmossdktypes.Context + } + mock.lockGetParams.RLock() + calls = mock.calls.GetParams + mock.lockGetParams.RUnlock() + return calls +} + // GetRecipient calls GetRecipientFunc. func (mock *NexusMock) GetRecipient(ctx cosmossdktypes.Context, sender github_com_axelarnetwork_axelar_core_x_nexus_exported.CrossChainAddress) (github_com_axelarnetwork_axelar_core_x_nexus_exported.CrossChainAddress, bool) { if mock.GetRecipientFunc == nil { @@ -1427,6 +2071,42 @@ func (mock *NexusMock) GetTransfersForChainPaginatedCalls() []struct { return calls } +// InitGenesis calls InitGenesisFunc. +func (mock *NexusMock) InitGenesis(ctx cosmossdktypes.Context, genState *nexustypes.GenesisState) { + if mock.InitGenesisFunc == nil { + panic("NexusMock.InitGenesisFunc: method is nil but Nexus.InitGenesis was just called") + } + callInfo := struct { + Ctx cosmossdktypes.Context + GenState *nexustypes.GenesisState + }{ + Ctx: ctx, + GenState: genState, + } + mock.lockInitGenesis.Lock() + mock.calls.InitGenesis = append(mock.calls.InitGenesis, callInfo) + mock.lockInitGenesis.Unlock() + mock.InitGenesisFunc(ctx, genState) +} + +// InitGenesisCalls gets all the calls that were made to InitGenesis. +// Check the length with: +// +// len(mockedNexus.InitGenesisCalls()) +func (mock *NexusMock) InitGenesisCalls() []struct { + Ctx cosmossdktypes.Context + GenState *nexustypes.GenesisState +} { + var calls []struct { + Ctx cosmossdktypes.Context + GenState *nexustypes.GenesisState + } + mock.lockInitGenesis.RLock() + calls = mock.calls.InitGenesis + mock.lockInitGenesis.RUnlock() + return calls +} + // IsAssetRegistered calls IsAssetRegisteredFunc. func (mock *NexusMock) IsAssetRegistered(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain, denom string) bool { if mock.IsAssetRegisteredFunc == nil { @@ -1503,6 +2183,78 @@ func (mock *NexusMock) IsChainActivatedCalls() []struct { return calls } +// IsChainMaintainer calls IsChainMaintainerFunc. +func (mock *NexusMock) IsChainMaintainer(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain, maintainer cosmossdktypes.ValAddress) bool { + if mock.IsChainMaintainerFunc == nil { + panic("NexusMock.IsChainMaintainerFunc: method is nil but Nexus.IsChainMaintainer was just called") + } + callInfo := struct { + Ctx cosmossdktypes.Context + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain + Maintainer cosmossdktypes.ValAddress + }{ + Ctx: ctx, + Chain: chain, + Maintainer: maintainer, + } + mock.lockIsChainMaintainer.Lock() + mock.calls.IsChainMaintainer = append(mock.calls.IsChainMaintainer, callInfo) + mock.lockIsChainMaintainer.Unlock() + return mock.IsChainMaintainerFunc(ctx, chain, maintainer) +} + +// IsChainMaintainerCalls gets all the calls that were made to IsChainMaintainer. +// Check the length with: +// +// len(mockedNexus.IsChainMaintainerCalls()) +func (mock *NexusMock) IsChainMaintainerCalls() []struct { + Ctx cosmossdktypes.Context + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain + Maintainer cosmossdktypes.ValAddress +} { + var calls []struct { + Ctx cosmossdktypes.Context + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain + Maintainer cosmossdktypes.ValAddress + } + mock.lockIsChainMaintainer.RLock() + calls = mock.calls.IsChainMaintainer + mock.lockIsChainMaintainer.RUnlock() + return calls +} + +// IsWasmConnectionActivated calls IsWasmConnectionActivatedFunc. +func (mock *NexusMock) IsWasmConnectionActivated(ctx cosmossdktypes.Context) bool { + if mock.IsWasmConnectionActivatedFunc == nil { + panic("NexusMock.IsWasmConnectionActivatedFunc: method is nil but Nexus.IsWasmConnectionActivated was just called") + } + callInfo := struct { + Ctx cosmossdktypes.Context + }{ + Ctx: ctx, + } + mock.lockIsWasmConnectionActivated.Lock() + mock.calls.IsWasmConnectionActivated = append(mock.calls.IsWasmConnectionActivated, callInfo) + mock.lockIsWasmConnectionActivated.Unlock() + return mock.IsWasmConnectionActivatedFunc(ctx) +} + +// IsWasmConnectionActivatedCalls gets all the calls that were made to IsWasmConnectionActivated. +// Check the length with: +// +// len(mockedNexus.IsWasmConnectionActivatedCalls()) +func (mock *NexusMock) IsWasmConnectionActivatedCalls() []struct { + Ctx cosmossdktypes.Context +} { + var calls []struct { + Ctx cosmossdktypes.Context + } + mock.lockIsWasmConnectionActivated.RLock() + calls = mock.calls.IsWasmConnectionActivated + mock.lockIsWasmConnectionActivated.RUnlock() + return calls +} + // LinkAddresses calls LinkAddressesFunc. func (mock *NexusMock) LinkAddresses(ctx cosmossdktypes.Context, sender github_com_axelarnetwork_axelar_core_x_nexus_exported.CrossChainAddress, recipient github_com_axelarnetwork_axelar_core_x_nexus_exported.CrossChainAddress) error { if mock.LinkAddressesFunc == nil { @@ -1543,6 +2295,38 @@ func (mock *NexusMock) LinkAddressesCalls() []struct { return calls } +// Logger calls LoggerFunc. +func (mock *NexusMock) Logger(ctx cosmossdktypes.Context) log.Logger { + if mock.LoggerFunc == nil { + panic("NexusMock.LoggerFunc: method is nil but Nexus.Logger was just called") + } + callInfo := struct { + Ctx cosmossdktypes.Context + }{ + Ctx: ctx, + } + mock.lockLogger.Lock() + mock.calls.Logger = append(mock.calls.Logger, callInfo) + mock.lockLogger.Unlock() + return mock.LoggerFunc(ctx) +} + +// LoggerCalls gets all the calls that were made to Logger. +// Check the length with: +// +// len(mockedNexus.LoggerCalls()) +func (mock *NexusMock) LoggerCalls() []struct { + Ctx cosmossdktypes.Context +} { + var calls []struct { + Ctx cosmossdktypes.Context + } + mock.lockLogger.RLock() + calls = mock.calls.Logger + mock.lockLogger.RUnlock() + return calls +} + // RateLimitTransfer calls RateLimitTransferFunc. func (mock *NexusMock) RateLimitTransfer(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.ChainName, asset cosmossdktypes.Coin, direction github_com_axelarnetwork_axelar_core_x_nexus_exported.TransferDirection) error { if mock.RateLimitTransferFunc == nil { @@ -1635,6 +2419,86 @@ func (mock *NexusMock) RegisterAssetCalls() []struct { return calls } +// RegisterFee calls RegisterFeeFunc. +func (mock *NexusMock) RegisterFee(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain, feeInfo github_com_axelarnetwork_axelar_core_x_nexus_exported.FeeInfo) error { + if mock.RegisterFeeFunc == nil { + panic("NexusMock.RegisterFeeFunc: method is nil but Nexus.RegisterFee was just called") + } + callInfo := struct { + Ctx cosmossdktypes.Context + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain + FeeInfo github_com_axelarnetwork_axelar_core_x_nexus_exported.FeeInfo + }{ + Ctx: ctx, + Chain: chain, + FeeInfo: feeInfo, + } + mock.lockRegisterFee.Lock() + mock.calls.RegisterFee = append(mock.calls.RegisterFee, callInfo) + mock.lockRegisterFee.Unlock() + return mock.RegisterFeeFunc(ctx, chain, feeInfo) +} + +// RegisterFeeCalls gets all the calls that were made to RegisterFee. +// Check the length with: +// +// len(mockedNexus.RegisterFeeCalls()) +func (mock *NexusMock) RegisterFeeCalls() []struct { + Ctx cosmossdktypes.Context + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain + FeeInfo github_com_axelarnetwork_axelar_core_x_nexus_exported.FeeInfo +} { + var calls []struct { + Ctx cosmossdktypes.Context + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain + FeeInfo github_com_axelarnetwork_axelar_core_x_nexus_exported.FeeInfo + } + mock.lockRegisterFee.RLock() + calls = mock.calls.RegisterFee + mock.lockRegisterFee.RUnlock() + return calls +} + +// RemoveChainMaintainer calls RemoveChainMaintainerFunc. +func (mock *NexusMock) RemoveChainMaintainer(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain, validator cosmossdktypes.ValAddress) error { + if mock.RemoveChainMaintainerFunc == nil { + panic("NexusMock.RemoveChainMaintainerFunc: method is nil but Nexus.RemoveChainMaintainer was just called") + } + callInfo := struct { + Ctx cosmossdktypes.Context + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain + Validator cosmossdktypes.ValAddress + }{ + Ctx: ctx, + Chain: chain, + Validator: validator, + } + mock.lockRemoveChainMaintainer.Lock() + mock.calls.RemoveChainMaintainer = append(mock.calls.RemoveChainMaintainer, callInfo) + mock.lockRemoveChainMaintainer.Unlock() + return mock.RemoveChainMaintainerFunc(ctx, chain, validator) +} + +// RemoveChainMaintainerCalls gets all the calls that were made to RemoveChainMaintainer. +// Check the length with: +// +// len(mockedNexus.RemoveChainMaintainerCalls()) +func (mock *NexusMock) RemoveChainMaintainerCalls() []struct { + Ctx cosmossdktypes.Context + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain + Validator cosmossdktypes.ValAddress +} { + var calls []struct { + Ctx cosmossdktypes.Context + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.Chain + Validator cosmossdktypes.ValAddress + } + mock.lockRemoveChainMaintainer.RLock() + calls = mock.calls.RemoveChainMaintainer + mock.lockRemoveChainMaintainer.RUnlock() + return calls +} + // RouteMessage calls RouteMessageFunc. func (mock *NexusMock) RouteMessage(ctx cosmossdktypes.Context, id string, routingCtx ...github_com_axelarnetwork_axelar_core_x_nexus_exported.RoutingContext) error { if mock.RouteMessageFunc == nil { @@ -1784,21 +2648,21 @@ func (mock *NexusMock) SetMessageFailedCalls() []struct { } // SetNewMessage calls SetNewMessageFunc. -func (mock *NexusMock) SetNewMessage(ctx cosmossdktypes.Context, m github_com_axelarnetwork_axelar_core_x_nexus_exported.GeneralMessage) error { +func (mock *NexusMock) SetNewMessage(ctx cosmossdktypes.Context, msg github_com_axelarnetwork_axelar_core_x_nexus_exported.GeneralMessage) error { if mock.SetNewMessageFunc == nil { panic("NexusMock.SetNewMessageFunc: method is nil but Nexus.SetNewMessage was just called") } callInfo := struct { Ctx cosmossdktypes.Context - M github_com_axelarnetwork_axelar_core_x_nexus_exported.GeneralMessage + Msg github_com_axelarnetwork_axelar_core_x_nexus_exported.GeneralMessage }{ Ctx: ctx, - M: m, + Msg: msg, } mock.lockSetNewMessage.Lock() mock.calls.SetNewMessage = append(mock.calls.SetNewMessage, callInfo) mock.lockSetNewMessage.Unlock() - return mock.SetNewMessageFunc(ctx, m) + return mock.SetNewMessageFunc(ctx, msg) } // SetNewMessageCalls gets all the calls that were made to SetNewMessage. @@ -1807,11 +2671,11 @@ func (mock *NexusMock) SetNewMessage(ctx cosmossdktypes.Context, m github_com_ax // len(mockedNexus.SetNewMessageCalls()) func (mock *NexusMock) SetNewMessageCalls() []struct { Ctx cosmossdktypes.Context - M github_com_axelarnetwork_axelar_core_x_nexus_exported.GeneralMessage + Msg github_com_axelarnetwork_axelar_core_x_nexus_exported.GeneralMessage } { var calls []struct { Ctx cosmossdktypes.Context - M github_com_axelarnetwork_axelar_core_x_nexus_exported.GeneralMessage + Msg github_com_axelarnetwork_axelar_core_x_nexus_exported.GeneralMessage } mock.lockSetNewMessage.RLock() calls = mock.calls.SetNewMessage @@ -1819,6 +2683,86 @@ func (mock *NexusMock) SetNewMessageCalls() []struct { return calls } +// SetParams calls SetParamsFunc. +func (mock *NexusMock) SetParams(ctx cosmossdktypes.Context, p nexustypes.Params) { + if mock.SetParamsFunc == nil { + panic("NexusMock.SetParamsFunc: method is nil but Nexus.SetParams was just called") + } + callInfo := struct { + Ctx cosmossdktypes.Context + P nexustypes.Params + }{ + Ctx: ctx, + P: p, + } + mock.lockSetParams.Lock() + mock.calls.SetParams = append(mock.calls.SetParams, callInfo) + mock.lockSetParams.Unlock() + mock.SetParamsFunc(ctx, p) +} + +// SetParamsCalls gets all the calls that were made to SetParams. +// Check the length with: +// +// len(mockedNexus.SetParamsCalls()) +func (mock *NexusMock) SetParamsCalls() []struct { + Ctx cosmossdktypes.Context + P nexustypes.Params +} { + var calls []struct { + Ctx cosmossdktypes.Context + P nexustypes.Params + } + mock.lockSetParams.RLock() + calls = mock.calls.SetParams + mock.lockSetParams.RUnlock() + return calls +} + +// SetRateLimit calls SetRateLimitFunc. +func (mock *NexusMock) SetRateLimit(ctx cosmossdktypes.Context, chainName github_com_axelarnetwork_axelar_core_x_nexus_exported.ChainName, limit cosmossdktypes.Coin, window time.Duration) error { + if mock.SetRateLimitFunc == nil { + panic("NexusMock.SetRateLimitFunc: method is nil but Nexus.SetRateLimit was just called") + } + callInfo := struct { + Ctx cosmossdktypes.Context + ChainName github_com_axelarnetwork_axelar_core_x_nexus_exported.ChainName + Limit cosmossdktypes.Coin + Window time.Duration + }{ + Ctx: ctx, + ChainName: chainName, + Limit: limit, + Window: window, + } + mock.lockSetRateLimit.Lock() + mock.calls.SetRateLimit = append(mock.calls.SetRateLimit, callInfo) + mock.lockSetRateLimit.Unlock() + return mock.SetRateLimitFunc(ctx, chainName, limit, window) +} + +// SetRateLimitCalls gets all the calls that were made to SetRateLimit. +// Check the length with: +// +// len(mockedNexus.SetRateLimitCalls()) +func (mock *NexusMock) SetRateLimitCalls() []struct { + Ctx cosmossdktypes.Context + ChainName github_com_axelarnetwork_axelar_core_x_nexus_exported.ChainName + Limit cosmossdktypes.Coin + Window time.Duration +} { + var calls []struct { + Ctx cosmossdktypes.Context + ChainName github_com_axelarnetwork_axelar_core_x_nexus_exported.ChainName + Limit cosmossdktypes.Coin + Window time.Duration + } + mock.lockSetRateLimit.RLock() + calls = mock.calls.SetRateLimit + mock.lockSetRateLimit.RUnlock() + return calls +} + // SubTransferFee calls SubTransferFeeFunc. func (mock *NexusMock) SubTransferFee(ctx cosmossdktypes.Context, coin cosmossdktypes.Coin) { if mock.SubTransferFeeFunc == nil { @@ -2993,9 +3937,6 @@ var _ axelarnettypes.AccountKeeper = &AccountKeeperMock{} // // // make and configure a mocked axelarnettypes.AccountKeeper // mockedAccountKeeper := &AccountKeeperMock{ -// GetModuleAccountFunc: func(ctx cosmossdktypes.Context, moduleName string) types.ModuleAccountI { -// panic("mock out the GetModuleAccount method") -// }, // GetModuleAddressFunc: func(moduleName string) cosmossdktypes.AccAddress { // panic("mock out the GetModuleAddress method") // }, @@ -3006,67 +3947,20 @@ var _ axelarnettypes.AccountKeeper = &AccountKeeperMock{} // // } type AccountKeeperMock struct { - // GetModuleAccountFunc mocks the GetModuleAccount method. - GetModuleAccountFunc func(ctx cosmossdktypes.Context, moduleName string) types.ModuleAccountI - // GetModuleAddressFunc mocks the GetModuleAddress method. GetModuleAddressFunc func(moduleName string) cosmossdktypes.AccAddress // calls tracks calls to the methods. calls struct { - // GetModuleAccount holds details about calls to the GetModuleAccount method. - GetModuleAccount []struct { - // Ctx is the ctx argument value. - Ctx cosmossdktypes.Context - // ModuleName is the moduleName argument value. - ModuleName string - } // GetModuleAddress holds details about calls to the GetModuleAddress method. GetModuleAddress []struct { // ModuleName is the moduleName argument value. ModuleName string } } - lockGetModuleAccount sync.RWMutex lockGetModuleAddress sync.RWMutex } -// GetModuleAccount calls GetModuleAccountFunc. -func (mock *AccountKeeperMock) GetModuleAccount(ctx cosmossdktypes.Context, moduleName string) types.ModuleAccountI { - if mock.GetModuleAccountFunc == nil { - panic("AccountKeeperMock.GetModuleAccountFunc: method is nil but AccountKeeper.GetModuleAccount was just called") - } - callInfo := struct { - Ctx cosmossdktypes.Context - ModuleName string - }{ - Ctx: ctx, - ModuleName: moduleName, - } - mock.lockGetModuleAccount.Lock() - mock.calls.GetModuleAccount = append(mock.calls.GetModuleAccount, callInfo) - mock.lockGetModuleAccount.Unlock() - return mock.GetModuleAccountFunc(ctx, moduleName) -} - -// GetModuleAccountCalls gets all the calls that were made to GetModuleAccount. -// Check the length with: -// -// len(mockedAccountKeeper.GetModuleAccountCalls()) -func (mock *AccountKeeperMock) GetModuleAccountCalls() []struct { - Ctx cosmossdktypes.Context - ModuleName string -} { - var calls []struct { - Ctx cosmossdktypes.Context - ModuleName string - } - mock.lockGetModuleAccount.RLock() - calls = mock.calls.GetModuleAccount - mock.lockGetModuleAccount.RUnlock() - return calls -} - // GetModuleAddress calls GetModuleAddressFunc. func (mock *AccountKeeperMock) GetModuleAddress(moduleName string) cosmossdktypes.AccAddress { if mock.GetModuleAddressFunc == nil { @@ -3409,6 +4303,12 @@ var _ axelarnettypes.IBCKeeper = &IBCKeeperMock{} // // // make and configure a mocked axelarnettypes.IBCKeeper // mockedIBCKeeper := &IBCKeeperMock{ +// GetIBCPathFunc: func(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.ChainName) (string, bool) { +// panic("mock out the GetIBCPath method") +// }, +// ParseIBCDenomFunc: func(ctx cosmossdktypes.Context, ibcDenom string) (ibctransfertypes.DenomTrace, error) { +// panic("mock out the ParseIBCDenom method") +// }, // SendMessageFunc: func(c context.Context, recipient github_com_axelarnetwork_axelar_core_x_nexus_exported.CrossChainAddress, asset cosmossdktypes.Coin, payload string, id string) error { // panic("mock out the SendMessage method") // }, @@ -3419,11 +4319,31 @@ var _ axelarnettypes.IBCKeeper = &IBCKeeperMock{} // // } type IBCKeeperMock struct { + // GetIBCPathFunc mocks the GetIBCPath method. + GetIBCPathFunc func(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.ChainName) (string, bool) + + // ParseIBCDenomFunc mocks the ParseIBCDenom method. + ParseIBCDenomFunc func(ctx cosmossdktypes.Context, ibcDenom string) (ibctransfertypes.DenomTrace, error) + // SendMessageFunc mocks the SendMessage method. SendMessageFunc func(c context.Context, recipient github_com_axelarnetwork_axelar_core_x_nexus_exported.CrossChainAddress, asset cosmossdktypes.Coin, payload string, id string) error // calls tracks calls to the methods. calls struct { + // GetIBCPath holds details about calls to the GetIBCPath method. + GetIBCPath []struct { + // Ctx is the ctx argument value. + Ctx cosmossdktypes.Context + // Chain is the chain argument value. + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.ChainName + } + // ParseIBCDenom holds details about calls to the ParseIBCDenom method. + ParseIBCDenom []struct { + // Ctx is the ctx argument value. + Ctx cosmossdktypes.Context + // IbcDenom is the ibcDenom argument value. + IbcDenom string + } // SendMessage holds details about calls to the SendMessage method. SendMessage []struct { // C is the c argument value. @@ -3438,7 +4358,81 @@ type IBCKeeperMock struct { ID string } } - lockSendMessage sync.RWMutex + lockGetIBCPath sync.RWMutex + lockParseIBCDenom sync.RWMutex + lockSendMessage sync.RWMutex +} + +// GetIBCPath calls GetIBCPathFunc. +func (mock *IBCKeeperMock) GetIBCPath(ctx cosmossdktypes.Context, chain github_com_axelarnetwork_axelar_core_x_nexus_exported.ChainName) (string, bool) { + if mock.GetIBCPathFunc == nil { + panic("IBCKeeperMock.GetIBCPathFunc: method is nil but IBCKeeper.GetIBCPath was just called") + } + callInfo := struct { + Ctx cosmossdktypes.Context + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.ChainName + }{ + Ctx: ctx, + Chain: chain, + } + mock.lockGetIBCPath.Lock() + mock.calls.GetIBCPath = append(mock.calls.GetIBCPath, callInfo) + mock.lockGetIBCPath.Unlock() + return mock.GetIBCPathFunc(ctx, chain) +} + +// GetIBCPathCalls gets all the calls that were made to GetIBCPath. +// Check the length with: +// +// len(mockedIBCKeeper.GetIBCPathCalls()) +func (mock *IBCKeeperMock) GetIBCPathCalls() []struct { + Ctx cosmossdktypes.Context + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.ChainName +} { + var calls []struct { + Ctx cosmossdktypes.Context + Chain github_com_axelarnetwork_axelar_core_x_nexus_exported.ChainName + } + mock.lockGetIBCPath.RLock() + calls = mock.calls.GetIBCPath + mock.lockGetIBCPath.RUnlock() + return calls +} + +// ParseIBCDenom calls ParseIBCDenomFunc. +func (mock *IBCKeeperMock) ParseIBCDenom(ctx cosmossdktypes.Context, ibcDenom string) (ibctransfertypes.DenomTrace, error) { + if mock.ParseIBCDenomFunc == nil { + panic("IBCKeeperMock.ParseIBCDenomFunc: method is nil but IBCKeeper.ParseIBCDenom was just called") + } + callInfo := struct { + Ctx cosmossdktypes.Context + IbcDenom string + }{ + Ctx: ctx, + IbcDenom: ibcDenom, + } + mock.lockParseIBCDenom.Lock() + mock.calls.ParseIBCDenom = append(mock.calls.ParseIBCDenom, callInfo) + mock.lockParseIBCDenom.Unlock() + return mock.ParseIBCDenomFunc(ctx, ibcDenom) +} + +// ParseIBCDenomCalls gets all the calls that were made to ParseIBCDenom. +// Check the length with: +// +// len(mockedIBCKeeper.ParseIBCDenomCalls()) +func (mock *IBCKeeperMock) ParseIBCDenomCalls() []struct { + Ctx cosmossdktypes.Context + IbcDenom string +} { + var calls []struct { + Ctx cosmossdktypes.Context + IbcDenom string + } + mock.lockParseIBCDenom.RLock() + calls = mock.calls.ParseIBCDenom + mock.lockParseIBCDenom.RUnlock() + return calls } // SendMessage calls SendMessageFunc.