-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Confirmation redesign: add message section to personal sign page #22766
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
Conversation
|
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. |
Builds ready [3dbf2a7]
Page Load Metrics (833 ± 40 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Codecov ReportAttention: Patch coverage is
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. |
Co-authored-by: Olusegun Akintayo <akintayo.segun@gmail.com>
| return hex; | ||
| } | ||
| try { | ||
| const stripped = stripHexPrefix(hex); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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(() => { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ref: #22763
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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:
- 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.
- 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.
- 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.
There was a problem hiding this comment.
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)
eriknson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…extension into personal_sign_message
…extension into personal_sign_message
Builds ready [f8bab21]
Page Load Metrics (1404 ± 393 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
| }); | ||
| }); | ||
|
|
||
| describe('hexToText', () => { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 /> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
segun
left a comment
There was a problem hiding this 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
| style={{ | ||
| columnGap: '8px', | ||
| }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| style={{ | |
| columnGap: '8px', | |
| }} | |
| gap={2} |
There was a problem hiding this comment.
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
…extension into personal_sign_message
Builds ready [fb52651]
Page Load Metrics (1179 ± 335 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
cryptotavares
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good ✅
Builds ready [80daf05]
Page Load Metrics (1454 ± 240 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|


Description
Adding message section to personal sign page
Related issues
Fixes: MetaMask/MetaMask-planning#1514
Manual testing steps
Screenshots/Recordings
Pre-merge author checklist
Pre-merge reviewer checklist