-
Notifications
You must be signed in to change notification settings - Fork 38
/
generate-borvalidatorset.js
47 lines (44 loc) · 1.3 KB
/
generate-borvalidatorset.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
37
38
39
40
41
42
43
44
45
46
47
const program = require("commander")
const fs = require("fs")
const nunjucks = require("nunjucks")
const web3 = require("web3")
const validators = require("./validators")
program.version("0.0.1")
program.option("--bor-chain-id <bor-chain-id>", "Bor chain id", "15001")
program.option(
"--heimdall-chain-id <heimdall-chain-id>",
"Heimdall chain id",
"heimdall-P5rXwg"
)
program.option("--sprint-size <sprint-size>", "Sprint size", "64")
program.option(
"--first-end-block <first-end-block>",
"End block for first span",
"255"
)
program.option(
"-o, --output <output-file>",
"BorValidatorSet.sol",
"./contracts/BorValidatorSet.sol"
)
program.option(
"-t, --template <template>",
"BorValidatorSet template file",
"./contracts/BorValidatorSet.template"
)
program.parse(process.argv)
// process validators
validators.forEach(v => {
v.address = web3.utils.toChecksumAddress(v.address)
})
const data = {
borChainId: program.borChainId,
heimdallChainId: program.heimdallChainId,
firstEndBlock: program.firstEndBlock,
validators: validators,
sprintSize: program.sprintSize
}
const templateString = fs.readFileSync(program.template).toString()
const resultString = nunjucks.renderString(templateString, data)
fs.writeFileSync(program.output, resultString)
console.log("Bor validator set file updated.")