Created
November 18, 2022 18:01
-
-
Save tgmarinho/30111ae476b6a06633b3f54fd0733133 to your computer and use it in GitHub Desktop.
generateTokenImageURI
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 fs = require("fs"); | |
const axios = require("axios"); | |
const URLS = [ | |
"https://tokens.uniswap.org", | |
"https://extendedtokens.uniswap.org", | |
"https://unsupportedtokens.uniswap.org", | |
"https://raw.githubusercontent.com/The-Blockchain-Association/sec-notice-list/master/ba-sec-list.json", | |
"https://api.coinmarketcap.com/data-api/v3/uniswap/all.json", | |
"https://tokens.coingecko.com/uniswap/all.json", | |
"https://raw.githubusercontent.com/compound-finance/token-list/master/compound.tokenlist.json", | |
"https://www.gemini.com/uniswap/manifest.json", | |
"https://app.tryroll.com/tokens.json", | |
"https://raw.githubusercontent.com/SetProtocol/uniswap-tokenlist/main/set.tokenlist.json", | |
"https://static.optimism.io/optimism.tokenlist.json", | |
"https://bridge.arbitrum.io/token-list-42161.json", | |
"https://celo-org.github.io/celo-token-list/celo.tokenlist.json", | |
]; | |
Promise.all(URLS.map((url) => axios.get(url))) | |
.then((lists) => { | |
return lists.map((list) => list.data.tokens).flat(); | |
}) | |
.then((tokens) => { | |
return tokens | |
.filter((t) => t !== undefined && t.logoURI) | |
.reduce((result, curr) => { | |
let logoURI = curr.logoURI; | |
if (logoURI.indexOf("ipfs://") !== -1) { | |
logoURI = logoURI.replace(`ipfs://`, `https://ipfs.io/ipfs/`); | |
} | |
result[curr.address.toLowerCase()] = logoURI; | |
return result; | |
}, {}); | |
}) | |
.then((data) => { | |
const filepath = "./src/utils/uniswapv3/tokenImageURI.json"; | |
fs.writeFileSync(filepath, JSON.stringify(data, 2, 2)); | |
console.log(`[DONE] Generated token image URI mapping file to ${filepath}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment