List of known phishing addresses (for use in wallets) (#57)

* Add list of known addresses

* Sorted

* Add polkadot.express

* typo

* Add checkAddress & tests

* Update comments

* Return error

* U8a cache
This commit is contained in:
Jaco Greeff
2021-01-22 12:16:41 +01:00
committed by GitHub
parent 55b0fb1f9e
commit 53be1b8416
6 changed files with 428 additions and 24 deletions
+13 -3
View File
@@ -7,14 +7,24 @@ function sortSection (values) {
return values.sort((a, b) => a.localeCompare(b));
}
const original = JSON.parse(fs.readFileSync('all.json', 'utf-8'));
function sortAddress (values) {
return Object
.entries(values)
.sort(([a], [b]) => a.localeCompare(b))
.map(([key, addresses]) => [key, sortSection(addresses)])
.reduce((all, [key, addresses]) => ({ ...all, [key]: addresses }), {});
}
const addr = JSON.parse(fs.readFileSync('address.json', 'utf-8'));
const all = JSON.parse(fs.readFileSync('all.json', 'utf-8'));
const meta = JSON.parse(fs.readFileSync('urlmeta.json', 'utf-8'));
// sorted order for all entries
const allow = sortSection(original.allow);
const deny = sortSection(original.deny);
const allow = sortSection(all.allow);
const deny = sortSection(all.deny);
// rewrite with all our entries (newline included)
fs.writeFileSync('address.json', `${JSON.stringify(sortAddress(addr), null, 2)}\n`);
fs.writeFileSync('all.json', `${JSON.stringify({ allow, deny }, null, 2)}\n`);
// find out what we don't have