Skip to content

Commit 698726f

Browse files
committed
update
1 parent a4f3da7 commit 698726f

File tree

8 files changed

+16
-29
lines changed

8 files changed

+16
-29
lines changed
File renamed without changes.
File renamed without changes.

index/external.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,25 @@
11
{
22
"!!NOTE!!": "This file is manually maintained, and represents the external token lists that are not part of the token directory.",
3-
"!!NOTE2!!": "The token list url sources below will be indexed by external indexers, in order.",
3+
"!!NOTE2!!": "The token-list url sources below will be indexed by external indexers, in order of priority.",
44
"externalTokenLists": [
55
{
66
"name": "uniswap",
7-
"chainIds": [],
87
"url": "https://unpkg.com/@uniswap/default-token-list"
98
},
109
{
1110
"name": "sushiswap",
12-
"chainIds": [],
1311
"url": "https://unpkg.com/@sushiswap/default-token-list"
1412
},
1513
{
1614
"name": "coingecko",
17-
"chainIds": [],
1815
"url": "https://tokens.coingecko.com/uniswap/all.json"
1916
},
2017
{
2118
"name": "pancakeswap-default",
22-
"chainIds": [],
2319
"url": "https://tokens.pancakeswap.finance/pancakeswap-default.json"
2420
},
2521
{
2622
"name": "pancakeswap-extended",
27-
"chainIds": [],
2823
"url": "https://tokens.pancakeswap.finance/pancakeswap-extended.json"
2924
}
3025
]

index/index.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"_external": {
55
"chainId": 0,
66
"tokenLists": {
7-
"coingecko.json": "b9bc9410adba20611a32a5b53faf313747a00a5245aecd3ca9f6dc8b94a1a1e3",
8-
"pancakeswap-default.json": "d35bdd7bbc4db9baa4ff25c2a018aef99e67a40592aee94a3f5992cd92a7ced2",
9-
"pancakeswap-extended.json": "4585fb956fcd46b87814c5ad174146c24afc90dff12800f1bb9acd09514f5c26",
10-
"sushiswap.json": "b871b728c4c7b8c2cc987c41238d43188c6936da3cd69615eb9a013f820a99d3",
11-
"uniswap.json": "322028085aea76523700e23016113da6b80da8915dbf90f48144351e6d62fea1"
7+
"1-uniswap.json": "322028085aea76523700e23016113da6b80da8915dbf90f48144351e6d62fea1",
8+
"2-sushiswap.json": "b871b728c4c7b8c2cc987c41238d43188c6936da3cd69615eb9a013f820a99d3",
9+
"3-coingecko.json": "b9bc9410adba20611a32a5b53faf313747a00a5245aecd3ca9f6dc8b94a1a1e3",
10+
"4-pancakeswap-default.json": "d35bdd7bbc4db9baa4ff25c2a018aef99e67a40592aee94a3f5992cd92a7ced2",
11+
"5-pancakeswap-extended.json": "4585fb956fcd46b87814c5ad174146c24afc90dff12800f1bb9acd09514f5c26"
1212
}
1313
},
1414
"amoy": {

tools/sync-external.ts

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import crypto from 'crypto';
44

55
interface ExternalTokenList {
66
name: string;
7-
chainIds: number[];
87
url: string;
98
}
109

@@ -46,29 +45,22 @@ async function checkExternalTokenLists() {
4645
process.exit(1);
4746
}
4847

49-
// Validate chainIds are all numbers
50-
for (const tokenList of externalData.externalTokenLists) {
51-
if (!Array.isArray(tokenList.chainIds)) {
52-
console.error(`Error: chainIds for ${tokenList.name} is not an array`);
53-
process.exit(1);
54-
}
55-
56-
const nonNumberChainIds = tokenList.chainIds.filter(id => typeof id !== 'number');
57-
if (nonNumberChainIds.length > 0) {
58-
console.error(`Error: Non-number chainIds found for ${tokenList.name}: ${nonNumberChainIds.join(', ')}`);
59-
process.exit(1);
60-
}
61-
}
62-
6348
// Create the _external directory if it doesn't exist
6449
const externalDir = path.join(process.cwd(), 'index', '_external');
6550
if (!fs.existsSync(externalDir)) {
6651
fs.mkdirSync(externalDir, { recursive: true });
52+
} else {
53+
// Empty the directory first
54+
const existingFiles = fs.readdirSync(externalDir);
55+
for (const file of existingFiles) {
56+
fs.unlinkSync(path.join(externalDir, file));
57+
}
58+
console.log(`Cleared ${existingFiles.length} files from _external directory`);
6759
}
6860

6961
// Check each URL
7062
const results = await Promise.allSettled(
71-
externalData.externalTokenLists.map(async (tokenList) => {
63+
externalData.externalTokenLists.map(async (tokenList, index) => {
7264
try {
7365
console.log(`Fetching ${tokenList.name} from ${tokenList.url}...`);
7466
const response = await fetch(tokenList.url, { redirect: 'follow' });
@@ -92,8 +84,8 @@ async function checkExternalTokenLists() {
9284
// Validate JSON
9385
const jsonData = JSON.parse(text);
9486

95-
// Write the file to disk
96-
const fileName = `${tokenList.name}.json`;
87+
// Write the file to disk with numbered prefix to maintain order
88+
const fileName = `${index + 1}-${tokenList.name}.json`;
9789
const filePath = path.join(externalDir, fileName);
9890
fs.writeFileSync(filePath, JSON.stringify(jsonData, null, 2));
9991

0 commit comments

Comments
 (0)