Skip to content

Conversation

@jpuri
Copy link
Contributor

@jpuri jpuri commented Feb 1, 2024

Description

Adding message section to personal sign page

Related issues

Fixes: MetaMask/MetaMask-planning#1514

Manual testing steps

  1. Enable confirmation re-design locally
  2. Submit a personal signature request
  3. Check origin section on personal sign page

Screenshots/Recordings

Screenshot 2024-02-01 at 6 03 04 PM

Screenshot 2024-02-01 at 4 16 23 PM

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've clearly explained what problem this PR is solving and how it is solved.
  • I've linked related issues
  • I've included manual testing steps
  • I've included screenshots/recordings if applicable
  • I’ve included tests if applicable
  • I’ve documented my code using JSDoc format if applicable
  • I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.
  • I’ve properly set the pull request status:
    • In case it's not yet "ready for review", I've set it to "draft".
    • In case it's "ready for review", I've changed it from "draft" to "non-draft".

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.

@jpuri jpuri added team-confirmations-secure-ux-PR PRs from the confirmations team needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) confirmation-redesign labels Feb 1, 2024
@jpuri jpuri requested a review from a team as a code owner February 1, 2024 11:08
@github-actions
Copy link
Contributor

github-actions bot commented Feb 1, 2024

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.

@metamaskbot
Copy link
Collaborator

Builds ready [3dbf2a7]
Page Load Metrics (833 ± 40 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint94139114136
domContentLoaded9391863
load75411288338340
domInteractive9391863
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 1.21 KiB (0.02%)
  • common: 314 Bytes (0.01%)

@codecov
Copy link

codecov bot commented Feb 1, 2024

Codecov Report

Attention: Patch coverage is 90.90909% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 68.59%. Comparing base (f561faa) to head (f8bab21).

❗ Current head f8bab21 differs from pull request most recent head fb52651. Consider uploading reports for the commit fb52651 to get more accurate results

Files Patch % Lines
ui/components/app/confirm/info/info.tsx 0.00% 2 Missing ⚠️
ui/helpers/utils/util.js 87.50% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #22766      +/-   ##
===========================================
- Coverage    68.70%   68.59%   -0.11%     
===========================================
  Files         1102     1102              
  Lines        43221    43165      -56     
  Branches     11558    11541      -17     
===========================================
- Hits         29691    29607      -84     
- Misses       13530    13558      +28     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

segun
segun previously approved these changes Feb 1, 2024
Co-authored-by: Olusegun Akintayo <akintayo.segun@gmail.com>
return hex;
}
try {
const stripped = stripHexPrefix(hex);
Copy link
Member

Choose a reason for hiding this comment

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

Can we use @metamask/utils instead of defining new functions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could not find an equivalent method in @matamask/utils.

Copy link
Member

@FrederikBolding FrederikBolding Feb 14, 2024

Choose a reason for hiding this comment

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

I would recommend hexToBytes and bytesToString, though I'm not sure I fully understand the conditionals in this utility function.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jpuri thoughts on the above?
Also for consistent behaviour we should replace the msgHexToText in the SignatureRequestOriginal 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.

@cryptotavares : I would avoid changing original confirmation components. As we work on more confirmations, we will come across many situations like this to keep code consistent, but it will be hard to change + test existing stuff also as we make new. Ans, also eventually we will g et rid of old components.

Copy link
Contributor

Choose a reason for hiding this comment

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

We have agreed that if it is a straightforward duplication then yes we should update current confirmations components with the shared code (instead of keeping the duplication)... it should simplify maintenance (for the time where we have to support old and new components). But the moment the logic is no longer a duplication and branches off somewhere, then we shouldn't update the old components (as we do not want to couple any new code paths that we are adding to old components, making it harder to get rid of them once the time comes).

const t = useI18nContext();
const currentConfirmation = useSelector(currentConfirmationSelector);

const args = useMemo(() => {
Copy link
Member

Choose a reason for hiding this comment

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

Why is this architecture preferable than just using plain JSX? It seems like this would be harder to maintain without much added benefit. Unless I am missing something?

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 gives us more flexibility as these components will be reused for different types of confirmations.
And I actually do not see any maintenance overhead in keeping this logic in / out of jsx.

Copy link
Member

Choose a reason for hiding this comment

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

Could you elaborate on how this system "gives us more flexibility"? I'm having some trouble following how this config maps to components, but it seems like this would be simpler to understand using more standard techniques.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Gudahtt : we have multiple confirmation pages with different combination of this information displayed. I see this new info section more as tabular display of this data.

Screenshot 2024-02-09 at 4 32 53 PM

And using array to pass data to ConfirmInfo components gives us flexibility. But wherever we have fixed set of data like this example of message it will be better to use the jsx version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ref: #22763

Copy link
Contributor Author

@jpuri jpuri Feb 19, 2024

Choose a reason for hiding this comment

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

IMHO, jsx is not the best place for conditional, plain JS or TS code is better at that. These components will take care of different confirmation type with differing data to be displayed, this nested conditional in JSX does not look like a good idea to me.

I am not against either of the approaches, I also agree its more of preference, but I do not see a downside of current approach either.

JSX is syntactic sugar and the conditionals will be eventually converted to JS code only.

Copy link
Member

Choose a reason for hiding this comment

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

JSX is syntactic sugar

Exactly, "syntactic sugar" making the code more readable (at least to my eyes, fwiw)

Copy link
Member

Choose a reason for hiding this comment

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

As someone not as heavily involved with this code as everyone else is in this thread, reading (conditional) JSX seems much easier to me than what is proposed in the 2nd example

Copy link
Contributor

Choose a reason for hiding this comment

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

I see a lot of people chiming in into this decision. The reality is that due to the nature of confirmations (all different possibilities and confirmations types, data that is displayed to the user, actions that the user can perform, etc) confirmations will always be complex. It is what it is. The question that we asked, was where can we move that complexity, so that it becomes easier to maintain, extend, and build on top of those confirmations.

There are infinite ways to solve this, but we have went through either having:

  1. multiple confirmations pages (which is similar to what we have now a days). Easier to understand the structure of each confirmation screen, but complexity lies on routing and making the right data available to each page. It also encourages coupling components to each confirmation page.
  2. single page with conditional jsx. Though for simple components this might seem a far more readable option, that might not be the case for confirmations. In this case complexity will be in the jsx and all the conditions that it will have. It also encourages coupling confirmation type logic to the jsx.
  3. single page with props array mapping confirm info rows. In this case complexity goes into building/reading the props array. However it offers a more decoupled config per confirmation type, making it easier to maintain and extend. I would even argue if we can tweak the solution a bit and abstract the conditionals from the args and rely on a Map to get the args for each Confirmation type, could provide a more readable solution option 2 (especially if you take confirmations complexity into account).

We are trying to build a solution that will allow us to not only support current confirmations features but also eases up a lot the burden of maintenance while making it easier to continuously build on top. The decision to go with option 3 does not seem an incorrect one to me.

Copy link
Member

@eriknson eriknson Feb 21, 2024

Choose a reason for hiding this comment

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

I might be overlooking something here, but how is (1) mutually exclusive from (2)? To me, a combination of the two feels ideal.

For context, every confirmation screen in the redesign is built up with the following sections / components with conditional sections italicized;

An overview of the confirmations DS / structure

  • Header (required)
  • Banner / alert (conditional)
  • Title & description (required)
  • Request body (required)
    • Request specific content / rows
    • 3rd party insights in-line of request content (conditional)
  • 3rd party (snaps) insight (conditional)
  • Footer w/ actions (required)
confirmations-overview-hifi

Copy link
Member

@eriknson eriknson left a comment

Choose a reason for hiding this comment

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

So excited to see this! Here's design review / QA:
redesigned-signature-review

@jpuri jpuri marked this pull request as draft February 9, 2024 12:21
@metamaskbot
Copy link
Collaborator

Builds ready [f8bab21]
Page Load Metrics (1404 ± 393 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint722221394019
domContentLoaded877332210
load5930261404819393
domInteractive877332210
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 1.21 KiB (0.02%)
  • common: 423 Bytes (0.01%)

segun
segun previously approved these changes Mar 5, 2024
});
});

