Skip to content

Commit

Permalink
🌏 Switch hardhat errors priority (#820)
Browse files Browse the repository at this point in the history
  • Loading branch information
yivlad authored Jan 26, 2023
1 parent 13d1af0 commit 216f1d8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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

0 comments on commit 216f1d8

Please sign in to comment.