@rocketh/export 0.10.8 → 0.10.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cli.cjs +10 -2
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +10 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/index.cjs +57 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.mjs +57 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/cli.ts +10 -0
- package/src/index.ts +74 -6
package/CHANGELOG.md
CHANGED
package/dist/cli.cjs
CHANGED
|
@@ -8,7 +8,7 @@ require('node:fs');
|
|
|
8
8
|
require('node:path');
|
|
9
9
|
|
|
10
10
|
var name = "@rocketh/export";
|
|
11
|
-
var version = "0.10.
|
|
11
|
+
var version = "0.10.10";
|
|
12
12
|
var description = "export deployments";
|
|
13
13
|
var publishConfig = {
|
|
14
14
|
access: "public"
|
|
@@ -70,13 +70,21 @@ var pkg = {
|
|
|
70
70
|
|
|
71
71
|
const commandName = pkg.name;
|
|
72
72
|
const program = new commander.Command();
|
|
73
|
-
program.name(commandName).description("export deployments to consume elswhere").version(pkg.version).option("-d, --deployments <value>", "folder where deployments are saved").option("--ts <value>", "list of filepath where the typescript export will be written, separated by commas").option("--js <value>", "list of filepath where the javascript export will be written, separated by commas").option("--json <value>", "list of filepath where the json export will be written, separated by commas").option(
|
|
73
|
+
program.name(commandName).description("export deployments to consume elswhere").version(pkg.version).option("-d, --deployments <value>", "folder where deployments are saved").option("--ts <value>", "list of filepath where the typescript export will be written, separated by commas").option("--js <value>", "list of filepath where the javascript export will be written, separated by commas").option("--json <value>", "list of filepath where the json export will be written, separated by commas").option(
|
|
74
|
+
"--tsm <value>",
|
|
75
|
+
"list of filepath where the typescript export with individual export will be written, separated by commas"
|
|
76
|
+
).option(
|
|
77
|
+
"--jsm <value>",
|
|
78
|
+
"list of filepath where the javascript export with individual exportwill be written, separated by commas"
|
|
79
|
+
).option("-b, --bytecode", "if set, the bytecode will also be part of the output").requiredOption("-n, --network <value>", "network context to use").parse(process.argv);
|
|
74
80
|
const options = program.opts();
|
|
75
81
|
const resolvedConfig = rocketh.readAndResolveConfig({ ...options, ignoreMissingRPC: true });
|
|
76
82
|
index.run(resolvedConfig, {
|
|
77
83
|
tots: options.ts ? options.ts.split(",") : void 0,
|
|
78
84
|
tojson: options.json ? options.json.split(",") : void 0,
|
|
79
85
|
tojs: options.js ? options.js.split(",") : void 0,
|
|
86
|
+
totsm: options.tsm ? options.tsm.split(",") : void 0,
|
|
87
|
+
tojsm: options.jsm ? options.jsm.split(",") : void 0,
|
|
80
88
|
includeBytecode: options.bytecode
|
|
81
89
|
});
|
|
82
90
|
//# sourceMappingURL=cli.cjs.map
|
package/dist/cli.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.cjs","sources":["../src/cli.ts"],"sourcesContent":["#! /usr/bin/env node\nimport {readAndResolveConfig} from 'rocketh';\nimport {run} from '.';\nimport {Command} from 'commander';\nimport pkg from '../package.json';\nimport {ConfigOptions} from 'rocketh';\n\nconst commandName = pkg.name;\n\nconst program = new Command();\nprogram\n\t.name(commandName)\n\t.description('export deployments to consume elswhere')\n\t.version(pkg.version)\n\t.option('-d, --deployments <value>', 'folder where deployments are saved')\n\t.option('--ts <value>', 'list of filepath where the typescript export will be written, separated by commas')\n\t.option('--js <value>', 'list of filepath where the javascript export will be written, separated by commas')\n\t.option('--json <value>', 'list of filepath where the json export will be written, separated by commas')\n\t.option('-b, --bytecode', 'if set, the bytecode will also be part of the output')\n\t.requiredOption('-n, --network <value>', 'network context to use')\n\t.parse(process.argv);\n\nconst options = program.opts();\nconst resolvedConfig = readAndResolveConfig({...(options as ConfigOptions), ignoreMissingRPC: true});\nrun(resolvedConfig, {\n\ttots: options.ts ? options.ts.split(',') : undefined,\n\ttojson: options.json ? options.json.split(',') : undefined,\n\ttojs: options.js ? options.js.split(',') : undefined,\n\tincludeBytecode: options.bytecode,\n});\n"],"names":["Command","readAndResolveConfig","run"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAW,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAG,CAAG,CAAA,CAAA,CAAC,IAAI,CAAC;AAC7B,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAA,EAAA,CAAA;AACA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,
|
|
1
|
+
{"version":3,"file":"cli.cjs","sources":["../src/cli.ts"],"sourcesContent":["#! /usr/bin/env node\nimport {readAndResolveConfig} from 'rocketh';\nimport {run} from '.';\nimport {Command} from 'commander';\nimport pkg from '../package.json';\nimport {ConfigOptions} from 'rocketh';\n\nconst commandName = pkg.name;\n\nconst program = new Command();\nprogram\n\t.name(commandName)\n\t.description('export deployments to consume elswhere')\n\t.version(pkg.version)\n\t.option('-d, --deployments <value>', 'folder where deployments are saved')\n\t.option('--ts <value>', 'list of filepath where the typescript export will be written, separated by commas')\n\t.option('--js <value>', 'list of filepath where the javascript export will be written, separated by commas')\n\t.option('--json <value>', 'list of filepath where the json export will be written, separated by commas')\n\t.option(\n\t\t'--tsm <value>',\n\t\t'list of filepath where the typescript export with individual export will be written, separated by commas'\n\t)\n\t.option(\n\t\t'--jsm <value>',\n\t\t'list of filepath where the javascript export with individual exportwill be written, separated by commas'\n\t)\n\t.option('-b, --bytecode', 'if set, the bytecode will also be part of the output')\n\t.requiredOption('-n, --network <value>', 'network context to use')\n\t.parse(process.argv);\n\nconst options = program.opts();\nconst resolvedConfig = readAndResolveConfig({...(options as ConfigOptions), ignoreMissingRPC: true});\nrun(resolvedConfig, {\n\ttots: options.ts ? options.ts.split(',') : undefined,\n\ttojson: options.json ? options.json.split(',') : undefined,\n\ttojs: options.js ? options.js.split(',') : undefined,\n\ttotsm: options.tsm ? options.tsm.split(',') : undefined,\n\ttojsm: options.jsm ? options.jsm.split(',') : undefined,\n\tincludeBytecode: options.bytecode,\n});\n"],"names":["Command","readAndResolveConfig","run"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAM,CAAW,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAG,CAAG,CAAA,CAAA,CAAC,IAAI,CAAC;AAC7B,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAA,EAAA,CAAA;AACA,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAC,IAAI,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAW,CAAC,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAG,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAA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,CAAA,CAAG,GAAG,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAC,CAAG,CAAA,CAAA,CAAC,KAAK,CAAC,CAAA,CAAA,CAAG,CAAC,CAAA,CAAA,CAAG,KAAK,CAAC,CAAA;AACtD,CAAA,CAAE,KAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,KAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,KAAA,CAAA,CAAA;AACF,CAAA,CAAE,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACT,CAAC,CAAC"}
|
package/dist/cli.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import 'node:fs';
|
|
|
5
5
|
import 'node:path';
|
|
6
6
|
|
|
7
7
|
var name = "@rocketh/export";
|
|
8
|
-
var version = "0.10.
|
|
8
|
+
var version = "0.10.10";
|
|
9
9
|
var description = "export deployments";
|
|
10
10
|
var publishConfig = {
|
|
11
11
|
access: "public"
|
|
@@ -67,13 +67,21 @@ var pkg = {
|
|
|
67
67
|
|
|
68
68
|
const commandName = pkg.name;
|
|
69
69
|
const program = new Command();
|
|
70
|
-
program.name(commandName).description("export deployments to consume elswhere").version(pkg.version).option("-d, --deployments <value>", "folder where deployments are saved").option("--ts <value>", "list of filepath where the typescript export will be written, separated by commas").option("--js <value>", "list of filepath where the javascript export will be written, separated by commas").option("--json <value>", "list of filepath where the json export will be written, separated by commas").option(
|
|
70
|
+
program.name(commandName).description("export deployments to consume elswhere").version(pkg.version).option("-d, --deployments <value>", "folder where deployments are saved").option("--ts <value>", "list of filepath where the typescript export will be written, separated by commas").option("--js <value>", "list of filepath where the javascript export will be written, separated by commas").option("--json <value>", "list of filepath where the json export will be written, separated by commas").option(
|
|
71
|
+
"--tsm <value>",
|
|
72
|
+
"list of filepath where the typescript export with individual export will be written, separated by commas"
|
|
73
|
+
).option(
|
|
74
|
+
"--jsm <value>",
|
|
75
|
+
"list of filepath where the javascript export with individual exportwill be written, separated by commas"
|
|
76
|
+
).option("-b, --bytecode", "if set, the bytecode will also be part of the output").requiredOption("-n, --network <value>", "network context to use").parse(process.argv);
|
|
71
77
|
const options = program.opts();
|
|
72
78
|
const resolvedConfig = readAndResolveConfig({ ...options, ignoreMissingRPC: true });
|
|
73
79
|
run(resolvedConfig, {
|
|
74
80
|
tots: options.ts ? options.ts.split(",") : void 0,
|
|
75
81
|
tojson: options.json ? options.json.split(",") : void 0,
|
|
76
82
|
tojs: options.js ? options.js.split(",") : void 0,
|
|
83
|
+
totsm: options.tsm ? options.tsm.split(",") : void 0,
|
|
84
|
+
tojsm: options.jsm ? options.jsm.split(",") : void 0,
|
|
77
85
|
includeBytecode: options.bytecode
|
|
78
86
|
});
|
|
79
87
|
//# sourceMappingURL=cli.mjs.map
|
package/dist/cli.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.mjs","sources":["../src/cli.ts"],"sourcesContent":["#! /usr/bin/env node\nimport {readAndResolveConfig} from 'rocketh';\nimport {run} from '.';\nimport {Command} from 'commander';\nimport pkg from '../package.json';\nimport {ConfigOptions} from 'rocketh';\n\nconst commandName = pkg.name;\n\nconst program = new Command();\nprogram\n\t.name(commandName)\n\t.description('export deployments to consume elswhere')\n\t.version(pkg.version)\n\t.option('-d, --deployments <value>', 'folder where deployments are saved')\n\t.option('--ts <value>', 'list of filepath where the typescript export will be written, separated by commas')\n\t.option('--js <value>', 'list of filepath where the javascript export will be written, separated by commas')\n\t.option('--json <value>', 'list of filepath where the json export will be written, separated by commas')\n\t.option('-b, --bytecode', 'if set, the bytecode will also be part of the output')\n\t.requiredOption('-n, --network <value>', 'network context to use')\n\t.parse(process.argv);\n\nconst options = program.opts();\nconst resolvedConfig = readAndResolveConfig({...(options as ConfigOptions), ignoreMissingRPC: true});\nrun(resolvedConfig, {\n\ttots: options.ts ? options.ts.split(',') : undefined,\n\ttojson: options.json ? options.json.split(',') : undefined,\n\ttojs: options.js ? options.js.split(',') : undefined,\n\tincludeBytecode: options.bytecode,\n});\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAM,WAAW,GAAG,GAAG,CAAC,IAAI,CAAC;AAC7B,MAAA,OAAA,GAAA,IAAA,OAAA,EAAA,CAAA;AACA,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,WAAG,CAAA,wCAAA,CAAA,CAAA,OAAA,CAAA,GAAA,CAAA,OAAA,CAAA,CAAA,MAAA,CAAA,2BAAA,EAAA,oCAAA,CAAA,CAAA,MAAA,CAAA,cAAA,EAAA,mFAAA,CAAA,CAAA,MAAA,CAAA,cAAA,EAAA,mFAAA,CAAA,CAAA,MAAA,CAAA,gBAAA,EAAA,6EAAA,CAAA,CAAA,MAAA,
|
|
1
|
+
{"version":3,"file":"cli.mjs","sources":["../src/cli.ts"],"sourcesContent":["#! /usr/bin/env node\nimport {readAndResolveConfig} from 'rocketh';\nimport {run} from '.';\nimport {Command} from 'commander';\nimport pkg from '../package.json';\nimport {ConfigOptions} from 'rocketh';\n\nconst commandName = pkg.name;\n\nconst program = new Command();\nprogram\n\t.name(commandName)\n\t.description('export deployments to consume elswhere')\n\t.version(pkg.version)\n\t.option('-d, --deployments <value>', 'folder where deployments are saved')\n\t.option('--ts <value>', 'list of filepath where the typescript export will be written, separated by commas')\n\t.option('--js <value>', 'list of filepath where the javascript export will be written, separated by commas')\n\t.option('--json <value>', 'list of filepath where the json export will be written, separated by commas')\n\t.option(\n\t\t'--tsm <value>',\n\t\t'list of filepath where the typescript export with individual export will be written, separated by commas'\n\t)\n\t.option(\n\t\t'--jsm <value>',\n\t\t'list of filepath where the javascript export with individual exportwill be written, separated by commas'\n\t)\n\t.option('-b, --bytecode', 'if set, the bytecode will also be part of the output')\n\t.requiredOption('-n, --network <value>', 'network context to use')\n\t.parse(process.argv);\n\nconst options = program.opts();\nconst resolvedConfig = readAndResolveConfig({...(options as ConfigOptions), ignoreMissingRPC: true});\nrun(resolvedConfig, {\n\ttots: options.ts ? options.ts.split(',') : undefined,\n\ttojson: options.json ? options.json.split(',') : undefined,\n\ttojs: options.js ? options.js.split(',') : undefined,\n\ttotsm: options.tsm ? options.tsm.split(',') : undefined,\n\ttojsm: options.jsm ? options.jsm.split(',') : undefined,\n\tincludeBytecode: options.bytecode,\n});\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAM,WAAW,GAAG,GAAG,CAAC,IAAI,CAAC;AAC7B,MAAA,OAAA,GAAA,IAAA,OAAA,EAAA,CAAA;AACA,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,WAAG,CAAA,wCAAA,CAAA,CAAA,OAAA,CAAA,GAAA,CAAA,OAAA,CAAA,CAAA,MAAA,CAAA,2BAAA,EAAA,oCAAA,CAAA,CAAA,MAAA,CAAA,cAAA,EAAA,mFAAA,CAAA,CAAA,MAAA,CAAA,cAAA,EAAA,mFAAA,CAAA,CAAA,MAAA,CAAA,gBAAA,EAAA,6EAAA,CAAA,CAAA,MAAA;AAC7B,EAAA,eAAA;AACA,EAAE,0GAA4B;AAC9B,CAAC,CAAC,MAAK;AACP,EAAE,eAAe;AACjB,EAAE,0GAAqD;AACvD,CAAC,CAAC,MAAM,CAAC,gBAAa,EAAA,sDAAA,CAAA,CAAA,cAAA,CAAA,uBAAA,EAAA,wBAAA,CAAA,CAAA,KAAA,CAAA,OAAA,CAAA,IAAA,CAAA,CAAA;AACtB,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;AAC/B,MAAM,cAAc,GAAG,oBAAoB,CAAC,EAAE,GAAG,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAC,CAAC;AACpF,GAAG,CAAC,cAAc,EAAE;AACpB,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AACnD,EAAE,MAAM,EAAC,OAAA,CAAA,IAAA,GAAA,OAAA,CAAA,IAAA,CAAA,KAAA,CAAA,GAAA,CAAA,GAAA,KAAA,CAAA;AACT,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,GAAA,OAAA,CAAA,EAAA,CAAA,KAAA,CAAA,GAAA,CAAA,GAAA,KAAA,CAAA;AAClB,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AACtD,EAAE,KAAA,EAAA,OAAA,CAAA,GAAA,GAAA,OAAA,CAAA,GAAA,CAAA,KAAA,CAAA,GAAA,CAAA,GAAA,KAAA,CAAA;AACF,EAAE,eAAO,EAAA,OAAA,CAAA,QAAA;AACT,CAAC,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -11,7 +11,7 @@ function objectMap(object, mapFn) {
|
|
|
11
11
|
}, {});
|
|
12
12
|
}
|
|
13
13
|
async function run(config, options) {
|
|
14
|
-
if (!options.tots && !options.tojs && !options.tojson) {
|
|
14
|
+
if (!options.tots && !options.tojs && !options.tojson && !options.tojsm && !options.totsm) {
|
|
15
15
|
console.log(`no filepath to export to are specified`);
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
@@ -44,6 +44,7 @@ async function run(config, options) {
|
|
|
44
44
|
address: d.address,
|
|
45
45
|
linkedData: d.linkedData,
|
|
46
46
|
bytecode: options.includeBytecode ? d.bytecode : void 0,
|
|
47
|
+
argsData: options.includeBytecode ? d.argsData : void 0,
|
|
47
48
|
startBlock: d.receipt?.blockNumber ? parseInt(d.receipt.blockNumber.slice(2), 16) : void 0
|
|
48
49
|
})),
|
|
49
50
|
name: config.network.name
|
|
@@ -51,7 +52,9 @@ async function run(config, options) {
|
|
|
51
52
|
const js = typeof options.tojs === "string" ? [options.tojs] : options.tojs || [];
|
|
52
53
|
const ts = typeof options.tots === "string" ? [options.tots] : options.tots || [];
|
|
53
54
|
const json = typeof options.tojson === "string" ? [options.tojson] : options.tojson || [];
|
|
54
|
-
|
|
55
|
+
const tsmodule = typeof options.totsm === "string" ? [options.totsm] : options.totsm || [];
|
|
56
|
+
const jsmodule = typeof options.tojsm === "string" ? [options.tojsm] : options.tojsm || [];
|
|
57
|
+
if (ts.length > 0) {
|
|
55
58
|
const newContent = `export default ${JSON.stringify(exportData, null, 2)} as const;`;
|
|
56
59
|
for (const tsFile of ts) {
|
|
57
60
|
const folderPath = path.dirname(tsFile);
|
|
@@ -59,7 +62,7 @@ async function run(config, options) {
|
|
|
59
62
|
fs.writeFileSync(tsFile, newContent);
|
|
60
63
|
}
|
|
61
64
|
}
|
|
62
|
-
if (
|
|
65
|
+
if (js.length > 0) {
|
|
63
66
|
const newContent = `export default /** @type {const} **/ (${JSON.stringify(exportData, null, 2)});`;
|
|
64
67
|
const dtsContent = `export = ${JSON.stringify(exportData, null, 2)} as const;`;
|
|
65
68
|
for (const jsFile of js) {
|
|
@@ -69,7 +72,7 @@ async function run(config, options) {
|
|
|
69
72
|
fs.writeFileSync(jsFile.replace(".js", ".d.ts"), dtsContent);
|
|
70
73
|
}
|
|
71
74
|
}
|
|
72
|
-
if (
|
|
75
|
+
if (json.length > 0) {
|
|
73
76
|
const newContent = JSON.stringify(exportData, null, 2);
|
|
74
77
|
for (const jsonFile of json) {
|
|
75
78
|
const folderPath = path.dirname(jsonFile);
|
|
@@ -77,6 +80,56 @@ async function run(config, options) {
|
|
|
77
80
|
fs.writeFileSync(jsonFile, newContent);
|
|
78
81
|
}
|
|
79
82
|
}
|
|
83
|
+
if (tsmodule.length > 0) {
|
|
84
|
+
let newContent = `export const chain = ${JSON.stringify(
|
|
85
|
+
{
|
|
86
|
+
chainId: exportData.chainId,
|
|
87
|
+
genesisHash: exportData.genesisHash,
|
|
88
|
+
chainInfo: exportData.chainInfo,
|
|
89
|
+
name: exportData.name
|
|
90
|
+
},
|
|
91
|
+
null,
|
|
92
|
+
2
|
|
93
|
+
)} as const;
|
|
94
|
+
`;
|
|
95
|
+
for (const contractName of Object.keys(exportData.contracts)) {
|
|
96
|
+
newContent += `export const ${contractName} = ${JSON.stringify(
|
|
97
|
+
exportData.contracts[contractName],
|
|
98
|
+
null,
|
|
99
|
+
2
|
|
100
|
+
)} as const;`;
|
|
101
|
+
}
|
|
102
|
+
for (const tsFile of tsmodule) {
|
|
103
|
+
const folderPath = path.dirname(tsFile);
|
|
104
|
+
fs.mkdirSync(folderPath, { recursive: true });
|
|
105
|
+
fs.writeFileSync(tsFile, newContent);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (jsmodule.length > 0) {
|
|
109
|
+
let newContent = `export const chain = /** @type {const} **/ (${JSON.stringify(
|
|
110
|
+
{
|
|
111
|
+
chainId: exportData.chainId,
|
|
112
|
+
genesisHash: exportData.genesisHash,
|
|
113
|
+
chainInfo: exportData.chainInfo,
|
|
114
|
+
name: exportData.name
|
|
115
|
+
},
|
|
116
|
+
null,
|
|
117
|
+
2
|
|
118
|
+
)});
|
|
119
|
+
`;
|
|
120
|
+
for (const contractName of Object.keys(exportData.contracts)) {
|
|
121
|
+
newContent += `export const ${contractName} = /** @type {const} **/ (${JSON.stringify(
|
|
122
|
+
exportData.contracts[contractName],
|
|
123
|
+
null,
|
|
124
|
+
2
|
|
125
|
+
)});`;
|
|
126
|
+
}
|
|
127
|
+
for (const jsFile of jsmodule) {
|
|
128
|
+
const folderPath = path.dirname(jsFile);
|
|
129
|
+
fs.mkdirSync(folderPath, { recursive: true });
|
|
130
|
+
fs.writeFileSync(jsFile, newContent);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
80
133
|
}
|
|
81
134
|
|
|
82
135
|
exports.run = run;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import {Abi, Address} from 'abitype';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport {Deployment, ResolvedConfig, chainTypes, getChain, loadDeployments} from 'rocketh';\n\nexport interface ContractExport {\n\taddress: string;\n\tabi: Abi;\n\t// linkedData?: any; TODO\n}\n\ntype ChainBlockExplorer = {\n\tname: string;\n\turl: string;\n\tapiUrl?: string | undefined;\n};\ntype ChainContract = {\n\taddress: Address;\n\tblockCreated?: number | undefined;\n};\n\ntype ChainNativeCurrency = {\n\tname: string;\n\t/** 2-6 characters long */\n\tsymbol: string;\n\tdecimals: number;\n};\n\ntype ChainRpcUrls = {\n\thttp: readonly string[];\n\twebSocket?: readonly string[] | undefined;\n};\n\n/**\n * @description Combines members of an intersection into a readable type.\n *\n * @see {@link https://twitter.com/mattpocockuk/status/1622730173446557697?s=20&t=NdpAcmEFXY01xkqU3KO0Mg}\n * @example\n * Prettify<{ a: string } & { b: string } & { c: number, d: bigint }>\n * => { a: string, b: string, c: number, d: bigint }\n */\ntype Prettify<T> = {\n\t[K in keyof T]: T[K];\n} & {};\n\nexport type ChainInfo = {\n\t/** ID in number form */\n\tid: number;\n\t/** Human-readable name */\n\tname: string;\n\t/** Collection of block explorers */\n\tblockExplorers?:\n\t\t| {\n\t\t\t\t[key: string]: ChainBlockExplorer;\n\t\t\t\tdefault: ChainBlockExplorer;\n\t\t }\n\t\t| undefined;\n\t/** Collection of contracts */\n\tcontracts?:\n\t\t| Prettify<\n\t\t\t\t{\n\t\t\t\t\t[key: string]: ChainContract | {[sourceId: number]: ChainContract | undefined} | undefined;\n\t\t\t\t} & {\n\t\t\t\t\tensRegistry?: ChainContract | undefined;\n\t\t\t\t\tensUniversalResolver?: ChainContract | undefined;\n\t\t\t\t\tmulticall3?: ChainContract | undefined;\n\t\t\t\t}\n\t\t >\n\t\t| undefined;\n\t/** Currency used by chain */\n\tnativeCurrency: ChainNativeCurrency;\n\t/** Collection of RPC endpoints */\n\trpcUrls: {\n\t\t[key: string]: ChainRpcUrls;\n\t\tdefault: ChainRpcUrls;\n\t};\n\t/** Source Chain ID (ie. the L1 chain) */\n\tsourceId?: number | undefined;\n\t/** Flag for test networks */\n\ttestnet?: boolean | undefined;\n\n\tchainType: 'zksync' | 'op-stack' | 'celo' | 'default';\n\n\t// this will bring in the following when reconstructed from the data above\n\n\t// /** Custom chain data. */\n\t// custom?: any;\n\n\t// /**\n\t// * Modifies how chain data structures (ie. Blocks, Transactions, etc)\n\t// * are formatted & typed.\n\t// */\n\t// formatters?: any | undefined;\n\t// /** Modifies how data (ie. Transactions) is serialized. */\n\t// serializers?: any | undefined;\n\t// /** Modifies how fees are derived. */\n\t// fees?: any | undefined;\n};\n\nexport type ExportedDeployments = {\n\tchainId: string;\n\tgenesisHash?: string;\n\tchainInfo: ChainInfo;\n\tname: string;\n\tcontracts: {[name: string]: ContractExport};\n};\n\ntype Trandformed<O, Value> = {\n\t[Property in keyof O]: Value;\n};\n\nfunction objectMap<V, N, O extends Trandformed<{}, V> = Trandformed<{}, V>>(\n\tobject: O,\n\tmapFn: (v: V) => N\n): Trandformed<O, N> {\n\treturn Object.keys(object).reduce((result, key) => {\n\t\t(result as any)[key] = mapFn((object as any)[key]);\n\t\treturn result;\n\t}, {} as Trandformed<O, N>);\n}\n\nexport async function run(\n\tconfig: ResolvedConfig,\n\toptions: {tojs?: string[]; tots?: string[]; tojson?: string[]; includeBytecode?: boolean}\n) {\n\tif (!options.tots && !options.tojs && !options.tojson) {\n\t\tconsole.log(`no filepath to export to are specified`);\n\t\treturn;\n\t}\n\n\tconst {deployments, chainId, genesisHash} = loadDeployments(config.deployments, config.network.name);\n\n\tif (!deployments || Object.keys(deployments).length === 0) {\n\t\tconsole.log(`no deployments to export`);\n\t\treturn;\n\t}\n\n\tif (!chainId) {\n\t\tthrow new Error(`no chainId found for ${config.network.name}`);\n\t}\n\n\tconst chain = getChain(chainId);\n\n\tconst chainInfo: ChainInfo = {\n\t\tid: chain.id,\n\t\tname: chain.name,\n\t\tnativeCurrency: chain.nativeCurrency,\n\t\trpcUrls: chain.rpcUrls,\n\t\tblockExplorers: chain.blockExplorers,\n\t\tchainType: chainTypes[chainId] || 'default',\n\t\tcontracts: chain.contracts,\n\t\tsourceId: chain.sourceId,\n\t\ttestnet: chain.testnet,\n\t};\n\n\tconst exportData: ExportedDeployments = {\n\t\tchainId,\n\t\tgenesisHash,\n\t\tchainInfo,\n\t\tcontracts: objectMap<Deployment<Abi>, ContractExport>(deployments, (d) => ({\n\t\t\tabi: d.abi,\n\t\t\taddress: d.address,\n\t\t\tlinkedData: d.linkedData,\n\t\t\tbytecode: options.includeBytecode ? d.bytecode : undefined,\n\t\t\tstartBlock: d.receipt?.blockNumber ? parseInt(d.receipt.blockNumber.slice(2), 16) : undefined,\n\t\t})),\n\t\tname: config.network.name,\n\t};\n\n\tconst js = typeof options.tojs === 'string' ? [options.tojs] : options.tojs || [];\n\tconst ts = typeof options.tots === 'string' ? [options.tots] : options.tots || [];\n\tconst json = typeof options.tojson === 'string' ? [options.tojson] : options.tojson || [];\n\n\tif (typeof ts === 'object' && ts.length > 0) {\n\t\tconst newContent = `export default ${JSON.stringify(exportData, null, 2)} as const;`;\n\t\tfor (const tsFile of ts) {\n\t\t\tconst folderPath = path.dirname(tsFile);\n\t\t\tfs.mkdirSync(folderPath, {recursive: true});\n\t\t\tfs.writeFileSync(tsFile, newContent);\n\t\t}\n\t}\n\n\tif (typeof js === 'object' && js.length > 0) {\n\t\tconst newContent = `export default /** @type {const} **/ (${JSON.stringify(exportData, null, 2)});`;\n\t\tconst dtsContent = `export = ${JSON.stringify(exportData, null, 2)} as const;`;\n\t\tfor (const jsFile of js) {\n\t\t\tconst folderPath = path.dirname(jsFile);\n\t\t\tfs.mkdirSync(folderPath, {recursive: true});\n\t\t\tfs.writeFileSync(jsFile, newContent);\n\t\t\tfs.writeFileSync(jsFile.replace('.js', '.d.ts'), dtsContent);\n\t\t}\n\t}\n\n\tif (typeof json === 'object' && json.length > 0) {\n\t\tconst newContent = JSON.stringify(exportData, null, 2);\n\t\tfor (const jsonFile of json) {\n\t\t\tconst folderPath = path.dirname(jsonFile);\n\t\t\tfs.mkdirSync(folderPath, {recursive: true});\n\t\t\tfs.writeFileSync(jsonFile, newContent);\n\t\t}\n\t}\n}\n"],"names":["loadDeployments","getChain","chainTypes"],"mappings":";;;;;;AAIA,SAAS,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE;AAClC,EAAE,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,GAAG,KAAK;AACrD,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;AACrC,IAAI,OAAO,MAAM,CAAC;AAClB,GAAG,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AACM,eAAe,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE;AAC3C,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;AACzD,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,sCAAsC,CAAC,CAAC,CAAC;AAC1D,IAAI,OAAO;AACX,GAAG;AACH,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE,GAAGA,uBAAe,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACzG,EAAE,IAAI,CAAC,WAAW,IAAI,MAAM,CAAC,IAAI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"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import {Abi, Address} from 'abitype';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport {Deployment, ResolvedConfig, chainTypes, getChain, loadDeployments} from 'rocketh';\n\nexport interface ContractExport {\n\taddress: `0x${string}`;\n\tabi: Abi;\n\targsData?: string;\n\tbytecode?: `0x${string}`;\n\t// linkedData?: any; TODO\n}\n\ntype ChainBlockExplorer = {\n\tname: string;\n\turl: string;\n\tapiUrl?: string | undefined;\n};\ntype ChainContract = {\n\taddress: Address;\n\tblockCreated?: number | undefined;\n};\n\ntype ChainNativeCurrency = {\n\tname: string;\n\t/** 2-6 characters long */\n\tsymbol: string;\n\tdecimals: number;\n};\n\ntype ChainRpcUrls = {\n\thttp: readonly string[];\n\twebSocket?: readonly string[] | undefined;\n};\n\n/**\n * @description Combines members of an intersection into a readable type.\n *\n * @see {@link https://twitter.com/mattpocockuk/status/1622730173446557697?s=20&t=NdpAcmEFXY01xkqU3KO0Mg}\n * @example\n * Prettify<{ a: string } & { b: string } & { c: number, d: bigint }>\n * => { a: string, b: string, c: number, d: bigint }\n */\ntype Prettify<T> = {\n\t[K in keyof T]: T[K];\n} & {};\n\nexport type ChainInfo = {\n\t/** ID in number form */\n\tid: number;\n\t/** Human-readable name */\n\tname: string;\n\t/** Collection of block explorers */\n\tblockExplorers?:\n\t\t| {\n\t\t\t\t[key: string]: ChainBlockExplorer;\n\t\t\t\tdefault: ChainBlockExplorer;\n\t\t }\n\t\t| undefined;\n\t/** Collection of contracts */\n\tcontracts?:\n\t\t| Prettify<\n\t\t\t\t{\n\t\t\t\t\t[key: string]: ChainContract | {[sourceId: number]: ChainContract | undefined} | undefined;\n\t\t\t\t} & {\n\t\t\t\t\tensRegistry?: ChainContract | undefined;\n\t\t\t\t\tensUniversalResolver?: ChainContract | undefined;\n\t\t\t\t\tmulticall3?: ChainContract | undefined;\n\t\t\t\t}\n\t\t >\n\t\t| undefined;\n\t/** Currency used by chain */\n\tnativeCurrency: ChainNativeCurrency;\n\t/** Collection of RPC endpoints */\n\trpcUrls: {\n\t\t[key: string]: ChainRpcUrls;\n\t\tdefault: ChainRpcUrls;\n\t};\n\t/** Source Chain ID (ie. the L1 chain) */\n\tsourceId?: number | undefined;\n\t/** Flag for test networks */\n\ttestnet?: boolean | undefined;\n\n\tchainType: 'zksync' | 'op-stack' | 'celo' | 'default';\n\n\t// this will bring in the following when reconstructed from the data above\n\n\t// /** Custom chain data. */\n\t// custom?: any;\n\n\t// /**\n\t// * Modifies how chain data structures (ie. Blocks, Transactions, etc)\n\t// * are formatted & typed.\n\t// */\n\t// formatters?: any | undefined;\n\t// /** Modifies how data (ie. Transactions) is serialized. */\n\t// serializers?: any | undefined;\n\t// /** Modifies how fees are derived. */\n\t// fees?: any | undefined;\n};\n\nexport type ExportedDeployments = {\n\tchainId: string;\n\tgenesisHash?: string;\n\tchainInfo: ChainInfo;\n\tname: string;\n\tcontracts: {[name: string]: ContractExport};\n};\n\ntype Trandformed<O, Value> = {\n\t[Property in keyof O]: Value;\n};\n\nfunction objectMap<V, N, O extends Trandformed<{}, V> = Trandformed<{}, V>>(\n\tobject: O,\n\tmapFn: (v: V) => N\n): Trandformed<O, N> {\n\treturn Object.keys(object).reduce((result, key) => {\n\t\t(result as any)[key] = mapFn((object as any)[key]);\n\t\treturn result;\n\t}, {} as Trandformed<O, N>);\n}\n\nexport async function run(\n\tconfig: ResolvedConfig,\n\toptions: {\n\t\ttojs?: string[];\n\t\ttots?: string[];\n\t\ttojson?: string[];\n\t\ttotsm?: string[];\n\t\ttojsm?: string[];\n\t\tincludeBytecode?: boolean;\n\t}\n) {\n\tif (!options.tots && !options.tojs && !options.tojson && !options.tojsm && !options.totsm) {\n\t\tconsole.log(`no filepath to export to are specified`);\n\t\treturn;\n\t}\n\n\tconst {deployments, chainId, genesisHash} = loadDeployments(config.deployments, config.network.name);\n\n\tif (!deployments || Object.keys(deployments).length === 0) {\n\t\tconsole.log(`no deployments to export`);\n\t\treturn;\n\t}\n\n\tif (!chainId) {\n\t\tthrow new Error(`no chainId found for ${config.network.name}`);\n\t}\n\n\tconst chain = getChain(chainId);\n\n\tconst chainInfo: ChainInfo = {\n\t\tid: chain.id,\n\t\tname: chain.name,\n\t\tnativeCurrency: chain.nativeCurrency,\n\t\trpcUrls: chain.rpcUrls,\n\t\tblockExplorers: chain.blockExplorers,\n\t\tchainType: chainTypes[chainId] || 'default',\n\t\tcontracts: chain.contracts,\n\t\tsourceId: chain.sourceId,\n\t\ttestnet: chain.testnet,\n\t};\n\n\tconst exportData: ExportedDeployments = {\n\t\tchainId,\n\t\tgenesisHash,\n\t\tchainInfo,\n\t\tcontracts: objectMap<Deployment<Abi>, ContractExport>(deployments, (d) => ({\n\t\t\tabi: d.abi,\n\t\t\taddress: d.address,\n\t\t\tlinkedData: d.linkedData,\n\t\t\tbytecode: options.includeBytecode ? d.bytecode : undefined,\n\t\t\targsData: options.includeBytecode ? d.argsData : undefined,\n\t\t\tstartBlock: d.receipt?.blockNumber ? parseInt(d.receipt.blockNumber.slice(2), 16) : undefined,\n\t\t})),\n\t\tname: config.network.name,\n\t};\n\n\tconst js = typeof options.tojs === 'string' ? [options.tojs] : options.tojs || [];\n\tconst ts = typeof options.tots === 'string' ? [options.tots] : options.tots || [];\n\tconst json = typeof options.tojson === 'string' ? [options.tojson] : options.tojson || [];\n\n\tconst tsmodule = typeof options.totsm === 'string' ? [options.totsm] : options.totsm || [];\n\tconst jsmodule = typeof options.tojsm === 'string' ? [options.tojsm] : options.tojsm || [];\n\n\tif (ts.length > 0) {\n\t\tconst newContent = `export default ${JSON.stringify(exportData, null, 2)} as const;`;\n\t\tfor (const tsFile of ts) {\n\t\t\tconst folderPath = path.dirname(tsFile);\n\t\t\tfs.mkdirSync(folderPath, {recursive: true});\n\t\t\tfs.writeFileSync(tsFile, newContent);\n\t\t}\n\t}\n\n\tif (js.length > 0) {\n\t\tconst newContent = `export default /** @type {const} **/ (${JSON.stringify(exportData, null, 2)});`;\n\t\tconst dtsContent = `export = ${JSON.stringify(exportData, null, 2)} as const;`;\n\t\tfor (const jsFile of js) {\n\t\t\tconst folderPath = path.dirname(jsFile);\n\t\t\tfs.mkdirSync(folderPath, {recursive: true});\n\t\t\tfs.writeFileSync(jsFile, newContent);\n\t\t\tfs.writeFileSync(jsFile.replace('.js', '.d.ts'), dtsContent);\n\t\t}\n\t}\n\n\tif (json.length > 0) {\n\t\tconst newContent = JSON.stringify(exportData, null, 2);\n\t\tfor (const jsonFile of json) {\n\t\t\tconst folderPath = path.dirname(jsonFile);\n\t\t\tfs.mkdirSync(folderPath, {recursive: true});\n\t\t\tfs.writeFileSync(jsonFile, newContent);\n\t\t}\n\t}\n\n\tif (tsmodule.length > 0) {\n\t\tlet newContent = `export const chain = ${JSON.stringify(\n\t\t\t{\n\t\t\t\tchainId: exportData.chainId,\n\t\t\t\tgenesisHash: exportData.genesisHash,\n\t\t\t\tchainInfo: exportData.chainInfo,\n\t\t\t\tname: exportData.name,\n\t\t\t},\n\t\t\tnull,\n\t\t\t2\n\t\t)} as const;\\n`;\n\n\t\tfor (const contractName of Object.keys(exportData.contracts)) {\n\t\t\tnewContent += `export const ${contractName} = ${JSON.stringify(\n\t\t\t\t(exportData.contracts as any)[contractName],\n\t\t\t\tnull,\n\t\t\t\t2\n\t\t\t)} as const;`;\n\t\t}\n\n\t\tfor (const tsFile of tsmodule) {\n\t\t\tconst folderPath = path.dirname(tsFile);\n\t\t\tfs.mkdirSync(folderPath, {recursive: true});\n\t\t\tfs.writeFileSync(tsFile, newContent);\n\t\t}\n\t}\n\n\tif (jsmodule.length > 0) {\n\t\t// TODO test\n\t\tlet newContent = `export const chain = /** @type {const} **/ (${JSON.stringify(\n\t\t\t{\n\t\t\t\tchainId: exportData.chainId,\n\t\t\t\tgenesisHash: exportData.genesisHash,\n\t\t\t\tchainInfo: exportData.chainInfo,\n\t\t\t\tname: exportData.name,\n\t\t\t},\n\t\t\tnull,\n\t\t\t2\n\t\t)});\\n`;\n\n\t\tfor (const contractName of Object.keys(exportData.contracts)) {\n\t\t\tnewContent += `export const ${contractName} = /** @type {const} **/ (${JSON.stringify(\n\t\t\t\t(exportData.contracts as any)[contractName],\n\t\t\t\tnull,\n\t\t\t\t2\n\t\t\t)});`;\n\t\t}\n\n\t\tfor (const jsFile of jsmodule) {\n\t\t\tconst folderPath = path.dirname(jsFile);\n\t\t\tfs.mkdirSync(folderPath, {recursive: true});\n\t\t\tfs.writeFileSync(jsFile, newContent);\n\t\t}\n\t}\n}\n"],"names":["loadDeployments","getChain","chainTypes"],"mappings":";;;;;;AAIA,SAAS,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE;AAClC,EAAE,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,GAAG,KAAK;AACrD,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;AACrC,IAAI,OAAO,MAAM,CAAC;AAClB,GAAG,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AACM,eAAe,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE;AAC3C,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;AAC7F,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,sCAAsC,CAAC,CAAC,CAAC;AAC1D,IAAI,OAAO;AACX,GAAG;AACH,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE,GAAGA,uBAAe,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACzG,EAAE,IAAI,CAAC,WAAW,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,KAAK,C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AAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;AAC3B,IAAI,IAAI,UAAU,GAAG,CAAC,4CAA4C,EAAE,IAAI,CAAC,SAAS;AAClF,MAAM;AACN,QAAQ,OAAO,EAAE,UAAU,CAAC,OAAO;AACnC,QAAQ,WAAW,EAAE,UAAU,CAAC,WAAW;AAC3C,QAAQ,SAAS,EAAE,UAAU,CAAC,SAAS;AACvC,QAAQ,IAAI,EAAE,UAAU,CAAC,IAAI;AAC7B,OAAO;AACP,MAAM,IAAI;AACV,MAAM,CAAC;AACP,KAAK,CAAC;AACN,CAAC,CAAC;AACF,IAAI,KAAK,MAAM,YAAY,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;AAClE,MAAM,UAAU,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC,0BAA0B,EAAE,IAAI,CAAC,SAAS;AAC3F,QAAQ,UAAU,CAAC,SAAS,CAAC,YAAY,CAAC;AAC1C,QAAQ,IAAI;AACZ,QAAQ,CAAC;AACT,OAAO,CAAC,EAAE,CAAC,CAAC;AACZ,KAAK;AACL,IAAI,KAAK,MAAM,MAAM,IAAI,QAAQ,EAAE;AACnC,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AAC9C,MAAM,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AACpD,MAAM,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAC3C,KAAK;AACL,GAAG;AACH;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -287,8 +287,10 @@ type AbiError = {
|
|
|
287
287
|
type Abi = readonly (AbiConstructor | AbiError | AbiEvent | AbiFallback | AbiFunction | AbiReceive)[];
|
|
288
288
|
|
|
289
289
|
interface ContractExport {
|
|
290
|
-
address: string
|
|
290
|
+
address: `0x${string}`;
|
|
291
291
|
abi: Abi;
|
|
292
|
+
argsData?: string;
|
|
293
|
+
bytecode?: `0x${string}`;
|
|
292
294
|
}
|
|
293
295
|
type ChainBlockExplorer = {
|
|
294
296
|
name: string;
|
|
@@ -366,6 +368,8 @@ declare function run(config: ResolvedConfig, options: {
|
|
|
366
368
|
tojs?: string[];
|
|
367
369
|
tots?: string[];
|
|
368
370
|
tojson?: string[];
|
|
371
|
+
totsm?: string[];
|
|
372
|
+
tojsm?: string[];
|
|
369
373
|
includeBytecode?: boolean;
|
|
370
374
|
}): Promise<void>;
|
|
371
375
|
|
package/dist/index.mjs
CHANGED
|
@@ -9,7 +9,7 @@ function objectMap(object, mapFn) {
|
|
|
9
9
|
}, {});
|
|
10
10
|
}
|
|
11
11
|
async function run(config, options) {
|
|
12
|
-
if (!options.tots && !options.tojs && !options.tojson) {
|
|
12
|
+
if (!options.tots && !options.tojs && !options.tojson && !options.tojsm && !options.totsm) {
|
|
13
13
|
console.log(`no filepath to export to are specified`);
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
@@ -42,6 +42,7 @@ async function run(config, options) {
|
|
|
42
42
|
address: d.address,
|
|
43
43
|
linkedData: d.linkedData,
|
|
44
44
|
bytecode: options.includeBytecode ? d.bytecode : void 0,
|
|
45
|
+
argsData: options.includeBytecode ? d.argsData : void 0,
|
|
45
46
|
startBlock: d.receipt?.blockNumber ? parseInt(d.receipt.blockNumber.slice(2), 16) : void 0
|
|
46
47
|
})),
|
|
47
48
|
name: config.network.name
|
|
@@ -49,7 +50,9 @@ async function run(config, options) {
|
|
|
49
50
|
const js = typeof options.tojs === "string" ? [options.tojs] : options.tojs || [];
|
|
50
51
|
const ts = typeof options.tots === "string" ? [options.tots] : options.tots || [];
|
|
51
52
|
const json = typeof options.tojson === "string" ? [options.tojson] : options.tojson || [];
|
|
52
|
-
|
|
53
|
+
const tsmodule = typeof options.totsm === "string" ? [options.totsm] : options.totsm || [];
|
|
54
|
+
const jsmodule = typeof options.tojsm === "string" ? [options.tojsm] : options.tojsm || [];
|
|
55
|
+
if (ts.length > 0) {
|
|
53
56
|
const newContent = `export default ${JSON.stringify(exportData, null, 2)} as const;`;
|
|
54
57
|
for (const tsFile of ts) {
|
|
55
58
|
const folderPath = path.dirname(tsFile);
|
|
@@ -57,7 +60,7 @@ async function run(config, options) {
|
|
|
57
60
|
fs.writeFileSync(tsFile, newContent);
|
|
58
61
|
}
|
|
59
62
|
}
|
|
60
|
-
if (
|
|
63
|
+
if (js.length > 0) {
|
|
61
64
|
const newContent = `export default /** @type {const} **/ (${JSON.stringify(exportData, null, 2)});`;
|
|
62
65
|
const dtsContent = `export = ${JSON.stringify(exportData, null, 2)} as const;`;
|
|
63
66
|
for (const jsFile of js) {
|
|
@@ -67,7 +70,7 @@ async function run(config, options) {
|
|
|
67
70
|
fs.writeFileSync(jsFile.replace(".js", ".d.ts"), dtsContent);
|
|
68
71
|
}
|
|
69
72
|
}
|
|
70
|
-
if (
|
|
73
|
+
if (json.length > 0) {
|
|
71
74
|
const newContent = JSON.stringify(exportData, null, 2);
|
|
72
75
|
for (const jsonFile of json) {
|
|
73
76
|
const folderPath = path.dirname(jsonFile);
|
|
@@ -75,6 +78,56 @@ async function run(config, options) {
|
|
|
75
78
|
fs.writeFileSync(jsonFile, newContent);
|
|
76
79
|
}
|
|
77
80
|
}
|
|
81
|
+
if (tsmodule.length > 0) {
|
|
82
|
+
let newContent = `export const chain = ${JSON.stringify(
|
|
83
|
+
{
|
|
84
|
+
chainId: exportData.chainId,
|
|
85
|
+
genesisHash: exportData.genesisHash,
|
|
86
|
+
chainInfo: exportData.chainInfo,
|
|
87
|
+
name: exportData.name
|
|
88
|
+
},
|
|
89
|
+
null,
|
|
90
|
+
2
|
|
91
|
+
)} as const;
|
|
92
|
+
`;
|
|
93
|
+
for (const contractName of Object.keys(exportData.contracts)) {
|
|
94
|
+
newContent += `export const ${contractName} = ${JSON.stringify(
|
|
95
|
+
exportData.contracts[contractName],
|
|
96
|
+
null,
|
|
97
|
+
2
|
|
98
|
+
)} as const;`;
|
|
99
|
+
}
|
|
100
|
+
for (const tsFile of tsmodule) {
|
|
101
|
+
const folderPath = path.dirname(tsFile);
|
|
102
|
+
fs.mkdirSync(folderPath, { recursive: true });
|
|
103
|
+
fs.writeFileSync(tsFile, newContent);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (jsmodule.length > 0) {
|
|
107
|
+
let newContent = `export const chain = /** @type {const} **/ (${JSON.stringify(
|
|
108
|
+
{
|
|
109
|
+
chainId: exportData.chainId,
|
|
110
|
+
genesisHash: exportData.genesisHash,
|
|
111
|
+
chainInfo: exportData.chainInfo,
|
|
112
|
+
name: exportData.name
|
|
113
|
+
},
|
|
114
|
+
null,
|
|
115
|
+
2
|
|
116
|
+
)});
|
|
117
|
+
`;
|
|
118
|
+
for (const contractName of Object.keys(exportData.contracts)) {
|
|
119
|
+
newContent += `export const ${contractName} = /** @type {const} **/ (${JSON.stringify(
|
|
120
|
+
exportData.contracts[contractName],
|
|
121
|
+
null,
|
|
122
|
+
2
|
|
123
|
+
)});`;
|
|
124
|
+
}
|
|
125
|
+
for (const jsFile of jsmodule) {
|
|
126
|
+
const folderPath = path.dirname(jsFile);
|
|
127
|
+
fs.mkdirSync(folderPath, { recursive: true });
|
|
128
|
+
fs.writeFileSync(jsFile, newContent);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
78
131
|
}
|
|
79
132
|
|
|
80
133
|
export { run };
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import {Abi, Address} from 'abitype';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport {Deployment, ResolvedConfig, chainTypes, getChain, loadDeployments} from 'rocketh';\n\nexport interface ContractExport {\n\taddress: string;\n\tabi: Abi;\n\t// linkedData?: any; TODO\n}\n\ntype ChainBlockExplorer = {\n\tname: string;\n\turl: string;\n\tapiUrl?: string | undefined;\n};\ntype ChainContract = {\n\taddress: Address;\n\tblockCreated?: number | undefined;\n};\n\ntype ChainNativeCurrency = {\n\tname: string;\n\t/** 2-6 characters long */\n\tsymbol: string;\n\tdecimals: number;\n};\n\ntype ChainRpcUrls = {\n\thttp: readonly string[];\n\twebSocket?: readonly string[] | undefined;\n};\n\n/**\n * @description Combines members of an intersection into a readable type.\n *\n * @see {@link https://twitter.com/mattpocockuk/status/1622730173446557697?s=20&t=NdpAcmEFXY01xkqU3KO0Mg}\n * @example\n * Prettify<{ a: string } & { b: string } & { c: number, d: bigint }>\n * => { a: string, b: string, c: number, d: bigint }\n */\ntype Prettify<T> = {\n\t[K in keyof T]: T[K];\n} & {};\n\nexport type ChainInfo = {\n\t/** ID in number form */\n\tid: number;\n\t/** Human-readable name */\n\tname: string;\n\t/** Collection of block explorers */\n\tblockExplorers?:\n\t\t| {\n\t\t\t\t[key: string]: ChainBlockExplorer;\n\t\t\t\tdefault: ChainBlockExplorer;\n\t\t }\n\t\t| undefined;\n\t/** Collection of contracts */\n\tcontracts?:\n\t\t| Prettify<\n\t\t\t\t{\n\t\t\t\t\t[key: string]: ChainContract | {[sourceId: number]: ChainContract | undefined} | undefined;\n\t\t\t\t} & {\n\t\t\t\t\tensRegistry?: ChainContract | undefined;\n\t\t\t\t\tensUniversalResolver?: ChainContract | undefined;\n\t\t\t\t\tmulticall3?: ChainContract | undefined;\n\t\t\t\t}\n\t\t >\n\t\t| undefined;\n\t/** Currency used by chain */\n\tnativeCurrency: ChainNativeCurrency;\n\t/** Collection of RPC endpoints */\n\trpcUrls: {\n\t\t[key: string]: ChainRpcUrls;\n\t\tdefault: ChainRpcUrls;\n\t};\n\t/** Source Chain ID (ie. the L1 chain) */\n\tsourceId?: number | undefined;\n\t/** Flag for test networks */\n\ttestnet?: boolean | undefined;\n\n\tchainType: 'zksync' | 'op-stack' | 'celo' | 'default';\n\n\t// this will bring in the following when reconstructed from the data above\n\n\t// /** Custom chain data. */\n\t// custom?: any;\n\n\t// /**\n\t// * Modifies how chain data structures (ie. Blocks, Transactions, etc)\n\t// * are formatted & typed.\n\t// */\n\t// formatters?: any | undefined;\n\t// /** Modifies how data (ie. Transactions) is serialized. */\n\t// serializers?: any | undefined;\n\t// /** Modifies how fees are derived. */\n\t// fees?: any | undefined;\n};\n\nexport type ExportedDeployments = {\n\tchainId: string;\n\tgenesisHash?: string;\n\tchainInfo: ChainInfo;\n\tname: string;\n\tcontracts: {[name: string]: ContractExport};\n};\n\ntype Trandformed<O, Value> = {\n\t[Property in keyof O]: Value;\n};\n\nfunction objectMap<V, N, O extends Trandformed<{}, V> = Trandformed<{}, V>>(\n\tobject: O,\n\tmapFn: (v: V) => N\n): Trandformed<O, N> {\n\treturn Object.keys(object).reduce((result, key) => {\n\t\t(result as any)[key] = mapFn((object as any)[key]);\n\t\treturn result;\n\t}, {} as Trandformed<O, N>);\n}\n\nexport async function run(\n\tconfig: ResolvedConfig,\n\toptions: {tojs?: string[]; tots?: string[]; tojson?: string[]; includeBytecode?: boolean}\n) {\n\tif (!options.tots && !options.tojs && !options.tojson) {\n\t\tconsole.log(`no filepath to export to are specified`);\n\t\treturn;\n\t}\n\n\tconst {deployments, chainId, genesisHash} = loadDeployments(config.deployments, config.network.name);\n\n\tif (!deployments || Object.keys(deployments).length === 0) {\n\t\tconsole.log(`no deployments to export`);\n\t\treturn;\n\t}\n\n\tif (!chainId) {\n\t\tthrow new Error(`no chainId found for ${config.network.name}`);\n\t}\n\n\tconst chain = getChain(chainId);\n\n\tconst chainInfo: ChainInfo = {\n\t\tid: chain.id,\n\t\tname: chain.name,\n\t\tnativeCurrency: chain.nativeCurrency,\n\t\trpcUrls: chain.rpcUrls,\n\t\tblockExplorers: chain.blockExplorers,\n\t\tchainType: chainTypes[chainId] || 'default',\n\t\tcontracts: chain.contracts,\n\t\tsourceId: chain.sourceId,\n\t\ttestnet: chain.testnet,\n\t};\n\n\tconst exportData: ExportedDeployments = {\n\t\tchainId,\n\t\tgenesisHash,\n\t\tchainInfo,\n\t\tcontracts: objectMap<Deployment<Abi>, ContractExport>(deployments, (d) => ({\n\t\t\tabi: d.abi,\n\t\t\taddress: d.address,\n\t\t\tlinkedData: d.linkedData,\n\t\t\tbytecode: options.includeBytecode ? d.bytecode : undefined,\n\t\t\tstartBlock: d.receipt?.blockNumber ? parseInt(d.receipt.blockNumber.slice(2), 16) : undefined,\n\t\t})),\n\t\tname: config.network.name,\n\t};\n\n\tconst js = typeof options.tojs === 'string' ? [options.tojs] : options.tojs || [];\n\tconst ts = typeof options.tots === 'string' ? [options.tots] : options.tots || [];\n\tconst json = typeof options.tojson === 'string' ? [options.tojson] : options.tojson || [];\n\n\tif (typeof ts === 'object' && ts.length > 0) {\n\t\tconst newContent = `export default ${JSON.stringify(exportData, null, 2)} as const;`;\n\t\tfor (const tsFile of ts) {\n\t\t\tconst folderPath = path.dirname(tsFile);\n\t\t\tfs.mkdirSync(folderPath, {recursive: true});\n\t\t\tfs.writeFileSync(tsFile, newContent);\n\t\t}\n\t}\n\n\tif (typeof js === 'object' && js.length > 0) {\n\t\tconst newContent = `export default /** @type {const} **/ (${JSON.stringify(exportData, null, 2)});`;\n\t\tconst dtsContent = `export = ${JSON.stringify(exportData, null, 2)} as const;`;\n\t\tfor (const jsFile of js) {\n\t\t\tconst folderPath = path.dirname(jsFile);\n\t\t\tfs.mkdirSync(folderPath, {recursive: true});\n\t\t\tfs.writeFileSync(jsFile, newContent);\n\t\t\tfs.writeFileSync(jsFile.replace('.js', '.d.ts'), dtsContent);\n\t\t}\n\t}\n\n\tif (typeof json === 'object' && json.length > 0) {\n\t\tconst newContent = JSON.stringify(exportData, null, 2);\n\t\tfor (const jsonFile of json) {\n\t\t\tconst folderPath = path.dirname(jsonFile);\n\t\t\tfs.mkdirSync(folderPath, {recursive: true});\n\t\t\tfs.writeFileSync(jsonFile, newContent);\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;AAIA,SAAS,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE;AAClC,EAAE,OAAO,MA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AC,aAAa,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAC3C,MAAM,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,UAAU,CAAC,CAAC;AACnE,KAAK;AACL,GAAG;AACH,EAAE,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;AACnD,IAAI,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAC3D,IAAI,KAAK,MAAM,QAAQ,IAAI,IAAI,EAAE;AACjC,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;AAChD,MAAM,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AACpD,MAAM,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;AAC7C,KAAK;AACL,GAAG;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import {Abi, Address} from 'abitype';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport {Deployment, ResolvedConfig, chainTypes, getChain, loadDeployments} from 'rocketh';\n\nexport interface ContractExport {\n\taddress: `0x${string}`;\n\tabi: Abi;\n\targsData?: string;\n\tbytecode?: `0x${string}`;\n\t// linkedData?: any; TODO\n}\n\ntype ChainBlockExplorer = {\n\tname: string;\n\turl: string;\n\tapiUrl?: string | undefined;\n};\ntype ChainContract = {\n\taddress: Address;\n\tblockCreated?: number | undefined;\n};\n\ntype ChainNativeCurrency = {\n\tname: string;\n\t/** 2-6 characters long */\n\tsymbol: string;\n\tdecimals: number;\n};\n\ntype ChainRpcUrls = {\n\thttp: readonly string[];\n\twebSocket?: readonly string[] | undefined;\n};\n\n/**\n * @description Combines members of an intersection into a readable type.\n *\n * @see {@link https://twitter.com/mattpocockuk/status/1622730173446557697?s=20&t=NdpAcmEFXY01xkqU3KO0Mg}\n * @example\n * Prettify<{ a: string } & { b: string } & { c: number, d: bigint }>\n * => { a: string, b: string, c: number, d: bigint }\n */\ntype Prettify<T> = {\n\t[K in keyof T]: T[K];\n} & {};\n\nexport type ChainInfo = {\n\t/** ID in number form */\n\tid: number;\n\t/** Human-readable name */\n\tname: string;\n\t/** Collection of block explorers */\n\tblockExplorers?:\n\t\t| {\n\t\t\t\t[key: string]: ChainBlockExplorer;\n\t\t\t\tdefault: ChainBlockExplorer;\n\t\t }\n\t\t| undefined;\n\t/** Collection of contracts */\n\tcontracts?:\n\t\t| Prettify<\n\t\t\t\t{\n\t\t\t\t\t[key: string]: ChainContract | {[sourceId: number]: ChainContract | undefined} | undefined;\n\t\t\t\t} & {\n\t\t\t\t\tensRegistry?: ChainContract | undefined;\n\t\t\t\t\tensUniversalResolver?: ChainContract | undefined;\n\t\t\t\t\tmulticall3?: ChainContract | undefined;\n\t\t\t\t}\n\t\t >\n\t\t| undefined;\n\t/** Currency used by chain */\n\tnativeCurrency: ChainNativeCurrency;\n\t/** Collection of RPC endpoints */\n\trpcUrls: {\n\t\t[key: string]: ChainRpcUrls;\n\t\tdefault: ChainRpcUrls;\n\t};\n\t/** Source Chain ID (ie. the L1 chain) */\n\tsourceId?: number | undefined;\n\t/** Flag for test networks */\n\ttestnet?: boolean | undefined;\n\n\tchainType: 'zksync' | 'op-stack' | 'celo' | 'default';\n\n\t// this will bring in the following when reconstructed from the data above\n\n\t// /** Custom chain data. */\n\t// custom?: any;\n\n\t// /**\n\t// * Modifies how chain data structures (ie. Blocks, Transactions, etc)\n\t// * are formatted & typed.\n\t// */\n\t// formatters?: any | undefined;\n\t// /** Modifies how data (ie. Transactions) is serialized. */\n\t// serializers?: any | undefined;\n\t// /** Modifies how fees are derived. */\n\t// fees?: any | undefined;\n};\n\nexport type ExportedDeployments = {\n\tchainId: string;\n\tgenesisHash?: string;\n\tchainInfo: ChainInfo;\n\tname: string;\n\tcontracts: {[name: string]: ContractExport};\n};\n\ntype Trandformed<O, Value> = {\n\t[Property in keyof O]: Value;\n};\n\nfunction objectMap<V, N, O extends Trandformed<{}, V> = Trandformed<{}, V>>(\n\tobject: O,\n\tmapFn: (v: V) => N\n): Trandformed<O, N> {\n\treturn Object.keys(object).reduce((result, key) => {\n\t\t(result as any)[key] = mapFn((object as any)[key]);\n\t\treturn result;\n\t}, {} as Trandformed<O, N>);\n}\n\nexport async function run(\n\tconfig: ResolvedConfig,\n\toptions: {\n\t\ttojs?: string[];\n\t\ttots?: string[];\n\t\ttojson?: string[];\n\t\ttotsm?: string[];\n\t\ttojsm?: string[];\n\t\tincludeBytecode?: boolean;\n\t}\n) {\n\tif (!options.tots && !options.tojs && !options.tojson && !options.tojsm && !options.totsm) {\n\t\tconsole.log(`no filepath to export to are specified`);\n\t\treturn;\n\t}\n\n\tconst {deployments, chainId, genesisHash} = loadDeployments(config.deployments, config.network.name);\n\n\tif (!deployments || Object.keys(deployments).length === 0) {\n\t\tconsole.log(`no deployments to export`);\n\t\treturn;\n\t}\n\n\tif (!chainId) {\n\t\tthrow new Error(`no chainId found for ${config.network.name}`);\n\t}\n\n\tconst chain = getChain(chainId);\n\n\tconst chainInfo: ChainInfo = {\n\t\tid: chain.id,\n\t\tname: chain.name,\n\t\tnativeCurrency: chain.nativeCurrency,\n\t\trpcUrls: chain.rpcUrls,\n\t\tblockExplorers: chain.blockExplorers,\n\t\tchainType: chainTypes[chainId] || 'default',\n\t\tcontracts: chain.contracts,\n\t\tsourceId: chain.sourceId,\n\t\ttestnet: chain.testnet,\n\t};\n\n\tconst exportData: ExportedDeployments = {\n\t\tchainId,\n\t\tgenesisHash,\n\t\tchainInfo,\n\t\tcontracts: objectMap<Deployment<Abi>, ContractExport>(deployments, (d) => ({\n\t\t\tabi: d.abi,\n\t\t\taddress: d.address,\n\t\t\tlinkedData: d.linkedData,\n\t\t\tbytecode: options.includeBytecode ? d.bytecode : undefined,\n\t\t\targsData: options.includeBytecode ? d.argsData : undefined,\n\t\t\tstartBlock: d.receipt?.blockNumber ? parseInt(d.receipt.blockNumber.slice(2), 16) : undefined,\n\t\t})),\n\t\tname: config.network.name,\n\t};\n\n\tconst js = typeof options.tojs === 'string' ? [options.tojs] : options.tojs || [];\n\tconst ts = typeof options.tots === 'string' ? [options.tots] : options.tots || [];\n\tconst json = typeof options.tojson === 'string' ? [options.tojson] : options.tojson || [];\n\n\tconst tsmodule = typeof options.totsm === 'string' ? [options.totsm] : options.totsm || [];\n\tconst jsmodule = typeof options.tojsm === 'string' ? [options.tojsm] : options.tojsm || [];\n\n\tif (ts.length > 0) {\n\t\tconst newContent = `export default ${JSON.stringify(exportData, null, 2)} as const;`;\n\t\tfor (const tsFile of ts) {\n\t\t\tconst folderPath = path.dirname(tsFile);\n\t\t\tfs.mkdirSync(folderPath, {recursive: true});\n\t\t\tfs.writeFileSync(tsFile, newContent);\n\t\t}\n\t}\n\n\tif (js.length > 0) {\n\t\tconst newContent = `export default /** @type {const} **/ (${JSON.stringify(exportData, null, 2)});`;\n\t\tconst dtsContent = `export = ${JSON.stringify(exportData, null, 2)} as const;`;\n\t\tfor (const jsFile of js) {\n\t\t\tconst folderPath = path.dirname(jsFile);\n\t\t\tfs.mkdirSync(folderPath, {recursive: true});\n\t\t\tfs.writeFileSync(jsFile, newContent);\n\t\t\tfs.writeFileSync(jsFile.replace('.js', '.d.ts'), dtsContent);\n\t\t}\n\t}\n\n\tif (json.length > 0) {\n\t\tconst newContent = JSON.stringify(exportData, null, 2);\n\t\tfor (const jsonFile of json) {\n\t\t\tconst folderPath = path.dirname(jsonFile);\n\t\t\tfs.mkdirSync(folderPath, {recursive: true});\n\t\t\tfs.writeFileSync(jsonFile, newContent);\n\t\t}\n\t}\n\n\tif (tsmodule.length > 0) {\n\t\tlet newContent = `export const chain = ${JSON.stringify(\n\t\t\t{\n\t\t\t\tchainId: exportData.chainId,\n\t\t\t\tgenesisHash: exportData.genesisHash,\n\t\t\t\tchainInfo: exportData.chainInfo,\n\t\t\t\tname: exportData.name,\n\t\t\t},\n\t\t\tnull,\n\t\t\t2\n\t\t)} as const;\\n`;\n\n\t\tfor (const contractName of Object.keys(exportData.contracts)) {\n\t\t\tnewContent += `export const ${contractName} = ${JSON.stringify(\n\t\t\t\t(exportData.contracts as any)[contractName],\n\t\t\t\tnull,\n\t\t\t\t2\n\t\t\t)} as const;`;\n\t\t}\n\n\t\tfor (const tsFile of tsmodule) {\n\t\t\tconst folderPath = path.dirname(tsFile);\n\t\t\tfs.mkdirSync(folderPath, {recursive: true});\n\t\t\tfs.writeFileSync(tsFile, newContent);\n\t\t}\n\t}\n\n\tif (jsmodule.length > 0) {\n\t\t// TODO test\n\t\tlet newContent = `export const chain = /** @type {const} **/ (${JSON.stringify(\n\t\t\t{\n\t\t\t\tchainId: exportData.chainId,\n\t\t\t\tgenesisHash: exportData.genesisHash,\n\t\t\t\tchainInfo: exportData.chainInfo,\n\t\t\t\tname: exportData.name,\n\t\t\t},\n\t\t\tnull,\n\t\t\t2\n\t\t)});\\n`;\n\n\t\tfor (const contractName of Object.keys(exportData.contracts)) {\n\t\t\tnewContent += `export const ${contractName} = /** @type {const} **/ (${JSON.stringify(\n\t\t\t\t(exportData.contracts as any)[contractName],\n\t\t\t\tnull,\n\t\t\t\t2\n\t\t\t)});`;\n\t\t}\n\n\t\tfor (const jsFile of jsmodule) {\n\t\t\tconst folderPath = path.dirname(jsFile);\n\t\t\tfs.mkdirSync(folderPath, {recursive: true});\n\t\t\tfs.writeFileSync(jsFile, newContent);\n\t\t}\n\t}\n}\n"],"names":[],"mappings":";;;;AAIA,SAAS,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE;AAClC,EAAE,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,GAAG,KAAK;AACrD,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,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,UAAU,CAAC,SAAS,CAAC,YAAY,CAAC;AAC1C,QAAQ,IAAI;AACZ,QAAQ,CAAC;AACT,OAAO,CAAC,EAAE,CAAC,CAAC;AACZ,KAAK;AACL,IAAI,KAAK,MAAM,MAAM,IAAI,QAAQ,EAAE;AACnC,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AAC9C,MAAM,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AACpD,MAAM,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAC3C,KAAK;AACL,GAAG;AACH;;;;"}
|
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -16,6 +16,14 @@ program
|
|
|
16
16
|
.option('--ts <value>', 'list of filepath where the typescript export will be written, separated by commas')
|
|
17
17
|
.option('--js <value>', 'list of filepath where the javascript export will be written, separated by commas')
|
|
18
18
|
.option('--json <value>', 'list of filepath where the json export will be written, separated by commas')
|
|
19
|
+
.option(
|
|
20
|
+
'--tsm <value>',
|
|
21
|
+
'list of filepath where the typescript export with individual export will be written, separated by commas'
|
|
22
|
+
)
|
|
23
|
+
.option(
|
|
24
|
+
'--jsm <value>',
|
|
25
|
+
'list of filepath where the javascript export with individual exportwill be written, separated by commas'
|
|
26
|
+
)
|
|
19
27
|
.option('-b, --bytecode', 'if set, the bytecode will also be part of the output')
|
|
20
28
|
.requiredOption('-n, --network <value>', 'network context to use')
|
|
21
29
|
.parse(process.argv);
|
|
@@ -26,5 +34,7 @@ run(resolvedConfig, {
|
|
|
26
34
|
tots: options.ts ? options.ts.split(',') : undefined,
|
|
27
35
|
tojson: options.json ? options.json.split(',') : undefined,
|
|
28
36
|
tojs: options.js ? options.js.split(',') : undefined,
|
|
37
|
+
totsm: options.tsm ? options.tsm.split(',') : undefined,
|
|
38
|
+
tojsm: options.jsm ? options.jsm.split(',') : undefined,
|
|
29
39
|
includeBytecode: options.bytecode,
|
|
30
40
|
});
|
package/src/index.ts
CHANGED
|
@@ -5,8 +5,10 @@ import path from 'node:path';
|
|
|
5
5
|
import {Deployment, ResolvedConfig, chainTypes, getChain, loadDeployments} from 'rocketh';
|
|
6
6
|
|
|
7
7
|
export interface ContractExport {
|
|
8
|
-
address: string
|
|
8
|
+
address: `0x${string}`;
|
|
9
9
|
abi: Abi;
|
|
10
|
+
argsData?: string;
|
|
11
|
+
bytecode?: `0x${string}`;
|
|
10
12
|
// linkedData?: any; TODO
|
|
11
13
|
}
|
|
12
14
|
|
|
@@ -122,9 +124,16 @@ function objectMap<V, N, O extends Trandformed<{}, V> = Trandformed<{}, V>>(
|
|
|
122
124
|
|
|
123
125
|
export async function run(
|
|
124
126
|
config: ResolvedConfig,
|
|
125
|
-
options: {
|
|
127
|
+
options: {
|
|
128
|
+
tojs?: string[];
|
|
129
|
+
tots?: string[];
|
|
130
|
+
tojson?: string[];
|
|
131
|
+
totsm?: string[];
|
|
132
|
+
tojsm?: string[];
|
|
133
|
+
includeBytecode?: boolean;
|
|
134
|
+
}
|
|
126
135
|
) {
|
|
127
|
-
if (!options.tots && !options.tojs && !options.tojson) {
|
|
136
|
+
if (!options.tots && !options.tojs && !options.tojson && !options.tojsm && !options.totsm) {
|
|
128
137
|
console.log(`no filepath to export to are specified`);
|
|
129
138
|
return;
|
|
130
139
|
}
|
|
@@ -163,6 +172,7 @@ export async function run(
|
|
|
163
172
|
address: d.address,
|
|
164
173
|
linkedData: d.linkedData,
|
|
165
174
|
bytecode: options.includeBytecode ? d.bytecode : undefined,
|
|
175
|
+
argsData: options.includeBytecode ? d.argsData : undefined,
|
|
166
176
|
startBlock: d.receipt?.blockNumber ? parseInt(d.receipt.blockNumber.slice(2), 16) : undefined,
|
|
167
177
|
})),
|
|
168
178
|
name: config.network.name,
|
|
@@ -172,7 +182,10 @@ export async function run(
|
|
|
172
182
|
const ts = typeof options.tots === 'string' ? [options.tots] : options.tots || [];
|
|
173
183
|
const json = typeof options.tojson === 'string' ? [options.tojson] : options.tojson || [];
|
|
174
184
|
|
|
175
|
-
|
|
185
|
+
const tsmodule = typeof options.totsm === 'string' ? [options.totsm] : options.totsm || [];
|
|
186
|
+
const jsmodule = typeof options.tojsm === 'string' ? [options.tojsm] : options.tojsm || [];
|
|
187
|
+
|
|
188
|
+
if (ts.length > 0) {
|
|
176
189
|
const newContent = `export default ${JSON.stringify(exportData, null, 2)} as const;`;
|
|
177
190
|
for (const tsFile of ts) {
|
|
178
191
|
const folderPath = path.dirname(tsFile);
|
|
@@ -181,7 +194,7 @@ export async function run(
|
|
|
181
194
|
}
|
|
182
195
|
}
|
|
183
196
|
|
|
184
|
-
if (
|
|
197
|
+
if (js.length > 0) {
|
|
185
198
|
const newContent = `export default /** @type {const} **/ (${JSON.stringify(exportData, null, 2)});`;
|
|
186
199
|
const dtsContent = `export = ${JSON.stringify(exportData, null, 2)} as const;`;
|
|
187
200
|
for (const jsFile of js) {
|
|
@@ -192,7 +205,7 @@ export async function run(
|
|
|
192
205
|
}
|
|
193
206
|
}
|
|
194
207
|
|
|
195
|
-
if (
|
|
208
|
+
if (json.length > 0) {
|
|
196
209
|
const newContent = JSON.stringify(exportData, null, 2);
|
|
197
210
|
for (const jsonFile of json) {
|
|
198
211
|
const folderPath = path.dirname(jsonFile);
|
|
@@ -200,4 +213,59 @@ export async function run(
|
|
|
200
213
|
fs.writeFileSync(jsonFile, newContent);
|
|
201
214
|
}
|
|
202
215
|
}
|
|
216
|
+
|
|
217
|
+
if (tsmodule.length > 0) {
|
|
218
|
+
let newContent = `export const chain = ${JSON.stringify(
|
|
219
|
+
{
|
|
220
|
+
chainId: exportData.chainId,
|
|
221
|
+
genesisHash: exportData.genesisHash,
|
|
222
|
+
chainInfo: exportData.chainInfo,
|
|
223
|
+
name: exportData.name,
|
|
224
|
+
},
|
|
225
|
+
null,
|
|
226
|
+
2
|
|
227
|
+
)} as const;\n`;
|
|
228
|
+
|
|
229
|
+
for (const contractName of Object.keys(exportData.contracts)) {
|
|
230
|
+
newContent += `export const ${contractName} = ${JSON.stringify(
|
|
231
|
+
(exportData.contracts as any)[contractName],
|
|
232
|
+
null,
|
|
233
|
+
2
|
|
234
|
+
)} as const;`;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
for (const tsFile of tsmodule) {
|
|
238
|
+
const folderPath = path.dirname(tsFile);
|
|
239
|
+
fs.mkdirSync(folderPath, {recursive: true});
|
|
240
|
+
fs.writeFileSync(tsFile, newContent);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (jsmodule.length > 0) {
|
|
245
|
+
// TODO test
|
|
246
|
+
let newContent = `export const chain = /** @type {const} **/ (${JSON.stringify(
|
|
247
|
+
{
|
|
248
|
+
chainId: exportData.chainId,
|
|
249
|
+
genesisHash: exportData.genesisHash,
|
|
250
|
+
chainInfo: exportData.chainInfo,
|
|
251
|
+
name: exportData.name,
|
|
252
|
+
},
|
|
253
|
+
null,
|
|
254
|
+
2
|
|
255
|
+
)});\n`;
|
|
256
|
+
|
|
257
|
+
for (const contractName of Object.keys(exportData.contracts)) {
|
|
258
|
+
newContent += `export const ${contractName} = /** @type {const} **/ (${JSON.stringify(
|
|
259
|
+
(exportData.contracts as any)[contractName],
|
|
260
|
+
null,
|
|
261
|
+
2
|
|
262
|
+
)});`;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
for (const jsFile of jsmodule) {
|
|
266
|
+
const folderPath = path.dirname(jsFile);
|
|
267
|
+
fs.mkdirSync(folderPath, {recursive: true});
|
|
268
|
+
fs.writeFileSync(jsFile, newContent);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
203
271
|
}
|