@rocketh/export 0.10.8 → 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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @rocketh/export
2
2
 
3
+ ## 0.10.9
4
+
5
+ ### Patch Changes
6
+
7
+ - export argsData when exporting bytecode
8
+
3
9
  ## 0.10.8
4
10
 
5
11
  ### Patch Changes
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.7";
11
+ var version = "0.10.8";
12
12
  var description = "export deployments";
13
13
  var publishConfig = {
14
14
  access: "public"
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.7";
8
+ var version = "0.10.8";
9
9
  var description = "export deployments";
10
10
  var publishConfig = {
11
11
  access: "public"
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
@@ -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,IA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AAa,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.cjs","sources":["../src/index.ts"],"sourcesContent":["import {Abi, Address} from 'abitype';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport {Deployment, ResolvedConfig, chainTypes, getChain, loadDeployments} from 'rocketh';\n\nexport interface ContractExport {\n\taddress: `0x${string}`;\n\tabi: Abi;\n\targsData?: string;\n\tbytecode?: `0x${string}`;\n\t// linkedData?: any; TODO\n}\n\ntype ChainBlockExplorer = {\n\tname: string;\n\turl: string;\n\tapiUrl?: string | undefined;\n};\ntype ChainContract = {\n\taddress: Address;\n\tblockCreated?: number | undefined;\n};\n\ntype ChainNativeCurrency = {\n\tname: string;\n\t/** 2-6 characters long */\n\tsymbol: string;\n\tdecimals: number;\n};\n\ntype ChainRpcUrls = {\n\thttp: readonly string[];\n\twebSocket?: readonly string[] | undefined;\n};\n\n/**\n * @description Combines members of an intersection into a readable type.\n *\n * @see {@link https://twitter.com/mattpocockuk/status/1622730173446557697?s=20&t=NdpAcmEFXY01xkqU3KO0Mg}\n * @example\n * Prettify<{ a: string } & { b: string } & { c: number, d: bigint }>\n * => { a: string, b: string, c: number, d: bigint }\n */\ntype Prettify<T> = {\n\t[K in keyof T]: T[K];\n} & {};\n\nexport type ChainInfo = {\n\t/** ID in number form */\n\tid: number;\n\t/** Human-readable name */\n\tname: string;\n\t/** Collection of block explorers */\n\tblockExplorers?:\n\t\t| {\n\t\t\t\t[key: string]: ChainBlockExplorer;\n\t\t\t\tdefault: ChainBlockExplorer;\n\t\t }\n\t\t| undefined;\n\t/** Collection of contracts */\n\tcontracts?:\n\t\t| Prettify<\n\t\t\t\t{\n\t\t\t\t\t[key: string]: ChainContract | {[sourceId: number]: ChainContract | undefined} | undefined;\n\t\t\t\t} & {\n\t\t\t\t\tensRegistry?: ChainContract | undefined;\n\t\t\t\t\tensUniversalResolver?: ChainContract | undefined;\n\t\t\t\t\tmulticall3?: ChainContract | undefined;\n\t\t\t\t}\n\t\t >\n\t\t| undefined;\n\t/** Currency used by chain */\n\tnativeCurrency: ChainNativeCurrency;\n\t/** Collection of RPC endpoints */\n\trpcUrls: {\n\t\t[key: string]: ChainRpcUrls;\n\t\tdefault: ChainRpcUrls;\n\t};\n\t/** Source Chain ID (ie. the L1 chain) */\n\tsourceId?: number | undefined;\n\t/** Flag for test networks */\n\ttestnet?: boolean | undefined;\n\n\tchainType: 'zksync' | 'op-stack' | 'celo' | 'default';\n\n\t// this will bring in the following when reconstructed from the data above\n\n\t// /** Custom chain data. */\n\t// custom?: any;\n\n\t// /**\n\t// * Modifies how chain data structures (ie. Blocks, Transactions, etc)\n\t// * are formatted & typed.\n\t// */\n\t// formatters?: any | undefined;\n\t// /** Modifies how data (ie. Transactions) is serialized. */\n\t// serializers?: any | undefined;\n\t// /** Modifies how fees are derived. */\n\t// fees?: any | undefined;\n};\n\nexport type ExportedDeployments = {\n\tchainId: string;\n\tgenesisHash?: string;\n\tchainInfo: ChainInfo;\n\tname: string;\n\tcontracts: {[name: string]: ContractExport};\n};\n\ntype Trandformed<O, Value> = {\n\t[Property in keyof O]: Value;\n};\n\nfunction objectMap<V, N, O extends Trandformed<{}, V> = Trandformed<{}, V>>(\n\tobject: O,\n\tmapFn: (v: V) => N\n): Trandformed<O, N> {\n\treturn Object.keys(object).reduce((result, key) => {\n\t\t(result as any)[key] = mapFn((object as any)[key]);\n\t\treturn result;\n\t}, {} as Trandformed<O, N>);\n}\n\nexport async function run(\n\tconfig: ResolvedConfig,\n\toptions: {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,C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AAC,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/dist/index.d.ts CHANGED
@@ -287,8 +287,10 @@ type AbiError = {
287
287
  type Abi = readonly (AbiConstructor | AbiError | AbiEvent | AbiFallback | AbiFunction | AbiReceive)[];
288
288
 
289
289
  interface ContractExport {
290
- address: string;
290
+ address: `0x${string}`;
291
291
  abi: Abi;
292
+ argsData?: string;
293
+ bytecode?: `0x${string}`;
292
294
  }
293
295
  type ChainBlockExplorer = {
294
296
  name: string;
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
@@ -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\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AM,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;;;;"}
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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AC;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;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rocketh/export",
3
- "version": "0.10.8",
3
+ "version": "0.10.9",
4
4
  "description": "export deployments",
5
5
  "publishConfig": {
6
6
  "access": "public"
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,