-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
chore(runway): cherry-pick chore: cp-7.51.0 faster address checksum (#16926) #17458
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
chore(runway): cherry-pick chore: cp-7.51.0 faster address checksum (#16926) #17458
Conversation
…16926) (#17174) ## **Description** This [PR](#16926) is originally from @Nodonisko from Margelo This PR uses new faster memoized functions for working with address checksum. There is already significant boost in AccountList performance and it should be even better when MetaMask/core#6054 is released and also when we fix Blockies Avatars. ## **Related issues** Fixes: #15560 ## **Manual testing steps** 1. Open Account List 2. It should feel faster than before ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** You can set that before then was lot of interrupted work before Account List modal is even displayed. It takes around ~7s from click to modal to be actually visible. <img width="1324" alt="Screenshot 2025-07-03 at 21 36 06" src="https://github.com/user-attachments/assets/7c624f31-db84-4ade-9df6-a116bff9a68f" /> ### **After** Here it takes only around ~3s to mount. (still slow but much better than before) <img width="1325" alt="Screenshot 2025-07-03 at 21 38 16" src="https://github.com/user-attachments/assets/96a5a4f1-59b7-4cfa-b58c-ac84eb238654" /> ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [x] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [x] 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. <!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **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. Co-authored-by: Daniel Suchý <suchydan@gmail.com>
|
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. |
|
Cal-L
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.
LGTM
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.
Bug: Error Handling Flaw in `toChecksumAddress`
The new toChecksumAddress function has flawed and fragile error handling. It attempts backward compatibility by returning certain invalid hex strings (e.g., "0x1", "0x2") as Hex types if isStrictHexString passes, even when getChecksumAddress deems them invalid. This logic relies on catching getChecksumAddress errors with the exact message 'Invalid hex address.', making it fragile. A future change in @metamask/utils error messages would break this specific error handling, causing the original error to be re-thrown instead of handled as intended.
app/util/address/index.ts#L484-L501
metamask-mobile/app/util/address/index.ts
Lines 484 to 501 in 753c871
| export function toChecksumAddress(address: string) { | |
| try { | |
| return getChecksumAddress(address as Hex); | |
| } catch (error) { | |
| // This is necessary for backward compatibility with the old behavior of | |
| // `ethereumjs-util` which would return the original string if the address | |
| // was invalid. This should happen only in tests which uses invalid addresses | |
| // like 0x1, 0x2 etc. | |
| if (error instanceof Error && error.message === 'Invalid hex address.') { | |
| if (isStrictHexString(address)) { | |
| return address as Hex; | |
| } | |
| throw new Error('Invalid hex address.'); | |
| } | |
| throw error; | |
| } | |
| } |
Was this report helpful? Give feedback by reacting with 👍 or 👎
|
|
No release label on PR. Adding release label release-7.52.0 on PR, as PR was cherry-picked in branch 7.52.0. |
1 similar comment
|
No release label on PR. Adding release label release-7.52.0 on PR, as PR was cherry-picked in branch 7.52.0. |
|
No release label on PR. Adding release label release-7.52.0 on PR, as PR was cherry-picked in branch 7.52.0. |
7 similar comments
|
No release label on PR. Adding release label release-7.52.0 on PR, as PR was cherry-picked in branch 7.52.0. |
|
No release label on PR. Adding release label release-7.52.0 on PR, as PR was cherry-picked in branch 7.52.0. |
|
No release label on PR. Adding release label release-7.52.0 on PR, as PR was cherry-picked in branch 7.52.0. |
|
No release label on PR. Adding release label release-7.52.0 on PR, as PR was cherry-picked in branch 7.52.0. |
|
No release label on PR. Adding release label release-7.52.0 on PR, as PR was cherry-picked in branch 7.52.0. |
|
No release label on PR. Adding release label release-7.52.0 on PR, as PR was cherry-picked in branch 7.52.0. |
|
No release label on PR. Adding release label release-7.52.0 on PR, as PR was cherry-picked in branch 7.52.0. |



Description
This PR is
originally from @Nodonisko from Margelo
This PR uses new faster memoized functions for working with address
checksum.
There is already significant boost in AccountList performance and it
should be even better when MetaMask/core#6054 is
released and also when we fix Blockies Avatars.
Related issues
Fixes: #15560
Manual testing steps
Screenshots/Recordings
Before
You can set that before then was lot of interrupted work before Account
List modal is even displayed. It takes around ~7s from click to modal to
be actually visible.
After
Here it takes only around ~3s to mount. (still slow but much better than
before)
Pre-merge author checklist
Docs and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
if applicable
guidelines).
Not required for external contributors.
Pre-merge reviewer checklist
app, test code being changed).
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
Description
Changelog
CHANGELOG entry:
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Docs and MetaMask Mobile
Coding
Standards.
if applicable
guidelines).
Not required for external contributors.
Pre-merge reviewer checklist
app, test code being changed).
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
Co-authored-by: Daniel Suchý suchydan@gmail.com 55bc8a6