-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate-validatorset.js
44 lines (36 loc) · 1.08 KB
/
generate-validatorset.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
const program = require("commander");
const fs = require("fs");
const nunjucks = require("nunjucks");
program.version("0.0.1");
program.option(
"-t, --template <template>",
"validatorSet template file",
"./contracts/BSCValidatorSet.template"
);
program.option(
"-o, --output <output-file>",
"BSCValidatorSet.sol",
"./contracts/BSCValidatorSet.sol"
)
program.option(
"--initValidatorSetBytes <initValidatorSetBytes>",
"initValidatorSetBytes",
""
)
program.option("--mock <mock>",
"if use mock",
false);
program.parse(process.argv);
const validators = require("./validators")
let initValidatorSetBytes = program.initValidatorSetBytes;
if (initValidatorSetBytes == ""){
initValidatorSetBytes = validators.validatorSetBytes.slice(2);
}
const data = {
initValidatorSetBytes: initValidatorSetBytes,
mock: program.mock,
};
const templateString = fs.readFileSync(program.template).toString();
const resultString = nunjucks.renderString(templateString, data);
fs.writeFileSync(program.output, resultString);
console.log("BSCValidatorSet file updated.");