wevm / wagmi

React Hooks for Ethereum

Home Page:https://wagmi.sh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bug: waitForTransactionReceipt throws `code.substring is not a function` in case transaction reverted

yulafezmesi opened this issue · comments

Describe the bug

while fetching transaction receipt by hash, the function returns internal error: code.substring is not a function

image

Link to Minimal Reproducible Example

https://stackblitz.com/edit/new-wagmi-rhd8t3?file=src%2FApp.tsx,vite.config.ts,src%2Fmain.tsx

Steps To Reproduce

  • connect wallet
  • click "get details" button
  • you'll see code.substring is not a function error message on the screen.

image

Wagmi Version

2.5.20

Viem Version

2.9.25

TypeScript Version

5.2.2

Check existing issues

Anything else?

on this case, the code variable coming as { data: undefined } and the function tries to call .substring function over object which cause error.

i think needs to be:

const reason = code?.data ? hexToString(`0x${code.data.substring(138)}`) : "unknown reason";

bug place

debug
Screenshot 2024-04-24 at 21 33 19

This issue has been locked since it has been closed for more than 14 days.

If you found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest wagmi version. If you have any other comments you can create a new discussion.