refactor: use route from props for type derivation (SwitchAccountType…#26484
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. |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
The modal is registered in App.tsx as Selected tags:
The changes are primarily code quality improvements (TypeScript, tests, React key warning fix) and don't modify core business logic, making this a low-risk change. Performance Test Selection: |
| const { network7702List, pending } = useEIP7702Networks(address); | ||
| const address: Hex | undefined = | ||
| route?.params?.address ?? (selectedAccountAddress as Hex | undefined); | ||
| const { network7702List, pending } = useEIP7702Networks(address ?? ''); |
There was a problem hiding this comment.
Empty string to hook may crash via error boundary
Medium Severity
When address is undefined, useEIP7702Networks(address ?? '') passes an empty string to the hook. The hook calls isAtomicBatchSupported({ address: '' as Hex, ... }) via useAsyncResultOrThrow, which re-throws any async error during the render phase. If the API rejects the invalid empty-string address, the thrown error propagates to the error boundary, crashing the component tree — the if (!address) fallback UI on line 62 won't survive the subsequent re-render.
Additional Locations (1)
| }); | ||
|
|
||
| describe('rendering', () => { | ||
| it('displays account info and network details correctly', () => { |
There was a problem hiding this comment.
Test names use subjective outcome words
Low Severity
Two test names use subjective outcome words prohibited by the unit testing guidelines. 'displays account info and network details correctly' uses "correctly" and 'passes correct address to useEIP7702Networks hook' uses "correct". The naming convention requires indicating the actual expected result instead of using vague qualifiers like "correctly" or "correct".
Additional Locations (1)
Triggered by project rule: Unit Testing Guidelines


Description
Reason for the change:
The
SwitchAccountTypeModalcomponent was using theuseRoute()hook internally to access route parameters. This approach has several drawbacks:(route?.params as { address: Hex })?.address)useRoutehook globallyImprovement/Solution:
SwitchAccountTypeModalto receiverouteas a prop instead of callinguseRoute()internallySwitchAccountTypeModalRouteParams,SwitchAccountTypeModalParamList, andSwitchAccountTypeModalPropskeyprop toAccountNetworkRowcomponent in the map function (fixes React key warning)rendering,route params handling,navigation,hook integration)Changelog
CHANGELOG entry: null
Related issues
Fixes: N/A (internal refactoring)
Manual testing steps
Screenshots/Recordings
Before
N/A - No visual changes (except for new fallback state)
After
N/A - No visual changes (except for new fallback state when no address is available)
Pre-merge author checklist
Pre-merge reviewer checklist