70 lines
1.8 KiB
JavaScript
Raw Normal View History

2018-08-13 17:19:25 +07:00
'use strict';
const fs = require('fs');
const path = require('path');
const coins = require('coinlist');
const getColors = require('get-svg-colors');
const alphaSort = require('alpha-sort');
2018-08-13 17:19:25 +07:00
const manifest = require('../manifest.json');
const overrides = new Map([
2018-09-01 01:47:19 +07:00
['VRSC', 'VerusCoin'],
['GMR', 'Gimmer'],
2018-09-12 02:04:08 +07:00
['NEXO', 'Nexo'],
2018-09-17 13:53:55 +07:00
['GUSD', 'Gemini dollar'],
2018-10-02 14:09:09 +07:00
['CALL', 'Capital'],
['BOS', 'BOScoin'],
['CIX', 'Cryptonetix'],
['COQUI', 'COQUI Cash'],
['DEEZ', 'DeezNuts'],
2018-10-02 14:28:28 +07:00
['MZC', 'MAZA'],
['CVC', 'Civic'],
2018-10-07 20:37:35 +07:00
['BTM', 'Bitmark'],
2018-10-29 19:50:08 +07:00
['GLXT', 'GLX Token'],
['ONG', 'SoMee.Social'],
['CC', 'CoinCollect'],
2018-11-30 16:50:27 +07:00
['2GIVE', '2Give'],
['BOOTY', 'Booty'],
2019-01-13 09:41:29 +07:00
['PUNGO', 'Pungo Token'],
2018-12-03 10:53:57 +07:00
['X', 'GLX Equity Token'],
['AYWA', 'Aywa'],
['CHAIN', 'Chainmakers'],
2019-01-13 09:47:15 +07:00
['LPT', 'Livepeer Token'],
['AUDR', 'AUDRamp'],
['BAB', 'Bitcoin Cash ABC'],
['BSV', 'BitcoinSV'],
['GOLD', 'Dragonereum Gold'],
2019-03-19 20:45:17 +07:00
['USDC', 'USD Coin'],
['AEUR', 'Augmint Euro Token'],
['BCIO', 'Blockchain.io'],
['BEAM', 'Beam'],
['BTT', 'BitTorrent'],
['GRIN', 'Grin'],
2019-03-19 20:58:22 +07:00
['ILK', 'Inlock Token'],
2019-04-17 11:29:39 +07:00
['BTM', 'Bytom'],
['D', 'Denarius']
]);
const icons = manifest.map(icon => {
const id = typeof icon === 'string' ? icon : icon.symbol;
2019-04-17 11:42:51 +07:00
const filename = `${id.toLowerCase()}.svg`;
const svgPath = path.resolve(__dirname, '../svg/color/', filename);
const svg = fs.readFileSync(svgPath, 'utf8');
const fillColor = getColors(svg).fills[0];
if (!fillColor) {
throw new Error(`Couldn't get color for \`${id}\``);
}
return {
symbol: id.toUpperCase(),
name: overrides.get(id) || coins.get(id, 'name') || id,
2019-04-17 11:42:51 +07:00
color: fillColor.hex().toLowerCase()
};
});
2018-08-13 17:19:25 +07:00
icons.sort((a, b) => alphaSort.asc(a.symbol, b.symbol));
const data = JSON.stringify(icons, null, '\t') + '\n';
2018-08-13 17:19:25 +07:00
fs.writeFileSync(path.resolve(__dirname, '../manifest.json'), data);