-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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: add SIWE mismatch account warning alert and hide duplicate warnings in MultipleAlertModal #25559
base: develop
Are you sure you want to change the base?
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. |
32de38d
to
69cc879
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #25559 +/- ##
===========================================
+ Coverage 69.65% 69.66% +0.01%
===========================================
Files 1355 1356 +1
Lines 48007 48029 +22
Branches 13235 13239 +4
===========================================
+ Hits 33437 33459 +22
Misses 14570 14570 ☔ View full report in Codecov by Sentry. |
Builds ready [69cc879]
Page Load Metrics (322 ± 280 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [23cd578]
Page Load Metrics (91 ± 20 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [23cd578]
Page Load Metrics (91 ± 20 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
}, [isMismatchAccount, t]); | ||
|
||
return alerts; | ||
} |
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.
Above hook will re-render only if confirmation changes, thus do we really need 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.
We currently do this as standard on all alert hooks since they are returning arrays so it ensures any usages and future usages have stable data, at the cost of only around 4 extra lines.
const alerts = useMemo(() => { | ||
return allAlerts.reduce((result: Alert[], alert: Alert) => { | ||
const isDuplicateWarning = result.some((a: Alert) => { | ||
return a.severity === Severity.Warning && a.message === alert.message; |
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.
Currently, the only use case is for warning alerts (mismatch account). While this addresses the present scenario, should we extend it to handle duplicates for all alert severities?
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 agree. I think since the danger severity would require confirmation, it would require more updates. Because of this I think it’d be better to extend the functionality when we need 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.
Assuming we definitely want duplicate alerts on different fields, would it be cleaner to encapsulate this within useAlerts
in a property such as uniqueAlerts
?
severity: Severity.Warning, | ||
}, | ||
{ | ||
field: 'signingInWith', |
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 are we adding a single alert to two fields?
I understood our alert system assumes alerts are general or targeted to a single field?
Can we not pick the most relevant single field such as signing in with?
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.
oh I think you may be right. I was referring to the design in the screenshot but in Figma, it does indeed look like the alert only exists on "Signing in with". Let me double-check w/ design
const alerts = useMemo(() => { | ||
return allAlerts.reduce((result: Alert[], alert: Alert) => { | ||
const isDuplicateWarning = result.some((a: Alert) => { | ||
return a.severity === Severity.Warning && a.message === alert.message; |
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.
Assuming we definitely want duplicate alerts on different fields, would it be cleaner to encapsulate this within useAlerts
in a property such as uniqueAlerts
?
@@ -58,9 +58,13 @@ const PersonalSignInfo: React.FC = () => { | |||
<ConfirmInfoRowUrl url={currentConfirmation.msgParams.origin} /> | |||
</ConfirmInfoAlertRow> | |||
{isSIWE && ( | |||
<ConfirmInfoRow label={t('signingInWith')}> | |||
<ConfirmInfoAlertRow | |||
alertKey="signingInWith" |
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.
To avoid duplicate strings, there is now a RowAlertKey
enum inside ui/components/app/confirm/info/row/constants.ts
.
reason: t('alertReasonWrongAccount'), | ||
severity: Severity.Warning, | ||
}, | ||
] as Alert[]; |
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 do we need to cast? Does this suggest we have bad data or a bad type?
] as Alert[]; | ||
}, [isMismatchAccount, t]); | ||
|
||
return alerts; |
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.
Minor, but can we return
the hook directly to make it explicit we're caching the result?
}, [isMismatchAccount, t]); | ||
|
||
return alerts; | ||
} |
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 currently do this as standard on all alert hooks since they are returning arrays so it ensures any usages and future usages have stable data, at the cost of only around 4 extra lines.
Description
Related issues
Fixes: #25317
Manual testing steps
isSIWE
condition inui/pages/confirmations/hooks/useCurrentConfirmation.ts
fileyarn start
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist