Skip to content
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

feat: NFT token transfer #27955

Merged
merged 2 commits into from
Oct 24, 2024
Merged

feat: NFT token transfer #27955

merged 2 commits into from
Oct 24, 2024

Conversation

pedronfigueiredo
Copy link
Contributor

@pedronfigueiredo pedronfigueiredo commented Oct 18, 2024

Description

Implements token transfer confirmation for ERC721 and ERC1155 tokens, in the cases where they are wallet initiated and dApp initiated. Includes e2e tests.

Open in GitHub Codespaces

Related issues

Fixes: https://github.com/MetaMask/MetaMask-planning/issues/3018 https://github.com/MetaMask/MetaMask-planning/issues/3019

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

Screenshot 2024-10-18 at 12 46 52

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@pedronfigueiredo pedronfigueiredo added the team-confirmations Push issues to confirmations team label Oct 18, 2024
@pedronfigueiredo pedronfigueiredo self-assigned this Oct 18, 2024
@pedronfigueiredo pedronfigueiredo requested review from a team as code owners October 18, 2024 11:47
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.

jpuri
jpuri previously approved these changes Oct 18, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [cbc3616]
Page Load Metrics (1958 ± 94 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint16652476195719393
domContentLoaded16532464192219694
load16622477195819694
domInteractive1594492311
backgroundConnect10164333919
firstReactRender462981066330
getState55516167
initialActions00000
loadScripts12412059145518287
setupStore1193442612
uiStartup186126712215235113
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 4.83 KiB (0.06%)
  • common: 88 Bytes (0.00%)

matthewwalsh0
matthewwalsh0 previously approved these changes Oct 24, 2024
@@ -33,7 +33,16 @@ const Header = () => {

const { currentConfirmation } = useConfirmContext<Confirmation>();

if (currentConfirmation?.type === TransactionType.tokenMethodTransfer) {
const CONFIRMATIONS_WITH_NEW_HEADER = [
Copy link
Member

Choose a reason for hiding this comment

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

Minor, can this go at the top of the file?

And should we use a more explicit name, what does New mean in this context?

if (
currentConfirmation?.type &&
CONFIRMATIONS_WITH_NEW_HEADER.includes(currentConfirmation.type)
) {
Copy link
Member

Choose a reason for hiding this comment

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

Minor, would it make the logic clearer if we remove the nesting and have flat conditions for each alternate header?

We could even put the fallback into a local component such as DefaultHeader?

jpuri
jpuri previously approved these changes Oct 24, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [af00d32]
Page Load Metrics (1831 ± 86 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint30124841773380183
domContentLoaded16612433180717182
load16662485183117986
domInteractive17175483316
backgroundConnect992282411
firstReactRender45200903416
getState480182311
initialActions01000
loadScripts12161989135016378
setupStore1073262211
uiStartup186626772046216104
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 4.87 KiB (0.06%)
  • common: 88 Bytes (0.00%)

}

return (
const DefaultHeader = (
Copy link
Member

Choose a reason for hiding this comment

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

Minor, we've defined this as a nested component within the Header component but is it slightly more readable to define it at the top level and either re-use the same hooks or pass in the properties it needs?

(currentConfirmation as TransactionMeta)?.origin === 'metamask';
if (isConfirmationWithNewHeader && isWalletInitiated) {
return <WalletInitiatedHeader />;
} else if (isConfirmationWithNewHeader && !isWalletInitiated) {
Copy link
Member

Choose a reason for hiding this comment

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

Minor, we're using an else here but no need since we're returning in each condition.

currentConfirmation?.type &&
CONFIRMATIONS_WITH_NEW_HEADER.includes(currentConfirmation.type);
const isWalletInitiated =
(currentConfirmation as TransactionMeta)?.origin === 'metamask';
Copy link
Member

Choose a reason for hiding this comment

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

Minor, could we use ORIGIN_METAMASK here?

@pedronfigueiredo pedronfigueiredo added this pull request to the merge queue Oct 24, 2024
Merged via the queue into develop with commit cbfd131 Oct 24, 2024
76 checks passed
@pedronfigueiredo pedronfigueiredo deleted the pnf/3019 branch October 24, 2024 15:45
@github-actions github-actions bot locked and limited conversation to collaborators Oct 24, 2024
@metamaskbot metamaskbot added the release-12.7.0 Issue or pull request that will be included in release 12.7.0 label Oct 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.7.0 Issue or pull request that will be included in release 12.7.0 team-confirmations Push issues to confirmations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants