Skip to content

Conversation

@runway-github
Copy link
Contributor

@runway-github runway-github bot commented Jul 22, 2025

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

  1. Open Account List
  2. It should feel faster than before

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.

Screenshot 2025-07-03 at 21 36 06

After

Here it takes only around ~3s to mount. (still slow but much better than
before)

Screenshot 2025-07-03 at 21 38 16

Pre-merge author checklist

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 format
    if applicable
  • I’ve applied the right labels on the PR (see labeling
    guidelines
    ).
    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.

Description

Changelog

CHANGELOG entry:

Related issues

Fixes:

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

Pre-merge author checklist

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 55bc8a6

…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>
@runway-github runway-github bot requested review from a team as code owners July 22, 2025 16:14
@github-actions
Copy link
Contributor

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.

@metamaskbot metamaskbot added the team-runway-bot-deprecated DEPRECATED: please use "team-bots" instead label Jul 22, 2025
Copy link

@cursor cursor bot left a 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

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';

Fix in CursorFix in Web


Was this report helpful? Give feedback by reacting with 👍 or 👎

@sonarqubecloud
Copy link

@tommasini
Copy link
Contributor

We are not cherry picking this work to 7.51.0 only to 7.52.0

@tommasini tommasini closed this Jul 23, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Jul 23, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

team-runway-bot-deprecated DEPRECATED: please use "team-bots" instead

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants