From 3e5b2a70e5592519ee6c6004d20ff9bba91c9b4d Mon Sep 17 00:00:00 2001 From: Callum McIntyre Date: Tue, 26 Sep 2023 18:31:51 +0100 Subject: [PATCH] Use UTL API directly for address token info (#298) The problem here was not with our request coalescer, the `getMultipleAccounts` requests are coming from the UTL SDK. Specifically on the transaction page where we use `
{ + const chainId = getChainId(cluster); + if (!chainId) return undefined; + + // Request token info directly from UTL API + // We don't use the SDK here because we don't want it to fallback to an on-chain request + const response = await fetch(`https://token-list-api.solana.cloud/v1/mints?chainId=${chainId}`, { + body: JSON.stringify({ addresses: [address.toBase58()] }), + headers: { + "Content-Type": "application/json", + }, + method: 'POST', + }) + + if (response.status >= 400) { + console.error(`Error calling UTL API for address ${address} on chain ID ${chainId}. Status ${response.status}`); + return undefined + } + + const fetchedData = await response.json() as UtlApiResponse; + return fetchedData.content[0]; +} + async function getFullLegacyTokenInfoUsingCdn( address: PublicKey, chainId: ChainId @@ -111,9 +141,9 @@ export async function getFullTokenInfo( if (!sdkTokenInfo) { return legacyCdnTokenInfo ? { - ...legacyCdnTokenInfo, - verified: true, - } + ...legacyCdnTokenInfo, + verified: true, + } : undefined; }