-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stops the unintended 'User Rejected...' error caused by buggy submitt… #1578
Conversation
…ed<>confirmed nonce checks
app/components/Views/Asset/index.js
Outdated
const submittedNonces = []; | ||
submittedTxs = submittedTxs.filter(transaction => { | ||
const alreadyConfirmed = confirmedTxs.find( | ||
const alreadyConfirmed = currentAccountConfirmedTxs.find( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here couldn't we do:
tx => tx.transaction.nonce === transaction.transaction.nonce && tx.transaction.from === this.props.selectedAddress.toLowerCase()
?
In this way we can remove the previous filter and we would do only 1 cycle. This would be noticeable in terms of performance if confirmedTxs
possibly gets large.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have addressed this in the latest commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a small comment about the filter, to see what you think.
But apart from that, all the logic and solution looks great! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix looks good, QA Passed 👍
#1578) * Stops the unintended 'User Rejected...' error caused by buggy submitted<>confirmed nonce checks * Improve filtering logic Co-authored-by: Ibrahim Taveras <ibrahimtaveras00@gmail.com>
Fixes #1420
From this state, you can continuously recreate the error by doing the following:
14. Wait for the last transaction to confirm
15. Switch to Account 2
16. Repeat steps 7-13
Explanation of why this is happening from the perspective of the code.
TransactionView
component mountsTransactionView
component, itsnormalizeTransactions
method is calledTransactionView
component stays mounted. So when in this flow and confirming a transaction by clicking "Send", thenormalizeTransactions
method ofTransactionView
will be called.normalizeTransactions
compares the nonces of allsubmitted
transactions to allconfirmed
transactions, if any of the submitted tx nonces are the same as the confirmedTx nonces,TransactionController.cancelTransaction
is called on that submitted transaction.confirmed
transactions here includes all confirmed transactions from all accounts. If the just submitted transaction has a nonce equal to the nonce of an already confirmed transaction from another account then thecancelTransaction
method mentioned in 4 will be called.cancelTransaction
causes an error to be emitted that causes the modal "User rejected..." message to be shownTransactionController.approveTransaction
method has been called and sent the transaction to the blockchain. Which is why the transaction still goes through