useDApp icon indicating copy to clipboard operation
useDApp copied to clipboard

MetaMask - RPC Errors updating state but not appearing in notifications

Open naderhen opened this issue 3 years ago • 1 comments

In my dapp, I've noticed that some calls to useContractFunction can fail very quickly without updating the NotificationsContext. I've seen it happen when certain require() fail in the contract, but I can make it happen reliably by dropping the gas limit very low when I send the transaction. In that case, I see an error like: image

In my hook, I can see that state.status is correctly changing to Exception with the correct errorMessage but it's never making it the list of notifications. Is there a way to globally catch all useContractFunction exceptions that I'm maybe missing?

image

Thanks!

naderhen avatar Feb 15 '22 13:02 naderhen

First looks tells me that we don't update the NotificationsContext for transactions that fail before being successfully sent. It can include the transactions failing on require()s because a transaction first undergoes gas estimation.

I'll take a deeper look and see if we can make it work for you.

rzadp avatar Aug 10 '22 10:08 rzadp