Skip to content

Conversation

@adonesky1
Copy link
Contributor

@adonesky1 adonesky1 commented Feb 28, 2022

Fixes: #11611 (and generally improves the UX of NFT confirmation screens)

Overview

  • Creates a sub-component ConfirmTokenTransactionSwitch through which token/NF confirmation screens for the methods approve, transfer, and transferFrom are routed.
  • ConfirmTokenTransactionSwitch instantiates a newly created hook useAssetDetails which passes the pending transaction to the new method getTokenStandardAndDetails in the AssetsContractController and retrieves all the data ( assetName, userBalance, tokenSymbol, decimals, image etc.) we need for the three token specific method pages we currently support (approve, transfer, and transferFrom). This method call also returns the assetStandard to enable improved branching logic to provide suitable language depending on the token contract standard (ERC20, ERC721 or ERC1155).
    • Importantly this eliminates the unwanted behavior of adding the token to the TokensController state whenever a user interacts with a confirmation transaction of a token not already in TokensController state

Additionally (though less importantly)

  • Refactors confirm-token-transaction-base and confirm-send-token from class based to functional components for improved ease of use.

When reviewing PR in action:

The behavior/UX should be unaltered for ERC20 method calls listed above but be more accurate and clear for the same method calls for ERC721 and ERC1155 contracts.

For Example
ERC721 approve call before:
Screen Shot 2022-02-09 at 5 31 42 PM
the tokenId is incorrectly being used as token amount ☝️ 👇
Screen Shot 2022-02-09 at 5 26 07 PM

after:
the option to change the amount should not be present for ERC721 tokens 👇
Screen Shot 2022-01-14 at 2 36 02 PM

ERC721 transferFrom call before:
Screen Shot 2022-02-09 at 5 34 32 PM

after:
Screen Shot 2022-02-09 at 5 53 34 PM

@github-actions
Copy link
Contributor

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.

@adonesky1 adonesky1 force-pushed the refactor-the-refactor branch from f5c5a4a to 23926a0 Compare February 28, 2022 18:55
@adonesky1 adonesky1 changed the title ake use of getTokenStandardAndDetails method exposed on assetsContractController to determine how to represent the contract being interacted with in token contract method calls Refactor token send/method confirmation flow Feb 28, 2022
@adonesky1 adonesky1 changed the title Refactor token send/method confirmation flow Refactor token send/method confirmation flow (trimmed down) Feb 28, 2022
@adonesky1 adonesky1 force-pushed the refactor-the-refactor branch 5 times, most recently from 26ff8fc to e9f8461 Compare February 28, 2022 19:51
Comment on lines +1755 to +1767
Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the identicon we show on the approve screen should be for the address we are granting approval not the token for which we are granting approval:
Screen Shot 2022-02-28 at 12 57 50 PM

Comment on lines -181 to -192
Copy link
Contributor Author

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.

Copy link
Contributor Author

@adonesky1 adonesky1 Feb 28, 2022

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

Copy link
Contributor Author

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.

@adonesky1 adonesky1 changed the title Refactor token send/method confirmation flow (trimmed down) Refactor token send/method confirmation flow (slighly trimmed down) Feb 28, 2022
@adonesky1 adonesky1 force-pushed the refactor-the-refactor branch from e9f8461 to 0f8b920 Compare February 28, 2022 20:26
className="confirm-approve-content__address-identicon"
diameter={20}
address={toAddress}
image={tokenImage}
Copy link
Contributor Author

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.

@metamaskbot
Copy link
Collaborator

Builds ready [0f8b920]
Page Load Metrics (1236 ± 51 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint701391619515247
domContentLoaded10621420123310752
load10621420123610751
domInteractive10621420123310752

highlights:

storybook

@adonesky1 adonesky1 force-pushed the refactor-the-refactor branch 2 times, most recently from 2da6987 to a23960b Compare March 2, 2022 14:57
@metamaskbot
Copy link
Collaborator

Builds ready [a23960b]
Page Load Metrics (1106 ± 24 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint681106257359172
domContentLoaded1032122311034924
load1033122311065024
domInteractive1032122311034924

highlights:

storybook

@adonesky1 adonesky1 changed the title Refactor token send/method confirmation flow (slighly trimmed down) Refactor token send/method confirmation flow (trimmed down) Mar 2, 2022
DELJUJAZI
DELJUJAZI previously approved these changes Mar 7, 2022
@metamaskbot
Copy link
Collaborator

Builds ready [86826e7]
Page Load Metrics (1078 ± 22 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint651137504474228
domContentLoaded1003120510764622
load1010121210784622
domInteractive1003120510764622

highlights:

storybook

@adonesky1 adonesky1 requested review from jpuri and segun March 7, 2022 16:36
@adonesky1 adonesky1 force-pushed the refactor-the-refactor branch from 86826e7 to 1a76353 Compare March 7, 2022 21:36
@adonesky1
Copy link
Contributor Author

Just rebased to resolve conflicts. cc @jpuri @segun @mcmire

@metamaskbot
Copy link
Collaborator

Builds ready [1a76353]
Page Load Metrics (1297 ± 40 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint7312285147
domContentLoaded1202155112948239
load1202155712978440
domInteractive1201155112948239

highlights:

storybook

segun
segun previously approved these changes Mar 8, 2022
Copy link
Contributor

@segun segun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

mcmire
mcmire previously approved these changes Mar 8, 2022
Copy link
Contributor

@mcmire mcmire left a 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!

@adonesky1 adonesky1 dismissed stale reviews from mcmire and segun via cad8876 March 8, 2022 22:44
@adonesky1 adonesky1 force-pushed the refactor-the-refactor branch from 1a76353 to cad8876 Compare March 8, 2022 22:44
@adonesky1
Copy link
Contributor Author

@segun and @mcmire I just rebased to resolve a conflict on the typography component. No other changes were required. Please re-approve when you have a chance?

@adonesky1 adonesky1 requested review from mcmire and segun March 8, 2022 22:45
@metamaskbot
Copy link
Collaborator

Builds ready [2274bc1]
Page Load Metrics (1273 ± 27 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint7013792199
domContentLoaded1192143912715727
load1192143912735727
domInteractive1192143912715727

highlights:

storybook

@adonesky1 adonesky1 merged commit 3747ace into develop Mar 9, 2022
@adonesky1 adonesky1 deleted the refactor-the-refactor branch March 9, 2022 14:38
@github-actions github-actions bot locked and limited conversation to collaborators Mar 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug - For ERC721 NFT tokens

8 participants