forked from MyEtherWallet/ethereum-lists
-
Notifications
You must be signed in to change notification settings - Fork 0
/
renameIcons.js
40 lines (40 loc) · 1.43 KB
/
renameIcons.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const fs = require('fs');
const icons = fs.readdirSync('./').find(f => f.includes('PNG'));
const actualIcons = fs.readdirSync(icons);
const web3 = require('web3');
const utils = web3.utils;
actualIcons.forEach(item => {
if (
item !== 'eth.svg' &&
item !== 'btc.svg' &&
item !== 'btc.png' &&
item !== '.DS_Store' &&
item !== 'BNB-0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-bsc.png' &&
item !== 'BNB-0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.png' &&
item !== 'ETH-0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.png' &&
item !== 'ETH-0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.svg' &&
item !== 'MATIC-0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-matic.svg' &&
item !== 'MATIC-0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-matic.png'
) {
try {
const addressStart = item.indexOf('-0x');
const address = item.substr(addressStart + 1, 42);
const symbol = item.substr(0, addressStart);
const ending = item.substring(addressStart + 43, item.length);
const checksummed = `${symbol}-${utils.toChecksumAddress(
address
)}${ending}`;
if (checksummed !== item) {
fs.rename(`${icons}/${item}`, `${icons}/${checksummed}`, err => {
if (err) throw err;
console.log(
`Renamed: ${icons}/${item} to ${icons}/${checksummed} succesfully`
);
});
}
} catch (e) {
console.log('Errored on: ', item);
return;
}
}
});