UNPKG

@kba-tools/genesis-tool

Version:

A forked repo from ConsenSys which helps to generate genesis block for Besu Network with xemptyBlockPeriod field.

169 lines (150 loc) 4.05 kB
/* eslint-disable object-shorthand */ // import { CryptoCurve } from "../types/cryptoCurve"; import { QuestionTree } from "../types/questions"; import { integerValidator, passwordValidator, stringValidator, getYesNoValidator, allocStringValidator } from "./common"; import * as commonQs from "./commonQs"; // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const _outputPathQuestion: QuestionTree = Object.assign( {}, commonQs.outputPathQuestion ); _outputPathQuestion.transformerValidator = stringValidator( _outputPathQuestion, undefined, "./output" ); const _prefundedAccountsQuestion: QuestionTree = Object.assign( {}, commonQs.prefundedAccountsQuestion ); _prefundedAccountsQuestion.transformerValidator = allocStringValidator( _prefundedAccountsQuestion, _outputPathQuestion, "{}" ); const _quickstartDevAccountsQuestion: QuestionTree = Object.assign( {}, commonQs.quickstartDevAccountsQuestion ); _quickstartDevAccountsQuestion.transformerValidator = getYesNoValidator( _quickstartDevAccountsQuestion, _prefundedAccountsQuestion, "n" ); const _accountPasswordQuestion: QuestionTree = Object.assign( {}, commonQs.accountPasswordQuestion ); _accountPasswordQuestion.transformerValidator = passwordValidator( _accountPasswordQuestion, _quickstartDevAccountsQuestion ); // const _curveQuestion: QuestionTree = Object.assign({}, commonQs.curveQuestion); // _curveQuestion.options = [ // { label: "secp256k1", value: CryptoCurve.k1, nextQuestion: _accountPasswordQuestion, default: true }, // { label: "secp256r1", value: CryptoCurve.r1, nextQuestion: _accountPasswordQuestion } // ]; const _tesseraPasswordQuestion: QuestionTree = Object.assign( {}, commonQs.tesseraPasswordQuestion ); _tesseraPasswordQuestion.transformerValidator = passwordValidator( _tesseraPasswordQuestion, _accountPasswordQuestion ); const _tesseraEnabledQuestion: QuestionTree = Object.assign( {}, commonQs.tesseraEnabled ); _tesseraEnabledQuestion.transformerValidator = getYesNoValidator( _tesseraEnabledQuestion, _tesseraPasswordQuestion, "n" ); const _membersQuestion: QuestionTree = Object.assign( {}, commonQs.membersQuestion ); _membersQuestion.transformerValidator = integerValidator( _membersQuestion, _tesseraEnabledQuestion, 1 ); const _validatorsQuestion: QuestionTree = Object.assign( {}, commonQs.validatorsQuestion ); _validatorsQuestion.transformerValidator = integerValidator( _validatorsQuestion, _membersQuestion, 4 ); const _bootnodesQuestion: QuestionTree = Object.assign( {}, commonQs.bootnodesQuestion ); _bootnodesQuestion.transformerValidator = integerValidator( _bootnodesQuestion, _validatorsQuestion, 2 ); const _txnSizeLimitQuestion: QuestionTree = Object.assign( {}, commonQs.txnSizeLimitQuestion ); _txnSizeLimitQuestion.transformerValidator = integerValidator( _txnSizeLimitQuestion, _bootnodesQuestion, 64 ); const _maxCodeSizeQuestion: QuestionTree = Object.assign( {}, commonQs.maxCodeSizeQuestion ); _maxCodeSizeQuestion.transformerValidator = integerValidator( _maxCodeSizeQuestion, _txnSizeLimitQuestion, 64 ); const _coinbaseQuestion: QuestionTree = Object.assign( {}, commonQs.coinbaseQuestion ); _coinbaseQuestion.transformerValidator = stringValidator( _coinbaseQuestion, _maxCodeSizeQuestion, "0x0000000000000000000000000000000000000000" ); const _gasLimitQuestion: QuestionTree = Object.assign( {}, commonQs.gasLimitQuestion ); _gasLimitQuestion.transformerValidator = stringValidator( _gasLimitQuestion, _coinbaseQuestion, "0xFFFF" ); const _difficultyQuestion: QuestionTree = Object.assign( {}, commonQs.difficultyQuestion ); _difficultyQuestion.transformerValidator = integerValidator( _difficultyQuestion, _gasLimitQuestion, 1 ); export const _chainIDQuestion: QuestionTree = Object.assign( {}, commonQs.chainIDQuestion ); _chainIDQuestion.transformerValidator = integerValidator( _chainIDQuestion, _difficultyQuestion, 1337 );