diff --git a/package.json b/package.json
index 2a84d3419..ff0feaaec 100644
--- a/package.json
+++ b/package.json
@@ -84,6 +84,7 @@
"@shopify/restyle": "1.8.0",
"@solana/spl-account-compression": "0.1.4",
"@solana/spl-token": "0.3.6",
+ "@solana/spl-token-registry": "^0.2.4574",
"@solana/wallet-adapter-react": "^0.15.33",
"@solana/wallet-standard-features": "1.0.0",
"@solana/web3.js": "1.64.0",
diff --git a/src/App.tsx b/src/App.tsx
index 48a9fc476..d49213172 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -4,6 +4,7 @@ import { AccountContext } from '@helium/account-fetch-cache-hooks'
import { DarkTheme, NavigationContainer } from '@react-navigation/native'
import MapboxGL from '@rnmapbox/maps'
import { ThemeProvider } from '@shopify/restyle'
+import { TokenListProvider } from '@storage/TokenListProvider'
import TokensProvider from '@storage/TokensProvider'
import globalStyles from '@theme/globalStyles'
import { darkThemeColors, lightThemeColors, theme } from '@theme/theme'
@@ -125,12 +126,14 @@ const App = () => {
ref={navigationRef}
>
-
-
-
-
-
-
+
+
+
+
+
+
+
+
{
+ if (!tokenInfo) return undefined
+
+ return {
+ json: {
+ name: tokenInfo.name,
+ symbol: tokenInfo.symbol,
+ image: tokenInfo.logoURI,
+ },
+ symbol: tokenInfo.symbol,
+ name: tokenInfo.name,
+ }
+}
+
export function useMetaplexMetadata(mint: PublicKey | undefined): {
loading: boolean
metadata: Metadata | undefined
@@ -60,6 +79,14 @@ export function useMetaplexMetadata(mint: PublicKey | undefined): {
symbol: string | undefined
name: string | undefined
} {
+ const tokenList = useTokenList()
+ const tokenListToken = useMemo(() => {
+ if (mint) {
+ return tokenList?.get(mint.toBase58())
+ }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [tokenList, mint?.toBase58()])
+
const metadataAddr = useMemo(() => {
if (mint) {
return getMetadataId(mint)
@@ -72,6 +99,7 @@ export function useMetaplexMetadata(mint: PublicKey | undefined): {
METADATA_PARSER,
true,
)
+
const { result: json, loading: jsonLoading } = useAsync(getMetadata, [
metadataAcc?.uri,
])
@@ -93,9 +121,11 @@ export function useMetaplexMetadata(mint: PublicKey | undefined): {
return {
loading: jsonLoading || loading,
- json: json?.data,
+ json: tokenListToken
+ ? tokenInfoToMetadata(tokenListToken)?.json
+ : json?.data,
metadata: metadataAcc,
- symbol: json?.data.symbol || metadataAcc?.symbol,
- name: json?.data.name || metadataAcc?.name,
+ symbol: tokenListToken?.symbol || json?.data.symbol || metadataAcc?.symbol,
+ name: tokenListToken?.name || json?.data.name || metadataAcc?.name,
}
}
diff --git a/src/hooks/useTokenList.ts b/src/hooks/useTokenList.ts
new file mode 100644
index 000000000..7e62ffcbf
--- /dev/null
+++ b/src/hooks/useTokenList.ts
@@ -0,0 +1,6 @@
+import { useContext } from 'react'
+import { TokenListContext } from '../storage/TokenListProvider'
+
+export const useTokenList = () => {
+ return useContext(TokenListContext)
+}
diff --git a/src/storage/TokenListProvider.tsx b/src/storage/TokenListProvider.tsx
new file mode 100644
index 000000000..17c7c944d
--- /dev/null
+++ b/src/storage/TokenListProvider.tsx
@@ -0,0 +1,33 @@
+import {
+ TokenListProvider as Provider,
+ TokenInfo,
+ ENV,
+} from '@solana/spl-token-registry'
+import React, { ReactNode, useEffect, useState } from 'react'
+
+export const TokenListContext = React.createContext<
+ Map | undefined
+>(undefined)
+
+export const TokenListProvider = ({ children }: { children: ReactNode }) => {
+ const [tokenMap, setTokenMap] = useState