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

Replaced addresses by the address component on SignTypedData v4 signatures #16018

Merged
merged 13 commits into from
Nov 10, 2022

Conversation

VSaric
Copy link
Contributor

@VSaric VSaric commented Sep 28, 2022

Explanation

MetaMask has no control on what the message that is displayed is this screen is - this is something provided by the dapps and will look differently for each one of them. MetaMask does have control on how such messages are displayed and how the UI looks like - and this is what we are trying to achieve with this PR. So with this PR, we want every value that is an address to be displayed using the address component.

More Information

Screenshots

Before (test-dapp)

Screenshot 2022-10-04 at 14 32 15

Screenshot 2022-10-04 at 14 32 29

After (test-dapp)

Screenshot 2022-10-12 at 10 08 11

Screenshot 2022-10-12 at 10 08 51

Screencaps

Before (test-dapp)

Screen.Recording.2022-09-28.at.15.15.24.mov

After (test-dapp)

Screen.Recording.2022-10-04.at.16.59.21.mov

Before (OpenSea)

Screen.Recording.2022-09-29.at.15.03.37.mov

After (OpenSea)

Screen.Recording.2022-10-04.at.17.12.57.mov

Manual Testing Steps

  1. Open the test dapp https://metamask.github.io/test-dapp/
  2. Under the SignTypedData v4 section, click on Sign
    or
  3. Get some test NFTs on https://faucet.paradigm.xyz/
  4. Make sure MM is connected to Rinkeby test network
  5. Go to https://testnets.opensea.io/account
  6. Click on one of your NFTs
  7. Click on Sell
  8. Go through the steps until you get prompt to Confirm listing on OpenSea - this will trigger a SignTypedData v4 prompt in MM (you might have to sign a different message and approve a transaction if it's the first time you're going through this flow)

@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.

@VSaric VSaric self-assigned this Sep 28, 2022
@VSaric VSaric force-pushed the replace-addresses-by-the-address-component branch from 4cf7674 to ad47843 Compare September 28, 2022 14:19
@metamaskbot
Copy link
Collaborator

Builds ready [ad47843]
Page Load Metrics (2408 ± 75 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint89162115157
domContentLoaded19252747238316479
load19952747240815675
domInteractive19252747238316479

highlights:

storybook

@metamaskbot
Copy link
Collaborator

Builds ready [f1be052]
Page Load Metrics (2347 ± 102 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint91148113189
domContentLoaded196629262328224108
load198829262347213102
domInteractive196629262328224108

highlights:

storybook

@VSaric VSaric force-pushed the replace-addresses-by-the-address-component branch from f1be052 to 9fdef79 Compare September 30, 2022 14:24
@metamaskbot
Copy link
Collaborator

Builds ready [9fdef79]
Page Load Metrics (2373 ± 204 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint872361183316
domContentLoaded187035902344424204
load187035902373426204
domInteractive187035902344424204

highlights:

storybook

@VSaric VSaric force-pushed the replace-addresses-by-the-address-component branch from 9fdef79 to f84cdc2 Compare October 4, 2022 12:15
@metamaskbot
Copy link
Collaborator

Builds ready [f84cdc2]
Page Load Metrics (2285 ± 71 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint921571162110
domContentLoaded18772552224215474
load19492576228514871
domInteractive18772552224215474

highlights:

storybook

@metamaskbot
Copy link
Collaborator

Builds ready [ecf9f25]
Page Load Metrics (2488 ± 130 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint971901242412
domContentLoaded185029362454263126
load187529362488271130
domInteractive185029362454263126

highlights:

storybook

@mirjanaKukic
Copy link
Contributor

Verified by QA

@VSaric VSaric marked this pull request as ready for review October 5, 2022 09:53
@VSaric VSaric requested review from a team and kumavis as code owners October 5, 2022 09:53

const renderNode = (renderData) => {
return (
<div className="signature-request-message--node">
Copy link
Contributor

Choose a reason for hiding this comment

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

So, a few things.

  1. This isn't proper BEM syntax for class names -- is a modifier spacer and __ is a block spacer. so i think we'd want signature-request-message__node.
  2. Later you have --node-label and use &-label to style it, this also isn't proper BEM syntax, node-label would be its own new block not a nested block.
  3. I realize you are trying to use the existing styles here, but I would prefer that if you are going to remove old patterns (thank you!!! this is awesome!!!) by refactoring class components to functional, dropping the '.component' syntax that we also use Box and Typography to ease in the transition to the new design system in the future.

let me know if that makes sense

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right @brad-decker, sorry for that! I know that we are using Box and Typography by refactoring class components to functional and I know about proper BEM syntax, sorry for that once again! I will take care of this in the future PRs!
I left only one div because it has the ref property. I have not been able to do this with the Box component, because Box component don't have that property. If it is okay to stay like this great, but if you have some suggestions about this please comment and I will make changes. I made changes here.
Thank you in advance!

@VSaric VSaric force-pushed the replace-addresses-by-the-address-component branch from ecf9f25 to d327788 Compare October 7, 2022 15:20
@VSaric VSaric requested a review from brad-decker October 7, 2022 15:30
@metamaskbot
Copy link
Collaborator

Builds ready [820c8d0]
Page Load Metrics (2407 ± 105 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint952451393617
domContentLoaded187227052386216104
load187227822407219105
domInteractive187227042385216104

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.

This is a super cool update! I've checked out your branch and made some minor updates. It contains an update from develop so it will be failing currently but once rebased from develop it should work

PR with suggestions here

Would also be super cool to get a story with this view

@VSaric VSaric force-pushed the replace-addresses-by-the-address-component branch from 820c8d0 to 3c55ea2 Compare October 12, 2022 08:47
@VSaric
Copy link
Contributor Author

VSaric commented Oct 12, 2022

I added your suggestion changes manually here @georgewrmarshall. Thank you! 😄

@metamaskbot
Copy link
Collaborator

Builds ready [3c55ea2]
Page Load Metrics (2260 ± 85 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint87136103147
domContentLoaded19292607224316981
load19292608226017785
domInteractive19292607224316981

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.

UI LGTM! 💯

@VSaric VSaric requested a review from darkwing October 13, 2022 07:07
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.

Tested on local and UI lgtm!
I think we could do something about how the space is taken up by each section but that can be addressed in another PR

Screen Shot 2022-11-07 at 10 35 51 AM

Comment on lines 49 to 105
const renderNode = (renderData) => {
return (
<Box className="signature-request-message__node">
{Object.entries(renderData).map(([label, value], i) => (
<Box
className="signature-request-message__node"
key={i}
paddingLeft={2}
display={
typeof value !== 'object' || value === null ? DISPLAY.FLEX : null
}
>
<Typography
as="span"
color={COLORS.TEXT_DEFAULT}
marginLeft={4}
fontWeight={
typeof value === 'object'
? FONT_WEIGHT.BOLD
: FONT_WEIGHT.NORMAL
}
>
{label.charAt(0).toUpperCase() + label.slice(1)}:{' '}
</Typography>
{typeof value === 'object' && value !== null ? (
renderNode(value)
) : (
<Typography
as="span"
color={COLORS.TEXT_DEFAULT}
marginLeft={4}
className="signature-request-message__node__value"
>
{isValidHexAddress(value, {
mixedCaseUseChecksum: true,
}) ? (
<Typography
variant={TYPOGRAPHY.H7}
color={COLORS.INFO_DEFAULT}
className="signature-request-message__node__value__address"
>
<Address
addressOnly
checksummedRecipientAddress={toChecksumHexAddress(value)}
recipientName={getAccountName(identities, value)}
/>
</Typography>
) : (
`${value}`
)}
</Typography>
)}
</Box>
))}
</Box>
);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't create these functions for intermediary components, just render them inline unless they are rendered multiple times then lift them into a new component.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bschorchit
Copy link

Tested on local and UI lgtm! I think we could do something about how the space is taken up by each section but that can be addressed in another PR

Screen Shot 2022-11-07 at 10 35 51 AM

Created a new issue for this here: #16405

@metamaskbot
Copy link
Collaborator

Builds ready [2be69d3]
Page Load Metrics (2205 ± 115 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint942401232498239
domContentLoaded177226492190233112
load177326492205239115
domInteractive177226492190233112

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.

I completely agree with @brad-decker's suggestion to move the SignatureRequestData component to it's own file and will promote this pattern for maintainability in future review. Following this I think we could have a unit test and story for each new component but because it used in signature-request-message.js and there is a story for this component I think it's ok. Nice work! 💯

@metamaskbot
Copy link
Collaborator

Builds ready [8ef44b0]
Page Load Metrics (2060 ± 88 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint863121175225
domContentLoaded15992338205218287
load15992338206018488
domInteractive15992338205218287
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 317 bytes
  • ui: 11990 bytes
  • common: 1804 bytes

highlights:

storybook

@danjm danjm merged commit 42be5a0 into develop Nov 10, 2022
@danjm danjm deleted the replace-addresses-by-the-address-component branch November 10, 2022 10:28
@github-actions github-actions bot locked and limited conversation to collaborators Nov 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.

Replace addresses by the address component on SignTypedData v4 signatures
7 participants