-
-
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) #17457
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
…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. |
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: Address Formatting Refactor Introduces Errors
The refactor of address formatting introduces a potential runtime error and a functional change. toFormattedAddress is called unconditionally with selectedAddress, which can be null or undefined, potentially causing runtime errors. The previous code safely handled this with selectedAddress || ''. Additionally, the logic for determining address formatting changed from !isNonEvmAddress to toFormattedAddress (which uses isEthAddress), potentially leading to incorrect address formatting and balance lookups if the underlying logic differs. The selectedAddress as Hex type cast is also incorrect as toFormattedAddress expects a string.
app/selectors/earnController/earn/index.ts#L158-L200
metamask-mobile/app/selectors/earnController/earn/index.ts
Lines 158 to 200 in 33aa867
| selectLendingMarketsByChainIdAndOutputTokenAddress(earnState); | |
| const earnTokensData = allTokens.reduce((acc, token) => { | |
| const experiences: EarnTokenDetails['experiences'] = []; | |
| const decimalChainId = getDecimalChainId(token.chainId); | |
| const lendingMarketsForToken = | |
| lendingMarketsByChainIdAndTokenAddress?.[decimalChainId]?.[ | |
| token.address.toLowerCase() | |
| ] || []; | |
| const lendingMarketsForOutputToken = | |
| lendingMarketsByChainIdAndOutputTokenAddress?.[decimalChainId]?.[ | |
| token.address.toLowerCase() | |
| ] || []; | |
| const pooledStakingVaultForChain = | |
| pooledStakingPerChain?.[decimalChainId]?.vaultMetadata; | |
| const pooledStakingVaultAprForChain = parseFloat( | |
| pooledStakingPerChain?.[decimalChainId]?.vaultApy.apyPercentString, | |
| ).toString(); | |
| const isStakingSupportedChain = | |
| isSupportedPooledStakingChain(decimalChainId); | |
| const isLendingToken = lendingMarketsForToken.length > 0; | |
| const isLendingOutputToken = lendingMarketsForOutputToken.length > 0; | |
| const isStakingToken = | |
| token.isETH && !token.isStaked && isStakingSupportedChain; | |
| const isStakingOutputToken = | |
| token.isETH && token.isStaked && isStakingSupportedChain; | |
| const isEarnToken = isStakingToken || isLendingToken; | |
| const isEarnOutputToken = isStakingOutputToken || isLendingOutputToken; | |
| if (!isEarnToken && !isEarnOutputToken) { | |
| return acc; | |
| } | |
| // TODO: balance logic, extract to utils then use when we are clear to add token | |
| const formattedAddress = toFormattedAddress(selectedAddress as Hex); | |
| const rawAccountBalance = selectedAddress | |
| ? accountsByChainId[token?.chainId as Hex]?.[formattedAddress]?.balance | |
| : '0'; | |
| const rawStakedAccountBalance = selectedAddress | |
| ? accountsByChainId[token?.chainId as Hex]?.[formattedAddress] | |
| ?.stakedBalance | |
| : '0'; |
Was this report helpful? Give feedback by reacting with 👍 or 👎
|
|
We are not cherry picking this work to 7.51.0 only to 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