@@ -29,7 +29,6 @@ import (
2929 "github.com/cosmos/cosmos-sdk/types/module"
3030 "github.com/cosmos/cosmos-sdk/version"
3131 "github.com/cosmos/cosmos-sdk/x/auth"
32- "github.com/cosmos/cosmos-sdk/x/auth/ante"
3332 authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
3433 authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation"
3534 authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
@@ -110,9 +109,22 @@ import (
110109 ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
111110 "github.com/spf13/cast"
112111
112+ ethermint "github.com/evmos/ethermint/types"
113+
114+ ethante "github.com/evmos/ethermint/app/ante"
115+ "github.com/evmos/ethermint/server/flags"
116+ "github.com/evmos/ethermint/x/evm"
117+ evmkeeper "github.com/evmos/ethermint/x/evm/keeper"
118+ evmtypes "github.com/evmos/ethermint/x/evm/types"
119+ "github.com/evmos/ethermint/x/evm/vm/geth"
120+ "github.com/evmos/ethermint/x/feemarket"
121+ feemarketkeeper "github.com/evmos/ethermint/x/feemarket/keeper"
122+ feemarkettypes "github.com/evmos/ethermint/x/feemarket/types"
123+
113124 pushchainmodule "pushchain/x/pushchain"
114125 pushchainmodulekeeper "pushchain/x/pushchain/keeper"
115126 pushchainmoduletypes "pushchain/x/pushchain/types"
127+
116128 // this line is used by starport scaffolding # stargate/app/moduleImport
117129
118130 appparams "pushchain/app/params"
@@ -173,6 +185,11 @@ var (
173185 ica.AppModuleBasic {},
174186 vesting.AppModuleBasic {},
175187 consensus.AppModuleBasic {},
188+
189+ // Ethermint modules
190+ evm.AppModuleBasic {},
191+ feemarket.AppModuleBasic {},
192+
176193 pushchainmodule.AppModuleBasic {},
177194 // this line is used by starport scaffolding # stargate/app/moduleBasic
178195 )
@@ -187,6 +204,7 @@ var (
187204 stakingtypes .NotBondedPoolName : {authtypes .Burner , authtypes .Staking },
188205 govtypes .ModuleName : {authtypes .Burner },
189206 ibctransfertypes .ModuleName : {authtypes .Minter , authtypes .Burner },
207+ evmtypes .ModuleName : {authtypes .Minter , authtypes .Burner }, // used for secure addition and subtraction of balance using module account
190208 // this line is used by starport scaffolding # stargate/app/maccPerms
191209 }
192210)
@@ -203,6 +221,8 @@ func init() {
203221 }
204222
205223 DefaultNodeHome = filepath .Join (userHomeDir , "." + Name )
224+
225+ sdk .DefaultPowerReduction = ethermint .PowerReduction
206226}
207227
208228// App extends an ABCI application, but with most of its parameters exported.
@@ -249,6 +269,10 @@ type App struct {
249269 ScopedTransferKeeper capabilitykeeper.ScopedKeeper
250270 ScopedICAHostKeeper capabilitykeeper.ScopedKeeper
251271
272+ // Ethermint keepers
273+ EvmKeeper * evmkeeper.Keeper
274+ FeeMarketKeeper feemarketkeeper.Keeper
275+
252276 PushchainKeeper pushchainmodulekeeper.Keeper
253277 // this line is used by starport scaffolding # stargate/app/keeperDeclaration
254278
@@ -296,10 +320,11 @@ func New(
296320 govtypes .StoreKey , paramstypes .StoreKey , ibcexported .StoreKey , upgradetypes .StoreKey ,
297321 feegrant .StoreKey , evidencetypes .StoreKey , ibctransfertypes .StoreKey , icahosttypes .StoreKey ,
298322 capabilitytypes .StoreKey , group .StoreKey , icacontrollertypes .StoreKey , consensusparamtypes .StoreKey ,
323+ evmtypes .StoreKey , feemarkettypes .StoreKey ,
299324 pushchainmoduletypes .StoreKey ,
300325 // this line is used by starport scaffolding # stargate/app/storeKey
301326 )
302- tkeys := sdk .NewTransientStoreKeys (paramstypes .TStoreKey )
327+ tkeys := sdk .NewTransientStoreKeys (paramstypes .TStoreKey , evmtypes . TransientKey , feemarkettypes . TransientKey )
303328 memKeys := sdk .NewMemoryStoreKeys (capabilitytypes .MemStoreKey )
304329
305330 app := & App {
@@ -415,6 +440,35 @@ func New(
415440 authtypes .NewModuleAddress (govtypes .ModuleName ).String (),
416441 )
417442
443+ govModuleAddress := authtypes .NewModuleAddress (govtypes .ModuleName ).String ()
444+
445+ // Create Ethermint keepers
446+ app .FeeMarketKeeper = feemarketkeeper .NewKeeper (
447+ appCodec ,
448+ sdk .MustAccAddressFromBech32 (govModuleAddress ),
449+ app .ConsensusParamsKeeper ,
450+ app .keys [feemarkettypes .StoreKey ],
451+ app .tkeys [feemarkettypes .TransientKey ],
452+ app .GetSubspace (feemarkettypes .ModuleName ),
453+ )
454+
455+ // Create evmos keeper
456+ tracer := cast .ToString (appOpts .Get (flags .EVMTracer ))
457+ app .EvmKeeper = evmkeeper .NewKeeper (
458+ appCodec ,
459+ app .keys [evmtypes .StoreKey ],
460+ app .tkeys [evmtypes .TransientKey ],
461+ authtypes .NewModuleAddress (govtypes .ModuleName ),
462+ app .AccountKeeper ,
463+ app .BankKeeper ,
464+ app .StakingKeeper ,
465+ app .FeeMarketKeeper ,
466+ nil ,
467+ geth .NewEVM ,
468+ tracer ,
469+ app .GetSubspace (evmtypes .ModuleName ),
470+ )
471+
418472 groupConfig := group .DefaultConfig ()
419473 /*
420474 Example of setting group params:
@@ -588,6 +642,11 @@ func New(
588642 params .NewAppModule (app .ParamsKeeper ),
589643 transferModule ,
590644 icaModule ,
645+
646+ // Ethermint app modules
647+ evm .NewAppModule (app .EvmKeeper , app .AccountKeeper , app .BankKeeper , app .GetSubspace (evmtypes .ModuleName )),
648+ feemarket .NewAppModule (app .FeeMarketKeeper , app .GetSubspace (feemarkettypes .ModuleName )),
649+
591650 pushchainModule ,
592651 // this line is used by starport scaffolding # stargate/app/appModule
593652
@@ -620,6 +679,8 @@ func New(
620679 group .ModuleName ,
621680 paramstypes .ModuleName ,
622681 vestingtypes .ModuleName ,
682+ feemarkettypes .ModuleName ,
683+ evmtypes .ModuleName ,
623684 consensusparamtypes .ModuleName ,
624685 pushchainmoduletypes .ModuleName ,
625686 // this line is used by starport scaffolding # stargate/app/beginBlockers
@@ -636,6 +697,8 @@ func New(
636697 authtypes .ModuleName ,
637698 banktypes .ModuleName ,
638699 distrtypes .ModuleName ,
700+ feemarkettypes .ModuleName ,
701+ evmtypes .ModuleName ,
639702 slashingtypes .ModuleName ,
640703 minttypes .ModuleName ,
641704 genutiltypes .ModuleName ,
@@ -663,6 +726,8 @@ func New(
663726 distrtypes .ModuleName ,
664727 stakingtypes .ModuleName ,
665728 slashingtypes .ModuleName ,
729+ feemarkettypes .ModuleName ,
730+ evmtypes .ModuleName ,
666731 govtypes .ModuleName ,
667732 minttypes .ModuleName ,
668733 crisistypes .ModuleName ,
@@ -711,15 +776,18 @@ func New(
711776 app .MountMemoryStores (memKeys )
712777
713778 // initialize BaseApp
714- anteHandler , err := ante .NewAnteHandler (
715- ante.HandlerOptions {
716- AccountKeeper : app .AccountKeeper ,
717- BankKeeper : app .BankKeeper ,
718- SignModeHandler : encodingConfig .TxConfig .SignModeHandler (),
719- FeegrantKeeper : app .FeeGrantKeeper ,
720- SigGasConsumer : ante .DefaultSigVerificationGasConsumer ,
721- },
722- )
779+ maxGasWanted := cast .ToUint64 (appOpts .Get (flags .EVMMaxTxGasWanted ))
780+ anteHandler , err := ethante .NewAnteHandler (ethante.HandlerOptions {
781+ AccountKeeper : app .AccountKeeper ,
782+ BankKeeper : app .BankKeeper ,
783+ EvmKeeper : app .EvmKeeper ,
784+ FeegrantKeeper : app .FeeGrantKeeper ,
785+ IBCKeeper : app .IBCKeeper ,
786+ FeeMarketKeeper : app .FeeMarketKeeper ,
787+ SignModeHandler : encodingConfig .TxConfig .SignModeHandler (),
788+ SigGasConsumer : ethante .DefaultSigVerificationGasConsumer ,
789+ MaxTxGasWanted : maxGasWanted ,
790+ })
723791 if err != nil {
724792 panic (fmt .Errorf ("failed to create AnteHandler: %w" , err ))
725793 }
@@ -853,6 +921,7 @@ func (app *App) GetSubspace(moduleName string) paramstypes.Subspace {
853921// API server.
854922func (app * App ) RegisterAPIRoutes (apiSvr * api.Server , apiConfig config.APIConfig ) {
855923 clientCtx := apiSvr .ClientCtx
924+ // evmrest.RegisterTxRoutes(clientCtx, apiSvr.Router)
856925 // Register new tx routes from grpc-gateway.
857926 authtx .RegisterGRPCGatewayRoutes (clientCtx , apiSvr .GRPCGatewayRouter )
858927 // Register new tendermint queries routes from grpc-gateway.
@@ -904,6 +973,9 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
904973 paramsKeeper .Subspace (icacontrollertypes .SubModuleName )
905974 paramsKeeper .Subspace (icahosttypes .SubModuleName )
906975 paramsKeeper .Subspace (pushchainmoduletypes .ModuleName )
976+ // ethermint subspaces
977+ paramsKeeper .Subspace (evmtypes .ModuleName )
978+ paramsKeeper .Subspace (feemarkettypes .ModuleName )
907979 // this line is used by starport scaffolding # stargate/app/paramSubspace
908980
909981 return paramsKeeper
0 commit comments