-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fall back to token list for the token symbol
- Loading branch information
1 parent
f995e3c
commit ec108b9
Showing
3 changed files
with
38 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 10 additions & 3 deletions
13
...nts/confirm/info/hooks/use-token-image.ts → ...nts/confirm/info/hooks/useTokenDetails.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,27 @@ | ||
import { TokenListMap } from '@metamask/assets-controllers'; | ||
import { TransactionMeta } from '@metamask/transaction-controller'; | ||
import { useSelector } from 'react-redux'; | ||
import { useI18nContext } from '../../../../../../hooks/useI18nContext'; | ||
import { getTokenList } from '../../../../../../selectors'; | ||
import { SelectedToken } from '../shared/selected-token'; | ||
|
||
export const useTokenImage = ( | ||
export const useTokenDetails = ( | ||
transactionMeta: TransactionMeta, | ||
selectedToken: SelectedToken, | ||
) => { | ||
const t = useI18nContext(); | ||
|
||
const tokenList = useSelector(getTokenList) as TokenListMap; | ||
|
||
// TODO: Add support for NFT images in one of the following tasks | ||
const tokenImage = | ||
selectedToken?.iconUrl || | ||
selectedToken?.image || | ||
tokenList[transactionMeta?.txParams?.to as string]?.iconUrl; | ||
|
||
return { tokenImage }; | ||
const tokenSymbol = | ||
selectedToken?.symbol || | ||
tokenList[transactionMeta?.txParams?.to as string].symbol || | ||
t('unknown'); | ||
|
||
return { tokenImage, tokenSymbol }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters