Skip to content

Commit

Permalink
chore: refactor initializeEVM
Browse files Browse the repository at this point in the history
  • Loading branch information
arrivets committed Oct 23, 2024
1 parent 7789c56 commit 7db3bd1
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,13 @@ func (app *EthermintApp) setPostHandler() {
app.SetPostHandler(postHandler)
}

func (app *EthermintApp) initializeEVM(ctx sdk.Context) {
if app.EvmKeeper != nil && app.EvmKeeper.ChainID() == nil {
app.EvmKeeper.WithChainID(ctx)
app.EvmKeeper.InitChainer(ctx)
}
}

// Name returns the name of the App
func (app *EthermintApp) Name() string { return app.BaseApp.Name() }

Expand All @@ -880,12 +887,7 @@ func (app *EthermintApp) BeginBlocker(ctx sdk.Context) (sdk.BeginBlock, error) {
ctx = evmtracing.SetTracingHooks(ctx, app.evmTracer)
}

// Cosmos chains will only call InitChainer when the chain either starts
// from genesis or is being upgraded and a full state initialization is needed
if app.EvmKeeper != nil && app.EvmKeeper.ChainID() == nil {
app.EvmKeeper.WithChainID(ctx)
app.EvmKeeper.InitChainer(ctx)
}
app.initializeEVM(ctx)

return app.ModuleManager.BeginBlock(ctx)
}
Expand Down Expand Up @@ -917,10 +919,7 @@ func (app *EthermintApp) InitChainer(ctx sdk.Context, req *abci.RequestInitChain
ctx = evmtracing.SetTracingHooks(ctx, app.evmTracer)
}

if app.EvmKeeper != nil {
app.EvmKeeper.WithChainID(ctx)
app.EvmKeeper.InitChainer(ctx)
}
app.initializeEVM(ctx)

return app.ModuleManager.InitGenesis(ctx, app.appCodec, genesisState)
}
Expand Down

0 comments on commit 7db3bd1

Please sign in to comment.