@rocketh/export 0.10.7 → 0.10.9
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 +14 -0
- package/LICENSE +21 -0
- package/dist/cli.cjs +8 -8
- package/dist/cli.mjs +8 -8
- package/dist/index.cjs +1 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +98 -38
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
- package/src/index.ts +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @rocketh/export
|
|
2
2
|
|
|
3
|
+
## 0.10.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- export argsData when exporting bytecode
|
|
8
|
+
|
|
9
|
+
## 0.10.8
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- latest dependencies
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
- rocketh@0.10.14
|
|
16
|
+
|
|
3
17
|
## 0.10.7
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018-present Ronan Sandford
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
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.8";
|
|
12
12
|
var description = "export deployments";
|
|
13
13
|
var publishConfig = {
|
|
14
14
|
access: "public"
|
|
@@ -21,20 +21,20 @@ var bin = {
|
|
|
21
21
|
"rocketh-export": "dist/cli.cjs"
|
|
22
22
|
};
|
|
23
23
|
var devDependencies = {
|
|
24
|
-
"@types/node": "^20.
|
|
25
|
-
abitype: "^1.0.
|
|
24
|
+
"@types/node": "^20.14.8",
|
|
25
|
+
abitype: "^1.0.4",
|
|
26
26
|
"eip-1193": "^0.5.0",
|
|
27
|
-
pkgroll: "^2.
|
|
28
|
-
rimraf: "^5.0.
|
|
29
|
-
typescript: "^5.
|
|
27
|
+
pkgroll: "^2.1.1",
|
|
28
|
+
rimraf: "^5.0.7",
|
|
29
|
+
typescript: "^5.5.2"
|
|
30
30
|
};
|
|
31
31
|
var peerDependencies = {
|
|
32
32
|
rocketh: "workspace:*"
|
|
33
33
|
};
|
|
34
34
|
var dependencies = {
|
|
35
35
|
"@types/fs-extra": "^11.0.4",
|
|
36
|
-
chalk: "
|
|
37
|
-
commander: "^12.
|
|
36
|
+
chalk: "5.3.0",
|
|
37
|
+
commander: "^12.1.0",
|
|
38
38
|
"fs-extra": "^11.2.0",
|
|
39
39
|
rocketh: "workspace:*"
|
|
40
40
|
};
|
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.8";
|
|
9
9
|
var description = "export deployments";
|
|
10
10
|
var publishConfig = {
|
|
11
11
|
access: "public"
|
|
@@ -18,20 +18,20 @@ var bin = {
|
|
|
18
18
|
"rocketh-export": "dist/cli.cjs"
|
|
19
19
|
};
|
|
20
20
|
var devDependencies = {
|
|
21
|
-
"@types/node": "^20.
|
|
22
|
-
abitype: "^1.0.
|
|
21
|
+
"@types/node": "^20.14.8",
|
|
22
|
+
abitype: "^1.0.4",
|
|
23
23
|
"eip-1193": "^0.5.0",
|
|
24
|
-
pkgroll: "^2.
|
|
25
|
-
rimraf: "^5.0.
|
|
26
|
-
typescript: "^5.
|
|
24
|
+
pkgroll: "^2.1.1",
|
|
25
|
+
rimraf: "^5.0.7",
|
|
26
|
+
typescript: "^5.5.2"
|
|
27
27
|
};
|
|
28
28
|
var peerDependencies = {
|
|
29
29
|
rocketh: "workspace:*"
|
|
30
30
|
};
|
|
31
31
|
var dependencies = {
|
|
32
32
|
"@types/fs-extra": "^11.0.4",
|
|
33
|
-
chalk: "
|
|
34
|
-
commander: "^12.
|
|
33
|
+
chalk: "5.3.0",
|
|
34
|
+
commander: "^12.1.0",
|
|
35
35
|
"fs-extra": "^11.2.0",
|
|
36
36
|
rocketh: "workspace:*"
|
|
37
37
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -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
|
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,CAAC,WAAW,CAAC,CAAC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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: {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\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\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,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
|
3
|
-
|
|
3
|
+
interface Register {
|
|
4
|
+
}
|
|
4
5
|
type ResolvedRegister = {
|
|
5
6
|
/**
|
|
6
7
|
* TypeScript type to use for `address` values
|
|
7
8
|
* @default `0x${string}`
|
|
8
9
|
*/
|
|
9
|
-
|
|
10
|
+
addressType: Register extends {
|
|
11
|
+
addressType: infer type;
|
|
12
|
+
} ? type : Register extends {
|
|
10
13
|
AddressType: infer type;
|
|
11
|
-
} ? type : DefaultRegister['
|
|
14
|
+
} ? type : DefaultRegister['addressType'];
|
|
12
15
|
/**
|
|
13
16
|
* TypeScript type to use for `int<M>` and `uint<M>` values, where `M > 48`
|
|
14
17
|
* @default bigint
|
|
15
18
|
*/
|
|
16
|
-
|
|
19
|
+
bigIntType: Register extends {
|
|
20
|
+
bigIntType: infer type;
|
|
21
|
+
} ? type : Register extends {
|
|
17
22
|
BigIntType: infer type;
|
|
18
|
-
} ? type : DefaultRegister['
|
|
23
|
+
} ? type : DefaultRegister['bigIntType'];
|
|
19
24
|
/**
|
|
20
25
|
* TypeScript type to use for `bytes` values
|
|
21
26
|
* @default { inputs: `0x${string}`; outputs: `0x${string}`; }
|
|
22
27
|
*/
|
|
23
|
-
|
|
28
|
+
bytesType: Register extends {
|
|
29
|
+
bytesType: infer type extends {
|
|
30
|
+
inputs: unknown;
|
|
31
|
+
outputs: unknown;
|
|
32
|
+
};
|
|
33
|
+
} ? type : Register extends {
|
|
24
34
|
BytesType: infer type extends {
|
|
25
35
|
inputs: unknown;
|
|
26
36
|
outputs: unknown;
|
|
27
37
|
};
|
|
28
|
-
} ? type : DefaultRegister['
|
|
38
|
+
} ? type : DefaultRegister['bytesType'];
|
|
29
39
|
/**
|
|
30
40
|
* TypeScript type to use for `int<M>` and `uint<M>` values, where `M <= 48`
|
|
31
41
|
* @default number
|
|
32
42
|
*/
|
|
33
|
-
|
|
43
|
+
intType: Register extends {
|
|
44
|
+
intType: infer type;
|
|
45
|
+
} ? type : Register extends {
|
|
34
46
|
IntType: infer type;
|
|
35
|
-
} ? type : DefaultRegister['
|
|
47
|
+
} ? type : DefaultRegister['intType'];
|
|
36
48
|
/**
|
|
37
49
|
* Maximum depth for nested array types (e.g. string[][])
|
|
38
50
|
*
|
|
@@ -41,23 +53,29 @@ type ResolvedRegister = {
|
|
|
41
53
|
*
|
|
42
54
|
* @default false
|
|
43
55
|
*/
|
|
44
|
-
|
|
56
|
+
arrayMaxDepth: Register extends {
|
|
57
|
+
arrayMaxDepth: infer type extends number | false;
|
|
58
|
+
} ? type : Register extends {
|
|
45
59
|
ArrayMaxDepth: infer type extends number | false;
|
|
46
|
-
} ? type : DefaultRegister['
|
|
60
|
+
} ? type : DefaultRegister['arrayMaxDepth'];
|
|
47
61
|
/**
|
|
48
62
|
* Lower bound for fixed array length
|
|
49
63
|
* @default 1
|
|
50
64
|
*/
|
|
51
|
-
|
|
65
|
+
fixedArrayMinLength: Register extends {
|
|
66
|
+
fixedArrayMinLength: infer type extends number;
|
|
67
|
+
} ? type : Register extends {
|
|
52
68
|
FixedArrayMinLength: infer type extends number;
|
|
53
|
-
} ? type : DefaultRegister['
|
|
69
|
+
} ? type : DefaultRegister['fixedArrayMinLength'];
|
|
54
70
|
/**
|
|
55
71
|
* Upper bound for fixed array length
|
|
56
72
|
* @default 99
|
|
57
73
|
*/
|
|
58
|
-
|
|
74
|
+
fixedArrayMaxLength: Register extends {
|
|
75
|
+
fixedArrayMaxLength: infer type extends number;
|
|
76
|
+
} ? type : Register extends {
|
|
59
77
|
FixedArrayMaxLength: infer type extends number;
|
|
60
|
-
} ? type : DefaultRegister['
|
|
78
|
+
} ? type : DefaultRegister['fixedArrayMaxLength'];
|
|
61
79
|
/**
|
|
62
80
|
* When set, validates {@link AbiParameter}'s `type` against {@link AbiType}
|
|
63
81
|
*
|
|
@@ -66,32 +84,69 @@ type ResolvedRegister = {
|
|
|
66
84
|
*
|
|
67
85
|
* @default false
|
|
68
86
|
*/
|
|
69
|
-
|
|
87
|
+
strictAbiType: Register extends {
|
|
88
|
+
strictAbiType: infer type extends boolean;
|
|
89
|
+
} ? type : Register extends {
|
|
70
90
|
StrictAbiType: infer type extends boolean;
|
|
71
|
-
} ? type : DefaultRegister['
|
|
91
|
+
} ? type : DefaultRegister['strictAbiType'];
|
|
92
|
+
/** @deprecated Use `addressType` instead */
|
|
93
|
+
AddressType: ResolvedRegister['addressType'];
|
|
94
|
+
/** @deprecated Use `addressType` instead */
|
|
95
|
+
BigIntType: ResolvedRegister['bigIntType'];
|
|
96
|
+
/** @deprecated Use `bytesType` instead */
|
|
97
|
+
BytesType: ResolvedRegister['bytesType'];
|
|
98
|
+
/** @deprecated Use `intType` instead */
|
|
99
|
+
IntType: ResolvedRegister['intType'];
|
|
100
|
+
/** @deprecated Use `arrayMaxDepth` instead */
|
|
101
|
+
ArrayMaxDepth: ResolvedRegister['arrayMaxDepth'];
|
|
102
|
+
/** @deprecated Use `fixedArrayMinLength` instead */
|
|
103
|
+
FixedArrayMinLength: ResolvedRegister['fixedArrayMinLength'];
|
|
104
|
+
/** @deprecated Use `fixedArrayMaxLength` instead */
|
|
105
|
+
FixedArrayMaxLength: ResolvedRegister['fixedArrayMaxLength'];
|
|
106
|
+
/** @deprecated Use `strictAbiType` instead */
|
|
107
|
+
StrictAbiType: ResolvedRegister['strictAbiType'];
|
|
72
108
|
};
|
|
73
109
|
type DefaultRegister = {
|
|
74
110
|
/** Maximum depth for nested array types (e.g. string[][]) */
|
|
75
|
-
|
|
111
|
+
arrayMaxDepth: false;
|
|
76
112
|
/** Lower bound for fixed array length */
|
|
77
|
-
|
|
113
|
+
fixedArrayMinLength: 1;
|
|
78
114
|
/** Upper bound for fixed array length */
|
|
79
|
-
|
|
115
|
+
fixedArrayMaxLength: 99;
|
|
80
116
|
/** TypeScript type to use for `address` values */
|
|
81
|
-
|
|
117
|
+
addressType: `0x${string}`;
|
|
82
118
|
/** TypeScript type to use for `bytes` values */
|
|
83
|
-
|
|
119
|
+
bytesType: {
|
|
84
120
|
/** TypeScript type to use for `bytes` input values */
|
|
85
121
|
inputs: `0x${string}`;
|
|
86
122
|
/** TypeScript type to use for `bytes` output values */
|
|
87
123
|
outputs: `0x${string}`;
|
|
88
124
|
};
|
|
89
125
|
/** TypeScript type to use for `int<M>` and `uint<M>` values, where `M > 48` */
|
|
90
|
-
|
|
126
|
+
bigIntType: bigint;
|
|
91
127
|
/** TypeScript type to use for `int<M>` and `uint<M>` values, where `M <= 48` */
|
|
92
|
-
|
|
128
|
+
intType: number;
|
|
93
129
|
/** When set, validates {@link AbiParameter}'s `type` against {@link AbiType} */
|
|
94
|
-
|
|
130
|
+
strictAbiType: false;
|
|
131
|
+
/** @deprecated Use `arrayMaxDepth` instead */
|
|
132
|
+
ArrayMaxDepth: DefaultRegister['arrayMaxDepth'];
|
|
133
|
+
/** @deprecated Use `fixedArrayMinLength` instead */
|
|
134
|
+
FixedArrayMinLength: DefaultRegister['fixedArrayMinLength'];
|
|
135
|
+
/** @deprecated Use `fixedArrayMaxLength` instead */
|
|
136
|
+
FixedArrayMaxLength: DefaultRegister['fixedArrayMaxLength'];
|
|
137
|
+
/** @deprecated Use `addressType` instead */
|
|
138
|
+
AddressType: DefaultRegister['addressType'];
|
|
139
|
+
/** @deprecated Use `bytesType` instead */
|
|
140
|
+
BytesType: {
|
|
141
|
+
inputs: DefaultRegister['bytesType']['inputs'];
|
|
142
|
+
outputs: DefaultRegister['bytesType']['outputs'];
|
|
143
|
+
};
|
|
144
|
+
/** @deprecated Use `bigIntType` instead */
|
|
145
|
+
BigIntType: DefaultRegister['bigIntType'];
|
|
146
|
+
/** @deprecated Use `intType` instead */
|
|
147
|
+
IntType: DefaultRegister['intType'];
|
|
148
|
+
/** @deprecated Use `strictAbiType` instead */
|
|
149
|
+
StrictAbiType: DefaultRegister['strictAbiType'];
|
|
95
150
|
};
|
|
96
151
|
|
|
97
152
|
/**
|
|
@@ -102,23 +157,23 @@ type DefaultRegister = {
|
|
|
102
157
|
* type Result = Pretty<{ a: string } | { b: string } | { c: number, d: bigint }>
|
|
103
158
|
* // ^? type Result = { a: string; b: string; c: number; d: bigint }
|
|
104
159
|
*/
|
|
105
|
-
type Pretty<
|
|
106
|
-
[
|
|
160
|
+
type Pretty<type> = {
|
|
161
|
+
[key in keyof type]: type[key];
|
|
107
162
|
} & unknown;
|
|
108
163
|
/**
|
|
109
164
|
* 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
165
|
*
|
|
111
|
-
* @param
|
|
112
|
-
* @param
|
|
113
|
-
* @returns Array with inclusive range from {@link
|
|
166
|
+
* @param start - Number to start range
|
|
167
|
+
* @param stop - Number to end range
|
|
168
|
+
* @returns Array with inclusive range from {@link start} to {@link stop}
|
|
114
169
|
*
|
|
115
170
|
* @example
|
|
116
171
|
* type Result = Range<1, 3>
|
|
117
172
|
* // ^? type Result = [1, 2, 3]
|
|
118
173
|
*/
|
|
119
|
-
type Range<
|
|
174
|
+
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
175
|
|
|
121
|
-
type Address = ResolvedRegister['
|
|
176
|
+
type Address = ResolvedRegister['addressType'];
|
|
122
177
|
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
178
|
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
179
|
type SolidityAddress = 'address';
|
|
@@ -128,17 +183,20 @@ type SolidityFunction = 'function';
|
|
|
128
183
|
type SolidityString = 'string';
|
|
129
184
|
type SolidityTuple = 'tuple';
|
|
130
185
|
type SolidityInt = `${'u' | ''}int${MBits}`;
|
|
131
|
-
type SolidityFixedArrayRange = Range<ResolvedRegister['
|
|
186
|
+
type SolidityFixedArrayRange = Range<ResolvedRegister['fixedArrayMinLength'], ResolvedRegister['fixedArrayMaxLength']>[number];
|
|
132
187
|
/**
|
|
133
188
|
* Recursively build arrays up to maximum depth
|
|
134
189
|
* or use a more broad type when maximum depth is switched "off"
|
|
135
190
|
*/
|
|
136
|
-
type _BuildArrayTypes<T extends string, Depth extends readonly number[] = []> = ResolvedRegister['
|
|
191
|
+
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 | ''}]`, [
|
|
192
|
+
...Depth,
|
|
193
|
+
1
|
|
194
|
+
]> : _BuildArrayTypes<`${T}[${SolidityFixedArrayRange | ''}]`, [...Depth, 1]>;
|
|
137
195
|
type SolidityArrayWithoutTuple = _BuildArrayTypes<SolidityAddress | SolidityBool | SolidityBytes | SolidityFunction | SolidityInt | SolidityString>;
|
|
138
196
|
type SolidityArrayWithTuple = _BuildArrayTypes<SolidityTuple>;
|
|
139
197
|
type SolidityArray = SolidityArrayWithoutTuple | SolidityArrayWithTuple;
|
|
140
198
|
type AbiType = SolidityArray | SolidityAddress | SolidityBool | SolidityBytes | SolidityFunction | SolidityInt | SolidityString | SolidityTuple;
|
|
141
|
-
type ResolvedAbiType = ResolvedRegister['
|
|
199
|
+
type ResolvedAbiType = ResolvedRegister['strictAbiType'] extends true ? AbiType : string;
|
|
142
200
|
type AbiInternalType = ResolvedAbiType | `address ${string}` | `contract ${string}` | `enum ${string}` | `struct ${string}`;
|
|
143
201
|
type AbiParameter = Pretty<{
|
|
144
202
|
type: ResolvedAbiType;
|
|
@@ -151,9 +209,9 @@ type AbiParameter = Pretty<{
|
|
|
151
209
|
type: SolidityTuple | SolidityArrayWithTuple;
|
|
152
210
|
components: readonly AbiParameter[];
|
|
153
211
|
})>;
|
|
154
|
-
type AbiEventParameter =
|
|
212
|
+
type AbiEventParameter = AbiParameter & {
|
|
155
213
|
indexed?: boolean | undefined;
|
|
156
|
-
}
|
|
214
|
+
};
|
|
157
215
|
/**
|
|
158
216
|
* State mutability for {@link AbiFunction}
|
|
159
217
|
*
|
|
@@ -229,8 +287,10 @@ type AbiError = {
|
|
|
229
287
|
type Abi = readonly (AbiConstructor | AbiError | AbiEvent | AbiFallback | AbiFunction | AbiReceive)[];
|
|
230
288
|
|
|
231
289
|
interface ContractExport {
|
|
232
|
-
address: string
|
|
290
|
+
address: `0x${string}`;
|
|
233
291
|
abi: Abi;
|
|
292
|
+
argsData?: string;
|
|
293
|
+
bytecode?: `0x${string}`;
|
|
234
294
|
}
|
|
235
295
|
type ChainBlockExplorer = {
|
|
236
296
|
name: string;
|
package/dist/index.mjs
CHANGED
|
@@ -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
|
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(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G,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;;;;"}
|
|
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: {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\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\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,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AU,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;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rocketh/export",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.9",
|
|
4
4
|
"description": "export deployments",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -23,22 +23,22 @@
|
|
|
23
23
|
"rocketh-export": "dist/cli.cjs"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@types/node": "^20.
|
|
27
|
-
"abitype": "^1.0.
|
|
26
|
+
"@types/node": "^20.14.8",
|
|
27
|
+
"abitype": "^1.0.4",
|
|
28
28
|
"eip-1193": "^0.5.0",
|
|
29
|
-
"pkgroll": "^2.
|
|
30
|
-
"rimraf": "^5.0.
|
|
31
|
-
"typescript": "^5.
|
|
29
|
+
"pkgroll": "^2.1.1",
|
|
30
|
+
"rimraf": "^5.0.7",
|
|
31
|
+
"typescript": "^5.5.2"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"rocketh": "0.10.
|
|
34
|
+
"rocketh": "0.10.14"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@types/fs-extra": "^11.0.4",
|
|
38
|
-
"chalk": "
|
|
39
|
-
"commander": "^12.
|
|
38
|
+
"chalk": "5.3.0",
|
|
39
|
+
"commander": "^12.1.0",
|
|
40
40
|
"fs-extra": "^11.2.0",
|
|
41
|
-
"rocketh": "0.10.
|
|
41
|
+
"rocketh": "0.10.14"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "rimraf dist && pkgroll --sourcemap",
|
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
|
|
|
@@ -163,6 +165,7 @@ export async function run(
|
|
|
163
165
|
address: d.address,
|
|
164
166
|
linkedData: d.linkedData,
|
|
165
167
|
bytecode: options.includeBytecode ? d.bytecode : undefined,
|
|
168
|
+
argsData: options.includeBytecode ? d.argsData : undefined,
|
|
166
169
|
startBlock: d.receipt?.blockNumber ? parseInt(d.receipt.blockNumber.slice(2), 16) : undefined,
|
|
167
170
|
})),
|
|
168
171
|
name: config.network.name,
|