diff --git a/src/opcodes/index.ts b/src/opcodes/index.ts index 8b116d8..b68b16c 100644 --- a/src/opcodes/index.ts +++ b/src/opcodes/index.ts @@ -29,7 +29,7 @@ import staticcall from "./staticcall"; export function parse( step: MinimalInterpreterStep, - currentAddress: string + currentAddress: { value: string } ): Item | AwaitedItem | undefined { switch (step.opcode.name) { case "EXTCODESIZE": diff --git a/src/opcodes/log.ts b/src/opcodes/log.ts index d57bf64..1a9bcfc 100644 --- a/src/opcodes/log.ts +++ b/src/opcodes/log.ts @@ -7,7 +7,7 @@ import { parse } from "."; export interface LOG { data: string; topics: string[]; - address: string; + address: { value: string }; } async function format( @@ -19,7 +19,7 @@ async function format( data: item.params.data, topics: item.params.topics, }, - item.params.address, + item.params.address.value, dependencies )}`; } diff --git a/src/opcodes/log0.ts b/src/opcodes/log0.ts index cf11fe6..46af894 100644 --- a/src/opcodes/log0.ts +++ b/src/opcodes/log0.ts @@ -11,7 +11,7 @@ export interface LOG0 extends LOG { function parse( step: MinimalInterpreterStep, - currentAddress?: string + currentAddress?: { value: string } ): Item { if (!currentAddress) { throw new Error( diff --git a/src/opcodes/log1.ts b/src/opcodes/log1.ts index b601c80..e1ec627 100644 --- a/src/opcodes/log1.ts +++ b/src/opcodes/log1.ts @@ -16,7 +16,7 @@ export interface LOG1 extends LOG { function parse( step: MinimalInterpreterStep, - currentAddress?: string + currentAddress?: { value: string } ): Item { if (!currentAddress) { throw new Error( diff --git a/src/opcodes/log2.ts b/src/opcodes/log2.ts index 562ea7f..f5fbd93 100644 --- a/src/opcodes/log2.ts +++ b/src/opcodes/log2.ts @@ -16,7 +16,7 @@ export interface LOG2 extends LOG { function parse( step: MinimalInterpreterStep, - currentAddress?: string + currentAddress?: { value: string } ): Item { if (!currentAddress) { throw new Error( diff --git a/src/opcodes/log3.ts b/src/opcodes/log3.ts index dc3c845..b7fe8af 100644 --- a/src/opcodes/log3.ts +++ b/src/opcodes/log3.ts @@ -16,7 +16,7 @@ export interface LOG3 extends LOG { function parse( step: MinimalInterpreterStep, - currentAddress?: string + currentAddress?: { value: string } ): Item { if (!currentAddress) { throw new Error( diff --git a/src/opcodes/log4.ts b/src/opcodes/log4.ts index cfa896e..46901a7 100644 --- a/src/opcodes/log4.ts +++ b/src/opcodes/log4.ts @@ -16,7 +16,7 @@ export interface LOG4 extends LOG { function parse( step: MinimalInterpreterStep, - currentAddress?: string + currentAddress?: { value: string } ): Item { if (!currentAddress) { throw new Error( diff --git a/src/trace-recorder.ts b/src/trace-recorder.ts index 9f4b4d0..f24c17a 100644 --- a/src/trace-recorder.ts +++ b/src/trace-recorder.ts @@ -40,7 +40,7 @@ export class TraceRecorder { public previousOpcode: string | undefined; public tracerEnv: TracerEnv; public awaitedItems: Array>; - public addressStack: string[]; + public addressStack: { value: string }[]; // object is used to allow lazy assignment to value in CREATE/2 constructor(vm: MinimalEthereumJsVm, tracerEnv: TracerEnv) { this.vm = vm; @@ -131,6 +131,7 @@ export class TraceRecorder { }, children: [], } as Item; + this.addressStack.push({ value: "lazy" }); } else if (message.to === undefined && salt !== undefined) { item = { opcode: "CREATE2", @@ -143,9 +144,10 @@ export class TraceRecorder { }, children: [], } as Item; + this.addressStack.push({ value: "lazy" }); } else { item = { - opcode: "UNKNOWN", + opcode: "UNKNOWN_MESSAGE", params: {}, children: [], }; @@ -182,7 +184,8 @@ export class TraceRecorder { } } - this.addressStack.push(contractAddress); + let ptr = this.addressStack[this.addressStack.length - 1]; + ptr.value = contractAddress; resolve?.(); } diff --git a/src/types.ts b/src/types.ts index a7d782b..855fa84 100644 --- a/src/types.ts +++ b/src/types.ts @@ -110,7 +110,10 @@ export interface Item { export interface AwaitedItem { isAwaitedItem: true; next: number; - parse: (step: MinimalInterpreterStep, currentAddress?: string) => Item; + parse: ( + step: MinimalInterpreterStep, + currentAddress?: { value: string } + ) => Item; } export interface CallItem extends Item {