-
Notifications
You must be signed in to change notification settings - Fork 5.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
Display a warning and gas fee component for token allowance and NFT flow when transaction is expected to fail #17437
Display a warning and gas fee component for token allowance and NFT flow when transaction is expected to fail #17437
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. |
ca8dc8a
to
41c2404
Compare
Builds ready [41c2404]
Page Load Metrics (1361 ± 109 ms)
Bundle size diffs
|
I think that another fix is required for the confirmation screens other than token allowance and NFT approvals. I have made a PR for that here: #17458 |
Oh I see, sorry for that @danjm! Do you want maybe to delete that line in I tried |
Verified by QA |
Builds ready [6070ff2]
Page Load Metrics (1619 ± 138 ms)
Bundle size diffs
|
} | ||
/> | ||
</Box> | ||
)} |
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.
Might be useful to extract out a small component for above warning display. It seems to be repeated a few places.
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.
Will be nice to have more test coverage in the PR. |
supportsEIP1559 && | ||
!renderSimulationFailureWarning | ||
) { | ||
return <GasDetailsItem userAcknowledgedGasMissing />; |
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.
A re-usable hook to get this value renderSimulationFailureWarning
might be useful. I see this logic repeated a few places.
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.
…low when transaction is expected to fail
6070ff2
to
cabe23b
Compare
Builds ready [2bfc2ca]
Page Load Metrics (1388 ± 138 ms)
Bundle size diffs
|
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 [7e71360]
Page Load Metrics (1313 ± 124 ms)
Bundle size diffs
|
@@ -0,0 +1 @@ | |||
export { default } from './simulation-error-message'; |
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.
A better place for this will be ui/components/app
Explanation
With this fixes, when MM loads a confirmation screen for a transaction that is expected to fail, it's now displaying the gas component. This has been seen so far on both the NFT approve and the new token allowance confirmation screens. Also when a transaction is expected to fail, it displays a warning. Approving a second time USDT drives to a failed transaction where should display a warning and the gas component.
Further explanation:
The gas component isn't displayed because we aren't set
userAcknowledgedGasMissing
inGasDetailsItem
andEditGasFeeButton
component inapprove-content-card.js
(this is content for token allowance flow) andconfirm-approve-content.component.js
(this is for NFT flow). Default value foruserAcknowledgedGasMissing
isfalse
.Code where default value for
userAcknowledgedGasMissing
isfalse
inGasDisplayItem
component: https://github.com/MetaMask/metamask-extension/blob/develop/ui/components/app/gas-details-item/gas-details-item.js#L19Code where it is returning
null
inGasDisplayItem
component: https://github.com/MetaMask/metamask-extension/blob/develop/ui/components/app/gas-details-item/gas-details-item.js#L35Code where it is returning
null
inEditGasFeeButton
component: https://github.com/MetaMask/metamask-extension/blob/develop/ui/components/app/edit-gas-fee-button/edit-gas-fee-button.js#L35Now we are using
renderSimulationFailureWarning
to show a warning if it istrue
and if we want to proceed with a transaction that is expected to fail, we are settinguserAcknowledgedGasMissing
totrue
when we click onI want to proceed anyway
link and then gas component will displays.I also changed
setshowContractDetails
tosetShowContractDetails
what @darkwing suggested here.Screenshots/Screencaps
Before
ERC20 token (token allowance flow)
Screen.Recording.2023-01-26.at.16.47.01.mov
ERC721 or ERC1155 token (NFT flow)
Screen.Recording.2023-01-26.at.16.48.24.mov
After
ERC20 token (token allowance flow)
Screen.Recording.2023-01-26.at.15.01.52.mov
ERC721 or ERC1155 token (NFT flow)
Screen.Recording.2023-01-26.at.15.06.14.mov
Manual Testing Steps
ERC20 token (token allowance)
Write Contract
Approve
Write
I want to proceed anyway
link displays the gas component for this failing transaction (on the second page of token allowance flow)ERC721 or ERC1155 token (NFT flow)
approve
and input a random address and a random token id (I used 1, it's important that you don't actually own that NFT)Write
I want to proceed anyway
link displays the gas component for this failing transaction