From 216f1d8cdfd98d02c6a335d7789831559aecf955 Mon Sep 17 00:00:00 2001 From: Vladyslav Yatsenko <52505649+yivlad@users.noreply.github.com> Date: Thu, 26 Jan 2023 19:11:54 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=8F=20Switch=20hardhat=20errors=20prio?= =?UTF-8?q?rity=20(#820)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/thirty-dodos-doubt.md | 5 +++++ waffle-chai/src/matchers/revertedWith.ts | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .changeset/thirty-dodos-doubt.md 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) => {