-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Fix issue with awaiting swaps page #16344
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. |
cbc6fb0
to
e241359
Compare
Though changes look good, I would suggest a review by someone from swaps team also. |
Thanks for the code. I believe it should be also changed on the smart transaction status page, which is displayed when a smart transaction is submitted: https://github.com/MetaMask/metamask-extension/blob/develop/ui/pages/swaps/smart-transaction-status/smart-transaction-status.js#L76 |
7f43485
to
44f110c
Compare
Builds ready [97f6157]
Page Load Metrics (2017 ± 94 ms)
highlights:storybook
|
…tchParams are wiped when service worker dies
3bac654
to
5c3c319
Compare
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've tested it with and without smart transactions + terminating a service worker and it worked well. Great job!
Builds ready [35f8d44]
Page Load Metrics (2380 ± 128 ms)
highlights:storybook
|
Explanation
Currently when the service worker is terminated immediately after a swap is initiated the
SwapsController
controlledswapsState
is reset and so thequotes
empty out along with otherfetchParams
causing a redirect:https://github.com/MetaMask/metamask-extension/blob/develop/ui/pages/swaps/index.js#L505 . So if you don't quickly hit the
swap
button on theview quotes
page after terminating the SW you will be redirected back to thebuild-quote
page:Screen.Recording.2022-11-01.at.4.25.08.PM.mov
But if you hit swap button before the redirect we hit this call to
prepareToLeaveSwaps
, which clears the swaps stateAnd before the state clearing process is complete the
signAndSendTransactions
call - that is initiated when you hit theswap
button - goes through with the swaps state intacthttps://github.com/MetaMask/metamask-extension/blob/develop/ui/pages/swaps/index.js#L257
once you arrive on the
awaiting-swaps
page, though the swap has been submitted correctly, the token information that we use to tell the user which token they will be receiving is no longer accessible since it is accessed through the now clearedswapsState
(from theSwapsController
in the background)This PR fixes the issue by having the
await-swap
page fetch the swap transaction data from the transactions controller (where the state is persisted if the transaction is successfully initiated) rather than the swaps controller where the required state is cleared.More Information
Manual Testing Steps
Your <symbol of currency you are swapping for> will be added to your account once this transaction has processed.
Pre-Merge Checklist
+ If there are functional changes: