forked from bnb-chain/bsc-genesis-contract
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-tokenhub.js
51 lines (41 loc) · 1.29 KB
/
generate-tokenhub.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
const program = require("commander");
const fs = require("fs");
const nunjucks = require("nunjucks");
program.version("0.0.1");
program.option(
"-t, --template <template>",
"TokenHub template file",
"./contracts/TokenHub.template"
);
program.option(
"-o, --output <output-file>",
"TokenHub.sol",
"./contracts/TokenHub.sol"
)
program.option("--initRelayFee <initRelayFee>",
"initRelayFee",
"2e15");
program.option("--rewardUpperLimit <rewardUpperLimit>",
"rewardUpperLimit",
"1e18");
program.option("--maxGasForCallingBEP20 <maxGasForCallingBEP20>",
"maxGasForCallingBEP20",
"50000");
program.option("--maxGasForTransferringBNB <maxGasForTransferringBNB>",
"maxGasForTransferringBNB",
"10000");
program.option("--mock <mock>",
"if use mock",
false);
program.parse(process.argv);
const data = {
initRelayFee: program.initRelayFee,
rewardUpperLimit: program.rewardUpperLimit,
maxGasForCallingBEP20: program.maxGasForCallingBEP20,
maxGasForTransferringBNB: program.maxGasForTransferringBNB,
mock: program.mock,
};
const templateString = fs.readFileSync(program.template).toString();
const resultString = nunjucks.renderString(templateString, data);
fs.writeFileSync(program.output, resultString);
console.log("TokenHub file updated.");