Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

Commit

Permalink
Merge pull request #447 from thehubbleproject/custom-parameter
Browse files Browse the repository at this point in the history
deploy with parameters file and output path
  • Loading branch information
ChihChengLiang authored Jan 22, 2021
2 parents 4296f08 + b6ceca5 commit a219573
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules/
parameters.json
genesis.json
types/
cache/
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"deploy": "ts-node ./scripts/deploy.ts",
"deposit": "ts-node ./scripts/deposit.ts",
"bench": "hardhat run ./scripts/benchmark.ts",
"slither": "slither ."
"slither": "slither .",
"genParam": "ts-node ./scripts/genParam.ts"
},
"repository": {
"type": "git",
Expand Down
18 changes: 14 additions & 4 deletions scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { StateTree } from "../ts/stateTree";
import { execSync } from "child_process";

const argv = require("minimist")(process.argv.slice(2), {
string: ["url", "root", "key"]
string: ["url", "root", "key", "input", "output"]
});
/*
Note separate pubkeys with commas
Expand All @@ -17,6 +17,9 @@ const argv = require("minimist")(process.argv.slice(2), {
You can also specify a private key
> npm run deploy -- --key 0xYourPrivateKey
You can use a custom parameters.json
> npm run deploy -- --input parameters.json --output ../hubbe-commander/genesis.json
*/

function getDefaultGenesisRoot(parameters: DeploymentParameters) {
Expand All @@ -34,10 +37,17 @@ async function main() {
? new ethers.Wallet(argv.key).connect(provider)
: provider.getSigner();

const parameters = PRODUCTION_PARAMS;
const parameters = argv.input
? JSON.parse(fs.readFileSync(argv.input).toString())
: PRODUCTION_PARAMS;

parameters.GENESIS_STATE_ROOT =
argv.root || getDefaultGenesisRoot(parameters);

const genesisPath = argv.output ?? "genesis.json";

console.log("Deploy with parameters", parameters);

const genesisEth1Block = await provider.getBlockNumber();
const contracts = await deployAll(signer, parameters, true);
let addresses: { [key: string]: string } = {};
Expand All @@ -54,8 +64,8 @@ async function main() {
version
};
const configs = { parameters, addresses, auxiliary };
console.log("Writing genesis.json");
fs.writeFileSync("genesis.json", JSON.stringify(configs, null, 4));
console.log("Writing genesis file to", genesisPath);
fs.writeFileSync(genesisPath, JSON.stringify(configs, null, 4));
console.log("Successsfully deployed", configs);
}

Expand Down
5 changes: 5 additions & 0 deletions scripts/genParam.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { PRODUCTION_PARAMS } from "../ts/constants";

import fs from "fs";

fs.writeFileSync("parameters.json", JSON.stringify(PRODUCTION_PARAMS, null, 4));

0 comments on commit a219573

Please sign in to comment.