@@ -28,29 +28,29 @@ import (
2828 "github.com/cosmos/evm/x/erc20"
2929 erc20keeper "github.com/cosmos/evm/x/erc20/keeper"
3030 erc20types "github.com/cosmos/evm/x/erc20/types"
31+ erc20v2 "github.com/cosmos/evm/x/erc20/v2"
3132 "github.com/cosmos/evm/x/feemarket"
3233 feemarketkeeper "github.com/cosmos/evm/x/feemarket/keeper"
3334 feemarkettypes "github.com/cosmos/evm/x/feemarket/types"
3435 // NOTE: override ICS20 keeper to support IBC transfers of ERC20 tokens
3536 "github.com/cosmos/evm/x/ibc/transfer"
3637 transferkeeper "github.com/cosmos/evm/x/ibc/transfer/keeper"
38+ transferv2 "github.com/cosmos/evm/x/ibc/transfer/v2"
3739 "github.com/cosmos/evm/x/vm"
3840 evmkeeper "github.com/cosmos/evm/x/vm/keeper"
3941 evmtypes "github.com/cosmos/evm/x/vm/types"
4042 "github.com/cosmos/gogoproto/proto"
41- "github.com/cosmos/ibc-go/modules/capability"
42- capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper"
43- capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
44- ibctransfer "github.com/cosmos/ibc-go/v8/modules/apps/transfer"
45- ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
46- ibc "github.com/cosmos/ibc-go/v8/modules/core"
47- ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
48- ibcconnectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types"
49- porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types"
50- ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
51- ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"
52- ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
53- ibctestingtypes "github.com/cosmos/ibc-go/v8/testing/types"
43+ ibctransfer "github.com/cosmos/ibc-go/v10/modules/apps/transfer"
44+ ibctransfertypes "github.com/cosmos/ibc-go/v10/modules/apps/transfer/types"
45+ ibc "github.com/cosmos/ibc-go/v10/modules/core"
46+ ibcclienttypes "github.com/cosmos/ibc-go/v10/modules/core/02-client/types"
47+ ibcconnectiontypes "github.com/cosmos/ibc-go/v10/modules/core/03-connection/types"
48+ porttypes "github.com/cosmos/ibc-go/v10/modules/core/05-port/types"
49+ ibcapi "github.com/cosmos/ibc-go/v10/modules/core/api"
50+ ibcexported "github.com/cosmos/ibc-go/v10/modules/core/exported"
51+ ibckeeper "github.com/cosmos/ibc-go/v10/modules/core/keeper"
52+ ibctm "github.com/cosmos/ibc-go/v10/modules/light-clients/07-tendermint"
53+ ibctesting "github.com/cosmos/ibc-go/v10/testing"
5454
5555 autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
5656 reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
@@ -167,11 +167,10 @@ var (
167167var (
168168 _ runtime.AppI = (* EVMD )(nil )
169169 _ servertypes.Application = (* EVMD )(nil )
170+ _ ibctesting.TestingApp = (* EVMD )(nil )
170171)
171172
172173// EVMD extends an ABCI application, but with most of its parameters exported.
173- // They are exported for convenience in creating helper functions, as object
174- // capabilities aren't needed for testing.
175174type EVMD struct {
176175 * baseapp.BaseApp
177176
@@ -188,7 +187,6 @@ type EVMD struct {
188187 // keepers
189188 AccountKeeper authkeeper.AccountKeeper
190189 BankKeeper bankkeeper.Keeper
191- CapabilityKeeper * capabilitykeeper.Keeper
192190 StakingKeeper * stakingkeeper.Keeper
193191 SlashingKeeper slashingkeeper.Keeper
194192 MintKeeper mintkeeper.Keeper
@@ -202,10 +200,8 @@ type EVMD struct {
202200 ConsensusParamsKeeper consensusparamkeeper.Keeper
203201
204202 // IBC keepers
205- IBCKeeper * ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
206- TransferKeeper transferkeeper.Keeper
207- scopedIBCKeeper capabilitykeeper.ScopedKeeper
208- ScopedTransferKeeper capabilitykeeper.ScopedKeeper
203+ IBCKeeper * ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
204+ TransferKeeper transferkeeper.Keeper
209205
210206 // Cosmos EVM keepers
211207 FeeMarketKeeper feemarketkeeper.Keeper
@@ -287,17 +283,15 @@ func NewExampleApp(
287283 keys := storetypes .NewKVStoreKeys (
288284 authtypes .StoreKey , banktypes .StoreKey , stakingtypes .StoreKey ,
289285 minttypes .StoreKey , distrtypes .StoreKey , slashingtypes .StoreKey ,
290- govtypes .StoreKey , paramstypes .StoreKey , consensusparamtypes .StoreKey , upgradetypes .StoreKey , feegrant .StoreKey ,
291- evidencetypes .StoreKey , capabilitytypes .StoreKey ,
292- authzkeeper .StoreKey ,
286+ govtypes .StoreKey , paramstypes .StoreKey , consensusparamtypes .StoreKey ,
287+ upgradetypes .StoreKey , feegrant .StoreKey , evidencetypes .StoreKey , authzkeeper .StoreKey ,
293288 // ibc keys
294289 ibcexported .StoreKey , ibctransfertypes .StoreKey ,
295290 // Cosmos EVM store keys
296291 evmtypes .StoreKey , feemarkettypes .StoreKey , erc20types .StoreKey ,
297292 )
298293
299294 tkeys := storetypes .NewTransientStoreKeys (paramstypes .TStoreKey , evmtypes .TransientKey , feemarkettypes .TransientKey )
300- memKeys := storetypes .NewMemoryStoreKeys (capabilitytypes .MemStoreKey )
301295
302296 // load state streaming if enabled
303297 if err := bApp .RegisterStreamingServices (appOpts , keys ); err != nil {
@@ -318,7 +312,6 @@ func NewExampleApp(
318312 interfaceRegistry : interfaceRegistry ,
319313 keys : keys ,
320314 tkeys : tkeys ,
321- memKeys : memKeys ,
322315 }
323316
324317 app .ParamsKeeper = initParamsKeeper (appCodec , legacyAmino , keys [paramstypes .StoreKey ], tkeys [paramstypes .TStoreKey ])
@@ -335,15 +328,6 @@ func NewExampleApp(
335328 )
336329 bApp .SetParamStore (app .ConsensusParamsKeeper .ParamsStore )
337330
338- app .CapabilityKeeper = capabilitykeeper .NewKeeper (appCodec , keys [capabilitytypes .StoreKey ], memKeys [capabilitytypes .MemStoreKey ])
339-
340- app .scopedIBCKeeper = app .CapabilityKeeper .ScopeToModule (ibcexported .ModuleName )
341- app .ScopedTransferKeeper = app .CapabilityKeeper .ScopeToModule (ibctransfertypes .ModuleName )
342-
343- // Applications that wish to enforce statically created ScopedKeepers should call `Seal` after creating
344- // their scoped modules in `NewApp` with `ScopeToModule`
345- app .CapabilityKeeper .Seal ()
346-
347331 // add keepers
348332 app .AccountKeeper = authkeeper .NewAccountKeeper (
349333 appCodec , runtime .NewKVStoreService (keys [authtypes .StoreKey ]),
@@ -449,11 +433,9 @@ func NewExampleApp(
449433 // Create IBC Keeper
450434 app .IBCKeeper = ibckeeper .NewKeeper (
451435 appCodec ,
452- keys [ibcexported .StoreKey ],
436+ runtime . NewKVStoreService ( keys [ibcexported .StoreKey ]) ,
453437 app .GetSubspace (ibcexported .ModuleName ),
454- app .StakingKeeper ,
455438 app .UpgradeKeeper ,
456- app .scopedIBCKeeper ,
457439 authAddr ,
458440 )
459441
@@ -523,17 +505,18 @@ func NewExampleApp(
523505
524506 // instantiate IBC transfer keeper AFTER the ERC-20 keeper to use it in the instantiation
525507 app .TransferKeeper = transferkeeper .NewKeeper (
526- appCodec , keys [ibctransfertypes .StoreKey ], app .GetSubspace (ibctransfertypes .ModuleName ),
527- nil , // we are passing no ics4 wrapper
528- app .IBCKeeper .ChannelKeeper , app .IBCKeeper .PortKeeper ,
529- app .AccountKeeper , app .BankKeeper , app .ScopedTransferKeeper ,
508+ appCodec ,
509+ runtime .NewKVStoreService (keys [ibctransfertypes .StoreKey ]),
510+ app .GetSubspace (ibctransfertypes .ModuleName ),
511+ app .IBCKeeper .ChannelKeeper ,
512+ app .IBCKeeper .ChannelKeeper ,
513+ app .MsgServiceRouter (),
514+ app .AccountKeeper ,
515+ app .BankKeeper ,
530516 app .Erc20Keeper , // Add ERC20 Keeper for ERC20 transfers
531517 authAddr ,
532518 )
533519
534- // Override the ICS20 app module
535- transferModule := transfer .NewAppModule (app .TransferKeeper )
536-
537520 /*
538521 Create Transfer Stack
539522
@@ -554,11 +537,26 @@ func NewExampleApp(
554537 transferStack = transfer .NewIBCModule (app .TransferKeeper )
555538 transferStack = erc20 .NewIBCMiddleware (app .Erc20Keeper , transferStack )
556539
540+ var transferStackV2 ibcapi.IBCModule
541+ transferStackV2 = transferv2 .NewIBCModule (app .TransferKeeper )
542+ transferStackV2 = erc20v2 .NewIBCMiddleware (transferStackV2 , app .Erc20Keeper )
543+
557544 // Create static IBC router, add transfer route, then set and seal it
558545 ibcRouter := porttypes .NewRouter ()
559546 ibcRouter .AddRoute (ibctransfertypes .ModuleName , transferStack )
547+ ibcRouterV2 := ibcapi .NewRouter ()
548+ ibcRouterV2 .AddRoute (ibctransfertypes .ModuleName , transferStackV2 )
560549
561550 app .IBCKeeper .SetRouter (ibcRouter )
551+ app .IBCKeeper .SetRouterV2 (ibcRouterV2 )
552+
553+ clientKeeper := app .IBCKeeper .ClientKeeper
554+ storeProvider := app .IBCKeeper .ClientKeeper .GetStoreProvider ()
555+ tmLightClientModule := ibctm .NewLightClientModule (appCodec , storeProvider )
556+ clientKeeper .AddRoute (ibctm .ModuleName , & tmLightClientModule )
557+
558+ // Override the ICS20 app module
559+ transferModule := transfer .NewAppModule (app .TransferKeeper )
562560
563561 // NOTE: we are adding all available Cosmos EVM EVM extensions.
564562 // Not all of them need to be enabled, which can be configured on a per-chain basis.
@@ -589,7 +587,6 @@ func NewExampleApp(
589587 ),
590588 auth .NewAppModule (appCodec , app .AccountKeeper , authsims .RandomGenesisAccounts , app .GetSubspace (authtypes .ModuleName )),
591589 bank .NewAppModule (appCodec , app .BankKeeper , app .AccountKeeper , app .GetSubspace (banktypes .ModuleName )),
592- capability .NewAppModule (appCodec , * app .CapabilityKeeper , false ),
593590 feegrantmodule .NewAppModule (appCodec , app .AccountKeeper , app .BankKeeper , app .FeeGrantKeeper , app .interfaceRegistry ),
594591 gov .NewAppModule (appCodec , & app .GovKeeper , app .AccountKeeper , app .BankKeeper , app .GetSubspace (govtypes .ModuleName )),
595592 mint .NewAppModule (appCodec , app .MintKeeper , app .AccountKeeper , nil , app .GetSubspace (minttypes .ModuleName )),
@@ -603,7 +600,7 @@ func NewExampleApp(
603600 consensus .NewAppModule (appCodec , app .ConsensusParamsKeeper ),
604601 // IBC modules
605602 ibc .NewAppModule (app .IBCKeeper ),
606- ibctm .NewAppModule (),
603+ ibctm .NewAppModule (tmLightClientModule ),
607604 transferModule ,
608605 // Cosmos EVM modules
609606 vm .NewAppModule (app .EVMKeeper , app .AccountKeeper , app .GetSubspace (evmtypes .ModuleName )),
@@ -643,7 +640,7 @@ func NewExampleApp(
643640 // NOTE: staking module is required if HistoricalEntries param > 0
644641 // NOTE: capability module's beginblocker must come before any modules using capabilities (e.g. IBC)
645642 app .ModuleManager .SetOrderBeginBlockers (
646- capabilitytypes . ModuleName , minttypes .ModuleName ,
643+ minttypes .ModuleName ,
647644
648645 // IBC modules
649646 ibcexported .ModuleName , ibctransfertypes .ModuleName ,
@@ -664,7 +661,7 @@ func NewExampleApp(
664661 // to get the full block gas used.
665662 app .ModuleManager .SetOrderEndBlockers (
666663 govtypes .ModuleName , stakingtypes .ModuleName ,
667- capabilitytypes . ModuleName , authtypes .ModuleName , banktypes .ModuleName ,
664+ authtypes .ModuleName , banktypes .ModuleName ,
668665
669666 // Cosmos EVM EndBlockers
670667 evmtypes .ModuleName , erc20types .ModuleName , feemarkettypes .ModuleName ,
@@ -680,11 +677,8 @@ func NewExampleApp(
680677 // NOTE: The genutils module must occur after staking so that pools are
681678 // properly initialized with tokens from genesis accounts.
682679 // NOTE: The genutils module must also occur after auth so that it can access the params from auth.
683- // NOTE: Capability module must occur first so that it can initialize any capabilities
684- // so that other modules that want to create or claim capabilities afterwards in InitChain
685- // can do so safely.
686680 genesisModuleOrder := []string {
687- capabilitytypes . ModuleName , authtypes .ModuleName , banktypes .ModuleName ,
681+ authtypes .ModuleName , banktypes .ModuleName ,
688682 distrtypes .ModuleName , stakingtypes .ModuleName , slashingtypes .ModuleName , govtypes .ModuleName ,
689683 minttypes .ModuleName ,
690684 ibcexported .ModuleName ,
@@ -741,7 +735,6 @@ func NewExampleApp(
741735 // initialize stores
742736 app .MountKVStores (keys )
743737 app .MountTransientStores (tkeys )
744- app .MountMemoryStores (memKeys )
745738
746739 maxGasWanted := cast .ToUint64 (appOpts .Get (srvflags .EVMMaxTxGasWanted ))
747740
@@ -1001,11 +994,6 @@ func (app *EVMD) GetBaseApp() *baseapp.BaseApp {
1001994 return app .BaseApp
1002995}
1003996
1004- // GetStakingKeeper implements the TestingApp interface.
1005- func (app * EVMD ) GetStakingKeeper () ibctestingtypes.StakingKeeper {
1006- return app .StakingKeeper
1007- }
1008-
1009997// GetStakingKeeperSDK implements the TestingApp interface.
1010998func (app * EVMD ) GetStakingKeeperSDK () stakingkeeper.Keeper {
1011999 return * app .StakingKeeper
@@ -1016,11 +1004,6 @@ func (app *EVMD) GetIBCKeeper() *ibckeeper.Keeper {
10161004 return app .IBCKeeper
10171005}
10181006
1019- // GetScopedIBCKeeper implements the TestingApp interface.
1020- func (app * EVMD ) GetScopedIBCKeeper () capabilitykeeper.ScopedKeeper {
1021- return app .scopedIBCKeeper
1022- }
1023-
10241007// GetTxConfig implements the TestingApp interface.
10251008func (app * EVMD ) GetTxConfig () client.TxConfig {
10261009 return app .txConfig
0 commit comments