UNPKG

@tribecahq/registry

Version:

Registry of Tribeca DAOs.

20 lines 774 B
import { networkToChainId } from "@saberhq/token-utils"; import * as fs from "fs/promises"; let cachedTokenList = null; export const loadTokenList = async () => { if (cachedTokenList) { return cachedTokenList; } const tokenListRaw = await fs.readFile(`${__dirname}/../../solana-token-list.json`); cachedTokenList = JSON.parse(tokenListRaw.toString()); return cachedTokenList; }; export const getTokenInfo = async (address, network) => { const { tokens } = await loadTokenList(); if (!network) { return tokens.find((tok) => tok.address === address); } const chainId = networkToChainId(network); return tokens.find((tok) => tok.chainId === chainId && tok.address === address); }; //# sourceMappingURL=getTokenInfo.js.map