Created
February 4, 2020 16:02
-
-
Save cloudonshore/261e1036d102de9f4e1302b42caee2ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const _ = require('lodash') | |
const whitelist = require('assets/blockchains/ethereum/whitelist.json').map(address => address.toLowerCase()) | |
const { getERC20Name, getERC20Decimals, getERC20Symbol } = require('airswap.js/src/erc20/contractFunctions') | |
const fs = require('fs') | |
// package.json | |
// | |
// { | |
// "name": "token-crawl", | |
// "version": "1.0.0", | |
// "main": "index.js", | |
// "license": "MIT", | |
// "dependencies": { | |
// "airswap.js": "^0.1.130", | |
// "assets": "https://github.com/trustwallet/assets.git", | |
// "lodash": "^4.17.15" | |
// } | |
// } | |
function sleep (time) { | |
return new Promise((resolve) => setTimeout(resolve, time)); | |
} | |
const tokens =[] | |
whitelist.map(async (address, i) => { | |
try { | |
await sleep(100 * i) | |
const name = await getERC20Name(address) | |
const symbol = await getERC20Symbol(address) | |
const decimals = (await getERC20Decimals(address)).toString() | |
tokens.push({ | |
name, | |
symbol, | |
decimals, | |
address, | |
}) | |
} catch (e) { | |
const { code } = e | |
console.log(address, code) | |
return | |
} | |
if(i + 1 === whitelist.length) { | |
finish() | |
} | |
}) | |
function finish() { | |
console.log(tokens) | |
fs.writeFileSync('./tokens.json', JSON.stringify(tokens, null, 2)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment