Unverified Commit fac1c0fa authored by Thibaut Sardan's avatar Thibaut Sardan Committed by GitHub
Browse files

Use atomiclabs/cryptocurrency-icons/ set of icons (#488)

* fetch token icons not in the list

* fetch token icons not in the list

* fetch token icons not in the list

* enforce the use of a single logo source

* revert

* add goerli

* change to console.log

* I said console.log
parent 7dce51a1
Pipeline #34902 passed with stages
in 9 minutes and 42 seconds
[
{
"address": "0x7af963cF6D228E564e2A0aA0DdBF06210B38615D",
"symbol": "TST",
"decimals": 18,
"name": "goerli Test token"
}
]
\ No newline at end of file
......@@ -3,32 +3,35 @@
"address": "0x1Dad4783cf3fe3085C1426157aB175A6119A04bA",
"symbol": "MKR",
"decimals": 18,
"name": "RadarRelay test MakerDAO"
"name": "RadarRelay test MakerDAO",
"logo": "https://raw.githubusercontent.com/atomiclabs/cryptocurrency-icons/master/32%402x/color/mkr%402x.png"
},
{
"address": "0x4A6e6C3868A279e1D9047B42C3fB356FF4680003",
"symbol": "TIB",
"decimals": 18,
"name": "ThibCoin",
"logo": "https://i.imgur.com/qvmnsxw.jpg"
"name": "ThibCoin"
},
{
"address": "0xC4375B7De8af5a38a93548eb8453a498222C4fF2",
"symbol": "DAI",
"decimals": 18,
"name": "RadarRelay test Dai Stablecoin v1.0"
"name": "RadarRelay test Dai Stablecoin v1.0",
"logo": "https://raw.githubusercontent.com/atomiclabs/cryptocurrency-icons/master/32%402x/color/dai%402x.png"
},
{
"address": "0xeF7FfF64389B814A946f3E92105513705CA6B990",
"symbol": "GNT",
"decimals": 18,
"name": "RadarRelay test Golem Network Token"
"name": "RadarRelay test Golem Network Token",
"logo": "https://raw.githubusercontent.com/atomiclabs/cryptocurrency-icons/master/32%402x/color/gnt%402x.png"
},
{
"address": "0xB18845c260F680d5B9D84649638813E342E4F8C9",
"symbol": "REP",
"decimals": 18,
"name": "RadarRelay test Augur Reputation Token"
"name": "RadarRelay test Augur Reputation Token",
"logo": "https://raw.githubusercontent.com/atomiclabs/cryptocurrency-icons/master/32%402x/color/rep%402x.png"
},
{
"address": "0x8667559254241ddeD4d11392f868d72092765367",
......@@ -41,37 +44,40 @@
"symbol": "RLC",
"decimals": 9,
"name": "iExec RLC",
"logo": "https://ipfs.io/ipfs/QmcjNqEC4uDyZJBM946Pyrh8murWVkMh9ufBjpt5hPYuZp"
"logo": "https://raw.githubusercontent.com/atomiclabs/cryptocurrency-icons/master/32%402x/color/rlc%402x.png"
},
{
"address": "0xeeE3870657E4716670f185dF08652dd848fe8f7e",
"symbol": "DGD",
"decimals": 18,
"name": "RadarRelay test Digix DAO Token"
"name": "RadarRelay test Digix DAO Token",
"logo": "https://raw.githubusercontent.com/atomiclabs/cryptocurrency-icons/master/32%402x/color/dgd%402x.png"
},
{
"address": "0x3C67f7D4decF7795225f51b54134F81137385f83",
"symbol": "GUP",
"decimals": 3,
"name": "GUP"
"name": "GUP",
"logo": "https://raw.githubusercontent.com/atomiclabs/cryptocurrency-icons/master/32%402x/color/gup%402x.png"
},
{
"address": "0x4733659a5cB7896A65c918Add6f59C5148FB5ffa",
"symbol": "GAV",
"decimals": 6,
"name": "GavCoin",
"logo": "https://raw.githubusercontent.com/ethcore/dapp-assets/9e135f76fe9ba61e2d8ccbd72ed144c26c450780/tokens/gavcoin-64x64.png"
"name": "GavCoin"
},
{
"address": "0x323B5d4C32345ced77393B3530b1EeD0f346429D",
"symbol": "MLN",
"decimals": 18,
"name": "RadarRelay test Melon Tokens"
"name": "RadarRelay test Melon Tokens",
"logo": "https://raw.githubusercontent.com/atomiclabs/cryptocurrency-icons/master/32%402x/color/mln%402x.png"
},
{
"address": "0x6Ff6C0Ff1d68b964901F986d4C9FA3ac68346570",
"symbol": "ZRX",
"decimals": 18,
"name": "RadarRelay test 0x Protocol Token"
"name": "RadarRelay test 0x Protocol Token",
"logo": "https://raw.githubusercontent.com/atomiclabs/cryptocurrency-icons/master/32%402x/color/zrx%402x.png"
}
]
\ No newline at end of file
......@@ -4,14 +4,13 @@
"symbol": "RLC",
"decimals": 9,
"name": "iExec RLC",
"logo": "https://ipfs.io/ipfs/QmcjNqEC4uDyZJBM946Pyrh8murWVkMh9ufBjpt5hPYuZp"
"logo": "https://raw.githubusercontent.com/atomiclabs/cryptocurrency-icons/master/32%402x/color/rlc%402x.png"
},
{
"address": "0x6f95a3B682F8e9aacC86D057A6DF88A0E68145A8",
"symbol": "ILSC",
"decimals": 2,
"name": "IsraCoin",
"logo": "https://i.imgur.com/I1qkFfm.png"
"name": "IsraCoin"
},
{
"address": "0xa1bAccA0e12D4091Ec1f92e7CaE3394CC9854D3D",
......
import fetch from "node-fetch";
import {
RawTokenJSON,
ValidatedTokenJSON,
......@@ -27,10 +29,13 @@ const networks = [
}
];
function processTokenJson(tokensJson: RawTokenJSON[]): Token[] {
const normalizedTokens = tokensJson
async function processTokenJson(tokensJson: RawTokenJSON[]): Promise<Token[]> {
const normalizedTokensPromises = tokensJson
.map(validateTokenJSON)
.map(normalizeTokenJSON);
.map(normalizeTokenJSON)
.map(addLogo);
const normalizedTokens = await Promise.all(normalizedTokensPromises);
checkForDuplicateAddresses(normalizedTokens);
return handleDuplicateSymbols(normalizedTokens);
}
......@@ -50,13 +55,12 @@ function validateTokenJSON(token: RawTokenJSON): ValidatedTokenJSON {
}
function normalizeTokenJSON(token: ValidatedTokenJSON): NormalizedTokenJSON {
const { address, decimals, symbol, name, logo } = token;
const { address, decimals, symbol, name } = token;
return <NormalizedTokenJSON>{
address,
symbol,
decimals: +decimals,
name,
...(!!logo && logo.src ? { logo: logo.src } : {})
name
};
}
......@@ -163,5 +167,24 @@ function renameSymbolCollisions(
return [...prev, tokenToInsert];
}, renamedTokens);
}
async function addLogo(
token: NormalizedTokenJSON
): Promise<NormalizedTokenJSON> {
const { symbol } = token;
const fetchUrl = `https://raw.githubusercontent.com/atomiclabs/cryptocurrency-icons/master/32%402x/color/${encodeURIComponent(
symbol.toLowerCase()
)}%402x.png`;
const tokenResult = await fetch(fetchUrl)
.then(res => {
if (res.ok) {
token.logo = fetchUrl;
}
return token;
})
.catch(() => console.log(`Error: Could not fetch ${fetchUrl}`));
return tokenResult;
}
export { networks, processTokenJson };
......@@ -10,6 +10,8 @@ import * as path from "path";
const hardcoded_ipfs_files = {
eth:
"https://cloudflare-ipfs.com/ipfs/QmUJJpSQXWiKh6Jex6wLSZ1RWND8CxJu6XQMb7v2ByQhTR",
gor:
"https://cloudflare-ipfs.com/ipfs/QmYznKJJK52BaLkQVJnzeaJNf8U4QAFkFXd2PGVaT29otW",
kov:
"https://cloudflare-ipfs.com/ipfs/QmZUXkAH69BpjJWcpND5HnQVsro6CXVxKiSX9vK49KsyZn",
rop:
......@@ -103,7 +105,7 @@ async function run() {
const tokensJson: RawTokenJSON[] = JSON.parse(await httpsGet(tokensUrl));
// Format the json to match our format in /packages/fether-react/src/assets/tokens/<network>.json
const tokens = processTokenJson(tokensJson);
const tokens = await processTokenJson(tokensJson);
// Write to the file
console.log(
`Writing Tokens JSON to /packages/fether-react/src/assets/tokens/${
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment