Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@adonesky1
Copy link
Contributor

@adonesky1 adonesky1 commented Dec 10, 2021

This PR enables sending of ERC721 tokens from within the final piece of bringing the extension to parity with mobile for NFT support. ERC1155 sends are not yet enabled (as is the case on mobile).
Relevant Figma Designs

Screenshots:
Stepping through the Send Flow:
Screen Shot 2022-01-04 at 4 47 39 PM
Screen Shot 2022-01-04 at 4 51 08 PM
Screen Shot 2022-01-04 at 4 51 18 PM
Screen Shot 2022-01-04 at 4 51 31 PM

If the user does not own the collectible (if it is in the "Previously Owned" Section) they can still click into view the details,
but they will not see a send button available:
Screen Shot 2022-01-04 at 5 00 33 PM
Screen Shot 2022-01-04 at 4 51 54 PM

And if the token is an ERC1155 we show but disable the send button with an info tooltip to indicate that we don't yet support sending this type of token:
Screen Shot 2022-01-04 at 4 52 19 PM

Manual testing steps:

  • Add an NFT to your wallet on a test net (you can use this faucet)
  • Click into the details page of the NFT and click the send button
  • Go through the send flow as you would for a token.
  • Verify that the NFT has sent to the address you intended.
  • Click back into the token details page, the send button should disappear, and when you return back up to the collectibles tab, that NFT should be removed from your primary collection and added to the "Previously Owned" section.

Related (and non-blocking in my opinion) work still left to do:

  • Migrate or add notification tell users they will have to manually migrate their ERC721/1155 tokens via the Import NFT flow.
  • Add validation prevent users from adding ERC721/1155 tokens through the add tokens flow (and direct them to the Import NFT flow)
  • Create an NFT flow in the test-dapp
  • This related but not blocking bug for which I have PRs here and here (WIP)
  • ERC1155 sending

@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 dismissed a stale review via bcbc375 December 13, 2021 19:59
@adonesky1 adonesky1 force-pushed the feat/collectibles-send-flow branch from 86c870c to bcbc375 Compare December 13, 2021 19:59
@adonesky1 adonesky1 changed the base branch from develop to feat/collectibles-the-return December 13, 2021 20:00
Base automatically changed from feat/collectibles-the-return to develop December 13, 2021 23:41
@adonesky1 adonesky1 force-pushed the feat/collectibles-send-flow branch 3 times, most recently from abee450 to 26085b7 Compare December 16, 2021 23:05
@metamaskbot
Copy link
Collaborator

