UNPKG

@znode/erc20-tokens

Version:
34 lines (33 loc) 1.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getIndexAddresses = exports.getIndexSymbols = void 0; const officalTokens = require('../data/offical.json'); // lazy let indexSymbols = null; let indexAddresses = null; function getIndexSymbols() { if (!indexSymbols) { indexSymbols = officalTokens.reduce((all, one) => { if (all[one.symbol]) { throw new Error(`duplicated token symbol: ${one.symbol}`); } all[one.symbol] = one; return all; }, {}); } return indexSymbols; } exports.getIndexSymbols = getIndexSymbols; function getIndexAddresses() { if (!indexAddresses) { indexAddresses = officalTokens.reduce((all, one) => { if (all[one.address]) { throw new Error(`duplicated token address: ${one.address}`); } all[one.address] = one; return all; }, {}); } return indexAddresses; } exports.getIndexAddresses = getIndexAddresses;