UNPKG

@tribecahq/registry

Version:

Registry of Tribeca DAOs.

26 lines 1.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getTokenInfo = exports.loadTokenList = void 0; const tslib_1 = require("tslib"); const token_utils_1 = require("@saberhq/token-utils"); const fs = tslib_1.__importStar(require("fs/promises")); let cachedTokenList = null; const loadTokenList = async () => { if (cachedTokenList) { return cachedTokenList; } const tokenListRaw = await fs.readFile(`${__dirname}/../../solana-token-list.json`); cachedTokenList = JSON.parse(tokenListRaw.toString()); return cachedTokenList; }; exports.loadTokenList = loadTokenList; const getTokenInfo = async (address, network) => { const { tokens } = await (0, exports.loadTokenList)(); if (!network) { return tokens.find((tok) => tok.address === address); } const chainId = (0, token_utils_1.networkToChainId)(network); return tokens.find((tok) => tok.chainId === chainId && tok.address === address); }; exports.getTokenInfo = getTokenInfo; //# sourceMappingURL=getTokenInfo.js.map