diff --git a/app/app.go b/app/app.go index 8f9d2d0ce..0772f0f59 100644 --- a/app/app.go +++ b/app/app.go @@ -12,6 +12,7 @@ import ( v502 "github.com/neutron-org/neutron/v5/app/upgrades/v5.0.2" v504 "github.com/neutron-org/neutron/v5/app/upgrades/v5.0.4" + v505 "github.com/neutron-org/neutron/v5/app/upgrades/v5.0.5" dynamicfeestypes "github.com/neutron-org/neutron/v5/x/dynamicfees/types" "github.com/skip-mev/feemarket/x/feemarket" @@ -232,6 +233,7 @@ var ( v500.Upgrade, v502.Upgrade, v504.Upgrade, + v505.Upgrade, } // DefaultNodeHome default home directories for the application daemon @@ -623,6 +625,17 @@ func New( authtypes.NewModuleAddress(adminmoduletypes.ModuleName).String(), ) + tokenFactoryKeeper := tokenfactorykeeper.NewKeeper( + appCodec, + app.keys[tokenfactorytypes.StoreKey], + maccPerms, + app.AccountKeeper, + &app.BankKeeper, + &app.WasmKeeper, + authtypes.NewModuleAddress(adminmoduletypes.ModuleName).String(), + ) + app.TokenFactoryKeeper = &tokenFactoryKeeper + app.WireICS20PreWasmKeeper(appCodec) app.PFMModule = packetforward.NewAppModule(app.PFMKeeper, app.GetSubspace(pfmtypes.ModuleName)) @@ -686,17 +699,6 @@ func New( app.ConsumerKeeper = *app.ConsumerKeeper.SetHooks(app.SlashingKeeper.Hooks()) consumerModule := ccvconsumer.NewAppModule(app.ConsumerKeeper, app.GetSubspace(ccvconsumertypes.ModuleName)) - tokenFactoryKeeper := tokenfactorykeeper.NewKeeper( - appCodec, - app.keys[tokenfactorytypes.StoreKey], - maccPerms, - app.AccountKeeper, - &app.BankKeeper, - &app.WasmKeeper, - authtypes.NewModuleAddress(adminmoduletypes.ModuleName).String(), - ) - app.TokenFactoryKeeper = &tokenFactoryKeeper - app.BankKeeper.BaseSendKeeper = app.BankKeeper.BaseSendKeeper.SetHooks( banktypes.NewMultiBankHooks( app.TokenFactoryKeeper.Hooks(), @@ -1373,6 +1375,8 @@ func (app *App) setupUpgradeHandlers() { DynamicfeesKeeper: app.DynamicFeesKeeper, DexKeeper: &app.DexKeeper, IbcRateLimitKeeper: app.RateLimitingICS4Wrapper.IbcratelimitKeeper, + ChannelKeeper: &app.IBCKeeper.ChannelKeeper, + TransferKeeper: app.TransferKeeper.Keeper, GlobalFeeSubspace: app.GetSubspace(globalfee.ModuleName), CcvConsumerSubspace: app.GetSubspace(ccvconsumertypes.ModuleName), }, @@ -1722,6 +1726,7 @@ func (app *App) WireICS20PreWasmKeeper( transferSudo.NewIBCModule( app.TransferKeeper, contractmanager.NewSudoLimitWrapper(app.ContractManagerKeeper, &app.WasmKeeper), + app.TokenFactoryKeeper, ), app.PFMKeeper, 0, diff --git a/app/upgrades/types.go b/app/upgrades/types.go index 8c52a43b2..72cf7f709 100644 --- a/app/upgrades/types.go +++ b/app/upgrades/types.go @@ -12,6 +12,7 @@ import ( paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper" + channelkeeper "github.com/cosmos/ibc-go/v8/modules/core/04-channel/keeper" ccvconsumerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/consumer/keeper" auctionkeeper "github.com/skip-mev/block-sdk/v2/x/auction/keeper" feemarketkeeper "github.com/skip-mev/feemarket/x/feemarket/keeper" @@ -69,6 +70,7 @@ type UpgradeKeepers struct { DynamicfeesKeeper *dynamicfeeskeeper.Keeper DexKeeper *dexkeeper.Keeper IbcRateLimitKeeper *ibcratelimitkeeper.Keeper + ChannelKeeper *channelkeeper.Keeper // subspaces GlobalFeeSubspace paramtypes.Subspace CcvConsumerSubspace paramtypes.Subspace diff --git a/app/upgrades/v5.0.5/constants.go b/app/upgrades/v5.0.5/constants.go new file mode 100644 index 000000000..5bb7590d9 --- /dev/null +++ b/app/upgrades/v5.0.5/constants.go @@ -0,0 +1,18 @@ +package v505 + +import ( + storetypes "cosmossdk.io/store/types" + + "github.com/neutron-org/neutron/v5/app/upgrades" +) + +const ( + // UpgradeName defines the on-chain upgrade name. + UpgradeName = "v5.0.5" +) + +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: CreateUpgradeHandler, + StoreUpgrades: storetypes.StoreUpgrades{}, +} diff --git a/app/upgrades/v5.0.5/upgrades.go b/app/upgrades/v5.0.5/upgrades.go new file mode 100644 index 000000000..e90ebc332 --- /dev/null +++ b/app/upgrades/v5.0.5/upgrades.go @@ -0,0 +1,45 @@ +package v505 + +import ( + "context" + "fmt" + + transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + + upgradetypes "cosmossdk.io/x/upgrade/types" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + + "github.com/neutron-org/neutron/v5/app/upgrades" +) + +func CreateUpgradeHandler( + mm *module.Manager, + configurator module.Configurator, + keepers *upgrades.UpgradeKeepers, + _ upgrades.StoreKeys, + _ codec.Codec, +) upgradetypes.UpgradeHandler { + return func(c context.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + ctx := sdk.UnwrapSDKContext(c) + + ctx.Logger().Info("Starting module migrations...") + + vm, err := mm.RunMigrations(ctx, configurator, vm) + if err != nil { + return vm, err + } + + transferChannels := keepers.ChannelKeeper.GetAllChannelsWithPortPrefix(ctx, keepers.TransferKeeper.GetPort(ctx)) + for _, channel := range transferChannels { + escrowAddress := transfertypes.GetEscrowAddress(channel.PortId, channel.ChannelId) + ctx.Logger().Info("Saving escrow address", "port_id", channel.PortId, "channel_id", + channel.ChannelId, "address", escrowAddress.String()) + keepers.TokenFactoryKeeper.StoreEscrowAddress(ctx, escrowAddress) + } + + ctx.Logger().Info(fmt.Sprintf("Migration {%s} applied", UpgradeName)) + return vm, nil + } +} diff --git a/app/upgrades/v5.0.5/upgrades_test.go b/app/upgrades/v5.0.5/upgrades_test.go new file mode 100644 index 000000000..b65e60b3a --- /dev/null +++ b/app/upgrades/v5.0.5/upgrades_test.go @@ -0,0 +1,52 @@ +package v505_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" + + upgradetypes "cosmossdk.io/x/upgrade/types" + "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" + + v505 "github.com/neutron-org/neutron/v5/app/upgrades/v5.0.5" + "github.com/neutron-org/neutron/v5/testutil" +) + +type UpgradeTestSuite struct { + testutil.IBCConnectionTestSuite +} + +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(UpgradeTestSuite)) +} + +func (suite *UpgradeTestSuite) SetupTest() { + suite.IBCConnectionTestSuite.SetupTest() +} + +func (suite *UpgradeTestSuite) TestUpgrade() { + app := suite.GetNeutronZoneApp(suite.ChainA) + ctx := suite.ChainA.GetContext().WithChainID("neutron-1") + t := suite.T() + + upgrade := upgradetypes.Plan{ + Name: v505.UpgradeName, + Info: "some text here", + Height: 100, + } + + var escrowAddresses []sdk.AccAddress + transferChannels := app.IBCKeeper.ChannelKeeper.GetAllChannelsWithPortPrefix(ctx, app.TransferKeeper.GetPort(ctx)) + for _, channel := range transferChannels { + escrowAddresses = append(escrowAddresses, transfertypes.GetEscrowAddress(channel.PortId, channel.ChannelId)) + } + require.Greater(t, len(escrowAddresses), 0) + require.NoError(t, app.UpgradeKeeper.ApplyUpgrade(ctx, upgrade)) + + for _, escrowAddress := range escrowAddresses { + require.True(t, app.TokenFactoryKeeper.IsEscrowAddress(ctx, escrowAddress)) + } + require.False(t, app.TokenFactoryKeeper.IsEscrowAddress(ctx, []byte{1, 2, 3, 4, 5})) +} diff --git a/testutil/mocks/contractmanager/types/expected_keepers.go b/testutil/mocks/contractmanager/types/expected_keepers.go index 5d2ef0a4f..7ff82c05c 100644 --- a/testutil/mocks/contractmanager/types/expected_keepers.go +++ b/testutil/mocks/contractmanager/types/expected_keepers.go @@ -11,7 +11,6 @@ import ( types "github.com/CosmWasm/wasmd/x/wasm/types" types0 "github.com/cosmos/cosmos-sdk/types" gomock "github.com/golang/mock/gomock" - types1 "github.com/neutron-org/neutron/v5/x/contractmanager/types" ) diff --git a/testutil/mocks/interchainqueries/keeper/verify.go b/testutil/mocks/interchainqueries/keeper/verify.go index 02f03e7d9..b8cb86c6e 100644 --- a/testutil/mocks/interchainqueries/keeper/verify.go +++ b/testutil/mocks/interchainqueries/keeper/verify.go @@ -13,7 +13,6 @@ import ( exported "github.com/cosmos/ibc-go/v8/modules/core/exported" tendermint "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" gomock "github.com/golang/mock/gomock" - types1 "github.com/neutron-org/neutron/v5/x/interchainqueries/types" ) diff --git a/testutil/mocks/interchaintxs/types/expected_keepers.go b/testutil/mocks/interchaintxs/types/expected_keepers.go index 0c1d7c3b1..67cc758ab 100644 --- a/testutil/mocks/interchaintxs/types/expected_keepers.go +++ b/testutil/mocks/interchaintxs/types/expected_keepers.go @@ -14,7 +14,6 @@ import ( types2 "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" exported "github.com/cosmos/ibc-go/v8/modules/core/exported" gomock "github.com/golang/mock/gomock" - types3 "github.com/neutron-org/neutron/v5/x/feerefunder/types" ) diff --git a/testutil/mocks/transfer/types/expected_keepers.go b/testutil/mocks/transfer/types/expected_keepers.go index 9e952f77b..4789cb264 100644 --- a/testutil/mocks/transfer/types/expected_keepers.go +++ b/testutil/mocks/transfer/types/expected_keepers.go @@ -11,7 +11,6 @@ import ( types "github.com/cosmos/cosmos-sdk/types" types0 "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" gomock "github.com/golang/mock/gomock" - types1 "github.com/neutron-org/neutron/v5/x/feerefunder/types" ) @@ -245,3 +244,38 @@ func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(name interface{}) *gom mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetModuleAddress", reflect.TypeOf((*MockAccountKeeper)(nil).GetModuleAddress), name) } + +// MockTokenfactoryKeeper is a mock of TokenfactoryKeeper interface. +type MockTokenfactoryKeeper struct { + ctrl *gomock.Controller + recorder *MockTokenfactoryKeeperMockRecorder +} + +// MockTokenfactoryKeeperMockRecorder is the mock recorder for MockTokenfactoryKeeper. +type MockTokenfactoryKeeperMockRecorder struct { + mock *MockTokenfactoryKeeper +} + +// NewMockTokenfactoryKeeper creates a new mock instance. +func NewMockTokenfactoryKeeper(ctrl *gomock.Controller) *MockTokenfactoryKeeper { + mock := &MockTokenfactoryKeeper{ctrl: ctrl} + mock.recorder = &MockTokenfactoryKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockTokenfactoryKeeper) EXPECT() *MockTokenfactoryKeeperMockRecorder { + return m.recorder +} + +// StoreEscrowAddress mocks base method. +func (m *MockTokenfactoryKeeper) StoreEscrowAddress(ctx types.Context, address types.AccAddress) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "StoreEscrowAddress", ctx, address) +} + +// StoreEscrowAddress indicates an expected call of StoreEscrowAddress. +func (mr *MockTokenfactoryKeeperMockRecorder) StoreEscrowAddress(ctx, address interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StoreEscrowAddress", reflect.TypeOf((*MockTokenfactoryKeeper)(nil).StoreEscrowAddress), ctx, address) +} diff --git a/x/tokenfactory/keeper/bankactions.go b/x/tokenfactory/keeper/bankactions.go index ed2f7d565..7960c42e3 100644 --- a/x/tokenfactory/keeper/bankactions.go +++ b/x/tokenfactory/keeper/bankactions.go @@ -24,6 +24,10 @@ func (k Keeper) mintTo(ctx sdk.Context, amount sdk.Coin, mintTo string) error { return status.Errorf(codes.Internal, "minting to module accounts is forbidden") } + if k.IsEscrowAddress(ctx, mintToAcc) { + return status.Errorf(codes.Internal, "minting to IBC escrow accounts is forbidden") + } + err = k.bankKeeper.MintCoins(ctx, types.ModuleName, sdk.NewCoins(amount)) if err != nil { return err @@ -50,6 +54,10 @@ func (k Keeper) burnFrom(ctx sdk.Context, amount sdk.Coin, burnFrom string) erro return status.Errorf(codes.Internal, "burning from module accounts is forbidden") } + if k.IsEscrowAddress(ctx, burnFromAcc) { + return status.Errorf(codes.Internal, "burning from IBC escrow accounts is forbidden") + } + err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, burnFromAcc, types.ModuleName, @@ -86,6 +94,14 @@ func (k Keeper) forceTransfer(ctx sdk.Context, amount sdk.Coin, fromAddr, toAddr return status.Errorf(codes.Internal, "force transfer to module accounts is forbidden") } + if k.IsEscrowAddress(ctx, transferFromAcc) { + return status.Errorf(codes.Internal, "force transfer from IBC escrow accounts is forbidden") + } + + if k.IsEscrowAddress(ctx, transferToAcc) { + return status.Errorf(codes.Internal, "force transfer to IBC escrow accounts is forbidden") + } + return k.bankKeeper.SendCoins(ctx, transferFromAcc, transferToAcc, sdk.NewCoins(amount)) } diff --git a/x/tokenfactory/keeper/escrow_addresses.go b/x/tokenfactory/keeper/escrow_addresses.go new file mode 100644 index 000000000..5189a3e7d --- /dev/null +++ b/x/tokenfactory/keeper/escrow_addresses.go @@ -0,0 +1,21 @@ +package keeper + +import ( + "cosmossdk.io/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/neutron-org/neutron/v5/x/tokenfactory/types" +) + +// StoreEscrowAddress sets the total set of params. +func (k Keeper) StoreEscrowAddress(ctx sdk.Context, address sdk.AccAddress) { + prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.EscrowAddressKey) + + prefixStore.Set(address.Bytes(), []byte{0}) +} + +func (k Keeper) IsEscrowAddress(ctx sdk.Context, address sdk.AccAddress) bool { + prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), types.EscrowAddressKey) + bz := prefixStore.Get(address.Bytes()) + + return len(bz) != 0 +} diff --git a/x/tokenfactory/keeper/keeper.go b/x/tokenfactory/keeper/keeper.go index 241183ca1..aae912cb2 100644 --- a/x/tokenfactory/keeper/keeper.go +++ b/x/tokenfactory/keeper/keeper.go @@ -10,7 +10,6 @@ import ( storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/neutron-org/neutron/v5/x/tokenfactory/types" ) diff --git a/x/tokenfactory/types/keys.go b/x/tokenfactory/types/keys.go index 8bfeb012c..543775fdc 100644 --- a/x/tokenfactory/types/keys.go +++ b/x/tokenfactory/types/keys.go @@ -25,6 +25,7 @@ const ( const ( KeySeparator = "|" prefixParamsKey = iota + 1 + prefixEscrowAddressKey ) var ( @@ -34,6 +35,7 @@ var ( AdminPrefixKey = "admin" BeforeSendHookAddressPrefixKey = "beforesendhook" ParamsKey = []byte{prefixParamsKey} + EscrowAddressKey = []byte{prefixEscrowAddressKey} ) // GetDenomPrefixStore returns the store prefix where all the data associated with a specific denom diff --git a/x/transfer/ibc_handlers_test.go b/x/transfer/ibc_handlers_test.go index e6ccadc1a..e73b99be0 100644 --- a/x/transfer/ibc_handlers_test.go +++ b/x/transfer/ibc_handlers_test.go @@ -31,10 +31,12 @@ func TestHandleAcknowledgement(t *testing.T) { feeKeeper := mock_types.NewMockFeeRefunderKeeper(ctrl) chanKeeper := mock_types.NewMockChannelKeeper(ctrl) authKeeper := mock_types.NewMockAccountKeeper(ctrl) + tokenfactoryKeeper := mock_types.NewMockTokenfactoryKeeper(ctrl) + // required to initialize keeper authKeeper.EXPECT().GetModuleAddress(transfertypes.ModuleName).Return([]byte("address")) txKeeper, infCtx, _ := testkeeper.TransferKeeper(t, wmKeeper, feeKeeper, chanKeeper, authKeeper) - txModule := transfer.NewIBCModule(*txKeeper, wmKeeper) + txModule := transfer.NewIBCModule(*txKeeper, wmKeeper, tokenfactoryKeeper) ctx := infCtx.WithGasMeter(types2.NewGasMeter(1_000_000_000_000)) resACK := channeltypes.Acknowledgement{ @@ -114,10 +116,11 @@ func TestHandleTimeout(t *testing.T) { feeKeeper := mock_types.NewMockFeeRefunderKeeper(ctrl) chanKeeper := mock_types.NewMockChannelKeeper(ctrl) authKeeper := mock_types.NewMockAccountKeeper(ctrl) + tokenfactoryKeeper := mock_types.NewMockTokenfactoryKeeper(ctrl) // required to initialize keeper authKeeper.EXPECT().GetModuleAddress(transfertypes.ModuleName).Return([]byte("address")) txKeeper, infCtx, _ := testkeeper.TransferKeeper(t, wmKeeper, feeKeeper, chanKeeper, authKeeper) - txModule := transfer.NewIBCModule(*txKeeper, wmKeeper) + txModule := transfer.NewIBCModule(*txKeeper, wmKeeper, tokenfactoryKeeper) ctx := infCtx.WithGasMeter(types2.NewGasMeter(1_000_000_000_000)) contractAddress := sdk.MustAccAddressFromBech32(testutil.TestOwnerAddress) relayerBech32 := "neutron1fxudpred77a0grgh69u0j7y84yks5ev4n5050z45kecz792jnd6scqu98z" diff --git a/x/transfer/keeper/keeper.go b/x/transfer/keeper/keeper.go index 191a1ae4f..15a70efea 100644 --- a/x/transfer/keeper/keeper.go +++ b/x/transfer/keeper/keeper.go @@ -5,7 +5,6 @@ import ( "cosmossdk.io/errors" storetypes "cosmossdk.io/store/types" - "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" diff --git a/x/transfer/module.go b/x/transfer/module.go index 0479b53b5..e26810739 100644 --- a/x/transfer/module.go +++ b/x/transfer/module.go @@ -5,6 +5,7 @@ import ( "cosmossdk.io/core/appmodule" "cosmossdk.io/errors" + transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -12,7 +13,6 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/ibc-go/v8/modules/apps/transfer" "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper" - "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" wrapkeeper "github.com/neutron-org/neutron/v5/x/transfer/keeper" @@ -25,19 +25,21 @@ import ( */ type IBCModule struct { - wrappedKeeper wrapkeeper.KeeperTransferWrapper - keeper keeper.Keeper - sudoKeeper neutrontypes.WasmKeeper + wrappedKeeper wrapkeeper.KeeperTransferWrapper + keeper keeper.Keeper + sudoKeeper neutrontypes.WasmKeeper + tokenfactoryKeeper neutrontypes.TokenfactoryKeeper transfer.IBCModule } // NewIBCModule creates a new IBCModule given the keeper -func NewIBCModule(k wrapkeeper.KeeperTransferWrapper, sudoKeeper neutrontypes.WasmKeeper) IBCModule { +func NewIBCModule(k wrapkeeper.KeeperTransferWrapper, sudoKeeper neutrontypes.WasmKeeper, tokenfactoryKeeper neutrontypes.TokenfactoryKeeper) IBCModule { return IBCModule{ - wrappedKeeper: k, - keeper: k.Keeper, - sudoKeeper: sudoKeeper, - IBCModule: transfer.NewIBCModule(k.Keeper), + wrappedKeeper: k, + keeper: k.Keeper, + sudoKeeper: sudoKeeper, + IBCModule: transfer.NewIBCModule(k.Keeper), + tokenfactoryKeeper: tokenfactoryKeeper, } } @@ -69,6 +71,41 @@ func (im IBCModule) OnTimeoutPacket( return im.HandleTimeout(ctx, packet, relayer) } +func (im IBCModule) OnChanOpenAck( + ctx sdk.Context, + portID, + channelID string, + _ string, + counterpartyVersion string, +) error { + err := im.IBCModule.OnChanOpenAck(ctx, portID, channelID, "", counterpartyVersion) + if err != nil { + return errors.Wrap(err, "failed to process original OnChanOpenAck") + } + + escrowAddress := transfertypes.GetEscrowAddress(portID, channelID) + im.tokenfactoryKeeper.StoreEscrowAddress(ctx, escrowAddress.Bytes()) + + return nil +} + +// OnChanOpenConfirm implements the IBCModule interface +func (im IBCModule) OnChanOpenConfirm( + ctx sdk.Context, + portID, + channelID string, +) error { + err := im.IBCModule.OnChanOpenConfirm(ctx, portID, channelID) + if err != nil { + return errors.Wrap(err, "failed to process original OnChanOpenConfirm") + } + + escrowAddress := transfertypes.GetEscrowAddress(portID, channelID) + im.tokenfactoryKeeper.StoreEscrowAddress(ctx, escrowAddress.Bytes()) + + return nil +} + var _ appmodule.AppModule = AppModule{} type AppModule struct { @@ -94,25 +131,25 @@ func (am AppModule) IsAppModule() { // marker // RegisterServices registers module services. func (am AppModule) RegisterServices(cfg module.Configurator) { - types.RegisterQueryServer(cfg.QueryServer(), am.keeper) + transfertypes.RegisterQueryServer(cfg.QueryServer(), am.keeper) neutrontypes.RegisterMsgServer(cfg.MsgServer(), am.keeper) cfg.MsgServer().RegisterService(&neutrontypes.MsgServiceDescOrig, am.keeper) m := keeper.NewMigrator(am.keeper.Keeper) - if err := cfg.RegisterMigration(types.ModuleName, 1, m.MigrateTraces); err != nil { + if err := cfg.RegisterMigration(transfertypes.ModuleName, 1, m.MigrateTraces); err != nil { panic(fmt.Sprintf("failed to migrate transfer app from version 1 to 2: %v", err)) } - if err := cfg.RegisterMigration(types.ModuleName, 2, m.MigrateTotalEscrowForDenom); err != nil { + if err := cfg.RegisterMigration(transfertypes.ModuleName, 2, m.MigrateTotalEscrowForDenom); err != nil { panic(fmt.Sprintf("failed to migrate transfer app from version 2 to 3: %v", err)) } - if err := cfg.RegisterMigration(types.ModuleName, 3, m.MigrateParams); err != nil { + if err := cfg.RegisterMigration(transfertypes.ModuleName, 3, m.MigrateParams); err != nil { panic(fmt.Sprintf("failed to migrate transfer app version 3 to 4: %v", err)) } - if err := cfg.RegisterMigration(types.ModuleName, 4, m.MigrateDenomMetadata); err != nil { + if err := cfg.RegisterMigration(transfertypes.ModuleName, 4, m.MigrateDenomMetadata); err != nil { panic(fmt.Sprintf("failed to migrate transfer app from version 4 to 5: %v", err)) } } diff --git a/x/transfer/types/expected_keepers.go b/x/transfer/types/expected_keepers.go index 5eb6f8edc..8642079fc 100644 --- a/x/transfer/types/expected_keepers.go +++ b/x/transfer/types/expected_keepers.go @@ -32,3 +32,8 @@ type AccountKeeper interface { GetModuleAddress(name string) sdk.AccAddress GetModuleAccount(ctx context.Context, name string) sdk.ModuleAccountI } + +// TokenfactoryKeeper defines the tokenfactory keeper. +type TokenfactoryKeeper interface { + StoreEscrowAddress(ctx sdk.Context, address sdk.AccAddress) +}