-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Refactor token send/method confirmation flow (trimmed down) #13788
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. |
f5c5a4a to
23926a0
Compare
26ff8fc to
e9f8461
Compare
app/scripts/metamask-controller.js
Outdated
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.
decimals and balance are not converted from BNs to strings automagically in Firefox (as they are in Chrome) so we need to do this for now.
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.
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.
these are the routes that have been moved in to the sub routing component <ConfirmTokenTransactionSwitch>, added above on line 159.
ui/store/actions.js
Outdated
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 method has been superseded by the more flexible/token standard agnostic method getTokenStandardAndDetails added on metamask-controller.js
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 is a pretty good place to start reviewing this PR. This hook in the context of this token method confirmation routing component is the core of the changes.
e9f8461 to
0f8b920
Compare
| className="confirm-approve-content__address-identicon" | ||
| diameter={20} | ||
| address={toAddress} | ||
| image={tokenImage} |
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.
we shouldn't use the tokenImage for the identicon of the address being granted approval.
2da6987 to
a23960b
Compare
Builds ready [a23960b]Page Load Metrics (1106 ± 24 ms)
highlights:storybook
|
Builds ready [86826e7]Page Load Metrics (1078 ± 22 ms)
highlights:storybook
|
86826e7 to
1a76353
Compare
Builds ready [1a76353]Page Load Metrics (1297 ± 40 ms)
highlights:storybook
|
segun
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
mcmire
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.
Finally got some time to look at this. Everything looks good!
…ctController to determine how to represent the contract being interacted with in token contract method calls
1a76353 to
cad8876
Compare
Builds ready [2274bc1]Page Load Metrics (1273 ± 27 ms)
highlights:storybook
|

Fixes: #11611 (and generally improves the UX of NFT confirmation screens)
Overview
ConfirmTokenTransactionSwitchthrough which token/NF confirmation screens for the methodsapprove,transfer, andtransferFromare routed.ConfirmTokenTransactionSwitchinstantiates a newly created hookuseAssetDetailswhich passes the pending transaction to the new methodgetTokenStandardAndDetailsin theAssetsContractControllerand retrieves all the data (assetName,userBalance,tokenSymbol,decimals,imageetc.) we need for the three token specific method pages we currently support (approve,transfer, andtransferFrom). This method call also returns theassetStandardto enable improved branching logic to provide suitable language depending on the token contract standard (ERC20,ERC721orERC1155).TokensControllerstate whenever a user interacts with a confirmation transaction of a token not already inTokensControllerstateAdditionally (though less importantly)
confirm-token-transaction-baseandconfirm-send-tokenfrom class based to functional components for improved ease of use.When reviewing PR in action:
The behavior/UX should be unaltered for
ERC20method calls listed above but be more accurate and clear for the same method calls forERC721andERC1155contracts.For Example


ERC721
approvecall before:the tokenId is incorrectly being used as token amount ☝️ 👇
after:

the option to change the amount should not be present for ERC721 tokens 👇
ERC721

transferFromcall before:after:
