Skip to content

Commit 216f1d8

Browse files
authored
🌏 Switch hardhat errors priority (#820)
1 parent 13d1af0 commit 216f1d8

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

.changeset/thirty-dodos-doubt.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@ethereum-waffle/chai": patch
3+
---
4+
5+
Switch hardhat error priority

waffle-chai/src/matchers/revertedWith.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ export function supportRevertedWith(Assertion: Chai.AssertionStatic) {
4545
const errorInterface = new ethers.utils.Interface(['function Error(string)']);
4646
const decodeHardhatError = (error: any, context: any) => {
4747
const tryDecode = (error: any) => {
48+
if (error === undefined) {
49+
return undefined;
50+
}
4851
if (
4952
error?.errorName &&
5053
/**
@@ -119,7 +122,9 @@ const decodeHardhatError = (error: any, context: any) => {
119122
return undefined;
120123
};
121124

122-
return tryDecode(error) ?? tryDecode(error.error); // the error may be wrapped
125+
return tryDecode(error.error?.error) ??
126+
tryDecode(error.error) ??
127+
tryDecode(error); // the error may be wrapped
123128
};
124129

125130
const decodeOptimismError = (error: any) => {

0 commit comments

Comments
 (0)