Open samajammin opened 5 years ago
Hi @sbrichards, we've made some changes to the transactionStack
which will probably help here. See the docs here, but the TL;DR is that a temporary ID will be pushed to transactionStack
, which you can then use to access the error in the transactions
object (using the temporary ID).
@sbrichards Is this still an issue for you?
cacheSend uses promiEvents under the hood to observe the multiple stages of a transaction. When an error is detected its message is recorded to the transactions sub-tree of redux state. PromiEvent will catch and present an exception through the error listener, unlike web3 send.
Thanks for the update @cds-amal - I will take a look ASAP, might be a week or two.
@sbrichards Did you found the solution because I have the same problem
@DiscRiskandBisque
Consider the following: You run a contract with invalid parameters, causing the Ethereum VM to throw an error. Gas is spent, and you receive a transaction hash.
Drizzle registers this transaction as successful, even though it failed!
As you can see from Etherscan, this transaction clearly failed https://ropsten.etherscan.io/tx/0xd73f7c608d041ada2b27e094e682b53e119c7a5b1d0c38b71273a465d22692ad
// But the transaction is registered as successful in drizzleState
drizzleState.transactions['0xd73f7c608d041ada2b27e094e682b53e119c7a5b1d0c38b71273a465d22692ad']
{
"status": "success",
"confirmations": [
{
"blockHash": "0x8bbb5212640465d5cdb53943c615fb970d2f90eb017575b922f028c1c44273d0",
"blockNumber": 5727902,
"contractAddress": null,
"cumulativeGasUsed": 170757,
"from": "0x8f9359c5f31c067eefb4569b938f97851bd6ea96",
"gasUsed": 23757,
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"status": "0x0",
"to": "0xc47d9b2a41f775e9588c1dfb18d839212e8e83b5",
"transactionHash": "0xd73f7c608d041ada2b27e094e682b53e119c7a5b1d0c38b71273a465d22692ad",
"transactionIndex": 7,
"events": {}
}
],
"receipt": {
"blockHash": "0x8bbb5212640465d5cdb53943c615fb970d2f90eb017575b922f028c1c44273d0",
"blockNumber": 5727902,
"contractAddress": null,
"cumulativeGasUsed": 170757,
"from": "0x8f9359c5f31c067eefb4569b938f97851bd6ea96",
"gasUsed": 23757,
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"status": "0x0",
"to": "0xc47d9b2a41f775e9588c1dfb18d839212e8e83b5",
"transactionHash": "0xd73f7c608d041ada2b27e094e682b53e119c7a5b1d0c38b71273a465d22692ad",
"transactionIndex": 7,
"events": {}
}
}
EDIT: Corrected "Truffle" to "Drizzle"
Thanks for reporting this @bergkvist. Can you share the code/project so we can reproduce this issue?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been closed, but can be re-opened if further comments indicate that the problem persists. Feel free to tag maintainers if there is no reply to further comments.
I'm trying to catch & display errors on invalid transaction inputs in my Drizzle project. When clicking to confirm an invalid transaction in the MetaMask window, MetaMack triggers a console error with the RPC payload & my contract code's revert statement in the error.message.
Using
cacheSend
, the MetaMask exception logs to the browser console but isn't caught in my code:But if I use the web3 send, it DOES catch the error:
It appears this MetaMask error is logging before the failed transaction hash is added into Drizzle's state, so I can't access the error there. Perhaps I don't fully grok the
cacheSend
method? How should I properly catch transaction errors with Drizzle?Thanks!