Skip to content

Commit 4958c9a

Browse files
committed
update
1 parent c0b3ba5 commit 4958c9a

22 files changed

+144
-18745
lines changed

index/external.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
"name": "uniswap",
77
"chainIds": [],
88
"url": "https://unpkg.com/@uniswap/default-token-list"
9+
},
10+
{
11+
"name": "sushiswap",
12+
"chainIds": [],
13+
"url": "https://unpkg.com/@sushiswap/default-token-list"
914
}
1015
]
1116
}

index/index.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,11 @@
224224
"name": "uniswap",
225225
"chainIds": [],
226226
"url": "https://unpkg.com/@uniswap/default-token-list"
227+
},
228+
{
229+
"name": "sushiswap",
230+
"chainIds": [],
231+
"url": "https://unpkg.com/@sushiswap/default-token-list"
227232
}
228233
]
229234
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"license": "MIT",
99
"scripts": {
1010
"reindex": "tsx tools/reindex.ts",
11+
"external-check": "tsx tools/external-check.ts",
1112
"prepare": "husky"
1213
},
1314
"files": [

tools/external-check.ts

Lines changed: 133 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,133 @@
1-
console.log('hihi');
1+
import fs from 'fs';
2+
import path from 'path';
3+
import crypto from 'crypto';
4+
5+
interface ExternalTokenList {
6+
name: string;
7+
chainIds: number[];
8+
url: string;
9+
}
10+
11+
interface ExternalJson {
12+
externalTokenLists: ExternalTokenList[];
13+
}
14+
15+
function calculateSha256(content: string): string {
16+
return crypto.createHash('sha256').update(content).digest('hex');
17+
}
18+
19+
async function checkExternalTokenLists() {
20+
console.log('Starting external token lists check...');
21+
22+
try {
23+
// Read the external.json file
24+
const externalJsonPath = path.join(process.cwd(), 'index', 'external.json');
25+
const externalJsonContent = fs.readFileSync(externalJsonPath, 'utf-8');
26+
27+
// Validate JSON format
28+
let externalData: ExternalJson;
29+
try {
30+
externalData = JSON.parse(externalJsonContent);
31+
} catch (error) {
32+
console.error('Error: external.json is not valid JSON');
33+
throw new Error('Invalid JSON in external.json');
34+
}
35+
36+
if (!externalData.externalTokenLists || !Array.isArray(externalData.externalTokenLists)) {
37+
console.error('Error: external.json does not contain an externalTokenLists array');
38+
throw new Error('Invalid structure in external.json');
39+
}
40+
41+
// Check each URL
42+
const results = await Promise.allSettled(
43+
externalData.externalTokenLists.map(async (tokenList) => {
44+
try {
45+
console.log(`Fetching ${tokenList.name} from ${tokenList.url}...`);
46+
const response = await fetch(tokenList.url, { redirect: 'follow' });
47+
48+
if (!response.ok) {
49+
return {
50+
name: tokenList.name,
51+
url: tokenList.url,
52+
status: response.status,
53+
error: `HTTP error: ${response.status} ${response.statusText}`
54+
};
55+
}
56+
57+
// Try to parse the response as JSON
58+
try {
59+
const text = await response.text();
60+
// Calculate size in MB and hash
61+
const sizeInMB = (text.length / (1024 * 1024)).toFixed(2);
62+
const hash = calculateSha256(text);
63+
64+
JSON.parse(text);
65+
return {
66+
name: tokenList.name,
67+
url: tokenList.url,
68+
status: response.status,
69+
sizeInMB,
70+
hash,
71+
success: true
72+
};
73+
} catch (error) {
74+
return {
75+
name: tokenList.name,
76+
url: tokenList.url,
77+
status: response.status,
78+
error: 'Invalid JSON response'
79+
};
80+
}
81+
} catch (error) {
82+
return {
83+
name: tokenList.name,
84+
url: tokenList.url,
85+
error: error instanceof Error ? error.message : String(error)
86+
};
87+
}
88+
})
89+
);
90+
91+
// Report results
92+
const failures = results.filter(
93+
(result) => result.status === 'rejected' || (result.status === 'fulfilled' && 'error' in result.value)
94+
);
95+
96+
console.log('\nResults:');
97+
results.forEach((result) => {
98+
if (result.status === 'fulfilled') {
99+
if ('error' in result.value) {
100+
console.error(`❌ ${result.value.name}: ${result.value.error}`);
101+
} else {
102+
console.log(`✅ ${result.value.name}: Successfully fetched and validated JSON (${result.value.sizeInMB} MB)`);
103+
console.log(` Hash: ${result.value.hash}`);
104+
}
105+
} else {
106+
console.error(`❌ Failed to check: ${result.reason}`);
107+
}
108+
});
109+
110+
// Calculate total size
111+
let totalSizeMB = 0;
112+
results.forEach((result) => {
113+
if (result.status === 'fulfilled' && 'sizeInMB' in result.value && result.value.sizeInMB) {
114+
totalSizeMB += parseFloat(result.value.sizeInMB);
115+
}
116+
});
117+
118+
if (failures.length > 0) {
119+
console.error(`\nFound ${failures.length} failing external token lists out of ${results.length} total.`);
120+
console.log(`Total size of successful downloads: ${totalSizeMB.toFixed(2)} MB`);
121+
throw new Error('External token list check failed');
122+
} else {
123+
console.log(`\nAll ${results.length} external token lists are valid and return valid JSON.`);
124+
console.log(`Total size of all downloads: ${totalSizeMB.toFixed(2)} MB`);
125+
}
126+
} catch (error) {
127+
console.error('Error during external token list check:', error);
128+
process.exit(1);
129+
}
130+
}
131+
132+
// Run the check
133+
checkExternalTokenLists();

tools/legacy/config/creds.env.sample

Lines changed: 0 additions & 1 deletion
This file was deleted.

tools/legacy/package.json

Lines changed: 0 additions & 42 deletions
This file was deleted.

tools/legacy/scripts/erc1155-mainnet.ts

Lines changed: 0 additions & 157 deletions
This file was deleted.

0 commit comments

Comments
 (0)