Blockaid scanning : Status code is 200 with the error in the response
Bug description
Status code is 200 with the error in the response. The error is not displayed in the message on UI
Environment
- Browser: Chrome
- Wallet: MetaMask
- Chain: Ethereum mainnet
Steps to reproduce
Example : https://client.blockaid.io/v0/evm/json-rpc/scan
Payload : “{"chain":"0x1","account_address":"0x8675B754342754A30A2AeF474D114d8460bca19b","data":{"method":"eth_signTypedData_v4","params":["0x8675B754342754A30A2AeF474D114d8460bca19b","{\"types\":{\"EIP712Domain\":[{\"type\":\"uint256\",\"name\":\"chainId\"},{\"type\":\"address\",\"name\":\"verifyingContract\"}],\"SafeTx\":[{\"type\":\"address\",\"name\":\"to\"},{\"type\":\"uint256\",\"name\":\"value\"},{\"type\":\"bytes\",\"name\":\"data\"},{\"type\":\"uint8\",\"name\":\"operation\"},{\"type\":\"uint256\",\"name\":\"safeTxGas\"},{\"type\":\"uint256\",\"name\":\"baseGas\"},{\"type\":\"uint256\",\"name\":\"gasPrice\"},{\"type\":\"address\",\"name\":\"gasToken\"},{\"type\":\"address\",\"name\":\"refundReceiver\"},{\"type\":\"uint256\",\"name\":\"nonce\"}]},\"domain\":{\"verifyingContract\":\"0x8675B754342754A30A2AeF474D114d8460bca19b\",\"chainId\":\"1\"},\"primaryType\":\"SafeTx\",\"message\":{\"to\":\"0xC6d3D201530a6D4aD9dFbAAd39C5f68A9A470a69\",\"value\":\"0\",\"data\":\"0xa9059cbb00000000000000000000000065f8236309e5a99ff0d129d04e486ebce20dc7b00000000000000000000000000000000000000000000000000000000000002443\",\"operation\":0,\"baseGas\":\"0\",\"gasPrice\":\"0\",\"gasToken\":\"0x0000000000000000000000000000000000000000\",\"refundReceiver\":\"0x0000000000000000000000000000000000000000\",\"nonce\":445,\"safeTxGas\":\"0\"}}"]},"options":["simulation","validation"],"metadata":{"domain":"[fix_blockaid--walletweb.review.5afe.dev](http://fix_blockaid--walletweb.review.5afe.dev/)"}}”
Code 200
Response: {"validation":{"status":"Error","result_type":"Error","description":"","reason":"","features":[],"error":"Simulation Error: Reverted with reason string: 'ERC20: transfer amount exceeds balance'","labels":[]},"simulation":{"status":"Error","error":"Reverted with reason string: 'ERC20: transfer amount exceeds balance'"},"block":"21680411","chain":"ethereum","account_address":"0x8675B754342754A30A2AeF474D114d8460bca19b"}
UI message:
Expected result
Could we display the error from the response instead of the general message as a warning?
Obtained result
Screenshots
From Blockaid:
In the case of a revert from the node when simulating the transaction (for example, if the account is trying to send tokens that it doesn’t have), we will return the revert error (in his case, you can see that the revert is “insufficient balance” which is make sense)
so essentially the simulation itself was successful, the response from the node was the revert error (insufficient balance) that was returned
It means we should handle this case on the frontend and probably display the error to the user.
LGMT. I tried with sending more funds than we have, sending fake tokens, adding/removing the same owner twice.
It seems that we still show the warning type of message (the orange one instead of the red one) since the simulation cannot actually be run. I think is nice we at least show the user why the simulation failed to run so he can correct the tx parameters