@nomiclabs/buidler
Version:
Buidler is an extensible developer tool that helps smart contract developers increase productivity by reliably bringing together the tools they want.
28 lines (23 loc) • 801 B
text/typescript
import { ContractsIdentifier } from "./contracts-identifier";
import { isEvmStep, isPrecompileTrace, MessageTrace } from "./message-trace";
import { Bytecode } from "./model";
export class VmTraceDecoder {
constructor(private readonly _contractsIdentifier: ContractsIdentifier) {}
public tryToDecodeMessageTrace(messageTrace: MessageTrace): MessageTrace {
if (isPrecompileTrace(messageTrace)) {
return messageTrace;
}
return {
...messageTrace,
bytecode: this._contractsIdentifier.getBytecodeFromMessageTrace(
messageTrace
),
steps: messageTrace.steps.map((s) =>
isEvmStep(s) ? s : this.tryToDecodeMessageTrace(s)
),
};
}
public addBytecode(bytecode: Bytecode) {
this._contractsIdentifier.addBytecode(bytecode);
}
}