Skip to content

Commit

Permalink
fix: hotfix/issue-11539 (#11631)
Browse files Browse the repository at this point in the history
## **Description**

Fixes token details view when tokenExchangeRates have not yet resolved,
or are simply undefined.

## **Related issues**

Fixes: #11539

## **Manual testing steps**

1. Go to `TokenDetails`
2. Hardcode `tokenExchangeRates` to `undefined`
3. App should not crash. Token details will be empty. Error was when
pressing native gas token, but also check others.

## **Screenshots/Recordings**

Bug:

<img width="300" alt="Screenshot 2024-10-04 at 10 39 05 AM"
src="https://github.com/user-attachments/assets/70f2eee5-08f1-4cec-b07c-fd6f544c8532">

Fix:

<img width="300" alt="Screenshot 2024-10-04 at 10 40 31 AM"
src="https://github.com/user-attachments/assets/05420c64-014f-43ae-90ba-d772cb421d9a">

## **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**

- [ ] 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.
  • Loading branch information
gambinish authored and metamaskbot committed Oct 7, 2024
1 parent 1162cec commit 9d3d9ea
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/components/UI/AssetOverview/TokenDetails/TokenDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ const TokenDetails: React.FC<TokenDetailsProps> = ({ asset }) => {
let marketData;

if (asset.isETH) {
marketData = tokenExchangeRates[zeroAddress() as `0x${string}`];
marketData = tokenExchangeRates?.[zeroAddress() as `0x${string}`];
} else if (!asset.isETH && tokenContractAddress) {
tokenMetadata = tokenList[tokenContractAddress.toLowerCase()];
marketData = tokenExchangeRates[tokenContractAddress];
tokenMetadata = tokenList?.[tokenContractAddress.toLowerCase()];
marketData = tokenExchangeRates?.[tokenContractAddress];
} else {
Logger.log('cannot find contract address');
return null;
Expand Down

0 comments on commit 9d3d9ea

Please sign in to comment.