diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index f0306c310..4c76e2c1a 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -1007,24 +1007,27 @@ func (app *BaseApp) runTx(ctx sdk.Context, mode runTxMode, tx sdk.Tx, checksum [ if ctx.CheckTxCallback() != nil { ctx.CheckTxCallback()(ctx, err) } - var evmTxInfo *abci.EvmTxInfo - if ctx.IsEVM() { - evmTxInfo = &abci.EvmTxInfo{ - SenderAddress: ctx.EVMSenderAddress(), - Nonce: ctx.EVMNonce(), - TxHash: ctx.EVMTxHash(), - VmError: result.EvmError, + // only apply hooks if no error + if err == nil && (!ctx.IsEVM() || result.EvmError == "") { + var evmTxInfo *abci.EvmTxInfo + if ctx.IsEVM() { + evmTxInfo = &abci.EvmTxInfo{ + SenderAddress: ctx.EVMSenderAddress(), + Nonce: ctx.EVMNonce(), + TxHash: ctx.EVMTxHash(), + VmError: result.EvmError, + } + } + var events []abci.Event = []abci.Event{} + if result != nil { + events = sdk.MarkEventsToIndex(result.Events, app.indexEvents) + } + for _, hook := range app.deliverTxHooks { + hook(ctx, tx, checksum, sdk.DeliverTxHookInput{ + EvmTxInfo: evmTxInfo, + Events: events, + }) } - } - var events []abci.Event = []abci.Event{} - if result != nil { - events = sdk.MarkEventsToIndex(result.Events, app.indexEvents) - } - for _, hook := range app.deliverTxHooks { - hook(ctx, tx, checksum, sdk.DeliverTxHookInput{ - EvmTxInfo: evmTxInfo, - Events: events, - }) } return gInfo, result, anteEvents, priority, pendingTxChecker, expireHandler, ctx, err }