@@ -49,12 +49,10 @@ function getChainId(cluster: Cluster): ChainId | undefined {
4949function makeUtlClient ( cluster : Cluster , connectionString : string ) : Client | undefined {
5050 const chainId = getChainId ( cluster ) ;
5151 if ( ! chainId ) return undefined ;
52-
5352 const config : UtlConfig = new UtlConfig ( {
5453 chainId,
5554 connection : new Connection ( connectionString ) ,
5655 } ) ;
57-
5856 return new Client ( config ) ;
5957}
6058
@@ -67,9 +65,17 @@ export async function getTokenInfo(
6765 cluster : Cluster ,
6866 connectionString : string
6967) : Promise < Token | undefined > {
68+
7069 const client = makeUtlClient ( cluster , connectionString ) ;
7170 if ( ! client ) return undefined ;
72- const token = await client . fetchMint ( address ) ;
71+
72+ let token ;
73+ try {
74+ token = await client . fetchMint ( address ) ;
75+ } catch ( error ) {
76+ console . error ( error ) ;
77+ }
78+
7379 return token ;
7480}
7581
@@ -110,12 +116,14 @@ async function getFullLegacyTokenInfoUsingCdn(
110116 const tokenListResponse = await fetch (
111117 'https://cdn.jsdelivr.net/gh/solana-labs/token-list@latest/src/tokens/solana.tokenlist.json'
112118 ) ;
119+
113120 if ( tokenListResponse . status >= 400 ) {
114121 console . error ( new Error ( 'Error fetching token list from CDN' ) ) ;
115122 return undefined ;
116123 }
117124 const { tokens } = ( await tokenListResponse . json ( ) ) as FullLegacyTokenInfoList ;
118125 const tokenInfo = tokens . find ( t => t . address === address . toString ( ) && t . chainId === chainId ) ;
126+
119127 return tokenInfo ;
120128}
121129
@@ -131,6 +139,7 @@ export async function getFullTokenInfo(
131139 connectionString : string
132140) : Promise < FullTokenInfo | undefined > {
133141 const chainId = getChainId ( cluster ) ;
142+
134143 if ( ! chainId ) return undefined ;
135144
136145 const [ legacyCdnTokenInfo , sdkTokenInfo ] = await Promise . all ( [
@@ -146,7 +155,6 @@ export async function getFullTokenInfo(
146155 }
147156 : undefined ;
148157 }
149-
150158 // Merge the fields, prioritising the sdk ones which are more up to date
151159 let tags : string [ ] = [ ] ;
152160 if ( sdkTokenInfo . tags ) tags = Array . from ( sdkTokenInfo . tags ) ;
0 commit comments