-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathvalidateSupportedChains.ts
More file actions
36 lines (28 loc) · 956 Bytes
/
validateSupportedChains.ts
File metadata and controls
36 lines (28 loc) · 956 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { readFileSync } from 'node:fs'
import { join } from 'node:path'
import { exit, cwd } from 'node:process'
import { ALL_CHAINS_IDS } from '@cowprotocol/cow-sdk'
const COWSWAP_JSON_PATH = join(cwd(), 'src', 'public', 'CowSwap.json')
interface TokenEntry {
address: string
symbol?: string
name?: string
chainId: number
}
interface TokenList {
tokens: TokenEntry[]
}
function main(): void {
const supportedChainIds = new Set(ALL_CHAINS_IDS)
const list: TokenList = JSON.parse(readFileSync(COWSWAP_JSON_PATH, 'utf-8'))
const invalid = list.tokens.filter((token) => !supportedChainIds.has(token.chainId))
if (invalid.length === 0) {
console.log('All tokens in CowSwap.json use supported chain IDs.')
exit(0)
}
console.error(
`CowSwap.json contains ${invalid.length} token(s) with unsupported chainId:\n${invalid.map((t) => `- ${t.chainId}: ${t.symbol ?? '?'} (${t.address})`).join('\n')}`,
)
exit(1)
}
main()