@@ -13,6 +13,8 @@ import type { TxReceipt, IDebug } from './types'
1313import { InterpreterStep } from './evm/interpreter'
1414import * as DAOConfig from './config/dao_fork_accounts_config.json'
1515
16+ type PromisResultType < T > = T extends PromiseLike < infer U > ? U : T
17+
1618// For backwards compatibility from v5.3.0,
1719// TxReceipts are exported. These exports are
1820// deprecated and may be removed soon, please
@@ -78,7 +80,10 @@ export interface RunBlockOpts {
7880 /**
7981 * After apply block callback
8082 */
81- afterApply ?: ( stateManager : StateManager ) => Promise < void >
83+ afterApply ?: (
84+ stateManager : StateManager ,
85+ result : PromisResultType < ReturnType < typeof applyBlock > >
86+ ) => Promise < void >
8287}
8388
8489/**
@@ -189,6 +194,8 @@ export default async function runBlock(this: VM, opts: RunBlockOpts): Promise<Ru
189194 } txResults=${ result . results . length } `
190195 )
191196 }
197+ // Call after apply if exists
198+ opts . afterApply && ( await opts . afterApply ( state , result ) )
192199 } catch ( err ) {
193200 await state . revert ( )
194201 if ( this . DEBUG ) {
@@ -197,9 +204,6 @@ export default async function runBlock(this: VM, opts: RunBlockOpts): Promise<Ru
197204 throw err
198205 }
199206
200- // Call after apply if exists
201- opts . afterApply && ( await opts . afterApply ( state ) )
202-
203207 // Persist state
204208 await state . commit ( )
205209 if ( this . DEBUG ) {
0 commit comments