-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure.js
36 lines (33 loc) · 1.14 KB
/
configure.js
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 fs from 'node:fs'
import { argv } from 'node:process'
import Mustache from 'mustache'
import registryBlocks from '@airswap/registry/deploys-blocks.js'
import registryDeploys from '@airswap/registry/deploys.js'
import swapBlocks from '@airswap/swap-erc20/deploys-blocks.js'
import swapDeploys from '@airswap/swap-erc20/deploys.js'
import { ChainIds, chainNames } from '@airswap/utils'
async function main() {
const chainId = Number(argv[2])
if (ChainIds[chainId] === undefined) {
console.error(`Unknown chainId ${chainId}.`)
} else {
const content = Mustache.render(
fs.readFileSync('./subgraph.template.yaml').toString(),
{
network: ChainIds[chainId].toLowerCase(),
swap_erc20_address: swapDeploys[chainId],
swap_erc20_start_block: swapBlocks[chainId],
registry_address: registryDeploys[chainId],
registry_start_block: registryBlocks[chainId],
}
)
fs.writeFileSync('./subgraph.yaml', content)
console.log(`Wrote subgraph.yaml for ${chainNames[chainId]}.`)
}
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error)
process.exit(1)
})