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. |
| const t = useI18nContext(); | ||
| const currentConfirmation = useSelector(currentConfirmationSelector); | ||
|
|
||
| if (!currentConfirmation?.msgParams) { |
There was a problem hiding this comment.
is it possible for currentConfirmation to be undefined?
There was a problem hiding this comment.
TS complains if I do not use ?
|
|
||
| describe('personalSign', () => { | ||
| it('renders origin for personal sign request', () => { | ||
| describe('PersonalSignInfo', () => { |
There was a problem hiding this comment.
In case the currentConfirmation can be undefined, should we add a test for that?
There was a problem hiding this comment.
Not really... but since hook can possible return undefined, TS requires me to handle it
ui/pages/confirmations/components/confirm/info/personal-sign/personal-sign.test.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
No need for optional chainig.. we have arleady validated in the previous if clause
There was a problem hiding this comment.
Also would love if we could avoid type casting
There was a problem hiding this comment.
Yep optional chaining can be avoided here but typecasting not
ui/pages/confirmations/components/confirm/info/typed-sign/typed-sign.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Should this be abstracted in the ConfirmationInfoConponentMap?
We could isolate Confirmation component selection logic within it (in my opinion making it more isolate and readable). Something like:
const getTypedSignInfo = (currentConfirmation) => {
const { version } = currentConfirmation?.msgParams ?? {};
if (version === 'V1') {
return TypedSignV1Info;
}
return TypedSignInfo;
}
const ConfirmationInfoConponentMap = {
[TransactionType.personalSign]: () => PersonalSignInfo,
[TransactionType.signTypedData]: getTypedSignInfo,
};
...
const InfoComponent =
ConfirmationInfoConponentMap[currentConfirmation?.type as ConfirmationType](currentConfirmation);What do you think?
(Also just noticed, ConfirmationInfoConponentMap has a typo.. should be ConfirmationInfoComponentMap)
There was a problem hiding this comment.
We can do it either way, since the logic will stay in 1 file to me either looks ok
ui/pages/confirmations/components/confirm/info/typed-sign-v1/typed-sign-v1.test.tsx
Outdated
Show resolved
Hide resolved
…n into typed_sign_v1
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #23539 +/- ##
===========================================
+ Coverage 69.28% 69.30% +0.02%
===========================================
Files 1158 1160 +2
Lines 44069 44083 +14
Branches 11758 11760 +2
===========================================
+ Hits 30531 30548 +17
+ Misses 13538 13535 -3 ☔ View full report in Codecov by Sentry. |
Builds ready [04efefe]
Page Load Metrics (451 ± 336 ms)
Bundle size diffs
|
Description
Re-design implementation for typed sign V1 signature requests.
Related issues
Fixes: #23481
Manual testing steps
Screenshots/Recordings
Pre-merge author checklist
Pre-merge reviewer checklist