This npm module is a chain specification file modifier for a Substrate node.
- Key generation type sr25519 and ed25519
- Custom middleware support
- Built-in cli
npm install @halva-suite/halva-spec-builderUse 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 missingyarn 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.
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.