Builds ready [cea4fe9]
Page Load Metrics (1075 ± 13 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint671103323431207
domContentLoaded1015112810752613
load1015112810752613
domInteractive1015112810752613

highlights:

storybook

@adonesky1 adonesky1 dismissed a stale review via 72e4021 December 17, 2021 18:27
@adonesky1 adonesky1 force-pushed the feat/collectibles-send-flow branch 2 times, most recently from 07ea71a to 714f5df Compare December 17, 2021 21:52
@metamaskbot
Copy link
Collaborator

Builds ready [714f5df]
Page Load Metrics (1339 ± 104 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint661487397420202
domContentLoaded107016851338217104
load107016851339216104
domInteractive107016841338217104

highlights:

storybook

@adonesky1 adonesky1 force-pushed the feat/collectibles-send-flow branch from 481f088 to 1b74aee Compare December 22, 2021 22:46
@adonesky1 adonesky1 force-pushed the feat/collectibles-send-flow branch 3 times, most recently from 508894e to 9223382 Compare January 4, 2022 18:49
@adonesky1 adonesky1 force-pushed the feat/collectibles-send-flow branch from 9223382 to 898f775 Compare January 4, 2022 19:55
@metamaskbot
Copy link
Collaborator

Builds ready [898f775]
Page Load Metrics (1211 ± 68 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint691445483445214
domContentLoaded10391556121014168
load10391556121114168
domInteractive10391556121014168

highlights:

storybook

@adonesky1 adonesky1 marked this pull request as ready for review January 4, 2022 23:01
@adonesky1 adonesky1 requested a review from a team as a code owner January 4, 2022 23:01
@adonesky1 adonesky1 requested review from danjm, mcmire and ryanml January 4, 2022 23:01
@metamaskbot
Copy link
Collaborator

Builds ready [845fc2e]
Page Load Metrics (1126 ± 43 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint651413407457219
domContentLoaded1041142511249043
load1041142611268943
domInteractive1041142511249043

highlights:

storybook

@adonesky1 adonesky1 force-pushed the feat/collectibles-send-flow branch from 00220aa to f6d4123 Compare January 6, 2022 17:48
@adonesky1 adonesky1 dismissed darkwing’s stale review January 6, 2022 18:05

Needs a re-review

@adonesky1 adonesky1 requested a review from mcmire January 6, 2022 18:05
@metamaskbot
Copy link
Collaborator

Builds ready [f6d4123]
Page Load Metrics (1098 ± 22 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint671170596495238
domContentLoaded1037117710974723
load1037117710984622
domInteractive1037117710974723

highlights:

storybook

knownCollectible,
false,
// TODO add this when checkAndUpdateSingleCollectibleOwnershipStatus is updated
// { userAddress, chainId },
Copy link
Contributor Author

@adonesky1 adonesky1 Jan 6, 2022

Choose a reason for hiding this comment

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

This should/will be added once this PR lands MetaMask/core#672 and a new controllers version is cut.

Copy link
Contributor

Choose a reason for hiding this comment

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

We can add this after this PR is merged, correct?

Copy link
Contributor

Choose a reason for hiding this comment

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

What affect will this call to this.collectiblesController.checkAndUpdateSingleCollectibleOwnershipStatus have before this code is uncommented?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea we can add it later. Until the PR is merged and this code is uncommented the following scenario is possible:

  • User sends NFT on Account 1
  • User switches to Account 2 before transaction is complete
  • Transaction is confirmed while user is on Account 2
  • The collectibles controller will check whether this collectible is owned by Account 2 and update its status, but the NFT was owned by Account 1 so it won't find it and no status will be updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without the PR merged and code uncommented (in its current state) If however the user hasn't switched accounts between when they sent the NFT and when the transaction was confirmed, the status update will be completed correctly.

@adonesky1 adonesky1 requested a review from brad-decker January 6, 2022 21:29
@metamaskbot
Copy link
Collaborator

Builds ready [127eae4]
Page Load Metrics (1215 ± 84 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint671195495479230
domContentLoaded10281673121317785
load10281673121517684
domInteractive10281673121317785

highlights:

storybook

mcmire
mcmire previously approved these changes Jan 6, 2022
accounts: getMetaMaskAccounts(state),
nativeCurrency: getNativeCurrency(state),
nativeCurrencyImage: getNativeCurrencyImage(state),
testState: state,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this supposed to be here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nope 😶‍🌫️

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed here fea5a50

Copy link
Contributor

@georgewrmarshall georgewrmarshall left a comment

Choose a reason for hiding this comment

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

Looks great!! A couple nit picky 8px grid suggestions and the collapse state of the collectible dropdowns didn't seem to be working as intended for me? Overall really nice UI work!!

<Typography
color={COLORS.UI4}
variant={TYPOGRAPHY.H6}
boxProps={{ margin: 0, marginBottom: 3 }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Adhere to 8px grid. marginBottom: 3 would be 12px(3*4px). Update to 16px

Suggested change
boxProps={{ margin: 0, marginBottom: 3 }}
boxProps={{ margin: 0, marginBottom: 4 }}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed here: 2a88844

@metamaskbot
Copy link
Collaborator

Builds ready [fea5a50]
Page Load Metrics (1157 ± 60 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint651273525503241
domContentLoaded9981449115612459
load9981449115712460
domInteractive9981449115612459

highlights:

storybook

@adonesky1 adonesky1 force-pushed the feat/collectibles-send-flow branch from 2a88844 to 8771e9b Compare January 7, 2022 23:25
@metamaskbot
Copy link
Collaborator

Builds ready [8771e9b]
Page Load Metrics (1168 ± 41 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint691374696534256
domContentLoaded1051138211648440
load1052138211688541
domInteractive1051138211648440

highlights:

storybook

Copy link
Contributor

@georgewrmarshall georgewrmarshall left a comment

Choose a reason for hiding this comment

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

Looks great to me! Nicely done 💯

// in which case we will want to check and update ownership status of the transferred collectible.
if (
txMeta.type === TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER_FROM &&
txMeta.txParams !== undefined
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible for txMeta.type === TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER_FROM AND txMeta.txParams === undefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems unlikely. Added here for extra protection against unexpected scenarios.

Copy link
Contributor

@brad-decker brad-decker left a comment

Choose a reason for hiding this comment

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

Looks good to me, the additional code in the send duck looks clean and easy to understand, plus builds upon and extend existing standards and patterns. Great work, Alex.

@adonesky1 adonesky1 merged commit 4826c8c into develop Jan 10, 2022
@adonesky1 adonesky1 deleted the feat/collectibles-send-flow branch January 10, 2022 16:23
@github-actions github-actions bot locked and limited conversation to collaborators Jan 10, 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.

9 participants