Structured Solidity Test Cheatcode Errors#8141
Conversation
🦋 Changeset detectedLatest commit: 2f801bf The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Pull request overview
Integrates EDR’s structured Solidity Test cheatcode error details into Hardhat’s stack-trace message formatting so users get clearer “missing vs unsupported” cheatcode messages.
Changes:
- Add cheatcode-specific message formatting for
CHEATCODE_ERRORstack-trace entries (unsupported vs missing). - Re-export
CheatcodeErrorCode(andCheatcodeErrorDetailstype) through Hardhat’s EDR stack-trace wrapper. - Add unit tests for the Solidity Test stack-trace message formatter.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/hardhat/src/internal/builtin-plugins/solidity-test/stack-trace-solidity-errors.ts | Formats CHEATCODE_ERROR messages using structured details.code for Solidity Test output. |
| packages/hardhat/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-solidity-errors.ts | Formats CHEATCODE_ERROR messages (with VM-exception prefix) using structured details for transaction errors. |
| packages/hardhat/src/internal/builtin-plugins/network-manager/edr/stack-traces/solidity-stack-trace.ts | Re-exports CheatcodeErrorCode and CheatcodeErrorDetails to align Hardhat types with EDR. |
| packages/hardhat/test/internal/builtin-plugins/solidity-test/stack-trace-solidity-errors.ts | Adds tests for Solidity Test getMessageFromLastStackTraceEntry cheatcode error formatting. |
| packages/hardhat/test/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-solidity-errors.ts | Adds imports and a duplicated test block for cheatcode message formatting (currently targeting the Solidity Test formatter). |
There was a problem hiding this comment.
Pull request overview
Integrates EDR’s newly structured Solidity Test cheatcode error details into Hardhat’s stack-trace error message formatting, so users get clearer, Hardhat-specific explanations for missing/unsupported cheatcodes (per #7966).
Changes:
- Add cheatcode-detail-aware message formatting for
CHEATCODE_ERRORstack trace entries (missing vs unsupported cheatcodes). - Re-export EDR cheatcode error types/codes through Hardhat’s internal stack-trace module.
- Add/extend internal tests to cover the new message behavior (both Solidity Test and network-manager error construction).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/hardhat/src/internal/builtin-plugins/solidity-test/stack-trace-solidity-errors.ts | Uses structured details.code to return Hardhat-specific messages for cheatcode errors. |
| packages/hardhat/src/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-solidity-errors.ts | Formats CHEATCODE_ERROR messages using structured details before prefixing with “VM Exception…”. |
| packages/hardhat/src/internal/builtin-plugins/network-manager/edr/stack-traces/solidity-stack-trace.ts | Re-exports CheatcodeErrorCode and CheatcodeErrorDetails to support structured error handling downstream. |
| packages/hardhat/test/internal/builtin-plugins/solidity-test/stack-trace-solidity-errors.ts | Adds tests asserting the new cheatcode error messages returned by getMessageFromLastStackTraceEntry. |
| packages/hardhat/test/internal/builtin-plugins/network-manager/edr/stack-traces/stack-trace-solidity-errors.ts | Extends tests to assert createSolidityErrorWithStackTrace uses the new cheatcode message formatting. |
| .changeset/funny-socks-worry.md | Adds a patch changeset describing the new structured cheatcode error support. |
alcuadrado
left a comment
There was a problem hiding this comment.
LGTM, but let's wait for @popescuoctavian to see if the output matches his expectation
|
LGTM, thanks for implementing this! For some context, when a call targets the cheatcode address the inspector tries to ABI-decode the cheatcode address to known cheatcodes -- if that fails with
I am assuming the |
@popescuoctavian Yes, that's correct, the |
|
@ChristopherDedominici that's in line with what I had in mind when I added the structured errors (maximizing backward compatibility). Thanks! |
Fixes: #7966
Example of error:
