Skip to content
This repository has been archived by the owner on Jul 3, 2022. It is now read-only.

feat: add check for duplicates #361

Merged
merged 1 commit into from
Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions src/lib/tokenlist.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import fs from 'fs';

import test from 'ava';

import { CLUSTER_SLUGS, ENV, Strategy, TokenListProvider } from './tokenlist';
import {
CLUSTER_SLUGS,
ENV,
Strategy,
TokenInfo,
TokenListProvider,
} from './tokenlist';

test('Token list is filterable by a tag', async (t) => {
const list = (await new TokenListProvider().resolve(Strategy.Static))
Expand Down Expand Up @@ -49,11 +55,27 @@ test('Token list throws error when calling filterByClusterSlug with slug that do
);
});

test('Token list ris a valid json', async (t) => {
test('Token list is a valid json', async (t) => {
t.notThrows(() => {
const content = fs
.readFileSync('./src/tokens/solana.tokenlist.json')
.toString();
JSON.parse(content.toString());
});
});

test('Token list does not have duplicate entries', async (t) => {
const list = await new TokenListProvider().resolve(Strategy.Static);
list
.filterByChainId(ENV.MainnetBeta)
.getList()
.reduce((agg, item) => {
if (agg.has(item.address)) {
console.log(item.address);
}

t.false(agg.has(item.address));
agg.set(item.address, item);
return agg;
}, new Map<string, TokenInfo>());
});
12 changes: 0 additions & 12 deletions src/tokens/solana.tokenlist.json
Original file line number Diff line number Diff line change
Expand Up @@ -6778,18 +6778,6 @@
"website": "https://solanium.io/"
}
},
{
"chainId": 101,
"address": "Ae1aeYK9WrB2kP29jJU4aUUK7Y1vzsGNZFKoe4BG2h6P",
"symbol": "NINJA",
"name": "NINJA",
"decimals": 0,
"logoURI": "https://raw.githubusercontent.com/yuzu-ninjaprotocol/ninjaprotocol/main/NINJA%20Token.svg",
"tags": [],
"extensions": {
"website": "http://ninjaprotocol.io"
}
},
{
"chainId": 101,
"address": "8GPUjUHFxfNhaSS8kUkix8txRRXszeUAsHTjUmHuygZT",
Expand Down