Skip to content

Commit c08457e

Browse files
committed
chore: add a arg for afterApply and update version
1 parent 061d19e commit c08457e

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

packages/vm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@gxchain2-ethereumjs/vm",
3-
"version": "5.5.7",
3+
"version": "5.5.8",
44
"description": "An Ethereum VM implementation",
55
"license": "MPL-2.0",
66
"author": "mjbecze <[email protected]>",

packages/vm/src/evm/evm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export default class EVM {
166166
)
167167
}
168168

169-
// If receive `contractAddress` option, it must be update
169+
// If receive `contractAddress` option, it must be a update message
170170
if (message.contractAddress) {
171171
result = await this._executeUpdate(message)
172172
} else if (message.to) {

packages/vm/src/runBlock.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import type { TxReceipt, IDebug } from './types'
1313
import { InterpreterStep } from './evm/interpreter'
1414
import * 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

Comments
 (0)