diff --git a/app/app.go b/app/app.go index 2fcbe3d..2020a3f 100644 --- a/app/app.go +++ b/app/app.go @@ -231,11 +231,19 @@ func New( logger, // Supply block height getter, required by evm keeper - types.BlockGetter(app.LastBlockHeight), + types.BlockGetter(func() int64 { + return app.LastBlockHeight() + }), // Supply subspace params getter, required by fee and evm keeper app.GetSubspace, - types.ChainIDGetter(app.ChainID), + + types.ChainIDGetter(func() string { + return app.ChainID() + }), + + // Supply eth account + artela.ProtoAccount, // ADVANCED CONFIGURATION // @@ -309,69 +317,6 @@ func New( panic(err) } - // Below we could construct and set an application specific mempool and - // ABCI 1.0 PrepareProposal and ProcessProposal handlers. These defaults are - // already set in the SDK's BaseApp, this shows an example of how to override - // them. - // - // Example: - // - // app.App = appBuilder.Build(...) - // nonceMempool := mempool.NewSenderNonceMempool() - // abciPropHandler := NewDefaultProposalHandler(nonceMempool, app.App.BaseApp) - // - // app.App.BaseApp.SetMempool(nonceMempool) - // app.App.BaseApp.SetPrepareProposal(abciPropHandler.PrepareProposalHandler()) - // app.App.BaseApp.SetProcessProposal(abciPropHandler.ProcessProposalHandler()) - // - // Alternatively, you can construct BaseApp options, append those to - // baseAppOptions and pass them to the appBuilder. - // - // Example: - // - // prepareOpt = func(app *baseapp.BaseApp) { - // abciPropHandler := baseapp.NewDefaultProposalHandler(nonceMempool, app) - // app.SetPrepareProposal(abciPropHandler.PrepareProposalHandler()) - // } - // baseAppOptions = append(baseAppOptions, prepareOpt) - // - // create and set vote extension handler - // voteExtOp := func(bApp *baseapp.BaseApp) { - // voteExtHandler := NewVoteExtensionHandler() - // voteExtHandler.SetHandlers(bApp) - // } - - //kvStores := storetypes.NewKVStoreKeys( - // authtypes.StoreKey, authz.ModuleName, banktypes.StoreKey, stakingmodule.StoreKey, - // crisistypes.StoreKey, minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, - // govtypes.StoreKey, paramstypes.StoreKey, ibcexported.StoreKey, upgradetypes.StoreKey, - // feegrant.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey, icahosttypes.StoreKey, - // capabilitytypes.StoreKey, group.StoreKey, icacontrollertypes.StoreKey, consensustypes.StoreKey, - // evmmoduletypes.StoreKey, - // feemoduletypes.StoreKey, - // // this line is used by starport scaffolding # stargate/app/storeKey - //) - // - //for _, key := range kvStores { - // if err := app.RegisterStores(key); err != nil { - // panic(err) - // } - //} - // - //tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey, evmmoduletypes.TransientKey, feemoduletypes.TransientStoreKey) - //for _, key := range tkeys { - // if err := app.RegisterStores(key); err != nil { - // panic(err) - // } - //} - // - //memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) - //for _, key := range memKeys { - // if err := app.RegisterStores(key); err != nil { - // panic(err) - // } - //} - app.App = appBuilder.Build(db, traceStore, baseAppOptions...) // Register legacy modules diff --git a/app/app_config.go b/app/app_config.go index 72d879c..633a7bf 100644 --- a/app/app_config.go +++ b/app/app_config.go @@ -187,6 +187,7 @@ var ( {Account: ibcfeetypes.ModuleName}, {Account: icatypes.ModuleName}, // this line is used by starport scaffolding # stargate/app/maccPerms + {Account: evmmoduletypes.ModuleName, Permissions: []string{authtypes.Minter, authtypes.Burner}}, } // blocked account addresses diff --git a/ethereum/types/account.go b/ethereum/types/account.go index 4fbfccd..df8fa66 100644 --- a/ethereum/types/account.go +++ b/ethereum/types/account.go @@ -4,13 +4,14 @@ import ( "bytes" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" ) var ( - _ authtypes.AccountI = (*EthAccount)(nil) + _ sdk.AccountI = (*EthAccount)(nil) _ EthAccountI = (*EthAccount)(nil) _ authtypes.GenesisAccount = (*EthAccount)(nil) _ codectypes.UnpackInterfacesMessage = (*EthAccount)(nil) @@ -44,7 +45,7 @@ type EthAccountI interface { // ProtoAccount defines the prototype function for BaseAccount used for an // AccountKeeper. -func ProtoAccount() authtypes.AccountI { +func ProtoAccount() sdk.AccountI { return &EthAccount{ BaseAccount: &authtypes.BaseAccount{}, CodeHash: common.BytesToHash(emptyCodeHash).String(), diff --git a/x/evm/keeper/keeper.go b/x/evm/keeper/keeper.go index 59d7217..0489951 100644 --- a/x/evm/keeper/keeper.go +++ b/x/evm/keeper/keeper.go @@ -46,6 +46,7 @@ type ( subSpace types.ParamSubspace blockGetter types.BlockGetter logger log.Logger + ChainIDGetter types.ChainIDGetter // the address capable of executing a MsgUpdateParams message. Typically, this // should be the x/gov module account. @@ -117,8 +118,8 @@ func NewKeeper( aspectRuntimeContext: aspectRuntimeContext, aspect: aspect, VerifySigCache: new(sync.Map), + ChainIDGetter: chainIDGetter, } - k.WithChainID(chainIDGetter()) djpm.NewAspect(aspect, common.WrapLogger(k.logger.With("module", "aspect"))) api.InitAspectGlobals(&k) @@ -158,8 +159,9 @@ func (k Keeper) GetClientContext() client.Context { return k.clientContext } -// WithChainID sets the chain id to the local variable in the keeper -func (k *Keeper) WithChainID(chainId string) { +// InitChainID sets the chain id to the local variable in the keeper +func (k *Keeper) InitChainID() { + chainId := k.ChainIDGetter() if k.eip155ChainID != nil { return } @@ -178,6 +180,9 @@ func (k *Keeper) WithChainID(chainId string) { // ChainID returns the EIP155 chain ID for the EVM context func (k Keeper) ChainID() *big.Int { + if k.eip155ChainID == nil { + k.InitChainID() + } return k.eip155ChainID } diff --git a/x/evm/module/module.go b/x/evm/module/module.go index fa3630d..abbbd90 100644 --- a/x/evm/module/module.go +++ b/x/evm/module/module.go @@ -17,7 +17,6 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/grpc-ecosystem/grpc-gateway/runtime" - // this line is used by starport scaffolding # 1 modulev1 "github.com/artela-network/artela-rollkit/api/artela/evm/module"