-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate-tendermintlightclient.js
41 lines (33 loc) · 1.44 KB
/
generate-tendermintlightclient.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
const program = require("commander");
const fs = require("fs");
const nunjucks = require("nunjucks");
program.version("0.0.1");
program.option(
"-t, --template <template>",
"TendermintLightClient template file",
"./contracts/TendermintLightClient.template"
);
program.option(
"-o, --output <output-file>",
"TendermintLightClient.sol",
"./contracts/TendermintLightClient.sol"
)
program.option("--rewardForValidatorSetChange <rewardForValidatorSetChange>",
"rewardForValidatorSetChange",
"1e16"); //1e16
program.option("--initConsensusStateBytes <initConsensusStateBytes>",
"init consensusState bytes, hex encoding, no prefix with 0x",
"42696e616e63652d436861696e2d4e696c650000000000000000000000000000000000000000000229eca254b3859bffefaf85f4c95da9fbd26527766b784272789c30ec56b380b6eb96442aaab207bc59978ba3dd477690f5c5872334fc39e627723daa97e441e88ba4515150ec3182bc82593df36f8abb25a619187fcfab7e552b94e64ed2deed000000e8d4a51000");
program.option("--mock <mock>",
"if use mock",
false);
program.parse(process.argv);
const data = {
initConsensusStateBytes: program.initConsensusStateBytes,
rewardForValidatorSetChange: program.rewardForValidatorSetChange,
mock: program.mock,
};
const templateString = fs.readFileSync(program.template).toString();
const resultString = nunjucks.renderString(templateString, data);
fs.writeFileSync(program.output, resultString);
console.log("TendermintLightClient file updated.");