-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate-relayerincentivizecontract.js
60 lines (49 loc) · 1.77 KB
/
generate-relayerincentivizecontract.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
48
49
50
51
52
53
54
55
56
57
58
59
60
const program = require("commander");
const fs = require("fs");
const nunjucks = require("nunjucks");
program.version("0.0.1");
program.option(
"-t, --template <template>",
"RelayerIncentivize template file",
"./contracts/RelayerIncentivize.template"
);
program.option(
"-o, --output <output-file>",
"RelayerIncentivize.sol",
"./contracts/RelayerIncentivize.sol"
)
program.option("--roundSize <roundSize>",
"roundSize",
"100");
program.option("--maximumWeight <maximumWeight>",
"maximumWeight",
"40");
program.option("--headerRelayerRewardRateMolecule <headerRelayerRewardRateMolecule>",
"headerRelayerRewardRateMolecule",
"1");
program.option("--headerRelayerRewardRateDenominator <headerRelayerRewardRateDenominator>",
"headerRelayerRewardRateDenominator",
"5");
program.option("--callerCompensationMolecule <callerCompensationMolecule>",
"callerCompensationMolecule",
"1");
program.option("--callerCompensationDenominator <callerCompensationDenominator>",
"callerCompensationDenominator",
"80");
program.option("--mock <mock>",
"if use mock",
false);
program.parse(process.argv);
const data = {
roundSize: program.roundSize,
maximumWeight: program.maximumWeight,
headerRelayerRewardRateMolecule: program.headerRelayerRewardRateMolecule,
headerRelayerRewardRateDenominator: program.headerRelayerRewardRateDenominator,
callerCompensationMolecule: program.callerCompensationMolecule,
callerCompensationDenominator: program.callerCompensationDenominator,
mock: program.mock,
};
const templateString = fs.readFileSync(program.template).toString();
const resultString = nunjucks.renderString(templateString, data);
fs.writeFileSync(program.output, resultString);
console.log("RelayerIncentivize file updated.");