Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌏 Switch hardhat errors priority #820

Merged
merged 2 commits into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/thirty-dodos-doubt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ethereum-waffle/chai": patch
---

Switch hardhat error priority
7 changes: 6 additions & 1 deletion waffle-chai/src/matchers/revertedWith.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export function supportRevertedWith(Assertion: Chai.AssertionStatic) {
const errorInterface = new ethers.utils.Interface(['function Error(string)']);
const decodeHardhatError = (error: any, context: any) => {
const tryDecode = (error: any) => {
if (error === undefined) {
return undefined;
}
if (
error?.errorName &&
/**
Expand Down Expand Up @@ -119,7 +122,9 @@ const decodeHardhatError = (error: any, context: any) => {
return undefined;
};

return tryDecode(error) ?? tryDecode(error.error); // the error may be wrapped
return tryDecode(error.error?.error) ??
tryDecode(error.error) ??
tryDecode(error); // the error may be wrapped
};

const decodeOptimismError = (error: any) => {
Expand Down