forked from MyEtherWallet/ethereum-lists
-
Notifications
You must be signed in to change notification settings - Fork 0
/
renameIcons.js
39 lines (39 loc) · 1.39 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
const fs = require('fs');
const actualIcons = fs.readdirSync('./src/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(`./src/icons/${item}`, `./src/icons/${checksummed}`, err => {
if (err) throw err;
console.log(
`Renamed: ./src/icons/${item} to ./src/icons/${checksummed} succesfully`
);
});
}
} catch (e) {
console.log('Errored on:', item, e);
return;
}
}
});