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

Commit

Permalink
feat: add check for duplicates (#361)
Browse files Browse the repository at this point in the history
  • Loading branch information
bartosz-lipinski authored Jun 14, 2021
1 parent f8b8bb6 commit b9a5fa6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
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

0 comments on commit b9a5fa6

Please sign in to comment.