From 0d141f171d6ec44bcbfc9c876565b5e2fb8af6de Mon Sep 17 00:00:00 2001 From: Mert Certel <45617686+yulafezmesi@users.noreply.github.com> Date: Mon, 29 Apr 2024 01:28:43 +0300 Subject: [PATCH] fix: use `data` property of return code (#3858) * fix: use `data` property of return code * chore: add changeset * Update fresh-carrots-switch.md --------- Co-authored-by: jxom --- .changeset/fresh-carrots-switch.md | 6 ++++++ packages/core/src/actions/waitForTransactionReceipt.ts | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 .changeset/fresh-carrots-switch.md diff --git a/.changeset/fresh-carrots-switch.md b/.changeset/fresh-carrots-switch.md new file mode 100644 index 0000000000..63816ef9c3 --- /dev/null +++ b/.changeset/fresh-carrots-switch.md @@ -0,0 +1,6 @@ +--- +"@wagmi/core": patch +"wagmi": patch +--- + +Fixed accessing reverted reason property inside `waitForTransactionReceipt`. diff --git a/packages/core/src/actions/waitForTransactionReceipt.ts b/packages/core/src/actions/waitForTransactionReceipt.ts index 41f7f890c8..71d6a66afd 100644 --- a/packages/core/src/actions/waitForTransactionReceipt.ts +++ b/packages/core/src/actions/waitForTransactionReceipt.ts @@ -69,9 +69,9 @@ export async function waitForTransactionReceipt< maxFeePerGas: txn.type === 'eip1559' ? txn.maxFeePerGas : undefined, maxPriorityFeePerGas: txn.type === 'eip1559' ? txn.maxPriorityFeePerGas : undefined, - })) as unknown as string - const reason = code - ? hexToString(`0x${code.substring(138)}`) + })) + const reason = code?.data + ? hexToString(`0x${code.data.substring(138)}`) : 'unknown reason' throw new Error(reason) }