-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathgenerate-lib.js
40 lines (32 loc) · 1.14 KB
/
generate-lib.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
const program = require("commander");
const fs = require("fs");
const nunjucks = require("nunjucks");
const init_cycle = require("./init_cycle")
program.version("0.0.1");
program.option(
"-t, --template <template>",
"SatoshiPlus template file",
"./contracts/lib/SatoshiPlusHelper.template"
);
program.option(
"-o, --output <output-file>",
"SatoshiPlusHelper.sol",
"./contracts/lib/SatoshiPlusHelper.sol"
)
program.option("--mock <mock>",
"if use mock",
false);
program.option("-c, --chainid <chainid>", "chain id", "1116")
program.option("-d, --coreDecimal <coreDecimal>", "coreDecimal id", "1e18")
program.option("-s, --coreStakeDecimal <coreStakeDecimal>", "coreStakeDecimal id", "1e24")
program.parse(process.argv);
const data = {
chainid: program.chainid,
initRoundInterval: init_cycle.roundInterval,
coreDecimal: program.coreDecimal,
coreStakeDecimal: program.coreStakeDecimal
};
const templateString = fs.readFileSync(program.template).toString();
const resultString = nunjucks.renderString(templateString, data);
fs.writeFileSync(program.output, resultString);
console.log("SatoshiPlusHelper file updated.");