Metamask-extension: RPC errors not bubbled back to 脨app

Created on 30 Apr 2020  路  5Comments  路  Source: MetaMask/metamask-extension

Currently when a 脨app initiates a call to eth_sendTransaction, if the RPC backend throws an error (like transaction underpriced), this error is not returned to the 脨app, instead a generic internal wrapper is returned, like "Error: [ethjs-rpc] rpc error with payload {"...

Checked and this behavior continues to exist on develop.

Ideal case:

  • [ ] Return the RPC error to the 脨app itself.
  • [ ] Show the failure reason in the transaction history to the user.
T00-bug

All 5 comments

Ok, seems I am getting this issue, but I am getting the following error for every metamask tx, even when I use metamask ui to send ether to another address

Here is the error I get when executing one my dapp transaction :

{code: -32603, message: "Error: [ethjs-rpc] rpc error with payload {"id":79鈥ethod":"eth_sendRawTransaction"} [object Object]", stack: "Error: Error: [ethjs-rpc] rpc error with payload {鈥ethod":"eth_sendRawTransaction"} [object Object]"}
stack : "Error: Error: [ethjs-rpc] rpc error with payload {"id":7973398896595,"jsonrpc":"2.0","params":["0xf8cb2b8504a817c80082bd5d943037e0b21e7b8e0babaf3611d6d0d5cac51e67c080b864c47f0027000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000036473640000000000000000000000000000000000000000000000000000000000820a95a04314f99297ee7e82db567bc8008c3d2739558e9010b9dac763d266a71f72bb0ca03a9aa5658bfc4dde3c754c40a5345aaba47819cc6df5b39c57144fb42c60bf85"],"method":"eth_sendRawTransaction"} [object Object]"

This was on chrome and loaded a new profile with a new metamask and there my dapp function fine

This is quite frustrating, as things work fine when I am just running scripts in Node.js but suddenly throws a cryptic error when I do it through the frontend. Is there a toString() getting called somewhere that's causing the underlying object (w/ revert reason string) to become [object Object] instead?

Not only is the RPC mangled, it also is wrapped in a more opaque error. When I inspect the JSON-RPC error I get back from sendAsync, I see:

{
  "code": -32603,
  "message": "[object Object]",
  "data": {
    "code": -32603,
    "message": "revert: ERC20: transfer amount exceeds allowance"
  },
  "stack": "..."
}

Note that the actual JSON-RPC error (the onet hat would be immensely useful for debugging) is burried inside the data field of the error I actually get back.

I am not seeing the data member in Chrome.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DISC30 picture DISC30  路  3Comments

beether picture beether  路  4Comments

MarkOSullivan94 picture MarkOSullivan94  路  3Comments

kumavis picture kumavis  路  3Comments

whyrusleeping picture whyrusleeping  路  3Comments