mirror of
https://github.com/pezkuwichain/phishing.git
synced 2026-06-20 16:11:03 +00:00
Check ss58 for additions (#257)
This commit is contained in:
@@ -152,7 +152,7 @@ describe('addrcheck', (): void => {
|
|||||||
const results = _results.map(([url, addrs]): [string, string[]] => {
|
const results = _results.map(([url, addrs]): [string, string[]] => {
|
||||||
return [url, addrs.filter((a) => {
|
return [url, addrs.filter((a) => {
|
||||||
try {
|
try {
|
||||||
return !!decodeAddress(a);
|
return decodeAddress(a).length === 32;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(url, (error as Error).message);
|
console.error(url, (error as Error).message);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
// Copyright 2020-2021 @polkadot/phishing authors & contributors
|
// Copyright 2020-2021 @polkadot/phishing authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
import denied from '../../../address.json';
|
import { decodeAddress } from '@polkadot/util-crypto';
|
||||||
|
|
||||||
|
import addresses from '../../../address.json';
|
||||||
import allowed from '../../../known.json';
|
import allowed from '../../../known.json';
|
||||||
import { checkAddress, checkIfDenied } from '.';
|
import { checkAddress, checkIfDenied } from '.';
|
||||||
|
|
||||||
@@ -64,9 +66,30 @@ describe('checkAddress', (): void => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('check additions', (): void => {
|
describe('check additions', (): void => {
|
||||||
|
it('has no malformed addresses', (): void => {
|
||||||
|
const invalids = Object
|
||||||
|
.entries(addresses as Record<string, string[]>)
|
||||||
|
.map(([url, addrs]): [string, string[]] => {
|
||||||
|
return [url, addrs.filter((a) => {
|
||||||
|
try {
|
||||||
|
return decodeAddress(a).length !== 32;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(url, (error as Error).message);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
})];
|
||||||
|
})
|
||||||
|
.filter(([, addrs]) => addrs.length);
|
||||||
|
|
||||||
|
if (invalids.length) {
|
||||||
|
throw new Error(`Invalid ss58 checksum addresses found: ${invalids.map(([url, addrs]) => `\n\t${url}: ${addrs.join(', ')}`).join('')}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
it('has no entries on the known addresses list', (): void => {
|
it('has no entries on the known addresses list', (): void => {
|
||||||
const added = Object
|
const added = Object
|
||||||
.values(denied as Record<string, string[]>)
|
.values(addresses as Record<string, string[]>)
|
||||||
.reduce<string[]>((all, addrs) => all.concat(addrs), []);
|
.reduce<string[]>((all, addrs) => all.concat(addrs), []);
|
||||||
const dupes = Object
|
const dupes = Object
|
||||||
.entries(allowed as Record<string, string[]>)
|
.entries(allowed as Record<string, string[]>)
|
||||||
|
|||||||
Reference in New Issue
Block a user