diff --git a/.changeset/thirty-dodos-doubt.md b/.changeset/thirty-dodos-doubt.md new file mode 100644 index 000000000..f85222f74 --- /dev/null +++ b/.changeset/thirty-dodos-doubt.md @@ -0,0 +1,5 @@ +--- +"@ethereum-waffle/chai": patch +--- + +Switch hardhat error priority diff --git a/waffle-chai/src/matchers/revertedWith.ts b/waffle-chai/src/matchers/revertedWith.ts index 28178f195..e6d3ff69d 100644 --- a/waffle-chai/src/matchers/revertedWith.ts +++ b/waffle-chai/src/matchers/revertedWith.ts @@ -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 && /** @@ -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) => {