-
Notifications
You must be signed in to change notification settings - Fork 358
/
Copy pathmodify-plain-specs.ts
54 lines (48 loc) · 1.65 KB
/
modify-plain-specs.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import fs from "fs/promises";
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { ALITH_ADDRESS } from "@moonwall/util";
import { convertExponentials } from "@zombienet/utils";
import jsonBg from "json-bigint";
const JSONbig = jsonBg({ useNativeBigInt: true });
yargs(hideBin(process.argv))
.usage("Usage: $0")
.version("2.0.0")
.command(
"process <inputPath> <outputPath>",
"Overwrites a plainSpec with Alith modifications",
(yargs) => {
return yargs
.positional("inputPath", {
describe: "Input path for plainSpecFile to modify",
type: "string",
})
.positional("outputPath", {
describe: "Output path for modified file",
type: "string",
});
},
async (argv) => {
if (!argv.inputPath) {
throw new Error("Input path is required");
}
if (!argv.outputPath) {
throw new Error("Output path is required");
}
process.stdout.write(`Reading from: ${argv.inputPath} ...`);
const plainSpec = JSONbig.parse((await fs.readFile(argv.inputPath)).toString());
process.stdout.write("Done ✅\n");
plainSpec.bootNodes = [];
plainSpec.genesis.runtime.authorMapping.mappings = [
["5HEL3iLyDyaqmfibHXAXVzyQq4fBqLCHGMEYxZXgRAuhEKXX", ALITH_ADDRESS],
];
plainSpec.genesis.runtime.openTechCommitteeCollective.members = [ALITH_ADDRESS];
process.stdout.write(`Writing to: ${argv.outputPath} ...`);
await fs.writeFile(
argv.outputPath,
convertExponentials(JSONbig.stringify(plainSpec, null, 3))
);
process.stdout.write("Done ✅\n");
}
)
.parse();