Skip to content

Commit c305a31

Browse files
fvictorioalcuadrado
authored andcommitted
Add success flag and success/halt reason
1 parent 0681cac commit c305a31

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

packages/hardhat-core/src/internal/hardhat-network/provider/utils/convertToEdr.ts

+15-2
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,24 @@ export function edrTracingStepToMinimalInterpreterStep(
232232
export function edrTracingMessageResultToMinimalEVMResult(
233233
tracingMessageResult: TracingMessageResult
234234
): MinimalEVMResult {
235-
return {
235+
const executionResult = tracingMessageResult.executionResult.result;
236+
237+
// only SuccessResult has logs
238+
const success = "logs" in executionResult;
239+
240+
const minimalEVMResult: MinimalEVMResult = {
236241
execResult: {
237-
executionGasUsed: tracingMessageResult.executionResult.result.gasUsed,
242+
executionGasUsed: executionResult.gasUsed,
243+
success,
238244
},
239245
};
246+
247+
// only success and exceptional halt have reason
248+
if ("reason" in executionResult) {
249+
minimalEVMResult.execResult.reason = executionResult.reason;
250+
}
251+
252+
return minimalEVMResult;
240253
}
241254

242255
export function edrTracingMessageToMinimalMessage(

packages/hardhat-core/src/internal/hardhat-network/provider/vm/types.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { ExceptionalHalt, SuccessReason } from "@nomicfoundation/edr";
12
import type { Address } from "@nomicfoundation/ethereumjs-util";
23

34
/**
@@ -16,7 +17,9 @@ export interface MinimalInterpreterStep {
1617
}
1718

1819
export interface MinimalExecResult {
20+
success: boolean;
1921
executionGasUsed: bigint;
22+
reason?: SuccessReason | ExceptionalHalt;
2023
}
2124

2225
export interface MinimalEVMResult {

0 commit comments

Comments
 (0)