diff --git a/src/index.ts b/src/index.ts index cce509d..0f7b341 100644 --- a/src/index.ts +++ b/src/index.ts @@ -141,6 +141,12 @@ export async function main(): Promise { default: false, describe: "Include quorum-dev-quickstart test accounts", }, + genesisNodeAllocation: { + type: "string", + demandOption: true, + default: "1000000000000000000000000000", + describe: "Balance allocated to each nodes", + }, alloc: { type: "string", demandOption: true, @@ -181,6 +187,7 @@ export async function main(): Promise { quickstartDevAccounts: args.quickstartDevAccounts, noOutputTimestamp: args.noOutputTimestamp, prefundedAccounts: args.alloc, + genesisNodeAllocation: args.genesisNodeAllocation, }; } else { const qr = new QuestionRenderer(rootQuestion); diff --git a/src/lib/genesisGenerate.ts b/src/lib/genesisGenerate.ts index 806b8de..633f588 100644 --- a/src/lib/genesisGenerate.ts +++ b/src/lib/genesisGenerate.ts @@ -80,7 +80,7 @@ export function createBesuGenesis( } node.forEach((account) => { besu.alloc[account.ethAccount.address] = { - balance: "1000000000000000000000000000", + balance: quorumConfig.genesisNodeAllocation, }; }); @@ -153,7 +153,7 @@ export function createGoQuorumGenesis( } node.forEach((account) => { goquorum.alloc[account.ethAccount.address] = { - balance: "1000000000000000000000000000", + balance: quorumConfig.genesisNodeAllocation, }; }); diff --git a/src/questions/commonQs.ts b/src/questions/commonQs.ts index 50619dc..7c3d8fe 100644 --- a/src/questions/commonQs.ts +++ b/src/questions/commonQs.ts @@ -10,6 +10,12 @@ export const quickstartDevAccountsQuestion: QuestionTree = { prompt: "Include quorum-dev-quickstart test accounts: [y/N]", }; +export const genesisNodeAllocationQuestion: QuestionTree = { + name: "genesisNodeAllocation", + prompt: + "Balance allocated to each nodes: (default 1000000000000000000000000000)", +}; + export const prefundedAccountsQuestion: QuestionTree = { name: "prefundedAccounts", prompt: diff --git a/src/questions/qbftQs.ts b/src/questions/qbftQs.ts index 2aa5ad2..40a96da 100644 --- a/src/questions/qbftQs.ts +++ b/src/questions/qbftQs.ts @@ -31,6 +31,16 @@ _prefundedAccountsQuestion.transformerValidator = allocStringValidator( "{}" ); +const _genesisNodeAllocationQuestion: QuestionTree = Object.assign( + {}, + commonQs.genesisNodeAllocationQuestion +); +_genesisNodeAllocationQuestion.transformerValidator = stringValidator( + _genesisNodeAllocationQuestion, + _prefundedAccountsQuestion, + "1000000000000000000000000000" +); + const _quickstartDevAccountsQuestion: QuestionTree = Object.assign( {}, @@ -38,7 +48,7 @@ const _quickstartDevAccountsQuestion: QuestionTree = Object.assign( ); _quickstartDevAccountsQuestion.transformerValidator = getYesNoValidator( _quickstartDevAccountsQuestion, - _prefundedAccountsQuestion, + _genesisNodeAllocationQuestion, "n" ); diff --git a/src/types/quorumConfig.ts b/src/types/quorumConfig.ts index a3acaf3..d6aa773 100644 --- a/src/types/quorumConfig.ts +++ b/src/types/quorumConfig.ts @@ -24,4 +24,5 @@ export type QuorumConfig = { quickstartDevAccounts: boolean; noOutputTimestamp: boolean; prefundedAccounts: string; + genesisNodeAllocation: string; }; diff --git a/tests/lib/testConstants.ts b/tests/lib/testConstants.ts index 24e8761..6f7fbab 100644 --- a/tests/lib/testConstants.ts +++ b/tests/lib/testConstants.ts @@ -25,6 +25,7 @@ export const TEST_QUORUM_CONFIG: QuorumConfig = { quickstartDevAccounts: false, noOutputTimestamp: false, prefundedAccounts: "{}", + genesisNodeAllocation: "100", }; export const TEST_NODE = {