Package Exports
- @halva-suite/halva-spec-builder
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@halva-suite/halva-spec-builder) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Halva Spec Builder
Spec-Builder
This npm module is a chain specification file modifier for a Substrate node.
Features
- Key generation type sr25519 and ed25519
- Custom middleware support
- Built-in cli
Installation
npm install @halva-suite/halva-spec-builderUse Module
Use middleware runner
const spec = await HalvaSpecModifier.init('path/to/spec.json', 100, 10)
.apply(auraMiddleware)
.apply(balanceMiddleware)
.apply(grandpaMiddleware)
.run();
spec.output('/path/from/save/shc.json');Create custom middleware
.apply((context: HalvaMiddlewareContext): any => {
const ed25519pairs = context.ed25519Keys.getPairs();
for (let i = 0; i < ed25519pairs.length; i++) {
context.jsonSchema.genesis.runtime.customObject.customField.push(ed25519pairs[i].address);
}
return context.jsonSchema;
})Context structure
interface HalvaMiddlewareContext {
jsonSchema: any;
ed25519Keys: Keyring;
sr25519Keys: Keyring;
customArgs: any;
path: string;
mnemonic: string;
balance: number;
count: number;
}Use cli
spec-builder -i /path/to/spec.json spec-builder -i /path/to/spec.json -a 100 -b 1152921504606847000spec-builder -i /path/to/spec.json -a 100 -b 1152921504606847000 -m clip organ olive upper oak void inject side suit toilet stick narrowYou can also use separate middleware when working with cli
spec-builder -i /path/to/spec.json --am --bm # am - AuraMiddleware bm - BalanceMiddleware
#The grandpa block will not be filled, because the --gm argument is missingScript Commands
yarn test-- Runs tests.yarn typecheck-- Checks TypeScript types for correctness. This is disabled during tests for performance reasons.yarn lint-- Runs linting.yarn format-- Reformats all of the.tsand.tsxfiles with Prettier.yarn build-- Regeneratesdistfolder that gets included into NPM module.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.