-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Ensure that editing a tx from a transfer to a simple send resets data and updates type #15248
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
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
| }; | ||
|
|
||
| // only update what is defined | ||
| editableParams.txParams = pickBy(editableParams.txParams); |
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.
This allows us to set txParams to empty strings
ui/ducks/send/send.js
Outdated
| // transaction from being a token transfer to a simple send. | ||
| if ( | ||
| unapprovedTx?.type === TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER_FROM || | ||
| unapprovedTx?.type === TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER |
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 know this is nitty, but when I read this comment I thought unapprovedTx was like...any unapproved tx. Can we change this comment to be something along the lines of if the original type of this transaction was a token method then we need to null out he usetInputHeadData (words are not important just specifying original and ensuring that the unapprovedTx is clearly marked as the original tx in an edit flow)
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.
Comment improved in 91d8a85d2
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.
Should we include TOKEN_METHOD_SAFE_TRANSFER_FROM here. I don't believe it's possible for it to be a problem at the moment because it's a method on ERC721's and we don't enable the edit button on ERC721 sends at the moment, but we may want to soon?
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.
added in 1eed22c
ui/ducks/send/send.js
Outdated
| // If, after edit, we are sending the native asset, | ||
| // and if the send duck hex data was reset on this edit, | ||
| // and if the hex data from the tx's background state matches | ||
| // one of the special token methods that we handle, | ||
| // then we conclude that the user does not want to send hex data, | ||
| // and ensure it gets reset in the background state as well. | ||
| const sendingNativeAsset = | ||
| draftTransaction.asset.type === ASSET_TYPES.NATIVE; | ||
| const userInputHexDataHasBeenReset = | ||
| draftTransaction.userInputHexData === ''; | ||
| const priorHexDataMatchesSpecialTokenTxSignatures = | ||
| parseStandardTokenTransactionData(editingTx.txParams.data) !== | ||
| undefined; | ||
| if ( | ||
| sendingNativeAsset && | ||
| userInputHexDataHasBeenReset && | ||
| priorHexDataMatchesSpecialTokenTxSignatures | ||
| ) { | ||
| editingTx.txParams.data = ''; | ||
| } |
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"m confused why we can't just rely upon the value of userInputHexData to override this? It should be set to an empty string n 1920, therefor the call to generateTransactionParams on line 2115 should return an appropriate txParams object. with data null. Can you help me understand why this contract breaks down under these special conditions?
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.
yes removed in ee260f475
| throw error; | ||
| } | ||
|
|
||
| await forceUpdateMetamaskState(dispatch); |
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.
[q] why is this necessary?
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.
To ensure that transaction state is properly updated before hitting the confirm screen routing logic after clicking the "Next" button
ee260f4 to
97745fa
Compare
ui/ducks/send/send.js
Outdated
| // If an asset update occurs that changes the type from 'NATIVE' to | ||
| // 'NATIVE' then this is likely the initial asset set of an edit | ||
| // transaction. We don't need to set the amount to zero in this case. | ||
| // The only times where an update would occur of this nature that we | ||
| // would want to set the amount to zero is on a network or account change | ||
| // but that update is handled elsewhere. |
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.
why was this comment added back?
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.
rebase issue more than likely.
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 will reapprove after this is removed
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.
removed in 9514f02
ui/ducks/send/send.js
Outdated
| // If an asset update occurs that changes the type from 'NATIVE' to | ||
| // 'NATIVE' then this is likely the initial asset set of an edit | ||
| // transaction. We don't need to set the amount to zero in this case. | ||
| // The only times where an update would occur of this nature that we | ||
| // would want to set the amount to zero is on a network or account change | ||
| // but that update is handled elsewhere. |
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 will reapprove after this is removed
…from tx to native send
adonesky1
left a comment
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.
LGTM!
Builds ready [1eed22c]
Page Load Metrics (1690 ± 36 ms)
highlights:storybook
|
NiranjanaBinoy
left a comment
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.
LGTM
Fixes #15184
Preceding v10.18.0 there was a problem whereby changing from a token transfer to a simple send on the send edit screen would not change the transaction data. This would incorrectly leave the rendered type as transfer and incorrectly leave hex data on the transaction.
With v10.18.0, this could cause an unhandled error when trying to edit a transaction in this state of faulty data, because we would attempt to parse the recipient address of a simple send as if it were a token address.
The solution requires two parts: