Skip to content

Commit

Permalink
fetch missing mints using getMultipleAccountsInfo instead
Browse files Browse the repository at this point in the history
  • Loading branch information
macalinao committed Mar 25, 2024
1 parent 3d94583 commit b576704
Showing 1 changed file with 12 additions and 23 deletions.
35 changes: 12 additions & 23 deletions src/scripts/buildTokenList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,30 +190,19 @@ export const buildTokenList = async (network: Network): Promise<void> => {
.join(", ")})`,
);

const missingMintsDecimals = await Promise.all(
missingMintsNonReplica.map(async (mint) => {
if (network === "mainnet-beta") {
// TODO(igm): this is hardcoded for now since there's something wrong with getAccountInfo.
// We will investigate this when there is less time pressure.
if (
mint.toString() === "6sdr6tCfBwMzEbEhrv5oxde3KBBrJftfHQZr7xgP4C56"
) {
return 6;
}
if (
mint.toString() === "2wL27tLE24Vs4DmSNTnF1SPiNin2aVMPuReXesyPQFMR"
) {
return 6;
}
}
const missingMintsAccounts =
await provider.connection.getMultipleAccountsInfo(missingMintsNonReplica);

const mintDataRaw = await provider.connection.getAccountInfo(mint);
if (!mintDataRaw) {
throw new Error(`"Mint ${mint.toString()} not found on chain`);
}
return deserializeMint(mintDataRaw.data).decimals;
}),
);
const missingMintsDecimals = zip(
missingMintsNonReplica,
missingMintsAccounts,
).map(([mint, account]) => {
invariant(mint, "MINT");
if (!account) {
throw new Error(`"Mint ${mint.toString()} not found on chain`);
}
return deserializeMint(account.data).decimals;
});

// const missingMintsData = (
// await Promise.all(
Expand Down

0 comments on commit b576704

Please sign in to comment.