forked from MyEtherWallet/ethereum-lists
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generateMissingTokenListFromIcons.js
47 lines (43 loc) · 1.52 KB
/
generateMissingTokenListFromIcons.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
41
42
43
44
45
46
47
const ethList = './dist/tokens/eth/tokens-eth.json';
const ethIcons = './src/icons';
const web3 = require('web3');
const utils = web3.utils;
const fs = require('fs');
function generateMissingToken() {
const icons = fs.readdirSync(ethIcons);
const list = JSON.parse(fs.readFileSync(ethList, 'utf8'));
const exclusion = [
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
'0xef68e7c694f40c8202821edf525de3782458639f',
'0x85e076361cc813a908ff672f9bad1541474402b2' // TEL token migrated
]
const addressOnly = [];
const notInList = [];
icons.forEach(icon => {
const idxOf = icon.indexOf('-0x');
const getAddr = icon.substring(idxOf+1, icon.length);
if(getAddr.length !== 42) {
const actualAddress = getAddr.substring(getAddr.indexOf('0x'), 42);
addressOnly.push(actualAddress);
} else {
addressOnly.push(getAddr);
}
})
addressOnly.forEach(addr => {
if(utils.isAddress(addr)) {
const inExclusionList = exclusion.find(item => {
return utils.toChecksumAddress(item) === utils.toChecksumAddress(addr);
})
const found = list.find(item => {
if(addr.substring(0, 2) === '0x' && addr.length === 42) {
return utils.toChecksumAddress(item.address) === utils.toChecksumAddress(addr);
}
})
if(!found && addr.substring(0, 2) === '0x' && addr.length === 42 && !inExclusionList) notInList.push(addr);
} else {
console.log(addr);
}
});
fs.writeFileSync('notinlist.json', JSON.stringify(notInList))
}
generateMissingToken();