2020-07-29 13:42:51 +00:00
|
|
|
const BluebirdPromise = require("bluebird")
|
2020-02-04 08:54:44 +00:00
|
|
|
const axios = require("axios")
|
|
|
|
const chalk = require('chalk')
|
|
|
|
const fs = require("fs")
|
|
|
|
const path = require('path')
|
|
|
|
const constants = require('bip44-constants')
|
2020-08-06 19:17:38 +00:00
|
|
|
import { readFileSync } from "../../script/common/filesystem";
|
|
|
|
import { ethForkChains } from "../../script/common/blockchains";
|
2020-07-14 11:40:42 +00:00
|
|
|
import {
|
2020-08-06 19:17:38 +00:00
|
|
|
toChecksum,
|
2020-02-21 22:01:03 +00:00
|
|
|
getChainAssetLogoPath,
|
|
|
|
isPathExistsSync,
|
|
|
|
makeDirSync,
|
|
|
|
getChainAssetPath,
|
|
|
|
getChainBlacklist,
|
|
|
|
getChainWhitelist,
|
2020-08-06 19:17:38 +00:00
|
|
|
} from "../../script-old/helpers";
|
|
|
|
import { TickerType, mapTiker, PlatformType } from "../../script-old/models";
|
2020-02-04 08:54:44 +00:00
|
|
|
|
|
|
|
// Steps required to run this:
|
2020-07-14 14:30:05 +00:00
|
|
|
// 1. (Optional) CMC API key already setup, use yours if needed. Install script deps "npm i" if hasn't been run before.
|
2020-02-04 08:54:44 +00:00
|
|
|
// 2. Pull down tokens repo https://github.com/trustwallet/assets and point COIN_IMAGE_BASE_PATH and TOKEN_IMAGE_BASE_PATH to it.
|
2020-07-29 13:42:51 +00:00
|
|
|
// 3. Run: `npm run update`
|
2020-02-04 08:54:44 +00:00
|
|
|
|
|
|
|
const CMC_PRO_API_KEY = `df781835-e5f4-4448-8b0a-fe31402ab3af` // Free Basic Plan api key is enough to run script
|
|
|
|
const CMC_LATEST_BASE_URL = `https://pro-api.coinmarketcap.com/v1/global-metrics/quotes/latest?`
|
|
|
|
const typeToken = TickerType.Token
|
|
|
|
const typeCoin = TickerType.Coin
|
2020-02-21 22:01:03 +00:00
|
|
|
const mappedChainsBlacklistAssets = {} // {ethereum: {<0x...>: ""},}
|
|
|
|
const mappedChainsWhitelistAssets = {} // {ethereum: {<0x...>: ""},}
|
2020-02-04 08:54:44 +00:00
|
|
|
|
|
|
|
const custom: mapTiker[] = [
|
2020-02-28 19:40:37 +00:00
|
|
|
{"coin": 60, "type": typeToken, "token_id": "0x6758B7d441a9739b98552B373703d8d3d14f9e62", "id": 2548}, // POA ERC20 on Foundation (POA20)
|
|
|
|
{"coin": 195, "type": typeToken, "token_id": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", "id": 825}, // Tether (TRC20)
|
|
|
|
{"coin": 1023, "type": typeCoin, "id": 3945}, // Harmony ONE mainnet
|
2020-02-04 08:54:44 +00:00
|
|
|
{"coin": 60, "type": typeToken, "token_id": "0x799a4202c12ca952cB311598a024C80eD371a41e", "id": 3945}, // Harmony ONE (ERC20)
|
|
|
|
{"coin": 60, "type": typeToken, "token_id": "0xB8c77482e45F1F44dE1745F52C74426C631bDD52", "id": 1839}, // BNB (ERC20)
|
|
|
|
{"coin": 304, "type": typeCoin, "id": 2777}, // IoTex coin
|
|
|
|
{"coin": 1024, "type": typeToken, "token_id": "ong", "id": 3217}, // Ontology Gas (ONG)
|
|
|
|
{"coin": 500, "type": typeToken, "token_id": "tfuel", "id": 3822}, // Theta Fuel (TFUEL)
|
|
|
|
{"coin": 818, "type": typeToken, "token_id": "0x0000000000000000000000000000456E65726779", "id": 3012}, // VeThor Token (VTHO)
|
|
|
|
{"coin": 459, "type": typeCoin, "id": 4846}, // KAVA coin
|
|
|
|
{"coin": 60, "type": typeToken, "token_id": "0xFA1a856Cfa3409CFa145Fa4e20Eb270dF3EB21ab", "id": 2405}, // IOST (ERC20)
|
2020-02-28 19:40:37 +00:00
|
|
|
{"coin": 60, "type": typeToken, "token_id": "0x2fe39f22EAC6d3c1C86DD9D143640EbB94609FCE", "id": 4929}, // JDC Coin (ERC20)
|
2020-02-07 21:59:15 +00:00
|
|
|
{"coin": 60, "type": typeToken, "token_id": "0x5Cf04716BA20127F1E2297AdDCf4B5035000c9eb", "id": 2780}, // NKN (NKN)
|
2020-07-22 08:36:05 +00:00
|
|
|
// {"coin": 714, "type": typeToken, "token_id": "CHZ-ECD", "id": 4066}, // Chiliz (BEP-2)
|
2020-02-19 03:10:58 +00:00
|
|
|
{"coin": 60, "type": typeToken, "token_id": "0xdF1D6405df92d981a2fB3ce68F6A03baC6C0E41F", "id": 3816}, // VERA (VRA)
|
2020-02-21 22:01:03 +00:00
|
|
|
{"coin": 60, "type": typeToken, "token_id": "0x467Bccd9d29f223BcE8043b84E8C8B282827790F", "id": 2394}, // Telcoin (TEL)
|
2020-07-22 08:36:05 +00:00
|
|
|
// {"coin": 714, "type": typeToken, "token_id": "BUSD-BD1", "id": 4687}, // BUSD-BD1 (BEP2)
|
2020-02-28 19:46:58 +00:00
|
|
|
{"coin": 60, "type": typeToken, "token_id": "0xBD87447F48ad729C5c4b8bcb503e1395F62e8B98", "id": 3408}, // Pool Usdc (plUsdc)
|
|
|
|
{"coin": 60, "type": typeToken, "token_id": "0x49d716DFe60b37379010A75329ae09428f17118d", "id": 4943}, // Pool Dai (plDai)
|
2020-05-11 20:49:16 +00:00
|
|
|
{"coin": 60, "type": typeToken, "token_id": "0x589891a198195061Cb8ad1a75357A3b7DbaDD7Bc", "id": 4036}, // Contentos (COS)
|
2020-07-27 07:37:14 +00:00
|
|
|
{"coin": 60, "type": typeToken, "token_id": "0x30f271C9E86D2B7d00a6376Cd96A1cFBD5F0b9b3", "id": 5835}, // Decentr (DEC)
|
2020-07-29 09:33:32 +00:00
|
|
|
// CMC returns multiple entries with 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5 (2020-07-28), including them in the override to avoid duplicate
|
|
|
|
// 5636 5742 5743 5744 5745 5746
|
|
|
|
{"coin": 60, "type": typeToken, "token_id": "0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5", "id": 5636},
|
2020-08-03 09:29:26 +00:00
|
|
|
{"coin": 60, "type": typeToken, "token_id": "0x41AB1b6fcbB2fA9DCEd81aCbdeC13Ea6315F2Bf2", "id": 2634},
|
2020-08-16 07:49:39 +00:00
|
|
|
{"coin": 60, "type": typeToken, "token_id": "0xC011A72400E58ecD99Ee497CF89E3775d4bd732F", "id": 2586},
|
2020-02-19 03:10:58 +00:00
|
|
|
// {"coin": 60, "type": typeToken, "token_id": "XXX", "id": XXX}, // XXX (XXX)
|
2020-02-04 08:54:44 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
const allContracts: mapTiker[] = [] // Temp storage for mapped assets
|
|
|
|
let bnbOwnerToSymbol = {} // e.g: bnb1tawge8u97slduhhtumm03l4xl4c46dwv5m9yzk: WISH-2D5
|
|
|
|
let bnbOriginalSymbolToSymbol = {} // e.g: WISH: WISH-2D5
|
|
|
|
|
2020-08-06 19:17:38 +00:00
|
|
|
export async function run() {
|
2020-02-04 08:54:44 +00:00
|
|
|
try {
|
2020-05-20 21:52:27 +00:00
|
|
|
await Promise.all([initState(), setBinanceTokens()])
|
|
|
|
const [totalCrypto, coins] = await Promise.all([getTotalActiveCryptocurrencies(), getTickers()])
|
2020-02-04 08:54:44 +00:00
|
|
|
// setBIP44Constants()
|
|
|
|
log(`Found ${totalCrypto} on CMC`, chalk.yellowBright)
|
2020-07-29 13:42:51 +00:00
|
|
|
await BluebirdPromise.mapSeries(coins, processCoin)
|
2020-07-14 11:40:42 +00:00
|
|
|
|
2020-02-04 08:54:44 +00:00
|
|
|
addCustom()
|
|
|
|
printContracts()
|
|
|
|
} catch (error) {
|
|
|
|
log(`Error at the end ${error.message}`)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-29 09:33:32 +00:00
|
|
|
function buildCoinEntry(coin: any): any {
|
2020-02-04 08:54:44 +00:00
|
|
|
const { id, symbol, name, platform } = coin
|
|
|
|
const platformType: PlatformType = platform == null ? "" : platform.name
|
|
|
|
log(`${symbol}:${platformType}`)
|
2020-07-14 11:40:42 +00:00
|
|
|
switch (platformType) {
|
|
|
|
case PlatformType.Ethereum:
|
|
|
|
// log(`Ticker ${name}(${symbol}) is a token with address ${address} and CMC id ${id}`)
|
|
|
|
if (platform.token_address) {
|
|
|
|
try {
|
|
|
|
const checksum = toChecksum(platform.token_address)
|
|
|
|
if (!isAddressInBlackList("ethereum", checksum)) {
|
2020-07-29 09:33:32 +00:00
|
|
|
return {
|
2020-07-14 11:40:42 +00:00
|
|
|
coin: 60,
|
|
|
|
type: typeToken,
|
|
|
|
token_id: checksum,
|
|
|
|
id
|
2020-07-29 09:33:32 +00:00
|
|
|
}
|
2020-02-04 08:54:44 +00:00
|
|
|
}
|
2020-07-14 11:40:42 +00:00
|
|
|
} catch (error) {
|
|
|
|
console.log(`Etheruem platform error`, error)
|
2020-02-04 08:54:44 +00:00
|
|
|
break
|
|
|
|
}
|
2020-07-14 11:40:42 +00:00
|
|
|
}
|
|
|
|
break
|
2020-07-29 09:33:32 +00:00
|
|
|
|
2020-07-14 11:40:42 +00:00
|
|
|
case PlatformType.Binance:
|
|
|
|
if (symbol === "BNB") {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
const ownerAddress = platform.token_address.trim()
|
|
|
|
log(`Symbol ${symbol}:${ownerAddress}:${id}`)
|
|
|
|
if (ownerAddress && (ownerAddress in bnbOwnerToSymbol)) {
|
2020-07-29 09:33:32 +00:00
|
|
|
return {
|
2020-07-14 11:40:42 +00:00
|
|
|
coin: 714,
|
|
|
|
type: typeToken,
|
|
|
|
token_id: bnbOwnerToSymbol[ownerAddress],
|
|
|
|
id
|
2020-07-29 09:33:32 +00:00
|
|
|
}
|
2020-07-14 11:40:42 +00:00
|
|
|
}
|
2020-02-04 08:54:44 +00:00
|
|
|
|
2020-07-14 11:40:42 +00:00
|
|
|
if (symbol in bnbOriginalSymbolToSymbol) {
|
2020-07-29 09:33:32 +00:00
|
|
|
return {
|
2020-07-14 11:40:42 +00:00
|
|
|
coin: 714,
|
|
|
|
type: typeToken,
|
|
|
|
token_id: bnbOriginalSymbolToSymbol[symbol].trim(),
|
|
|
|
id
|
2020-07-29 09:33:32 +00:00
|
|
|
}
|
2020-07-14 11:40:42 +00:00
|
|
|
}
|
|
|
|
break
|
2020-07-29 09:33:32 +00:00
|
|
|
|
2020-07-14 11:40:42 +00:00
|
|
|
case PlatformType.TRON:
|
|
|
|
if (symbol === "TRX") {
|
2020-02-04 08:54:44 +00:00
|
|
|
break
|
2020-07-14 11:40:42 +00:00
|
|
|
}
|
|
|
|
const tokenAddr = platform.token_address.trim()
|
|
|
|
log(`tron: ${tokenAddr}`)
|
2020-07-14 18:28:08 +00:00
|
|
|
if (tokenAddr.length > 0) {
|
2020-07-29 09:33:32 +00:00
|
|
|
return {
|
2020-07-14 18:28:08 +00:00
|
|
|
coin: 195,
|
|
|
|
type: typeToken,
|
|
|
|
token_id: tokenAddr,
|
|
|
|
id
|
2020-07-29 09:33:32 +00:00
|
|
|
}
|
2020-07-14 18:28:08 +00:00
|
|
|
}
|
2020-07-14 11:40:42 +00:00
|
|
|
break
|
2020-07-29 09:33:32 +00:00
|
|
|
|
2020-07-14 11:40:42 +00:00
|
|
|
// case PlatformType.VeChain:
|
|
|
|
// if (symbol === "VET") {
|
|
|
|
// break
|
|
|
|
// }
|
|
|
|
|
|
|
|
// const addr = platform.token_address.trim()
|
|
|
|
// log(`vechain: ${tokenAddr}`)
|
|
|
|
// addToContractsList({
|
|
|
|
// coin: 0,
|
|
|
|
// type: typeCoin,
|
|
|
|
// token_id: addr,
|
|
|
|
// id
|
|
|
|
// })
|
|
|
|
// break
|
2020-07-29 09:33:32 +00:00
|
|
|
|
2020-07-14 11:40:42 +00:00
|
|
|
default:
|
|
|
|
const coinIndex = getSlip44Index(symbol, name)
|
|
|
|
|
|
|
|
if (coinIndex >= 0) {
|
|
|
|
log(`Ticker ${name}(${symbol}) is a coin with id ${coinIndex}`)
|
2020-07-29 09:33:32 +00:00
|
|
|
return {
|
2020-07-14 11:40:42 +00:00
|
|
|
coin: coinIndex,
|
|
|
|
type: typeCoin,
|
|
|
|
id
|
2020-07-29 09:33:32 +00:00
|
|
|
}
|
2020-07-14 11:40:42 +00:00
|
|
|
}
|
2020-07-29 09:33:32 +00:00
|
|
|
log(`Coin ${coinIndex} ${name}(${symbol}) not listed in slip44`)
|
2020-07-14 11:40:42 +00:00
|
|
|
break
|
|
|
|
}
|
2020-07-29 09:33:32 +00:00
|
|
|
log(`Could not process entry ${symbol}:${name}:${platformType}`)
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
|
|
|
async function processCoin(coin) {
|
|
|
|
const entry = buildCoinEntry(coin)
|
|
|
|
if (!entry) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
// check if it is in custom, in that case omit it
|
|
|
|
if (entry.token_id && custom.find(elem => elem.coin == entry.coin && elem.token_id === entry.token_id)) {
|
|
|
|
log(`Entry ${entry.token_id} is in custom, omitting`)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
addToContractsList(entry)
|
|
|
|
log(`Added entry ${entry.token_id}`)
|
2020-02-04 08:54:44 +00:00
|
|
|
}
|
|
|
|
|
2020-02-21 22:01:03 +00:00
|
|
|
// Iniitalize state necessary for faster data looup during script run
|
|
|
|
async function initState () {
|
|
|
|
await mapChainsAssetsLists()
|
|
|
|
}
|
|
|
|
|
|
|
|
async function mapChainsAssetsLists() {
|
2020-08-06 19:17:38 +00:00
|
|
|
ethForkChains.forEach(chain => {
|
2020-02-21 22:01:03 +00:00
|
|
|
Object.assign(mappedChainsWhitelistAssets, {[chain]: {}})
|
|
|
|
Object.assign(mappedChainsBlacklistAssets, {[chain]: {}})
|
2020-07-14 11:40:42 +00:00
|
|
|
|
2020-05-20 21:52:27 +00:00
|
|
|
getChainWhitelist(chain).forEach(addr => {
|
2020-02-21 22:01:03 +00:00
|
|
|
Object.assign(mappedChainsWhitelistAssets[chain], {[addr]: ""})
|
|
|
|
})
|
2020-05-20 21:52:27 +00:00
|
|
|
getChainBlacklist(chain).forEach(addr => {
|
2020-02-21 22:01:03 +00:00
|
|
|
Object.assign(mappedChainsBlacklistAssets[chain], {[addr]: ""})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-02-04 08:54:44 +00:00
|
|
|
function addCustom() {
|
|
|
|
custom.forEach(c => {
|
|
|
|
addToContractsList(c)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function addToContractsList(ticker: mapTiker) {
|
|
|
|
allContracts.push(ticker)
|
|
|
|
}
|
|
|
|
|
|
|
|
function printContracts() {
|
|
|
|
const sortedById = allContracts.sort((a,b) => {
|
|
|
|
if (a.id < b.id) return -1
|
|
|
|
if (a.id > b.id) return 1
|
|
|
|
|
|
|
|
if (a.hasOwnProperty("coin") && b.hasOwnProperty("coin")) {
|
|
|
|
if (a.coin < b.coin) return -1
|
|
|
|
if (a.coin > b.coin) return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
if (a.token_id < b.token_id) return -1
|
|
|
|
if (a.token_id > b.token_id) return 1
|
|
|
|
})
|
2020-05-20 21:52:27 +00:00
|
|
|
|
|
|
|
const wstream = fs.createWriteStream(path.join(__dirname, 'mapping.json'))
|
2020-02-04 08:54:44 +00:00
|
|
|
wstream.write(JSON.stringify(sortedById, null, 4))
|
|
|
|
}
|
|
|
|
|
|
|
|
function getSlip44Index(symbol: string, name: string): number {
|
|
|
|
const coins = constants.filter(item => item[1] === symbol)
|
|
|
|
if (coins.length == 0) return
|
|
|
|
if (coins.length == 1) {
|
|
|
|
const hex = '0x' + (coins[0][0]).toString(16)
|
|
|
|
return parseInt(hex, 16) - ((1<<31)>>>0)
|
|
|
|
}
|
|
|
|
|
|
|
|
const coin = coins.filter(c => c[2] === name || c[2].includes(name))
|
|
|
|
if (coin.length == 0) return
|
|
|
|
const hex = '0x' + (coin[0][0]).toString(16)
|
|
|
|
return parseInt(hex, 16) - ((1<<31)>>>0)
|
|
|
|
}
|
|
|
|
|
|
|
|
// id referes to cmc internal id
|
2020-02-28 19:40:37 +00:00
|
|
|
const getImageURL = (id: string | number): string => `https://s2.coinmarketcap.com/static/img/coins/128x128/${id}.png`
|
2020-02-04 08:54:44 +00:00
|
|
|
|
|
|
|
async function getImageIfMissing(chain: string, address: string, id: string) {
|
|
|
|
try {
|
|
|
|
const logoPath = getChainAssetLogoPath(chain, String(address))
|
2020-02-21 22:01:03 +00:00
|
|
|
if (!isPathExistsSync(logoPath) && !isAddressInBlackList(chain, address)) {
|
2020-02-04 08:54:44 +00:00
|
|
|
const imageStream = await fetchImage(getImageURL(id))
|
2020-07-14 11:40:42 +00:00
|
|
|
|
2020-02-04 08:54:44 +00:00
|
|
|
if (imageStream) {
|
2020-02-21 22:01:03 +00:00
|
|
|
const logoFolderPath = getChainAssetPath(chain, address)
|
2020-02-04 08:54:44 +00:00
|
|
|
if(!isPathExistsSync(logoFolderPath)) {
|
|
|
|
makeDirSync(logoFolderPath)
|
2020-07-14 11:40:42 +00:00
|
|
|
}
|
2020-02-04 08:54:44 +00:00
|
|
|
imageStream.pipe(fs.createWriteStream(logoPath))
|
|
|
|
log(`Image saved to: ${logoPath}`, chalk.green)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
log(`Failed getImage to save token image ${error.message}`)
|
|
|
|
exit(2)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-21 22:01:03 +00:00
|
|
|
|
|
|
|
function isAddressInBlackList(chain: string, address: string): boolean {
|
|
|
|
return mappedChainsBlacklistAssets[chain].hasOwnProperty(address)
|
|
|
|
}
|
|
|
|
|
2020-02-04 08:54:44 +00:00
|
|
|
async function fetchImage(url: string) {
|
|
|
|
try {
|
|
|
|
return axios.get(url, {
|
|
|
|
headers: {
|
|
|
|
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36'
|
|
|
|
},
|
|
|
|
responseType: "stream"
|
|
|
|
}).then(res => res.data).catch(error => {
|
|
|
|
console.log(`Error getRemoteResource ${error.message}`)
|
|
|
|
})
|
|
|
|
} catch (error) {
|
|
|
|
log(`${error.message}`)
|
|
|
|
exit(3)
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function exit(code?: number) {
|
2020-02-28 19:39:08 +00:00
|
|
|
process.exit(code ?? 1)
|
2020-02-04 08:54:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function getTotalActiveCryptocurrencies() {
|
2020-05-20 21:52:27 +00:00
|
|
|
return axios.get(`${CMC_LATEST_BASE_URL}CMC_PRO_API_KEY=${CMC_PRO_API_KEY}`).then((res) => res.data.data.active_cryptocurrencies).catch(e => {
|
2020-07-14 11:40:42 +00:00
|
|
|
throw `Error getTotalActiveCryptocurrencies ${e.message}`
|
2020-05-20 21:52:27 +00:00
|
|
|
})
|
2020-02-04 08:54:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function setBinanceTokens () {
|
|
|
|
return axios.get(`https://dex.binance.org/api/v1/tokens?limit=1000`).then(({ data }) => {
|
|
|
|
bnbOwnerToSymbol = data.reduce((acm, token) => {
|
|
|
|
log(`Token owner ${token.owner}:${token.symbol}`)
|
|
|
|
acm[token.owner] = token.symbol
|
|
|
|
return acm
|
|
|
|
}, {})
|
|
|
|
bnbOriginalSymbolToSymbol = data.reduce((acm, token) => {
|
|
|
|
acm[token.original_symbol] = token.symbol
|
|
|
|
return acm
|
|
|
|
}, {})
|
2020-07-14 11:40:42 +00:00
|
|
|
}).catch(error => {throw Error(`Error fetching Binance markets : ${error.message}`)})
|
2020-02-04 08:54:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function readBEP2() {
|
|
|
|
// Fetch https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest?CMC_PRO_API_KEY=YOUR_KEYc&limit=5000 and store full response
|
2020-02-21 22:01:03 +00:00
|
|
|
// in file
|
2020-02-04 08:54:44 +00:00
|
|
|
const validatorsList = JSON.parse(readFileSync("./pricing/coinmarketcap/cryptocurrency_map.json"))
|
|
|
|
return validatorsList.data
|
|
|
|
}
|
|
|
|
|
|
|
|
async function getTickers() {
|
2020-07-14 11:40:42 +00:00
|
|
|
const url = `https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest?&limit=3500&CMC_PRO_API_KEY=${CMC_PRO_API_KEY}`
|
|
|
|
return axios.get(url).then(res => res.data.data).catch(e => {throw `Error getTickers ${e.message}`})
|
2020-02-04 08:54:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function log(string, cb?) {
|
|
|
|
if (cb) {
|
|
|
|
console.log(cb(string))
|
|
|
|
} else {
|
|
|
|
console.log(string)
|
|
|
|
}
|
2020-05-20 21:52:27 +00:00
|
|
|
const saveToLogs = fs.createWriteStream(path.join(__dirname, '.syncTokensLog.txt'))
|
2020-02-04 08:54:44 +00:00
|
|
|
saveToLogs.write(`${string}\n`)
|
|
|
|
}
|
|
|
|
|
|
|
|
// function setBIP44Constants() {
|
|
|
|
// require('bip44-constants').forEach(row => {
|
|
|
|
// bip44Constants[row[1]] = {
|
|
|
|
// constant: row[0],
|
|
|
|
// coinName: row[2]
|
|
|
|
// }
|
|
|
|
// })
|
2020-07-29 13:42:51 +00:00
|
|
|
// }
|