Skip to content

Instantly share code, notes, and snippets.

@tgmarinho
Created November 18, 2022 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tgmarinho/30111ae476b6a06633b3f54fd0733133 to your computer and use it in GitHub Desktop.
Save tgmarinho/30111ae476b6a06633b3f54fd0733133 to your computer and use it in GitHub Desktop.
generateTokenImageURI
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