@rocketh/export 0.10.1

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.
@@ -0,0 +1,3 @@
1
+ dist/
2
+ node_modules/
3
+ package.json
package/.prettierrc ADDED
@@ -0,0 +1,7 @@
1
+ {
2
+ "useTabs": true,
3
+ "singleQuote": true,
4
+
5
+ "printWidth": 120,
6
+ "bracketSpacing": false
7
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # @rocketh/export
2
+
3
+ ## 0.10.1
4
+
5
+ ### Patch Changes
6
+
7
+ - use pkgroll and @rocketh namespace
8
+ - Updated dependencies
9
+ - rocketh@0.10.9
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # rocketh-export
package/dist/cli.cjs ADDED
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ var rocketh = require('rocketh');
5
+ var index = require('./index.cjs');
6
+ var commander = require('commander');
7
+ require('node:fs');
8
+ require('node:path');
9
+
10
+ var name = "@rocketh/export";
11
+ var version = "0.10.0";
12
+ var description = "export deployments";
13
+ var publishConfig = {
14
+ access: "public"
15
+ };
16
+ var type = "module";
17
+ var main = "dist/index.cjs";
18
+ var module$1 = "dist/index.mjs";
19
+ var types = "dist/index.d.ts";
20
+ var bin = {
21
+ "rocketh-export": "dist/cli.cjs"
22
+ };
23
+ var devDependencies = {
24
+ "@types/node": "^20.12.7",
25
+ abitype: "^1.0.2",
26
+ "eip-1193": "^0.5.0",
27
+ pkgroll: "^2.0.2",
28
+ rimraf: "^5.0.5",
29
+ typescript: "^5.4.5"
30
+ };
31
+ var peerDependencies = {
32
+ rocketh: "workspace:*"
33
+ };
34
+ var dependencies = {
35
+ "@types/fs-extra": "^11.0.4",
36
+ chalk: "^5.3.0",
37
+ commander: "^12.0.0",
38
+ "fs-extra": "^11.2.0",
39
+ rocketh: "workspace:*"
40
+ };
41
+ var scripts = {
42
+ build: "rimraf dist && pkgroll --sourcemap",
43
+ dev: "pkgroll --watch"
44
+ };
45
+ var pkg = {
46
+ name: name,
47
+ version: version,
48
+ description: description,
49
+ publishConfig: publishConfig,
50
+ type: type,
51
+ main: main,
52
+ module: module$1,
53
+ types: types,
54
+ ".": {
55
+ require: {
56
+ types: "./dist/index.d.ts",
57
+ "default": "./dist/index.cjs"
58
+ },
59
+ "import": {
60
+ types: "./dist/index.d.ts",
61
+ "default": "./dist/index.mjs"
62
+ }
63
+ },
64
+ bin: bin,
65
+ devDependencies: devDependencies,
66
+ peerDependencies: peerDependencies,
67
+ dependencies: dependencies,
68
+ scripts: scripts
69
+ };
70
+
71
+ const commandName = pkg.name;
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("-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
+ const options = program.opts();
75
+ const resolvedConfig = rocketh.readAndResolveConfig({ ...options, ignoreMissingRPC: true });
76
+ index.run(resolvedConfig, {
77
+ tots: options.ts ? options.ts.split(",") : void 0,
78
+ tojson: options.json ? options.json.split(",") : void 0,
79
+ tojs: options.js ? options.js.split(",") : void 0,
80
+ includeBytecode: options.bytecode
81
+ });
82
+ //# sourceMappingURL=cli.cjs.map
@@ -0,0 +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,CAAO,CAAC,CAAA,CAAA,CAAA,CAAI,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAW,CAAC,CAAC,CAAG,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,C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CAAC,CAAI,CAAA,CAAA,CAAA,CAAC,KAAK,CAAC,CAAA,CAAA,CAAG,CAAC,CAAA,CAAA,CAAG,KAAI,CAAA,CAAA;AACvD,CAAA,CAAE,IAAI,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAO,CAAC,CAAA,CAAE,GAAG,CAAC,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,KAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,KAAA,CAAA,CAAA;AACtB,CAAA,CAAE,CAAe,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAE,CAAO,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAC,CAAQ,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACnC,CAAC,CAAC"}
package/dist/cli.mjs ADDED
@@ -0,0 +1,79 @@
1
+ import { readAndResolveConfig } from 'rocketh';
2
+ import { run } from './index.mjs';
3
+ import { Command } from 'commander';
4
+ import 'node:fs';
5
+ import 'node:path';
6
+
7
+ var name = "@rocketh/export";
8
+ var version = "0.10.0";
9
+ var description = "export deployments";
10
+ var publishConfig = {
11
+ access: "public"
12
+ };
13
+ var type = "module";
14
+ var main = "dist/index.cjs";
15
+ var module = "dist/index.mjs";
16
+ var types = "dist/index.d.ts";
17
+ var bin = {
18
+ "rocketh-export": "dist/cli.cjs"
19
+ };
20
+ var devDependencies = {
21
+ "@types/node": "^20.12.7",
22
+ abitype: "^1.0.2",
23
+ "eip-1193": "^0.5.0",
24
+ pkgroll: "^2.0.2",
25
+ rimraf: "^5.0.5",
26
+ typescript: "^5.4.5"
27
+ };
28
+ var peerDependencies = {
29
+ rocketh: "workspace:*"
30
+ };
31
+ var dependencies = {
32
+ "@types/fs-extra": "^11.0.4",
33
+ chalk: "^5.3.0",
34
+ commander: "^12.0.0",
35
+ "fs-extra": "^11.2.0",
36
+ rocketh: "workspace:*"
37
+ };
38
+ var scripts = {
39
+ build: "rimraf dist && pkgroll --sourcemap",
40
+ dev: "pkgroll --watch"
41
+ };
42
+ var pkg = {
43
+ name: name,
44
+ version: version,
45
+ description: description,
46
+ publishConfig: publishConfig,
47
+ type: type,
48
+ main: main,
49
+ module: module,
50
+ types: types,
51
+ ".": {
52
+ require: {
53
+ types: "./dist/index.d.ts",
54
+ "default": "./dist/index.cjs"
55
+ },
56
+ "import": {
57
+ types: "./dist/index.d.ts",
58
+ "default": "./dist/index.mjs"
59
+ }
60
+ },
61
+ bin: bin,
62
+ devDependencies: devDependencies,
63
+ peerDependencies: peerDependencies,
64
+ dependencies: dependencies,
65
+ scripts: scripts
66
+ };
67
+
68
+ const commandName = pkg.name;
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("-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
+ const options = program.opts();
72
+ const resolvedConfig = readAndResolveConfig({ ...options, ignoreMissingRPC: true });
73
+ run(resolvedConfig, {
74
+ tots: options.ts ? options.ts.split(",") : void 0,
75
+ tojson: options.json ? options.json.split(",") : void 0,
76
+ tojs: options.js ? options.js.split(",") : void 0,
77
+ includeBytecode: options.bytecode
78
+ });
79
+ //# sourceMappingURL=cli.mjs.map
@@ -0,0 +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,CAAA,gBAAA,EAAA,sDAAA,CAAA,CAAA,cAAA,CAAA,uBAAA,EAAA,wBAAA,CAAA,CAAA,KAAA,CAAA,OAAA,CAAA,IAAA,CAAA,CAAA;AAC7B,MAAA,OAAA,GAAA,OAAA,CAAA,IAAA,EAAA,CAAA;AACA,MAAM,cAAc,GAAG,oBAAO,CAAA,EAAA,GAAA,OAAA,EAAA,gBAAA,EAAA,IAAA,EAAA,CAAA,CAAA;AAC9B,GAAG,CAAC,cAAG,EAAA;AACP,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,GAAC,OAAA,CAAA,EAAA,CAAA,KAAA,CAAA,GAAA,CAAA,GAAA,KAAA,CAAA;AACnB,EAAE,MAAM,EAAE,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,KAAI,CAAA;AACvD,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,GAAG,OAAC,CAAA,EAAA,CAAA,KAAA,CAAA,GAAA,CAAA,GAAA,KAAA,CAAA;AACtB,EAAE,eAAe,EAAE,OAAO,CAAC,QAAQ;AACnC,CAAC,CAAC"}
package/dist/index.cjs ADDED
@@ -0,0 +1,83 @@
1
+ 'use strict';
2
+
3
+ var fs = require('node:fs');
4
+ var path = require('node:path');
5
+ var rocketh = require('rocketh');
6
+
7
+ function objectMap(object, mapFn) {
8
+ return Object.keys(object).reduce((result, key) => {
9
+ result[key] = mapFn(object[key]);
10
+ return result;
11
+ }, {});
12
+ }
13
+ async function run(config, options) {
14
+ if (!options.tots && !options.tojs && !options.tojson) {
15
+ console.log(`no filepath to export to are specified`);
16
+ return;
17
+ }
18
+ const { deployments, chainId, genesisHash } = rocketh.loadDeployments(config.deployments, config.network.name);
19
+ if (!deployments || Object.keys(deployments).length === 0) {
20
+ console.log(`no deployments to export`);
21
+ return;
22
+ }
23
+ if (!chainId) {
24
+ throw new Error(`no chainId found for ${config.network.name}`);
25
+ }
26
+ const chain = rocketh.getChain(chainId);
27
+ const chainInfo = {
28
+ id: chain.id,
29
+ name: chain.name,
30
+ nativeCurrency: chain.nativeCurrency,
31
+ rpcUrls: chain.rpcUrls,
32
+ blockExplorers: chain.blockExplorers,
33
+ chainType: rocketh.chainTypes[chainId] || "default",
34
+ contracts: chain.contracts,
35
+ sourceId: chain.sourceId,
36
+ testnet: chain.testnet
37
+ };
38
+ const exportData = {
39
+ chainId,
40
+ genesisHash,
41
+ chainInfo,
42
+ contracts: objectMap(deployments, (d) => ({
43
+ abi: d.abi,
44
+ address: d.address,
45
+ linkedData: d.linkedData,
46
+ bytecode: options.includeBytecode ? d.bytecode : void 0,
47
+ startBlock: d.receipt?.blockNumber ? parseInt(d.receipt.blockNumber.slice(2), 16) : void 0
48
+ })),
49
+ name: config.network.name
50
+ };
51
+ const js = typeof options.tojs === "string" ? [options.tojs] : options.tojs || [];
52
+ const ts = typeof options.tots === "string" ? [options.tots] : options.tots || [];
53
+ const json = typeof options.tojson === "string" ? [options.tojson] : options.tojson || [];
54
+ if (typeof ts === "object" && ts.length > 0) {
55
+ const newContent = `export default ${JSON.stringify(exportData, null, 2)} as const;`;
56
+ for (const tsFile of ts) {
57
+ const folderPath = path.dirname(tsFile);
58
+ fs.mkdirSync(folderPath, { recursive: true });
59
+ fs.writeFileSync(tsFile, newContent);
60
+ }
61
+ }
62
+ if (typeof js === "object" && js.length > 0) {
63
+ const newContent = `export default /** @type {const} **/ (${JSON.stringify(exportData, null, 2)});`;
64
+ const dtsContent = `export = ${JSON.stringify(exportData, null, 2)} as const;`;
65
+ for (const jsFile of js) {
66
+ const folderPath = path.dirname(jsFile);
67
+ fs.mkdirSync(folderPath, { recursive: true });
68
+ fs.writeFileSync(jsFile, newContent);
69
+ fs.writeFileSync(jsFile.replace(".js", ".d.ts"), dtsContent);
70
+ }
71
+ }
72
+ if (typeof json === "object" && json.length > 0) {
73
+ const newContent = JSON.stringify(exportData, null, 2);
74
+ for (const jsonFile of json) {
75
+ const folderPath = path.dirname(jsonFile);
76
+ fs.mkdirSync(folderPath, { recursive: true });
77
+ fs.writeFileSync(jsonFile, newContent);
78
+ }
79
+ }
80
+ }
81
+
82
+ exports.run = run;
83
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +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,CAAC,WAAW,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;AAC7D,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC;AAC5C,IAAI,OAAO;AACX,GAAG;AACH,EAAE,IAAI,CAAC,OAAO,EAAE;AAChB,IAAI,MAAM,IAAI,KAAK,CAAC,CAAC,qBAAqB,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,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C,UAAU,CAAC,CAAC;AACnF,IAAI,KAAK,MAAM,MAAM,IAAI,EAAE,EAAE;AAC7B,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,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;;;;"}
@@ -0,0 +1,314 @@
1
+ import { ResolvedConfig } from 'rocketh';
2
+
3
+ type Register = {};
4
+ type ResolvedRegister = {
5
+ /**
6
+ * TypeScript type to use for `address` values
7
+ * @default `0x${string}`
8
+ */
9
+ AddressType: Register extends {
10
+ AddressType: infer type;
11
+ } ? type : DefaultRegister['AddressType'];
12
+ /**
13
+ * TypeScript type to use for `int<M>` and `uint<M>` values, where `M > 48`
14
+ * @default bigint
15
+ */
16
+ BigIntType: Register extends {
17
+ BigIntType: infer type;
18
+ } ? type : DefaultRegister['BigIntType'];
19
+ /**
20
+ * TypeScript type to use for `bytes` values
21
+ * @default { inputs: `0x${string}`; outputs: `0x${string}`; }
22
+ */
23
+ BytesType: Register extends {
24
+ BytesType: infer type extends {
25
+ inputs: unknown;
26
+ outputs: unknown;
27
+ };
28
+ } ? type : DefaultRegister['BytesType'];
29
+ /**
30
+ * TypeScript type to use for `int<M>` and `uint<M>` values, where `M <= 48`
31
+ * @default number
32
+ */
33
+ IntType: Register extends {
34
+ IntType: infer type;
35
+ } ? type : DefaultRegister['IntType'];
36
+ /**
37
+ * Maximum depth for nested array types (e.g. string[][])
38
+ *
39
+ * Note: You probably only want to set this to a specific number if parsed types are returning as `unknown`
40
+ * and you want to figure out why. If you set this, you should probably also reduce `FixedArrayMaxLength`.
41
+ *
42
+ * @default false
43
+ */
44
+ ArrayMaxDepth: Register extends {
45
+ ArrayMaxDepth: infer type extends number | false;
46
+ } ? type : DefaultRegister['ArrayMaxDepth'];
47
+ /**
48
+ * Lower bound for fixed array length
49
+ * @default 1
50
+ */
51
+ FixedArrayMinLength: Register extends {
52
+ FixedArrayMinLength: infer type extends number;
53
+ } ? type : DefaultRegister['FixedArrayMinLength'];
54
+ /**
55
+ * Upper bound for fixed array length
56
+ * @default 99
57
+ */
58
+ FixedArrayMaxLength: Register extends {
59
+ FixedArrayMaxLength: infer type extends number;
60
+ } ? type : DefaultRegister['FixedArrayMaxLength'];
61
+ /**
62
+ * When set, validates {@link AbiParameter}'s `type` against {@link AbiType}
63
+ *
64
+ * Note: You probably only want to set this to `true` if parsed types are returning as `unknown`
65
+ * and you want to figure out why.
66
+ *
67
+ * @default false
68
+ */
69
+ StrictAbiType: Register extends {
70
+ StrictAbiType: infer type extends boolean;
71
+ } ? type : DefaultRegister['StrictAbiType'];
72
+ };
73
+ type DefaultRegister = {
74
+ /** Maximum depth for nested array types (e.g. string[][]) */
75
+ ArrayMaxDepth: false;
76
+ /** Lower bound for fixed array length */
77
+ FixedArrayMinLength: 1;
78
+ /** Upper bound for fixed array length */
79
+ FixedArrayMaxLength: 99;
80
+ /** TypeScript type to use for `address` values */
81
+ AddressType: `0x${string}`;
82
+ /** TypeScript type to use for `bytes` values */
83
+ BytesType: {
84
+ /** TypeScript type to use for `bytes` input values */
85
+ inputs: `0x${string}`;
86
+ /** TypeScript type to use for `bytes` output values */
87
+ outputs: `0x${string}`;
88
+ };
89
+ /** TypeScript type to use for `int<M>` and `uint<M>` values, where `M > 48` */
90
+ BigIntType: bigint;
91
+ /** TypeScript type to use for `int<M>` and `uint<M>` values, where `M <= 48` */
92
+ IntType: number;
93
+ /** When set, validates {@link AbiParameter}'s `type` against {@link AbiType} */
94
+ StrictAbiType: false;
95
+ };
96
+
97
+ /**
98
+ * Combines members of an intersection into a readable type.
99
+ *
100
+ * @link https://twitter.com/mattpocockuk/status/1622730173446557697?s=20&t=NdpAcmEFXY01xkqU3KO0Mg
101
+ * @example
102
+ * type Result = Pretty<{ a: string } | { b: string } | { c: number, d: bigint }>
103
+ * // ^? type Result = { a: string; b: string; c: number; d: bigint }
104
+ */
105
+ type Pretty<T> = {
106
+ [K in keyof T]: T[K];
107
+ } & unknown;
108
+ /**
109
+ * Creates range between two positive numbers using [tail recursion](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-5.html#tail-recursion-elimination-on-conditional-types).
110
+ *
111
+ * @param Start - Number to start range
112
+ * @param Stop - Number to end range
113
+ * @returns Array with inclusive range from {@link Start} to {@link Stop}
114
+ *
115
+ * @example
116
+ * type Result = Range<1, 3>
117
+ * // ^? type Result = [1, 2, 3]
118
+ */
119
+ type Range<Start extends number, Stop extends number, Result extends number[] = [], Padding extends 0[] = [], Current extends number = [...Padding, ...Result]['length'] & number> = Current extends Stop ? Current extends Start ? [Current] : Result extends [] ? [] : [...Result, Current] : Current extends Start ? Range<Start, Stop, [Current], Padding> : Result extends [] ? Range<Start, Stop, [], [...Padding, 0]> : Range<Start, Stop, [...Result, Current], Padding>;
120
+
121
+ type Address = ResolvedRegister['AddressType'];
122
+ type MBytes = '' | 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;
123
+ type MBits = '' | 8 | 16 | 24 | 32 | 40 | 48 | 56 | 64 | 72 | 80 | 88 | 96 | 104 | 112 | 120 | 128 | 136 | 144 | 152 | 160 | 168 | 176 | 184 | 192 | 200 | 208 | 216 | 224 | 232 | 240 | 248 | 256;
124
+ type SolidityAddress = 'address';
125
+ type SolidityBool = 'bool';
126
+ type SolidityBytes = `bytes${MBytes}`;
127
+ type SolidityFunction = 'function';
128
+ type SolidityString = 'string';
129
+ type SolidityTuple = 'tuple';
130
+ type SolidityInt = `${'u' | ''}int${MBits}`;
131
+ type SolidityFixedArrayRange = Range<ResolvedRegister['FixedArrayMinLength'], ResolvedRegister['FixedArrayMaxLength']>[number];
132
+ /**
133
+ * Recursively build arrays up to maximum depth
134
+ * or use a more broad type when maximum depth is switched "off"
135
+ */
136
+ type _BuildArrayTypes<T extends string, Depth extends readonly number[] = []> = ResolvedRegister['ArrayMaxDepth'] extends false ? `${T}[${string}]` : Depth['length'] extends ResolvedRegister['ArrayMaxDepth'] ? T : T extends `${any}[${SolidityFixedArrayRange | ''}]` ? _BuildArrayTypes<T | `${T}[${SolidityFixedArrayRange | ''}]`, [...Depth, 1]> : _BuildArrayTypes<`${T}[${SolidityFixedArrayRange | ''}]`, [...Depth, 1]>;
137
+ type SolidityArrayWithoutTuple = _BuildArrayTypes<SolidityAddress | SolidityBool | SolidityBytes | SolidityFunction | SolidityInt | SolidityString>;
138
+ type SolidityArrayWithTuple = _BuildArrayTypes<SolidityTuple>;
139
+ type SolidityArray = SolidityArrayWithoutTuple | SolidityArrayWithTuple;
140
+ type AbiType = SolidityArray | SolidityAddress | SolidityBool | SolidityBytes | SolidityFunction | SolidityInt | SolidityString | SolidityTuple;
141
+ type ResolvedAbiType = ResolvedRegister['StrictAbiType'] extends true ? AbiType : string;
142
+ type AbiInternalType = ResolvedAbiType | `address ${string}` | `contract ${string}` | `enum ${string}` | `struct ${string}`;
143
+ type AbiParameter = Pretty<{
144
+ type: ResolvedAbiType;
145
+ name?: string | undefined;
146
+ /** Representation used by Solidity compiler */
147
+ internalType?: AbiInternalType | undefined;
148
+ } & ({
149
+ type: Exclude<ResolvedAbiType, SolidityTuple | SolidityArrayWithTuple>;
150
+ } | {
151
+ type: SolidityTuple | SolidityArrayWithTuple;
152
+ components: readonly AbiParameter[];
153
+ })>;
154
+ type AbiEventParameter = Pretty<AbiParameter & {
155
+ indexed?: boolean | undefined;
156
+ }>;
157
+ /**
158
+ * State mutability for {@link AbiFunction}
159
+ *
160
+ * @see https://docs.soliditylang.org/en/latest/contracts.html#state-mutability
161
+ */
162
+ type AbiStateMutability = 'pure' | 'view' | 'nonpayable' | 'payable';
163
+ /** ABI ["function"](https://docs.soliditylang.org/en/latest/abi-spec.html#json) type */
164
+ type AbiFunction = {
165
+ type: 'function';
166
+ /**
167
+ * @deprecated use `pure` or `view` from {@link AbiStateMutability} instead
168
+ * @see https://github.com/ethereum/solidity/issues/992
169
+ */
170
+ constant?: boolean | undefined;
171
+ /**
172
+ * @deprecated Vyper used to provide gas estimates
173
+ * @see https://github.com/vyperlang/vyper/issues/2151
174
+ */
175
+ gas?: number | undefined;
176
+ inputs: readonly AbiParameter[];
177
+ name: string;
178
+ outputs: readonly AbiParameter[];
179
+ /**
180
+ * @deprecated use `payable` or `nonpayable` from {@link AbiStateMutability} instead
181
+ * @see https://github.com/ethereum/solidity/issues/992
182
+ */
183
+ payable?: boolean | undefined;
184
+ stateMutability: AbiStateMutability;
185
+ };
186
+ /** ABI ["constructor"](https://docs.soliditylang.org/en/latest/abi-spec.html#json) type */
187
+ type AbiConstructor = {
188
+ type: 'constructor';
189
+ inputs: readonly AbiParameter[];
190
+ /**
191
+ * @deprecated use `payable` or `nonpayable` from {@link AbiStateMutability} instead
192
+ * @see https://github.com/ethereum/solidity/issues/992
193
+ */
194
+ payable?: boolean | undefined;
195
+ stateMutability: Extract<AbiStateMutability, 'payable' | 'nonpayable'>;
196
+ };
197
+ /** ABI ["fallback"](https://docs.soliditylang.org/en/latest/abi-spec.html#json) type */
198
+ type AbiFallback = {
199
+ type: 'fallback';
200
+ inputs?: readonly [] | undefined;
201
+ /**
202
+ * @deprecated use `payable` or `nonpayable` from {@link AbiStateMutability} instead
203
+ * @see https://github.com/ethereum/solidity/issues/992
204
+ */
205
+ payable?: boolean | undefined;
206
+ stateMutability: Extract<AbiStateMutability, 'payable' | 'nonpayable'>;
207
+ };
208
+ /** ABI ["receive"](https://docs.soliditylang.org/en/latest/contracts.html#receive-ether-function) type */
209
+ type AbiReceive = {
210
+ type: 'receive';
211
+ stateMutability: Extract<AbiStateMutability, 'payable'>;
212
+ };
213
+ /** ABI ["event"](https://docs.soliditylang.org/en/latest/abi-spec.html#events) type */
214
+ type AbiEvent = {
215
+ type: 'event';
216
+ anonymous?: boolean | undefined;
217
+ inputs: readonly AbiEventParameter[];
218
+ name: string;
219
+ };
220
+ /** ABI ["error"](https://docs.soliditylang.org/en/latest/abi-spec.html#errors) type */
221
+ type AbiError = {
222
+ type: 'error';
223
+ inputs: readonly AbiParameter[];
224
+ name: string;
225
+ };
226
+ /**
227
+ * Contract [ABI Specification](https://docs.soliditylang.org/en/latest/abi-spec.html#json)
228
+ */
229
+ type Abi = readonly (AbiConstructor | AbiError | AbiEvent | AbiFallback | AbiFunction | AbiReceive)[];
230
+
231
+ interface ContractExport {
232
+ address: string;
233
+ abi: Abi;
234
+ }
235
+ type ChainBlockExplorer = {
236
+ name: string;
237
+ url: string;
238
+ apiUrl?: string | undefined;
239
+ };
240
+ type ChainContract = {
241
+ address: Address;
242
+ blockCreated?: number | undefined;
243
+ };
244
+ type ChainNativeCurrency = {
245
+ name: string;
246
+ /** 2-6 characters long */
247
+ symbol: string;
248
+ decimals: number;
249
+ };
250
+ type ChainRpcUrls = {
251
+ http: readonly string[];
252
+ webSocket?: readonly string[] | undefined;
253
+ };
254
+ /**
255
+ * @description Combines members of an intersection into a readable type.
256
+ *
257
+ * @see {@link https://twitter.com/mattpocockuk/status/1622730173446557697?s=20&t=NdpAcmEFXY01xkqU3KO0Mg}
258
+ * @example
259
+ * Prettify<{ a: string } & { b: string } & { c: number, d: bigint }>
260
+ * => { a: string, b: string, c: number, d: bigint }
261
+ */
262
+ type Prettify<T> = {
263
+ [K in keyof T]: T[K];
264
+ } & {};
265
+ type ChainInfo = {
266
+ /** ID in number form */
267
+ id: number;
268
+ /** Human-readable name */
269
+ name: string;
270
+ /** Collection of block explorers */
271
+ blockExplorers?: {
272
+ [key: string]: ChainBlockExplorer;
273
+ default: ChainBlockExplorer;
274
+ } | undefined;
275
+ /** Collection of contracts */
276
+ contracts?: Prettify<{
277
+ [key: string]: ChainContract | {
278
+ [sourceId: number]: ChainContract | undefined;
279
+ } | undefined;
280
+ } & {
281
+ ensRegistry?: ChainContract | undefined;
282
+ ensUniversalResolver?: ChainContract | undefined;
283
+ multicall3?: ChainContract | undefined;
284
+ }> | undefined;
285
+ /** Currency used by chain */
286
+ nativeCurrency: ChainNativeCurrency;
287
+ /** Collection of RPC endpoints */
288
+ rpcUrls: {
289
+ [key: string]: ChainRpcUrls;
290
+ default: ChainRpcUrls;
291
+ };
292
+ /** Source Chain ID (ie. the L1 chain) */
293
+ sourceId?: number | undefined;
294
+ /** Flag for test networks */
295
+ testnet?: boolean | undefined;
296
+ chainType: 'zksync' | 'op-stack' | 'celo' | 'default';
297
+ };
298
+ type ExportedDeployments = {
299
+ chainId: string;
300
+ genesisHash?: string;
301
+ chainInfo: ChainInfo;
302
+ name: string;
303
+ contracts: {
304
+ [name: string]: ContractExport;
305
+ };
306
+ };
307
+ declare function run(config: ResolvedConfig, options: {
308
+ tojs?: string[];
309
+ tots?: string[];
310
+ tojson?: string[];
311
+ includeBytecode?: boolean;
312
+ }): Promise<void>;
313
+
314
+ export { type ChainInfo, type ContractExport, type ExportedDeployments, run };
package/dist/index.mjs ADDED
@@ -0,0 +1,81 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { loadDeployments, getChain, chainTypes } from 'rocketh';
4
+
5
+ function objectMap(object, mapFn) {
6
+ return Object.keys(object).reduce((result, key) => {
7
+ result[key] = mapFn(object[key]);
8
+ return result;
9
+ }, {});
10
+ }
11
+ async function run(config, options) {
12
+ if (!options.tots && !options.tojs && !options.tojson) {
13
+ console.log(`no filepath to export to are specified`);
14
+ return;
15
+ }
16
+ const { deployments, chainId, genesisHash } = loadDeployments(config.deployments, config.network.name);
17
+ if (!deployments || Object.keys(deployments).length === 0) {
18
+ console.log(`no deployments to export`);
19
+ return;
20
+ }
21
+ if (!chainId) {
22
+ throw new Error(`no chainId found for ${config.network.name}`);
23
+ }
24
+ const chain = getChain(chainId);
25
+ const chainInfo = {
26
+ id: chain.id,
27
+ name: chain.name,
28
+ nativeCurrency: chain.nativeCurrency,
29
+ rpcUrls: chain.rpcUrls,
30
+ blockExplorers: chain.blockExplorers,
31
+ chainType: chainTypes[chainId] || "default",
32
+ contracts: chain.contracts,
33
+ sourceId: chain.sourceId,
34
+ testnet: chain.testnet
35
+ };
36
+ const exportData = {
37
+ chainId,
38
+ genesisHash,
39
+ chainInfo,
40
+ contracts: objectMap(deployments, (d) => ({
41
+ abi: d.abi,
42
+ address: d.address,
43
+ linkedData: d.linkedData,
44
+ bytecode: options.includeBytecode ? d.bytecode : void 0,
45
+ startBlock: d.receipt?.blockNumber ? parseInt(d.receipt.blockNumber.slice(2), 16) : void 0
46
+ })),
47
+ name: config.network.name
48
+ };
49
+ const js = typeof options.tojs === "string" ? [options.tojs] : options.tojs || [];
50
+ const ts = typeof options.tots === "string" ? [options.tots] : options.tots || [];
51
+ const json = typeof options.tojson === "string" ? [options.tojson] : options.tojson || [];
52
+ if (typeof ts === "object" && ts.length > 0) {
53
+ const newContent = `export default ${JSON.stringify(exportData, null, 2)} as const;`;
54
+ for (const tsFile of ts) {
55
+ const folderPath = path.dirname(tsFile);
56
+ fs.mkdirSync(folderPath, { recursive: true });
57
+ fs.writeFileSync(tsFile, newContent);
58
+ }
59
+ }
60
+ if (typeof js === "object" && js.length > 0) {
61
+ const newContent = `export default /** @type {const} **/ (${JSON.stringify(exportData, null, 2)});`;
62
+ const dtsContent = `export = ${JSON.stringify(exportData, null, 2)} as const;`;
63
+ for (const jsFile of js) {
64
+ const folderPath = path.dirname(jsFile);
65
+ fs.mkdirSync(folderPath, { recursive: true });
66
+ fs.writeFileSync(jsFile, newContent);
67
+ fs.writeFileSync(jsFile.replace(".js", ".d.ts"), dtsContent);
68
+ }
69
+ }
70
+ if (typeof json === "object" && json.length > 0) {
71
+ const newContent = JSON.stringify(exportData, null, 2);
72
+ for (const jsonFile of json) {
73
+ const folderPath = path.dirname(jsonFile);
74
+ fs.mkdirSync(folderPath, { recursive: true });
75
+ fs.writeFileSync(jsonFile, newContent);
76
+ }
77
+ }
78
+ }
79
+
80
+ export { run };
81
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +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,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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,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;;;;"}
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@rocketh/export",
3
+ "version": "0.10.1",
4
+ "description": "export deployments",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "type": "module",
9
+ "main": "dist/index.cjs",
10
+ "module": "dist/index.mjs",
11
+ "types": "dist/index.d.ts",
12
+ ".": {
13
+ "require": {
14
+ "types": "./dist/index.d.ts",
15
+ "default": "./dist/index.cjs"
16
+ },
17
+ "import": {
18
+ "types": "./dist/index.d.ts",
19
+ "default": "./dist/index.mjs"
20
+ }
21
+ },
22
+ "bin": {
23
+ "rocketh-export": "dist/cli.cjs"
24
+ },
25
+ "devDependencies": {
26
+ "@types/node": "^20.12.7",
27
+ "abitype": "^1.0.2",
28
+ "eip-1193": "^0.5.0",
29
+ "pkgroll": "^2.0.2",
30
+ "rimraf": "^5.0.5",
31
+ "typescript": "^5.4.5"
32
+ },
33
+ "peerDependencies": {
34
+ "rocketh": "0.10.9"
35
+ },
36
+ "dependencies": {
37
+ "@types/fs-extra": "^11.0.4",
38
+ "chalk": "^5.3.0",
39
+ "commander": "^12.0.0",
40
+ "fs-extra": "^11.2.0",
41
+ "rocketh": "0.10.9"
42
+ },
43
+ "scripts": {
44
+ "build": "rimraf dist && pkgroll --sourcemap",
45
+ "dev": "pkgroll --watch"
46
+ }
47
+ }
package/src/cli.ts ADDED
@@ -0,0 +1,30 @@
1
+ #! /usr/bin/env node
2
+ import {readAndResolveConfig} from 'rocketh';
3
+ import {run} from '.';
4
+ import {Command} from 'commander';
5
+ import pkg from '../package.json';
6
+ import {ConfigOptions} from 'rocketh';
7
+
8
+ const commandName = pkg.name;
9
+
10
+ const program = new Command();
11
+ program
12
+ .name(commandName)
13
+ .description('export deployments to consume elswhere')
14
+ .version(pkg.version)
15
+ .option('-d, --deployments <value>', 'folder where deployments are saved')
16
+ .option('--ts <value>', 'list of filepath where the typescript export will be written, separated by commas')
17
+ .option('--js <value>', 'list of filepath where the javascript export will be written, separated by commas')
18
+ .option('--json <value>', 'list of filepath where the json export will be written, separated by commas')
19
+ .option('-b, --bytecode', 'if set, the bytecode will also be part of the output')
20
+ .requiredOption('-n, --network <value>', 'network context to use')
21
+ .parse(process.argv);
22
+
23
+ const options = program.opts();
24
+ const resolvedConfig = readAndResolveConfig({...(options as ConfigOptions), ignoreMissingRPC: true});
25
+ run(resolvedConfig, {
26
+ tots: options.ts ? options.ts.split(',') : undefined,
27
+ tojson: options.json ? options.json.split(',') : undefined,
28
+ tojs: options.js ? options.js.split(',') : undefined,
29
+ includeBytecode: options.bytecode,
30
+ });
package/src/index.ts ADDED
@@ -0,0 +1,203 @@
1
+ import {Abi, Address} from 'abitype';
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+
5
+ import {Deployment, ResolvedConfig, chainTypes, getChain, loadDeployments} from 'rocketh';
6
+
7
+ export interface ContractExport {
8
+ address: string;
9
+ abi: Abi;
10
+ // linkedData?: any; TODO
11
+ }
12
+
13
+ type ChainBlockExplorer = {
14
+ name: string;
15
+ url: string;
16
+ apiUrl?: string | undefined;
17
+ };
18
+ type ChainContract = {
19
+ address: Address;
20
+ blockCreated?: number | undefined;
21
+ };
22
+
23
+ type ChainNativeCurrency = {
24
+ name: string;
25
+ /** 2-6 characters long */
26
+ symbol: string;
27
+ decimals: number;
28
+ };
29
+
30
+ type ChainRpcUrls = {
31
+ http: readonly string[];
32
+ webSocket?: readonly string[] | undefined;
33
+ };
34
+
35
+ /**
36
+ * @description Combines members of an intersection into a readable type.
37
+ *
38
+ * @see {@link https://twitter.com/mattpocockuk/status/1622730173446557697?s=20&t=NdpAcmEFXY01xkqU3KO0Mg}
39
+ * @example
40
+ * Prettify<{ a: string } & { b: string } & { c: number, d: bigint }>
41
+ * => { a: string, b: string, c: number, d: bigint }
42
+ */
43
+ type Prettify<T> = {
44
+ [K in keyof T]: T[K];
45
+ } & {};
46
+
47
+ export type ChainInfo = {
48
+ /** ID in number form */
49
+ id: number;
50
+ /** Human-readable name */
51
+ name: string;
52
+ /** Collection of block explorers */
53
+ blockExplorers?:
54
+ | {
55
+ [key: string]: ChainBlockExplorer;
56
+ default: ChainBlockExplorer;
57
+ }
58
+ | undefined;
59
+ /** Collection of contracts */
60
+ contracts?:
61
+ | Prettify<
62
+ {
63
+ [key: string]: ChainContract | {[sourceId: number]: ChainContract | undefined} | undefined;
64
+ } & {
65
+ ensRegistry?: ChainContract | undefined;
66
+ ensUniversalResolver?: ChainContract | undefined;
67
+ multicall3?: ChainContract | undefined;
68
+ }
69
+ >
70
+ | undefined;
71
+ /** Currency used by chain */
72
+ nativeCurrency: ChainNativeCurrency;
73
+ /** Collection of RPC endpoints */
74
+ rpcUrls: {
75
+ [key: string]: ChainRpcUrls;
76
+ default: ChainRpcUrls;
77
+ };
78
+ /** Source Chain ID (ie. the L1 chain) */
79
+ sourceId?: number | undefined;
80
+ /** Flag for test networks */
81
+ testnet?: boolean | undefined;
82
+
83
+ chainType: 'zksync' | 'op-stack' | 'celo' | 'default';
84
+
85
+ // this will bring in the following when reconstructed from the data above
86
+
87
+ // /** Custom chain data. */
88
+ // custom?: any;
89
+
90
+ // /**
91
+ // * Modifies how chain data structures (ie. Blocks, Transactions, etc)
92
+ // * are formatted & typed.
93
+ // */
94
+ // formatters?: any | undefined;
95
+ // /** Modifies how data (ie. Transactions) is serialized. */
96
+ // serializers?: any | undefined;
97
+ // /** Modifies how fees are derived. */
98
+ // fees?: any | undefined;
99
+ };
100
+
101
+ export type ExportedDeployments = {
102
+ chainId: string;
103
+ genesisHash?: string;
104
+ chainInfo: ChainInfo;
105
+ name: string;
106
+ contracts: {[name: string]: ContractExport};
107
+ };
108
+
109
+ type Trandformed<O, Value> = {
110
+ [Property in keyof O]: Value;
111
+ };
112
+
113
+ function objectMap<V, N, O extends Trandformed<{}, V> = Trandformed<{}, V>>(
114
+ object: O,
115
+ mapFn: (v: V) => N
116
+ ): Trandformed<O, N> {
117
+ return Object.keys(object).reduce((result, key) => {
118
+ (result as any)[key] = mapFn((object as any)[key]);
119
+ return result;
120
+ }, {} as Trandformed<O, N>);
121
+ }
122
+
123
+ export async function run(
124
+ config: ResolvedConfig,
125
+ options: {tojs?: string[]; tots?: string[]; tojson?: string[]; includeBytecode?: boolean}
126
+ ) {
127
+ if (!options.tots && !options.tojs && !options.tojson) {
128
+ console.log(`no filepath to export to are specified`);
129
+ return;
130
+ }
131
+
132
+ const {deployments, chainId, genesisHash} = loadDeployments(config.deployments, config.network.name);
133
+
134
+ if (!deployments || Object.keys(deployments).length === 0) {
135
+ console.log(`no deployments to export`);
136
+ return;
137
+ }
138
+
139
+ if (!chainId) {
140
+ throw new Error(`no chainId found for ${config.network.name}`);
141
+ }
142
+
143
+ const chain = getChain(chainId);
144
+
145
+ const chainInfo: ChainInfo = {
146
+ id: chain.id,
147
+ name: chain.name,
148
+ nativeCurrency: chain.nativeCurrency,
149
+ rpcUrls: chain.rpcUrls,
150
+ blockExplorers: chain.blockExplorers,
151
+ chainType: chainTypes[chainId] || 'default',
152
+ contracts: chain.contracts,
153
+ sourceId: chain.sourceId,
154
+ testnet: chain.testnet,
155
+ };
156
+
157
+ const exportData: ExportedDeployments = {
158
+ chainId,
159
+ genesisHash,
160
+ chainInfo,
161
+ contracts: objectMap<Deployment<Abi>, ContractExport>(deployments, (d) => ({
162
+ abi: d.abi,
163
+ address: d.address,
164
+ linkedData: d.linkedData,
165
+ bytecode: options.includeBytecode ? d.bytecode : undefined,
166
+ startBlock: d.receipt?.blockNumber ? parseInt(d.receipt.blockNumber.slice(2), 16) : undefined,
167
+ })),
168
+ name: config.network.name,
169
+ };
170
+
171
+ const js = typeof options.tojs === 'string' ? [options.tojs] : options.tojs || [];
172
+ const ts = typeof options.tots === 'string' ? [options.tots] : options.tots || [];
173
+ const json = typeof options.tojson === 'string' ? [options.tojson] : options.tojson || [];
174
+
175
+ if (typeof ts === 'object' && ts.length > 0) {
176
+ const newContent = `export default ${JSON.stringify(exportData, null, 2)} as const;`;
177
+ for (const tsFile of ts) {
178
+ const folderPath = path.dirname(tsFile);
179
+ fs.mkdirSync(folderPath, {recursive: true});
180
+ fs.writeFileSync(tsFile, newContent);
181
+ }
182
+ }
183
+
184
+ if (typeof js === 'object' && js.length > 0) {
185
+ const newContent = `export default /** @type {const} **/ (${JSON.stringify(exportData, null, 2)});`;
186
+ const dtsContent = `export = ${JSON.stringify(exportData, null, 2)} as const;`;
187
+ for (const jsFile of js) {
188
+ const folderPath = path.dirname(jsFile);
189
+ fs.mkdirSync(folderPath, {recursive: true});
190
+ fs.writeFileSync(jsFile, newContent);
191
+ fs.writeFileSync(jsFile.replace('.js', '.d.ts'), dtsContent);
192
+ }
193
+ }
194
+
195
+ if (typeof json === 'object' && json.length > 0) {
196
+ const newContent = JSON.stringify(exportData, null, 2);
197
+ for (const jsonFile of json) {
198
+ const folderPath = path.dirname(jsonFile);
199
+ fs.mkdirSync(folderPath, {recursive: true});
200
+ fs.writeFileSync(jsonFile, newContent);
201
+ }
202
+ }
203
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "compilerOptions": {
3
+ "moduleResolution": "Node",
4
+ "lib": ["ES2020", "dom"],
5
+ "target": "ES2020",
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "sourceMap": true,
9
+ "strict": true,
10
+ "esModuleInterop": true,
11
+ "skipLibCheck": true,
12
+ "resolveJsonModule": true,
13
+ "module": "ES6"
14
+ }
15
+ }