describe('hexToText', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a test to cover the hexToText catch block?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just added this test case

<Title />
<Info />
<Box>CONFIRMATION PAGE BODY TO COME HERE</Box>
<SignatureMessage />
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be abstracted within the Info component? I would expect that the different info blocks would be coupled to each confirmation info component. For example, PersonalSignInfo component should return the actual structure that we are expecting:

<>
  <Box
    ...
  >
    <ConfirmInfoRow>
     ...
    </ConfirmInfoRow>
    ...
  </Box>
  <SignatureMessage>
</>

And the Info component could just be confirmation map to the right infoComponent and return it:

  return (
    <InfoComponent />
  )

What do you think about it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I also have been thinking about this, I actually I wanted to discuss the confirmation designs with Saya to have more clarity on this. In one of the following PRs I will make this change.

blackdevelopa
blackdevelopa previously approved these changes Mar 5, 2024
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.

looks good except one comment

Comment on lines 20 to 22
style={{
columnGap: '8px',
}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
style={{
columnGap: '8px',
}}
gap={2}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I made this update

@jpuri jpuri dismissed stale reviews from blackdevelopa and segun via 918892c March 6, 2024 05:37
@metamaskbot
Copy link
Collaborator

Builds ready [fb52651]
Page Load Metrics (1179 ± 335 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint751931313316
domContentLoaded979332211
load6219411179697335
domInteractive979332211
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 1.16 KiB (0.02%)
  • common: 423 Bytes (0.01%)

Copy link
Contributor

@cryptotavares cryptotavares 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 ✅

@jpuri jpuri merged commit 75a91b0 into develop Mar 6, 2024
@jpuri jpuri deleted the personal_sign_message branch March 6, 2024 15:04
@github-actions github-actions bot removed the needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) label Mar 6, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Mar 6, 2024
@metamaskbot metamaskbot added the release-11.13.0 Issue or pull request that will be included in release 11.13.0 label Mar 6, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [80daf05]
Page Load Metrics (1454 ± 240 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint681681233115
domContentLoaded985302311
load5822881454500240
domInteractive985302311
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 723 Bytes (0.01%)
  • common: 423 Bytes (0.01%)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

confirmation-redesign release-11.13.0 Issue or pull request that will be included in release 11.13.0 team-confirmations-secure-ux-PR PRs from the confirmations team

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

10 participants