-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathindex.ts
36 lines (31 loc) · 1.16 KB
/
index.ts
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 path from 'path'
import fs from 'fs'
import { verifiedAssets, blacklist, hardAssets, exemptedAssets } from './constants'
const buildList = (list: any, listName: any) => {
const tokenListPath = path.resolve(`./config/${listName}.json`)
const listWithLowercaseAddress = list.map((item: any) => {
if (item.tokenAddresses) {
item.tokenAddresses = item.tokenAddresses.map((addressObject: any) => {
return { ...addressObject, address: addressObject.address.toLowerCase() }
})
}
return item
})
const listWithLowercaseKnownOwners = listWithLowercaseAddress.map((item: any) => {
if (item.knownOwners) {
item.knownOwners = item.knownOwners.map((addressObject: string) => addressObject.toLowerCase())
}
return item
})
const stringifiedList = JSON.stringify(listWithLowercaseKnownOwners, null, 2)
fs.writeFile(tokenListPath, stringifiedList, (err) => {
if (err) {
console.error(err)
} else {
console.info(`✅ Creation of ${listName} complete!`)
}
})
}
buildList([...verifiedAssets, ...hardAssets, ...exemptedAssets], 'whitelist')
buildList(blacklist, 'blacklist')
buildList(hardAssets, 'hardAssets')