Skip to content

Commit

Permalink
chore: Small cleanup to vm._emit
Browse files Browse the repository at this point in the history
- Move it to an instance method. There shouldn't be any issues with it being an instance method since the underlying event emitter is still per object.
- Make it more typesafe by taking keyof Events rather than string

Syntax error

fix broken build

run linter
  • Loading branch information
roninjin10 authored and William Cory committed May 7, 2024
1 parent 0ed0a07 commit af0ef0c
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/vm/src/vm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ export class VM {
* set to public due to implementation internals
* @hidden
*/
public readonly _emit: (topic: string, data: any) => Promise<void>
public _emit(topic: keyof VMEvents, data: any): Promise<void> {
return new Promise((resolve) => this.events.emit(topic, data, resolve))
}

/**
* VM is run in DEBUG mode (default: false)
Expand Down Expand Up @@ -168,10 +170,6 @@ export class VM {

this._setHardfork = opts.setHardfork ?? false

this._emit = async (topic: string, data: any): Promise<void> => {
return new Promise((resolve) => this.events.emit(topic as keyof VMEvents, data, resolve))
}

// Skip DEBUG calls unless 'ethjs' included in environmental DEBUG variables
// Additional window check is to prevent vite browser bundling (and potentially other) to break
this.DEBUG =
Expand Down

0 comments on commit af0ef0c

Please sign in to comment.