rocketh 0.5.2 → 0.5.3

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/dist/cli.cjs CHANGED
@@ -150,9 +150,53 @@ function loadDeployments(deploymentsPath, subPath, onlyABIAndAddress, expectedCh
150
150
  return { deployments: deploymentsFound, chainId };
151
151
  }
152
152
 
153
+ // src/internal/logging.ts
154
+ var import_named_logs = require("named-logs");
155
+ var import_named_logs_console = require("named-logs-console");
156
+ var import_ora = __toESM(require("ora"), 1);
157
+ (0, import_named_logs_console.hookup)();
158
+ function setLogLevel(level) {
159
+ import_named_logs_console.logs.level = level;
160
+ if (import_named_logs_console.logs.level > 0) {
161
+ import_named_logs_console.logs.enable();
162
+ } else {
163
+ import_named_logs_console.logs.disable();
164
+ }
165
+ }
166
+ var logger = (0, import_named_logs.logs)("rocketh");
167
+ var voidSpinner = {
168
+ stop() {
169
+ return this;
170
+ },
171
+ succeed(msg) {
172
+ return this;
173
+ },
174
+ fail(msg) {
175
+ return this;
176
+ }
177
+ };
178
+ var lastSpin = (0, import_ora.default)("rocketh");
179
+ function spin(message) {
180
+ if (import_named_logs_console.logs.level > 0) {
181
+ lastSpin = lastSpin.start(message);
182
+ return lastSpin;
183
+ } else {
184
+ return voidSpinner;
185
+ }
186
+ }
187
+
153
188
  // src/environment/index.ts
154
189
  globalThis.extensions = [];
155
190
  globalThis.signerProtocols = {};
191
+ function displayTransaction(transaction) {
192
+ if (transaction.type === "0x2") {
193
+ return `(maxFeePerGas: ${BigInt(transaction.maxFeePerGas).toString()}, maxPriorityFeePerGas: ${BigInt(
194
+ transaction.maxPriorityFeePerGas
195
+ ).toString()})`;
196
+ } else {
197
+ return `(gasPrice: ${BigInt(transaction.gasPrice).toString()})`;
198
+ }
199
+ }
156
200
  async function createEnvironment(config2, providedContext) {
157
201
  const provider = "provider" in config2 ? config2.provider : new import_eip_1193_json_provider.JSONRPCHTTPProvider(config2.nodeUrl);
158
202
  const transport = (0, import_viem.custom)(provider);
@@ -317,12 +361,18 @@ async function createEnvironment(config2, providedContext) {
317
361
  while (existingPendingDeployments.length > 0) {
318
362
  const pendingTransaction = existingPendingDeployments.shift();
319
363
  if (pendingTransaction) {
320
- console.log(
364
+ const spinner = spin(
321
365
  `recovering ${pendingTransaction.name} with transaction ${pendingTransaction.transaction.txHash}`
322
366
  );
323
- await waitForTransactionAndSave(pendingTransaction.name, pendingTransaction.transaction);
324
- console.log(`transaction ${pendingTransaction.transaction.txHash} complete`);
325
- import_node_fs3.default.writeFileSync(filepath, JSONToString(existingPendingDeployments, 2));
367
+ try {
368
+ await waitForTransactionAndSave(pendingTransaction.name, pendingTransaction.transaction);
369
+ console.log(`transaction ${pendingTransaction.transaction.txHash} complete`);
370
+ import_node_fs3.default.writeFileSync(filepath, JSONToString(existingPendingDeployments, 2));
371
+ spinner.succeed();
372
+ } catch (e) {
373
+ spinner.fail();
374
+ throw e;
375
+ }
326
376
  }
327
377
  }
328
378
  import_node_fs3.default.rmSync(filepath);
@@ -365,22 +415,46 @@ async function createEnvironment(config2, providedContext) {
365
415
  import_node_fs3.default.mkdirSync(folderPath, { recursive: true });
366
416
  import_node_fs3.default.writeFileSync(`${folderPath}/deployments.ts`, `export default ${JSONToString(deployments, 2)} as const;`);
367
417
  }
368
- async function waitForTransactionAndSave(name, pendingDeployment) {
369
- const receipt = await viemClient.waitForTransactionReceipt({
370
- hash: pendingDeployment.txHash
371
- });
418
+ async function waitForTransactionAndSave(name, pendingDeployment, transaction) {
419
+ const spinner = spin(`tx ${pendingDeployment.txHash}${transaction ? ` ${displayTransaction(transaction)}` : ""}`);
420
+ let receipt;
421
+ try {
422
+ receipt = await viemClient.waitForTransactionReceipt({
423
+ hash: pendingDeployment.txHash
424
+ });
425
+ } catch (e) {
426
+ spinner.fail();
427
+ throw e;
428
+ }
429
+ if (!receipt) {
430
+ spinner.fail(`receipt for ${pendingDeployment.txHash} not found`);
431
+ } else {
432
+ spinner.succeed();
433
+ }
372
434
  if (!receipt.contractAddress) {
373
435
  throw new Error(`failed to deploy contract ${name}`);
374
436
  }
375
437
  const { abi, ...artifactObjectWithoutABI } = pendingDeployment.partialDeployment;
376
438
  if (!artifactObjectWithoutABI.nonce) {
377
- const transaction = await provider.request({
378
- method: "eth_getTransactionByHash",
379
- params: [pendingDeployment.txHash]
380
- });
381
- if (transaction) {
382
- artifactObjectWithoutABI.nonce = transaction.nonce;
383
- artifactObjectWithoutABI.txOrigin = transaction.from;
439
+ const spinner2 = spin(`fetching nonce for ${pendingDeployment.txHash}`);
440
+ let transaction2 = null;
441
+ try {
442
+ transaction2 = await provider.request({
443
+ method: "eth_getTransactionByHash",
444
+ params: [pendingDeployment.txHash]
445
+ });
446
+ } catch (e) {
447
+ spinner2.fail();
448
+ throw e;
449
+ }
450
+ if (!transaction2) {
451
+ spinner2.fail(`tx ${pendingDeployment.txHash} not found`);
452
+ } else {
453
+ spinner2.stop();
454
+ }
455
+ if (transaction2) {
456
+ artifactObjectWithoutABI.nonce = transaction2.nonce;
457
+ artifactObjectWithoutABI.txOrigin = transaction2.from;
384
458
  }
385
459
  }
386
460
  for (const key of Object.keys(artifactObjectWithoutABI)) {
@@ -404,17 +478,30 @@ async function createEnvironment(config2, providedContext) {
404
478
  }
405
479
  async function saveWhilePending(name, pendingDeployment) {
406
480
  await saveTransaction(name, pendingDeployment);
407
- const transaction = await provider.request({
408
- method: "eth_getTransactionByHash",
409
- params: [pendingDeployment.txHash]
410
- });
481
+ let transaction = null;
482
+ const spinner = spin(`fetching tx from peers ${pendingDeployment.txHash}`);
483
+ try {
484
+ transaction = await provider.request({
485
+ method: "eth_getTransactionByHash",
486
+ params: [pendingDeployment.txHash]
487
+ });
488
+ } catch (e) {
489
+ spinner.fail();
490
+ throw e;
491
+ }
492
+ if (!transaction) {
493
+ spinner.fail(`tx ${pendingDeployment.txHash} not found`);
494
+ } else {
495
+ spinner.stop();
496
+ }
411
497
  const deployment = waitForTransactionAndSave(
412
498
  name,
413
499
  transaction ? {
414
500
  ...pendingDeployment,
415
501
  nonce: transaction.nonce,
416
502
  txOrigin: transaction.from
417
- } : pendingDeployment
503
+ } : pendingDeployment,
504
+ transaction
418
505
  );
419
506
  await deleteTransaction(pendingDeployment.txHash);
420
507
  return deployment;
@@ -459,16 +546,24 @@ function readConfig(options2, extra) {
459
546
  if (extra?.ignoreMissingRPC) {
460
547
  nodeUrl = "";
461
548
  } else {
462
- console.error(`network "${options2.network}" is not configured. Please add it to the rocketh.json file`);
463
- process.exit(1);
549
+ if (options2.network === "localhost") {
550
+ nodeUrl = "http://127.0.0.1:8545";
551
+ } else {
552
+ logger.error(`network "${options2.network}" is not configured. Please add it to the rocketh.json file`);
553
+ process.exit(1);
554
+ }
464
555
  }
465
556
  }
466
557
  } else {
467
558
  if (extra?.ignoreMissingRPC) {
468
559
  nodeUrl = "";
469
560
  } else {
470
- console.error(`network "${options2.network}" is not configured. Please add it to the rocketh.json file`);
471
- process.exit(1);
561
+ if (options2.network === "localhost") {
562
+ nodeUrl = "http://127.0.0.1:8545";
563
+ } else {
564
+ logger.error(`network "${options2.network}" is not configured. Please add it to the rocketh.json file`);
565
+ process.exit(1);
566
+ }
472
567
  }
473
568
  }
474
569
  }
@@ -495,6 +590,7 @@ async function loadAndExecuteDeployments(config2) {
495
590
  return executeDeployScripts(resolvedConfig);
496
591
  }
497
592
  async function executeDeployScripts(config2) {
593
+ setLogLevel(typeof config2.logLevel === "undefined" ? 0 : config2.logLevel);
498
594
  let filepaths;
499
595
  filepaths = traverseMultipleDirectory([config2.scripts]);
500
596
  filepaths = filepaths.filter((v) => !import_node_path4.default.basename(v).startsWith("_")).sort((a, b) => {
@@ -521,7 +617,7 @@ async function executeDeployScripts(config2) {
521
617
  if (scriptModule.default) {
522
618
  scriptModule = scriptModule.default;
523
619
  if (scriptModule.default) {
524
- console.warn(`double default...`);
620
+ logger.warn(`double default...`);
525
621
  scriptModule = scriptModule.default;
526
622
  }
527
623
  }
@@ -531,7 +627,7 @@ async function executeDeployScripts(config2) {
531
627
  }
532
628
  providedContext = scriptModule.providedContext;
533
629
  } catch (e) {
534
- console.error(`could not import ${filepath}`);
630
+ logger.error(`could not import ${filepath}`);
535
631
  throw e;
536
632
  }
537
633
  let scriptTags = scriptModule.tags;
@@ -611,21 +707,26 @@ async function executeDeployScripts(config2) {
611
707
  }
612
708
  for (const deployScript of scriptsToRun.concat(scriptsToRunAtTheEnd)) {
613
709
  const filename = import_node_path4.default.basename(deployScript.filePath);
710
+ const relativeFilepath = import_node_path4.default.relative(".", deployScript.filePath);
614
711
  let skip = false;
615
712
  if (deployScript.func.skip) {
713
+ const spinner = spin(`Executing skipping function from ${filename}`);
616
714
  try {
617
715
  skip = await deployScript.func.skip(external);
716
+ spinner.succeed(skip ? `skipping ${filename}` : void 0);
618
717
  } catch (e) {
619
- console.error(`skip failed for ${deployScript.filePath}`);
718
+ spinner.fail();
620
719
  throw e;
621
720
  }
622
721
  }
623
722
  if (!skip) {
624
723
  let result;
724
+ const spinner = spin(`Executing ${filename}`);
625
725
  try {
626
726
  result = await deployScript.func(external);
727
+ spinner.succeed(`${filename} execution complete`);
627
728
  } catch (e) {
628
- console.error(`execution failed for ${deployScript.filePath}`);
729
+ spinner.fail();
629
730
  throw e;
630
731
  }
631
732
  if (result && typeof result === "boolean") {
@@ -642,7 +743,7 @@ var import_commander = require("commander");
642
743
  // package.json
643
744
  var package_default = {
644
745
  name: "rocketh",
645
- version: "0.5.1",
746
+ version: "0.5.2",
646
747
  description: "deploy smart contract on ethereum-compatible networks",
647
748
  publishConfig: {
648
749
  access: "public"
@@ -658,7 +759,7 @@ var package_default = {
658
759
  "@types/figlet": "^1.5.5",
659
760
  "@types/node": "^18.15.5",
660
761
  abitype: "^0.7.1",
661
- "eip-1193": "^0.4.4",
762
+ "eip-1193": "^0.4.7",
662
763
  "ipfs-gateway-emulator": "4.2.1-ipfs.2",
663
764
  rimraf: "^4.4.1",
664
765
  tsup: "^6.7.0",
@@ -672,26 +773,26 @@ var package_default = {
672
773
  "esbuild-register": "^3.4.2",
673
774
  figlet: "^1.5.2",
674
775
  ldenv: "^0.3.5",
776
+ "named-logs": "^0.2.2",
777
+ "named-logs-console": "^0.2.3",
778
+ ora: "^6.3.1",
675
779
  viem: "^0.3.50"
676
780
  },
677
781
  scripts: {
678
782
  build: "rimraf dist && tsup --entry src/index.ts --entry src/cli.ts --dts --format esm,cjs",
679
783
  dev: "rimraf dist && tsup --entry src/index.ts --entry src/cli.ts --dts --format esm,cjs --watch",
784
+ "dev-no-reset": "tsup --entry src/index.ts --entry src/cli.ts --dts --format esm,cjs --watch",
680
785
  "gen-docs": "typedoc --out docs src",
681
786
  "serve-docs": "ipfs-emulator --only -d docs -p 8080"
682
787
  }
683
788
  };
684
789
 
685
790
  // src/cli.ts
686
- var import_figlet = __toESM(require("figlet"), 1);
687
791
  (0, import_ldenv.loadEnv)();
688
- console.log(`------------------------------------------------`);
689
- console.log(import_figlet.default.textSync("rocketh"));
690
- console.log(`------------------------------------------------`);
691
- var commandName = `rocketh`;
792
+ var commandName = package_default.name;
692
793
  var program = new import_commander.Command();
693
794
  program.name(commandName).version(package_default.version).usage(`${commandName}`).description("execute deploy scripts and store the deployments").option("-s, --scripts <value>", "path the folder containing the deploy scripts to execute").option("-t, --tags <value>", "comma separated list of tags to execute").option("-d, --deployments <value>", "folder where deployments are saved").requiredOption("-n, --network <value>", "network context to use").parse(process.argv);
694
795
  var options = program.opts();
695
796
  var config = readConfig(options);
696
- loadAndExecuteDeployments(config);
797
+ loadAndExecuteDeployments({ ...config, logLevel: 1 });
697
798
  //# sourceMappingURL=cli.cjs.map
package/dist/cli.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli.ts","../src/utils/fs.ts","../src/executor/index.ts","../src/environment/index.ts","../src/utils/json.ts","../src/environment/deployments.ts","../package.json"],"sourcesContent":["#! /usr/bin/env node\nimport {loadEnv} from 'ldenv';\nimport {loadAndExecuteDeployments, readConfig} from '.';\nimport {Command, Option} from 'commander';\nimport pkg from '../package.json';\nimport figlet from 'figlet';\n\nloadEnv();\n\nconsole.log(`------------------------------------------------`);\nconsole.log(figlet.textSync('rocketh'));\nconsole.log(`------------------------------------------------`);\n\nconst commandName = `rocketh`;\n\nconst program = new Command();\nprogram\n\t.name(commandName)\n\t.version(pkg.version)\n\t.usage(`${commandName}`)\n\t.description('execute deploy scripts and store the deployments')\n\t.option('-s, --scripts <value>', 'path the folder containing the deploy scripts to execute')\n\t// .addOption(\n\t// \tnew Option('-n, --node-url <value>', `ethereum's node url (fallback on ETHEREUM_NODE env variable)`).env(\n\t// \t\t'ETHEREUM_NODE'\n\t// \t)\n\t// )\n\t.option('-t, --tags <value>', 'comma separated list of tags to execute')\n\t.option('-d, --deployments <value>', 'folder where deployments are saved')\n\t// .option('-w, --watch', 'watch mode')\n\t.requiredOption('-n, --network <value>', 'network context to use')\n\t.parse(process.argv);\n\nconst options = program.opts();\nconst config = readConfig(options as any);\n\nloadAndExecuteDeployments(config);\n","// taken from https://github.com/vitejs/vite/blob/63524bac878e8d3771d34ad7ad2e10cd16870ff4/packages/vite/src/node/utils.ts#L371-L400\nimport fs from 'node:fs';\nimport path from 'node:path';\n\ninterface LookupFileOptions {\n\tpathOnly?: boolean;\n\trootDir?: string;\n\tpredicate?: (file: string) => boolean;\n}\n\nexport function lookupFile(dir: string, formats: string[], options?: LookupFileOptions): string | undefined {\n\tfor (const format of formats) {\n\t\tconst fullPath = path.join(dir, format);\n\t\tif (fs.existsSync(fullPath) && fs.statSync(fullPath).isFile()) {\n\t\t\tconst result = options?.pathOnly ? fullPath : fs.readFileSync(fullPath, 'utf-8');\n\t\t\tif (!options?.predicate || options.predicate(result)) {\n\t\t\t\treturn result;\n\t\t\t}\n\t\t}\n\t}\n\tconst parentDir = path.dirname(dir);\n\tif (parentDir !== dir && (!options?.rootDir || parentDir.startsWith(options?.rootDir))) {\n\t\treturn lookupFile(parentDir, formats, options);\n\t}\n}\n\nexport function traverseMultipleDirectory(dirs: string[]): string[] {\n\tconst filepaths = [];\n\tfor (const dir of dirs) {\n\t\tlet filesStats = traverse(dir);\n\t\tfilesStats = filesStats.filter((v) => !v.directory);\n\t\tfor (const filestat of filesStats) {\n\t\t\tfilepaths.push(path.join(dir, filestat.relativePath));\n\t\t}\n\t}\n\treturn filepaths;\n}\n\nexport const traverse = function (\n\tdir: string,\n\tresult: any[] = [],\n\ttopDir?: string,\n\tfilter?: (name: string, stats: any) => boolean // TODO any is Stats\n): Array<{\n\tname: string;\n\tpath: string;\n\trelativePath: string;\n\tmtimeMs: number;\n\tdirectory: boolean;\n}> {\n\tfs.readdirSync(dir).forEach((name) => {\n\t\tconst fPath = path.resolve(dir, name);\n\t\tconst stats = fs.statSync(fPath);\n\t\tif ((!filter && !name.startsWith('.')) || (filter && filter(name, stats))) {\n\t\t\tconst fileStats = {\n\t\t\t\tname,\n\t\t\t\tpath: fPath,\n\t\t\t\trelativePath: path.relative(topDir || dir, fPath),\n\t\t\t\tmtimeMs: stats.mtimeMs,\n\t\t\t\tdirectory: stats.isDirectory(),\n\t\t\t};\n\t\t\tif (fileStats.directory) {\n\t\t\t\tresult.push(fileStats);\n\t\t\t\treturn traverse(fPath, result, topDir || dir, filter);\n\t\t\t}\n\t\t\tresult.push(fileStats);\n\t\t}\n\t});\n\treturn result;\n};\n","import {traverseMultipleDirectory} from '../utils/fs';\nimport path from 'node:path';\nimport fs from 'node:fs';\nimport type {\n\tConfig,\n\tEnvironment,\n\tResolvedConfig,\n\tResolvedNamedAccounts,\n\tUnknownArtifacts,\n\tUnknownDeployments,\n\tUnresolvedUnknownNamedAccounts,\n} from '../environment/types';\nimport {createEnvironment} from '../environment';\nimport {DeployScriptFunction, DeployScriptModule, ProvidedContext} from './types';\n\nrequire('esbuild-register/dist/node').register();\n\nexport function execute<\n\tArtifacts extends UnknownArtifacts = UnknownArtifacts,\n\tNamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,\n\tDeployments extends UnknownDeployments = UnknownDeployments\n>(\n\tcontext: ProvidedContext<Artifacts, NamedAccounts>,\n\tcallback: DeployScriptFunction<Artifacts, ResolvedNamedAccounts<NamedAccounts>, Deployments>,\n\toptions: {tags?: string[]; dependencies?: string[]}\n): DeployScriptModule<Artifacts, NamedAccounts, Deployments> {\n\tconst scriptModule = (env: Environment<Artifacts, ResolvedNamedAccounts<NamedAccounts>, Deployments>) =>\n\t\tcallback(env);\n\tscriptModule.providedContext = context;\n\tscriptModule.tags = options.tags;\n\tscriptModule.dependencies = options.dependencies;\n\t// TODO id + skip\n\treturn scriptModule as unknown as DeployScriptModule<Artifacts, NamedAccounts, Deployments>;\n}\n\nexport type ConfigOptions = {network: string; deployments?: string; scripts?: string; tags?: string};\n\nexport function readConfig(options: ConfigOptions, extra?: {ignoreMissingRPC?: boolean}): Config {\n\ttype Networks = {[name: string]: {rpcUrl: string}};\n\ttype ConfigFile = {networks: Networks};\n\tlet configFile: ConfigFile | undefined;\n\ttry {\n\t\tconst configString = fs.readFileSync('./rocketh.json', 'utf-8');\n\t\tconfigFile = JSON.parse(configString);\n\t} catch {}\n\n\tlet nodeUrl: string;\n\tconst fromEnv = process.env['ETH_NODE_URI_' + options.network];\n\tif (typeof fromEnv === 'string') {\n\t\tnodeUrl = fromEnv;\n\t} else {\n\t\tif (configFile) {\n\t\t\tconst network = configFile.networks && configFile.networks[options.network];\n\t\t\tif (network) {\n\t\t\t\tnodeUrl = network.rpcUrl;\n\t\t\t} else {\n\t\t\t\tif (extra?.ignoreMissingRPC) {\n\t\t\t\t\tnodeUrl = '';\n\t\t\t\t} else {\n\t\t\t\t\tconsole.error(`network \"${options.network}\" is not configured. Please add it to the rocketh.json file`);\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (extra?.ignoreMissingRPC) {\n\t\t\t\tnodeUrl = '';\n\t\t\t} else {\n\t\t\t\tconsole.error(`network \"${options.network}\" is not configured. Please add it to the rocketh.json file`);\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\tnodeUrl,\n\t\tnetworkName: options.network,\n\t\tdeployments: options.deployments,\n\t\tscripts: options.scripts,\n\t\ttags: typeof options.tags === 'undefined' ? undefined : options.tags.split(','),\n\t};\n}\n\nexport function readAndResolveConfig(options: ConfigOptions, extra?: {ignoreMissingRPC?: boolean}): ResolvedConfig {\n\treturn resolveConfig(readConfig(options, extra));\n}\n\nexport function resolveConfig(config: Config): ResolvedConfig {\n\tconst resolvedConfig: ResolvedConfig = {\n\t\t...config,\n\t\tnetworkName: config.networkName || 'memory',\n\t\tdeployments: config.deployments || 'deployments',\n\t\tscripts: config.scripts || 'deploy',\n\t\ttags: config.tags || [],\n\t};\n\treturn resolvedConfig;\n}\n\nexport async function loadAndExecuteDeployments<\n\tArtifacts extends UnknownArtifacts = UnknownArtifacts,\n\tNamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,\n\tDeployments extends UnknownDeployments = UnknownDeployments\n>(config: Config) {\n\tconst resolvedConfig = resolveConfig(config);\n\n\treturn executeDeployScripts<Artifacts, NamedAccounts, Deployments>(resolvedConfig);\n\n\t// TODO\n\t// await this.export(options);\n}\n\nexport async function executeDeployScripts<\n\tArtifacts extends UnknownArtifacts = UnknownArtifacts,\n\tNamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,\n\tDeployments extends UnknownDeployments = UnknownDeployments\n>(config: ResolvedConfig): Promise<Deployments> {\n\tlet filepaths;\n\tfilepaths = traverseMultipleDirectory([config.scripts]);\n\tfilepaths = filepaths\n\t\t.filter((v) => !path.basename(v).startsWith('_'))\n\t\t.sort((a: string, b: string) => {\n\t\t\tif (a < b) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\tif (a > b) {\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\treturn 0;\n\t\t});\n\n\tlet providedContext: ProvidedContext<Artifacts, NamedAccounts> | undefined;\n\n\tconst scriptModuleByFilePath: {[filename: string]: DeployScriptModule} = {};\n\tconst scriptPathBags: {[tag: string]: string[]} = {};\n\tconst scriptFilePaths: string[] = [];\n\n\tfor (const filepath of filepaths) {\n\t\tconst scriptFilePath = path.resolve(filepath);\n\t\tlet scriptModule: DeployScriptModule;\n\t\ttry {\n\t\t\tif (require.cache) {\n\t\t\t\tdelete require.cache[scriptFilePath]; // ensure we reload it every time, so changes are taken in consideration\n\t\t\t}\n\t\t\tscriptModule = require(scriptFilePath);\n\n\t\t\tif ((scriptModule as any).default) {\n\t\t\t\tscriptModule = (scriptModule as any).default as DeployScriptModule;\n\t\t\t\tif ((scriptModule as any).default) {\n\t\t\t\t\tconsole.warn(`double default...`);\n\t\t\t\t\tscriptModule = (scriptModule as any).default as DeployScriptModule;\n\t\t\t\t}\n\t\t\t}\n\t\t\tscriptModuleByFilePath[scriptFilePath] = scriptModule;\n\t\t\tif (providedContext && providedContext !== scriptModule.providedContext) {\n\t\t\t\tthrow new Error(`context between 2 scripts is different, please share the same across them`);\n\t\t\t}\n\t\t\tprovidedContext = scriptModule.providedContext as ProvidedContext<Artifacts, NamedAccounts>;\n\t\t} catch (e) {\n\t\t\tconsole.error(`could not import ${filepath}`);\n\t\t\tthrow e;\n\t\t}\n\n\t\tlet scriptTags = scriptModule.tags;\n\t\tif (scriptTags !== undefined) {\n\t\t\tif (typeof scriptTags === 'string') {\n\t\t\t\tscriptTags = [scriptTags];\n\t\t\t}\n\t\t\tfor (const tag of scriptTags) {\n\t\t\t\tif (tag.indexOf(',') >= 0) {\n\t\t\t\t\tthrow new Error('Tag cannot contains commas');\n\t\t\t\t}\n\t\t\t\tconst bag = scriptPathBags[tag] || [];\n\t\t\t\tscriptPathBags[tag] = bag;\n\t\t\t\tbag.push(scriptFilePath);\n\t\t\t}\n\t\t}\n\n\t\tif (config.tags !== undefined && config.tags.length > 0) {\n\t\t\tlet found = false;\n\t\t\tif (scriptTags !== undefined) {\n\t\t\t\tfor (const tagToFind of config.tags) {\n\t\t\t\t\tfor (const tag of scriptTags) {\n\t\t\t\t\t\tif (tag === tagToFind) {\n\t\t\t\t\t\t\tscriptFilePaths.push(scriptFilePath);\n\t\t\t\t\t\t\tfound = true;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (found) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tscriptFilePaths.push(scriptFilePath);\n\t\t}\n\t}\n\n\tif (!providedContext) {\n\t\tthrow new Error(`no context loaded`);\n\t}\n\n\tconst {internal, external} = await createEnvironment(config, providedContext);\n\n\tawait internal.recoverTransactionsIfAny();\n\n\tconst scriptsRegisteredToRun: {[filename: string]: boolean} = {};\n\tconst scriptsToRun: Array<{\n\t\tfunc: DeployScriptModule;\n\t\tfilePath: string;\n\t}> = [];\n\tconst scriptsToRunAtTheEnd: Array<{\n\t\tfunc: DeployScriptModule;\n\t\tfilePath: string;\n\t}> = [];\n\tfunction recurseDependencies(scriptFilePath: string) {\n\t\tif (scriptsRegisteredToRun[scriptFilePath]) {\n\t\t\treturn;\n\t\t}\n\t\tconst scriptModule = scriptModuleByFilePath[scriptFilePath];\n\t\tif (scriptModule.dependencies) {\n\t\t\tfor (const dependency of scriptModule.dependencies) {\n\t\t\t\tconst scriptFilePathsToAdd = scriptPathBags[dependency];\n\t\t\t\tif (scriptFilePathsToAdd) {\n\t\t\t\t\tfor (const scriptFilenameToAdd of scriptFilePathsToAdd) {\n\t\t\t\t\t\trecurseDependencies(scriptFilenameToAdd);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (!scriptsRegisteredToRun[scriptFilePath]) {\n\t\t\tif (scriptModule.runAtTheEnd) {\n\t\t\t\tscriptsToRunAtTheEnd.push({\n\t\t\t\t\tfilePath: scriptFilePath,\n\t\t\t\t\tfunc: scriptModule,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tscriptsToRun.push({\n\t\t\t\t\tfilePath: scriptFilePath,\n\t\t\t\t\tfunc: scriptModule,\n\t\t\t\t});\n\t\t\t}\n\t\t\tscriptsRegisteredToRun[scriptFilePath] = true;\n\t\t}\n\t}\n\tfor (const scriptFilePath of scriptFilePaths) {\n\t\trecurseDependencies(scriptFilePath);\n\t}\n\n\tfor (const deployScript of scriptsToRun.concat(scriptsToRunAtTheEnd)) {\n\t\tconst filename = path.basename(deployScript.filePath);\n\t\t// if (deployScript.func.id && this.db.migrations[deployScript.func.id]) {\n\t\t// \tlog(`skipping ${filename} as migrations already executed and complete`);\n\t\t// \tcontinue;\n\t\t// }\n\t\tlet skip = false;\n\t\tif (deployScript.func.skip) {\n\t\t\ttry {\n\t\t\t\tskip = await deployScript.func.skip(external);\n\t\t\t} catch (e) {\n\t\t\t\tconsole.error(`skip failed for ${deployScript.filePath}`);\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t}\n\t\tif (!skip) {\n\t\t\tlet result;\n\t\t\ttry {\n\t\t\t\t// console.log(`Executing...`);\n\t\t\t\tresult = await deployScript.func(external);\n\t\t\t} catch (e) {\n\t\t\t\tconsole.error(`execution failed for ${deployScript.filePath}`);\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t\tif (result && typeof result === 'boolean') {\n\t\t\t\t// if (!deployScript.func.id) {\n\t\t\t\t// \tthrow new Error(\n\t\t\t\t// \t\t`${deployScript.filePath} return true to not be executed again, but does not provide an id. the script function needs to have the field \"id\" to be set`\n\t\t\t\t// \t);\n\t\t\t\t// }\n\t\t\t\t// this.db.migrations[deployScript.func.id] = Math.floor(Date.now() / 1000);\n\n\t\t\t\tconst deploymentFolderPath = config.deployments;\n\n\t\t\t\t// TODO refactor to extract this whole path and folder existence stuff\n\t\t\t\t// const toSave = this.db.writeDeploymentsToFiles && this.network.saveDeployments;\n\t\t\t\t// if (toSave) {\n\t\t\t\t// \ttry {\n\t\t\t\t// \t\tfs.mkdirSync(this.deploymentsPath);\n\t\t\t\t// \t} catch (e) {}\n\t\t\t\t// \ttry {\n\t\t\t\t// \t\tfs.mkdirSync(path.join(this.deploymentsPath, deploymentFolderPath));\n\t\t\t\t// \t} catch (e) {}\n\t\t\t\t// \tfs.writeFileSync(\n\t\t\t\t// \t\tpath.join(this.deploymentsPath, deploymentFolderPath, '.migrations.json'),\n\t\t\t\t// \t\tJSON.stringify(this.db.migrations, null, ' ')\n\t\t\t\t// \t);\n\t\t\t\t// }\n\t\t\t}\n\t\t}\n\t}\n\n\treturn external.deployments as Deployments;\n}\n","import fs from 'node:fs';\n\nimport {createPublicClient, custom} from 'viem';\nimport {\n\tAccountType,\n\tDeployment,\n\tEnvironment,\n\tNamedSigner,\n\tPendingDeployment,\n\tResolvedAccount,\n\tResolvedConfig,\n\tResolvedNamedAccounts,\n\tResolvedNamedSigners,\n\tUnknownArtifacts,\n\tUnknownDeployments,\n\tUnresolvedUnknownNamedAccounts,\n} from './types';\nimport {JSONRPCHTTPProvider} from 'eip-1193-json-provider';\nimport {Abi} from 'abitype';\nimport {InternalEnvironment} from '../internal/types';\nimport path from 'node:path';\nimport {JSONToString, stringToJSON} from '../utils/json';\nimport {loadDeployments} from './deployments';\nimport {EIP1193Account, EIP1193ProviderWithoutEvents} from 'eip-1193';\nimport {ProvidedContext} from '../executor/types';\n\nexport type EnvironmentExtenstion = (env: Environment) => Environment;\n//we store this globally so this is not lost\n(globalThis as any).extensions = [];\nexport function extendEnvironment(extension: EnvironmentExtenstion): void {\n\t(globalThis as any).extensions.push(extension);\n}\n\nexport type SignerProtocolFunction = (protocolString: string) => Promise<NamedSigner>;\nexport type SignerProtocol = {\n\tgetSigner: SignerProtocolFunction;\n};\n\n//we store this globally so this is not lost\n(globalThis as any).signerProtocols = {};\nexport function handleSignerProtocol(protocol: string, getSigner: SignerProtocolFunction): void {\n\t(globalThis as any).signerProtocols[protocol] = {\n\t\tgetSigner,\n\t};\n}\n\nexport async function createEnvironment<\n\tArtifacts extends UnknownArtifacts = UnknownArtifacts,\n\tNamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,\n\tDeployments extends UnknownDeployments = UnknownDeployments\n>(\n\tconfig: ResolvedConfig,\n\tprovidedContext: ProvidedContext<Artifacts, NamedAccounts>\n): Promise<{internal: InternalEnvironment; external: Environment}> {\n\tconst provider =\n\t\t'provider' in config ? config.provider : (new JSONRPCHTTPProvider(config.nodeUrl) as EIP1193ProviderWithoutEvents);\n\n\tconst transport = custom(provider);\n\tconst viemClient = createPublicClient({transport});\n\n\tconst chainId = (await viemClient.getChainId()).toString();\n\n\tlet networkName: string;\n\tlet saveDeployments: boolean;\n\tlet tags: {[tag: string]: boolean} = {};\n\tif ('nodeUrl' in config) {\n\t\tnetworkName = config.networkName;\n\t\tsaveDeployments = true;\n\t} else {\n\t\tif (config.networkName) {\n\t\t\tnetworkName = config.networkName;\n\t\t} else {\n\t\t\tnetworkName = 'memory';\n\t\t}\n\t\tif (networkName === 'memory' || networkName === 'hardhat') {\n\t\t\ttags['memory'] = true;\n\t\t\tsaveDeployments = false;\n\t\t} else {\n\t\t\tsaveDeployments = true;\n\t\t}\n\t}\n\n\tconst resolvedAccounts: {[name: string]: ResolvedAccount} = {};\n\n\tconst accountCache: {[name: string]: ResolvedAccount} = {};\n\tasync function getAccount(\n\t\tname: string,\n\t\taccounts: UnresolvedUnknownNamedAccounts,\n\t\taccountDef: AccountType\n\t): Promise<ResolvedAccount | undefined> {\n\t\tif (accountCache[name]) {\n\t\t\treturn accountCache[name];\n\t\t}\n\t\tlet account: ResolvedAccount | undefined;\n\t\tif (typeof accountDef === 'number') {\n\t\t\tconst accounts = await provider.request({method: 'eth_accounts'});\n\t\t\tconst accountPerIndex = accounts[accountDef];\n\t\t\tif (accountPerIndex) {\n\t\t\t\taccountCache[name] = account = {\n\t\t\t\t\ttype: 'remote',\n\t\t\t\t\taddress: accountPerIndex,\n\t\t\t\t\tsigner: provider,\n\t\t\t\t};\n\t\t\t}\n\t\t} else if (typeof accountDef === 'string') {\n\t\t\tif (accountDef.startsWith('0x')) {\n\t\t\t\tif (accountDef.length === 66) {\n\t\t\t\t\tconst privateKeyProtocol: SignerProtocol = (globalThis as any).signerProtocols['privateKey'];\n\t\t\t\t\tif (privateKeyProtocol) {\n\t\t\t\t\t\tconst namedSigner = await privateKeyProtocol.getSigner(`privateKey:${accountDef}`);\n\t\t\t\t\t\tconst [address] = await namedSigner.signer.request({method: 'eth_accounts'});\n\t\t\t\t\t\taccountCache[name] = account = {\n\t\t\t\t\t\t\t...namedSigner,\n\t\t\t\t\t\t\taddress,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\taccountCache[name] = account = {\n\t\t\t\t\t\ttype: 'remote',\n\t\t\t\t\t\taddress: accountDef as `0x${string}`,\n\t\t\t\t\t\tsigner: provider,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (accountDef.indexOf(':') > 0) {\n\t\t\t\t\tconst [protocolID, extra] = accountDef.split(':');\n\t\t\t\t\tconst protocol: SignerProtocol = (globalThis as any).signerProtocols[protocolID];\n\t\t\t\t\tif (!protocol) {\n\t\t\t\t\t\tthrow new Error(`protocol: ${protocol} is not supported`);\n\t\t\t\t\t}\n\t\t\t\t\tconst namedSigner = await protocol.getSigner(accountDef);\n\t\t\t\t\tconst [address] = await namedSigner.signer.request({method: 'eth_accounts'});\n\t\t\t\t\taccountCache[name] = account = {\n\t\t\t\t\t\t...namedSigner,\n\t\t\t\t\t\taddress,\n\t\t\t\t\t};\n\t\t\t\t} else {\n\t\t\t\t\tconst accountFetched = await getAccount(name, accounts, accounts[accountDef]);\n\t\t\t\t\tif (accountFetched) {\n\t\t\t\t\t\taccountCache[name] = account = accountFetched;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconst accountForNetwork = accountDef[networkName] || accountDef[chainId] || accountDef['default'];\n\t\t\tif (typeof accountForNetwork !== undefined) {\n\t\t\t\tconst accountFetched = await getAccount(name, accounts, accountForNetwork);\n\t\t\t\tif (accountFetched) {\n\t\t\t\t\taccountCache[name] = account = accountFetched;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn account;\n\t}\n\n\tif (providedContext.accounts) {\n\t\tconst accountNames = Object.keys(providedContext.accounts);\n\t\tfor (const accountName of accountNames) {\n\t\t\tlet account = await getAccount(accountName, providedContext.accounts, providedContext.accounts[accountName]);\n\t\t\t(resolvedAccounts as any)[accountName] = account;\n\t\t}\n\t}\n\n\tconst context = {\n\t\taccounts: resolvedAccounts,\n\t\tartifacts: providedContext.artifacts as Artifacts,\n\t\tnetwork: {\n\t\t\tname: networkName,\n\t\t\tsaveDeployments,\n\t\t\ttags,\n\t\t},\n\t};\n\n\tconst {deployments} = loadDeployments(config.deployments, context.network.name, false, chainId);\n\n\tconst namedAccounts: {[name: string]: EIP1193Account} = {};\n\tconst namedSigners: {[name: string]: NamedSigner} = {};\n\tconst addressSigners: {[name: `0x${string}`]: NamedSigner} = {};\n\n\tfor (const entry of Object.entries(resolvedAccounts)) {\n\t\tconst name = entry[0];\n\t\tconst {address, ...namedSigner} = entry[1];\n\t\tnamedAccounts[name] = address;\n\t\taddressSigners[address] = namedSigner;\n\t\tnamedSigners[name] = namedSigner;\n\t}\n\n\tconst perliminaryEnvironment = {\n\t\tconfig,\n\t\tdeployments: deployments as Deployments,\n\t\taccounts: namedAccounts as ResolvedNamedAccounts<NamedAccounts>,\n\t\tsigners: namedSigners as ResolvedNamedSigners<ResolvedNamedAccounts<NamedAccounts>>,\n\t\taddressSigners: addressSigners,\n\t\tartifacts: context.artifacts,\n\t\tnetwork: {\n\t\t\tchainId,\n\t\t\tname: context.network.name,\n\t\t\ttags: context.network.tags,\n\t\t\tprovider,\n\t\t},\n\t};\n\n\tfunction ensureDeploymentFolder(): string {\n\t\tconst folderPath = path.join(config.deployments, context.network.name);\n\t\tfs.mkdirSync(folderPath, {recursive: true});\n\t\tconst chainIdFilepath = path.join(folderPath, '.chainId');\n\t\tif (!fs.existsSync(chainIdFilepath)) {\n\t\t\tfs.writeFileSync(chainIdFilepath, chainId);\n\t\t}\n\t\treturn folderPath;\n\t}\n\n\t// const signer = {\n\t// \tasync sendTransaction(\n\t// \t\tprovider: EIP1193ProviderWithoutEvents,\n\t// \t\taccount: {\n\t// \t\t\taddresss: EIP1193Account;\n\t// \t\t\tconfig: unknown;\n\t// \t\t},\n\t// \t\ttransaction: EIP1193TransactionEIP1193DATA\n\t// \t): Promise<EIP1193DATA> {\n\t// \t\treturn '0x';\n\t// \t},\n\t// };\n\n\t// async function sendTransaction(transaction: EIP1193TransactionEIP1193DATA): Promise<EIP1193DATA> {\n\t// \treturn '0x';\n\t// }\n\n\tfunction get<TAbi extends Abi>(name: string): Deployment<TAbi> | undefined {\n\t\treturn deployments[name] as Deployment<TAbi> | undefined;\n\t}\n\n\tasync function save<TAbi extends Abi>(name: string, deployment: Deployment<TAbi>): Promise<Deployment<TAbi>> {\n\t\tdeployments[name] = deployment;\n\t\tif (context.network.saveDeployments) {\n\t\t\tconst folderPath = ensureDeploymentFolder();\n\t\t\tfs.writeFileSync(`${folderPath}/${name}.json`, JSONToString(deployment, 2));\n\t\t}\n\t\treturn deployment;\n\t}\n\n\tasync function recoverTransactionsIfAny<TAbi extends Abi = Abi>(): Promise<void> {\n\t\tconst filepath = path.join(config.deployments, context.network.name, '.pending_transactions.json');\n\t\tlet existingPendingDeployments: {name: string; transaction: PendingDeployment<TAbi>}[];\n\t\ttry {\n\t\t\texistingPendingDeployments = stringToJSON(fs.readFileSync(filepath, 'utf-8'));\n\t\t} catch {\n\t\t\texistingPendingDeployments = [];\n\t\t}\n\t\tif (existingPendingDeployments.length > 0) {\n\t\t\twhile (existingPendingDeployments.length > 0) {\n\t\t\t\tconst pendingTransaction = existingPendingDeployments.shift();\n\t\t\t\tif (pendingTransaction) {\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t`recovering ${pendingTransaction.name} with transaction ${pendingTransaction.transaction.txHash}`\n\t\t\t\t\t);\n\t\t\t\t\tawait waitForTransactionAndSave(pendingTransaction.name, pendingTransaction.transaction);\n\t\t\t\t\tconsole.log(`transaction ${pendingTransaction.transaction.txHash} complete`);\n\t\t\t\t\tfs.writeFileSync(filepath, JSONToString(existingPendingDeployments, 2));\n\t\t\t\t}\n\t\t\t}\n\t\t\tfs.rmSync(filepath);\n\t\t}\n\t}\n\n\tasync function saveTransaction<TAbi extends Abi = Abi>(name: string, transaction: PendingDeployment<TAbi>) {\n\t\tif (context.network.saveDeployments) {\n\t\t\tconst folderPath = ensureDeploymentFolder();\n\t\t\tconst filepath = path.join(folderPath, '.pending_transactions.json');\n\t\t\tlet existingPendingDeployments: {name: string; transaction: PendingDeployment<TAbi>}[];\n\t\t\ttry {\n\t\t\t\texistingPendingDeployments = stringToJSON(fs.readFileSync(filepath, 'utf-8'));\n\t\t\t} catch {\n\t\t\t\texistingPendingDeployments = [];\n\t\t\t}\n\t\t\texistingPendingDeployments.push({name, transaction});\n\t\t\tfs.writeFileSync(filepath, JSONToString(existingPendingDeployments, 2));\n\t\t}\n\t\treturn deployments;\n\t}\n\n\tasync function deleteTransaction<TAbi extends Abi = Abi>(hash: string) {\n\t\tif (context.network.saveDeployments) {\n\t\t\tconst filepath = path.join(config.deployments, context.network.name, '.pending_transactions.json');\n\t\t\tlet existingPendingDeployments: {name: string; transaction: PendingDeployment<TAbi>}[];\n\t\t\ttry {\n\t\t\t\texistingPendingDeployments = stringToJSON(fs.readFileSync(filepath, 'utf-8'));\n\t\t\t} catch {\n\t\t\t\texistingPendingDeployments = [];\n\t\t\t}\n\t\t\texistingPendingDeployments = existingPendingDeployments.filter((v) => v.transaction.txHash !== hash);\n\t\t\tif (existingPendingDeployments.length === 0) {\n\t\t\t\tfs.rmSync(filepath);\n\t\t\t} else {\n\t\t\t\tfs.writeFileSync(filepath, JSONToString(existingPendingDeployments, 2));\n\t\t\t}\n\t\t}\n\t}\n\n\tasync function exportDeploymentsAsTypes() {\n\t\tconst folderPath = './generated';\n\t\tfs.mkdirSync(folderPath, {recursive: true});\n\t\tfs.writeFileSync(`${folderPath}/deployments.ts`, `export default ${JSONToString(deployments, 2)} as const;`);\n\t}\n\n\tasync function waitForTransactionAndSave<TAbi extends Abi = Abi>(\n\t\tname: string,\n\t\tpendingDeployment: PendingDeployment<TAbi>\n\t): Promise<Deployment<TAbi>> {\n\t\tconst receipt = await viemClient.waitForTransactionReceipt({\n\t\t\thash: pendingDeployment.txHash,\n\t\t});\n\n\t\tif (!receipt.contractAddress) {\n\t\t\tthrow new Error(`failed to deploy contract ${name}`);\n\t\t}\n\t\tconst {abi, ...artifactObjectWithoutABI} = pendingDeployment.partialDeployment;\n\n\t\tif (!artifactObjectWithoutABI.nonce) {\n\t\t\tconst transaction = await provider.request({\n\t\t\t\tmethod: 'eth_getTransactionByHash',\n\t\t\t\tparams: [pendingDeployment.txHash],\n\t\t\t});\n\t\t\tif (transaction) {\n\t\t\t\tartifactObjectWithoutABI.nonce = transaction.nonce;\n\t\t\t\tartifactObjectWithoutABI.txOrigin = transaction.from;\n\t\t\t}\n\t\t}\n\n\t\t// TODO options\n\t\tfor (const key of Object.keys(artifactObjectWithoutABI)) {\n\t\t\tif (key.startsWith('_')) {\n\t\t\t\tdelete (artifactObjectWithoutABI as any)[key];\n\t\t\t}\n\t\t\tif (key === 'evm') {\n\t\t\t\tconst {gasEstimates} = artifactObjectWithoutABI.evm;\n\t\t\t\tartifactObjectWithoutABI.evm = {\n\t\t\t\t\tgasEstimates,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tconst deployment = {\n\t\t\taddress: receipt.contractAddress,\n\t\t\ttxHash: pendingDeployment.txHash,\n\t\t\tabi,\n\t\t\t...artifactObjectWithoutABI,\n\t\t};\n\t\treturn save(name, deployment);\n\t}\n\n\tasync function saveWhilePending<TAbi extends Abi = Abi>(name: string, pendingDeployment: PendingDeployment<TAbi>) {\n\t\tawait saveTransaction<TAbi>(name, pendingDeployment);\n\t\tconst transaction = await provider.request({\n\t\t\tmethod: 'eth_getTransactionByHash',\n\t\t\tparams: [pendingDeployment.txHash],\n\t\t});\n\n\t\tconst deployment = waitForTransactionAndSave<TAbi>(\n\t\t\tname,\n\t\t\ttransaction\n\t\t\t\t? {\n\t\t\t\t\t\t...pendingDeployment,\n\t\t\t\t\t\tnonce: transaction.nonce,\n\t\t\t\t\t\ttxOrigin: transaction.from,\n\t\t\t\t }\n\t\t\t\t: pendingDeployment\n\t\t);\n\t\tawait deleteTransaction(pendingDeployment.txHash);\n\t\treturn deployment;\n\t}\n\n\tlet env: Environment<Artifacts, NamedAccounts, Deployments> = {\n\t\t...perliminaryEnvironment,\n\t\tsave,\n\t\tsaveWhilePending,\n\t\tget,\n\t};\n\tfor (const extension of (globalThis as any).extensions) {\n\t\tenv = extension(env);\n\t}\n\n\treturn {\n\t\texternal: env,\n\t\tinternal: {\n\t\t\texportDeploymentsAsTypes,\n\t\t\trecoverTransactionsIfAny,\n\t\t},\n\t};\n}\n","// TODO share with db-utils\nexport function bnReplacer(k: string, v: any): any {\n\tif (typeof v === 'bigint') {\n\t\treturn v.toString() + 'n';\n\t}\n\treturn v;\n}\n\nexport function bnReviver(k: string, v: any): any {\n\tif (\n\t\ttypeof v === 'string' &&\n\t\t(v.startsWith('-') ? !isNaN(parseInt(v.charAt(1))) : !isNaN(parseInt(v.charAt(0)))) &&\n\t\tv.charAt(v.length - 1) === 'n'\n\t) {\n\t\treturn BigInt(v.slice(0, -1));\n\t}\n\treturn v;\n}\n\nexport function JSONToString<T = unknown>(json: unknown, space?: string | number) {\n\treturn JSON.stringify(json, bnReplacer, space);\n}\n\nexport function stringToJSON<T = unknown>(str: string): T {\n\treturn JSON.parse(str, bnReviver);\n}\n","import path from 'node:path';\nimport fs from 'node:fs';\nimport {traverse} from '../utils/fs';\nimport {UnknownDeployments} from './types';\n\nexport function loadDeployments(\n\tdeploymentsPath: string,\n\tsubPath: string,\n\tonlyABIAndAddress?: boolean,\n\texpectedChainId?: string\n): {deployments: UnknownDeployments; chainId?: string} {\n\tconst deploymentsFound: UnknownDeployments = {};\n\tconst deployPath = path.join(deploymentsPath, subPath);\n\n\tlet filesStats;\n\ttry {\n\t\tfilesStats = traverse(deployPath, undefined, undefined, (name) => !name.startsWith('.') && name !== 'solcInputs');\n\t} catch (e) {\n\t\t// console.log('no folder at ' + deployPath);\n\t\treturn {deployments: {}};\n\t}\n\tlet chainId: string;\n\tif (filesStats.length > 0) {\n\t\tconst chainIdFilepath = path.join(deployPath, '.chainId');\n\t\tif (fs.existsSync(chainIdFilepath)) {\n\t\t\tchainId = fs.readFileSync(chainIdFilepath).toString().trim();\n\t\t} else {\n\t\t\tthrow new Error(`A .chainId' file is expected to be present in the deployment folder for network ${subPath}`);\n\t\t}\n\n\t\tif (expectedChainId) {\n\t\t\tif (expectedChainId !== chainId) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Loading deployment in folder '${deployPath}' (with chainId: ${chainId}) for a different chainId (${expectedChainId})`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t} else {\n\t\treturn {deployments: {}};\n\t}\n\tlet fileNames = filesStats.map((a) => a.relativePath);\n\tfileNames = fileNames.sort((a, b) => {\n\t\tif (a < b) {\n\t\t\treturn -1;\n\t\t}\n\t\tif (a > b) {\n\t\t\treturn 1;\n\t\t}\n\t\treturn 0;\n\t});\n\n\tfor (const fileName of fileNames) {\n\t\tif (fileName.substring(fileName.length - 5) === '.json') {\n\t\t\tconst deploymentFileName = path.join(deployPath, fileName);\n\t\t\tlet deployment = JSON.parse(fs.readFileSync(deploymentFileName).toString());\n\t\t\t// truffleChainId argument:\n\t\t\t// if (!deployment.address && deployment.networks) {\n\t\t\t// \tif (truffleChainId && deployment.networks[truffleChainId]) {\n\t\t\t// \t\t// TRUFFLE support\n\t\t\t// \t\tconst truffleDeployment = deployment as any; // TruffleDeployment;\n\t\t\t// \t\tdeployment.address = truffleDeployment.networks[truffleChainId].address;\n\t\t\t// \t\tdeployment.transactionHash = truffleDeployment.networks[truffleChainId].transactionHash;\n\t\t\t// \t}\n\t\t\t// }\n\t\t\tif (onlyABIAndAddress) {\n\t\t\t\tdeployment = {\n\t\t\t\t\taddress: deployment.address,\n\t\t\t\t\tabi: deployment.abi,\n\t\t\t\t\tlinkedData: deployment.linkedData,\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst name = fileName.slice(0, fileName.length - 5);\n\t\t\t// console.log('fetching ' + deploymentFileName + ' for ' + name);\n\n\t\t\tdeploymentsFound[name] = deployment;\n\t\t}\n\t}\n\treturn {deployments: deploymentsFound, chainId};\n}\n","{\n\t\"name\": \"rocketh\",\n\t\"version\": \"0.5.1\",\n\t\"description\": \"deploy smart contract on ethereum-compatible networks\",\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t},\n\t\"type\": \"module\",\n\t\"main\": \"dist/index.cjs\",\n\t\"module\": \"dist/index.js\",\n\t\"types\": \"dist/index.d.ts\",\n\t\"bin\": {\n\t\t\"rocketh\": \"dist/cli.cjs\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@types/figlet\": \"^1.5.5\",\n\t\t\"@types/node\": \"^18.15.5\",\n\t\t\"abitype\": \"^0.7.1\",\n\t\t\"eip-1193\": \"^0.4.4\",\n\t\t\"ipfs-gateway-emulator\": \"4.2.1-ipfs.2\",\n\t\t\"rimraf\": \"^4.4.1\",\n\t\t\"tsup\": \"^6.7.0\",\n\t\t\"typedoc\": \"^0.23.28\",\n\t\t\"typescript\": \"^5.0.4\"\n\t},\n\t\"dependencies\": {\n\t\t\"commander\": \"^10.0.0\",\n\t\t\"eip-1193-json-provider\": \"^0.1.5\",\n\t\t\"esbuild\": \"^0.17.12\",\n\t\t\"esbuild-register\": \"^3.4.2\",\n\t\t\"figlet\": \"^1.5.2\",\n\t\t\"ldenv\": \"^0.3.5\",\n\t\t\"viem\": \"^0.3.50\"\n\t},\n\t\"scripts\": {\n\t\t\"build\": \"rimraf dist && tsup --entry src/index.ts --entry src/cli.ts --dts --format esm,cjs\",\n\t\t\"dev\": \"rimraf dist && tsup --entry src/index.ts --entry src/cli.ts --dts --format esm,cjs --watch\",\n\t\t\"gen-docs\": \"typedoc --out docs src\",\n\t\t\"serve-docs\": \"ipfs-emulator --only -d docs -p 8080\"\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,mBAAsB;;;ACAtB,qBAAe;AACf,uBAAiB;AAwBV,SAAS,0BAA0B,MAA0B;AACnE,QAAM,YAAY,CAAC;AACnB,aAAW,OAAO,MAAM;AACvB,QAAI,aAAa,SAAS,GAAG;AAC7B,iBAAa,WAAW,OAAO,CAAC,MAAM,CAAC,EAAE,SAAS;AAClD,eAAW,YAAY,YAAY;AAClC,gBAAU,KAAK,iBAAAA,QAAK,KAAK,KAAK,SAAS,YAAY,CAAC;AAAA,IACrD;AAAA,EACD;AACA,SAAO;AACR;AAEO,IAAM,WAAW,SACvB,KACA,SAAgB,CAAC,GACjB,QACA,QAOE;AACF,iBAAAC,QAAG,YAAY,GAAG,EAAE,QAAQ,CAAC,SAAS;AACrC,UAAM,QAAQ,iBAAAD,QAAK,QAAQ,KAAK,IAAI;AACpC,UAAM,QAAQ,eAAAC,QAAG,SAAS,KAAK;AAC/B,QAAK,CAAC,UAAU,CAAC,KAAK,WAAW,GAAG,KAAO,UAAU,OAAO,MAAM,KAAK,GAAI;AAC1E,YAAM,YAAY;AAAA,QACjB;AAAA,QACA,MAAM;AAAA,QACN,cAAc,iBAAAD,QAAK,SAAS,UAAU,KAAK,KAAK;AAAA,QAChD,SAAS,MAAM;AAAA,QACf,WAAW,MAAM,YAAY;AAAA,MAC9B;AACA,UAAI,UAAU,WAAW;AACxB,eAAO,KAAK,SAAS;AACrB,eAAO,SAAS,OAAO,QAAQ,UAAU,KAAK,MAAM;AAAA,MACrD;AACA,aAAO,KAAK,SAAS;AAAA,IACtB;AAAA,EACD,CAAC;AACD,SAAO;AACR;;;ACpEA,I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c;AAAA,EACf;AACD;;;ANnCA,oBAAmB;AAAA,IAEnB,sBAAQ;AAER,QAAQ,IAAI,kDAAkD;AAC9D,QAAQ,IAAI,cAAAE,QAAO,SAAS,SAAS,CAAC;AACtC,QAAQ,IAAI,kDAAkD;AAE9D,IAAM,cAAc;AAEpB,IAAM,UAAU,IAAI,yBAAQ;AAC5B,QACE,KAAK,WAAW,EAChB,QAAQ,gBAAI,OAAO,EACnB,MAAM,GAAG,aAAa,EACtB,YAAY,kDAAkD,EAC9D,OAAO,yBAAyB,0DAA0D,EAM1F,OAAO,sBAAsB,yCAAyC,EACtE,OAAO,6BAA6B,oCAAoC,EAExE,eAAe,yBAAyB,wBAAwB,EAChE,MAAM,QAAQ,IAAI;AAEpB,IAAM,UAAU,QAAQ,KAAK;AAC7B,IAAM,SAAS,WAAW,OAAc;AAExC,0BAA0B,MAAM;","names":["path","fs","import_node_path","import_node_fs","import_node_fs","import_node_path","import_node_path","import_node_fs","path","fs","config","accounts","path","fs","options","fs","config","path","figlet"]}
1
+ {"version":3,"sources":["../src/cli.ts","../src/utils/fs.ts","../src/executor/index.ts","../src/environment/index.ts","../src/utils/json.ts","../src/environment/deployments.ts","../src/internal/logging.ts","../package.json"],"sourcesContent":["#! /usr/bin/env node\nimport {loadEnv} from 'ldenv';\nimport {loadAndExecuteDeployments, readConfig} from '.';\nimport {Command} from 'commander';\nimport pkg from '../package.json';\n\nloadEnv();\n\nconst commandName = pkg.name;\nconst program = new Command();\nprogram\n\t.name(commandName)\n\t.version(pkg.version)\n\t.usage(`${commandName}`)\n\t.description('execute deploy scripts and store the deployments')\n\t.option('-s, --scripts <value>', 'path the folder containing the deploy scripts to execute')\n\t.option('-t, --tags <value>', 'comma separated list of tags to execute')\n\t.option('-d, --deployments <value>', 'folder where deployments are saved')\n\t.requiredOption('-n, --network <value>', 'network context to use')\n\t.parse(process.argv);\n\nconst options = program.opts();\nconst config = readConfig(options as any);\n\nloadAndExecuteDeployments({...config, logLevel: 1});\n","// taken from https://github.com/vitejs/vite/blob/63524bac878e8d3771d34ad7ad2e10cd16870ff4/packages/vite/src/node/utils.ts#L371-L400\nimport fs from 'node:fs';\nimport path from 'node:path';\n\ninterface LookupFileOptions {\n\tpathOnly?: boolean;\n\trootDir?: string;\n\tpredicate?: (file: string) => boolean;\n}\n\nexport function lookupFile(dir: string, formats: string[], options?: LookupFileOptions): string | undefined {\n\tfor (const format of formats) {\n\t\tconst fullPath = path.join(dir, format);\n\t\tif (fs.existsSync(fullPath) && fs.statSync(fullPath).isFile()) {\n\t\t\tconst result = options?.pathOnly ? fullPath : fs.readFileSync(fullPath, 'utf-8');\n\t\t\tif (!options?.predicate || options.predicate(result)) {\n\t\t\t\treturn result;\n\t\t\t}\n\t\t}\n\t}\n\tconst parentDir = path.dirname(dir);\n\tif (parentDir !== dir && (!options?.rootDir || parentDir.startsWith(options?.rootDir))) {\n\t\treturn lookupFile(parentDir, formats, options);\n\t}\n}\n\nexport function traverseMultipleDirectory(dirs: string[]): string[] {\n\tconst filepaths = [];\n\tfor (const dir of dirs) {\n\t\tlet filesStats = traverse(dir);\n\t\tfilesStats = filesStats.filter((v) => !v.directory);\n\t\tfor (const filestat of filesStats) {\n\t\t\tfilepaths.push(path.join(dir, filestat.relativePath));\n\t\t}\n\t}\n\treturn filepaths;\n}\n\nexport const traverse = function (\n\tdir: string,\n\tresult: any[] = [],\n\ttopDir?: string,\n\tfilter?: (name: string, stats: any) => boolean // TODO any is Stats\n): Array<{\n\tname: string;\n\tpath: string;\n\trelativePath: string;\n\tmtimeMs: number;\n\tdirectory: boolean;\n}> {\n\tfs.readdirSync(dir).forEach((name) => {\n\t\tconst fPath = path.resolve(dir, name);\n\t\tconst stats = fs.statSync(fPath);\n\t\tif ((!filter && !name.startsWith('.')) || (filter && filter(name, stats))) {\n\t\t\tconst fileStats = {\n\t\t\t\tname,\n\t\t\t\tpath: fPath,\n\t\t\t\trelativePath: path.relative(topDir || dir, fPath),\n\t\t\t\tmtimeMs: stats.mtimeMs,\n\t\t\t\tdirectory: stats.isDirectory(),\n\t\t\t};\n\t\t\tif (fileStats.directory) {\n\t\t\t\tresult.push(fileStats);\n\t\t\t\treturn traverse(fPath, result, topDir || dir, filter);\n\t\t\t}\n\t\t\tresult.push(fileStats);\n\t\t}\n\t});\n\treturn result;\n};\n","import {traverseMultipleDirectory} from '../utils/fs';\nimport path from 'node:path';\nimport fs from 'node:fs';\nimport type {\n\tConfig,\n\tEnvironment,\n\tResolvedConfig,\n\tResolvedNamedAccounts,\n\tUnknownArtifacts,\n\tUnknownDeployments,\n\tUnresolvedUnknownNamedAccounts,\n} from '../environment/types';\nimport {createEnvironment} from '../environment';\nimport {DeployScriptFunction, DeployScriptModule, ProvidedContext} from './types';\nimport {logger, setLogLevel, spin} from '../internal/logging';\n\nrequire('esbuild-register/dist/node').register();\n\nexport function execute<\n\tArtifacts extends UnknownArtifacts = UnknownArtifacts,\n\tNamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,\n\tDeployments extends UnknownDeployments = UnknownDeployments\n>(\n\tcontext: ProvidedContext<Artifacts, NamedAccounts>,\n\tcallback: DeployScriptFunction<Artifacts, ResolvedNamedAccounts<NamedAccounts>, Deployments>,\n\toptions: {tags?: string[]; dependencies?: string[]}\n): DeployScriptModule<Artifacts, NamedAccounts, Deployments> {\n\tconst scriptModule = (env: Environment<Artifacts, ResolvedNamedAccounts<NamedAccounts>, Deployments>) =>\n\t\tcallback(env);\n\tscriptModule.providedContext = context;\n\tscriptModule.tags = options.tags;\n\tscriptModule.dependencies = options.dependencies;\n\t// TODO id + skip\n\treturn scriptModule as unknown as DeployScriptModule<Artifacts, NamedAccounts, Deployments>;\n}\n\nexport type ConfigOptions = {network: string; deployments?: string; scripts?: string; tags?: string};\n\nexport function readConfig(options: ConfigOptions, extra?: {ignoreMissingRPC?: boolean}): Config {\n\ttype Networks = {[name: string]: {rpcUrl: string}};\n\ttype ConfigFile = {networks: Networks};\n\tlet configFile: ConfigFile | undefined;\n\ttry {\n\t\tconst configString = fs.readFileSync('./rocketh.json', 'utf-8');\n\t\tconfigFile = JSON.parse(configString);\n\t} catch {}\n\n\tlet nodeUrl: string;\n\tconst fromEnv = process.env['ETH_NODE_URI_' + options.network];\n\tif (typeof fromEnv === 'string') {\n\t\tnodeUrl = fromEnv;\n\t} else {\n\t\tif (configFile) {\n\t\t\tconst network = configFile.networks && configFile.networks[options.network];\n\t\t\tif (network) {\n\t\t\t\tnodeUrl = network.rpcUrl;\n\t\t\t} else {\n\t\t\t\tif (extra?.ignoreMissingRPC) {\n\t\t\t\t\tnodeUrl = '';\n\t\t\t\t} else {\n\t\t\t\t\tif (options.network === 'localhost') {\n\t\t\t\t\t\tnodeUrl = 'http://127.0.0.1:8545';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlogger.error(`network \"${options.network}\" is not configured. Please add it to the rocketh.json file`);\n\t\t\t\t\t\tprocess.exit(1);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (extra?.ignoreMissingRPC) {\n\t\t\t\tnodeUrl = '';\n\t\t\t} else {\n\t\t\t\tif (options.network === 'localhost') {\n\t\t\t\t\tnodeUrl = 'http://127.0.0.1:8545';\n\t\t\t\t} else {\n\t\t\t\t\tlogger.error(`network \"${options.network}\" is not configured. Please add it to the rocketh.json file`);\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\tnodeUrl,\n\t\tnetworkName: options.network,\n\t\tdeployments: options.deployments,\n\t\tscripts: options.scripts,\n\t\ttags: typeof options.tags === 'undefined' ? undefined : options.tags.split(','),\n\t};\n}\n\nexport function readAndResolveConfig(options: ConfigOptions, extra?: {ignoreMissingRPC?: boolean}): ResolvedConfig {\n\treturn resolveConfig(readConfig(options, extra));\n}\n\nexport function resolveConfig(config: Config): ResolvedConfig {\n\tconst resolvedConfig: ResolvedConfig = {\n\t\t...config,\n\t\tnetworkName: config.networkName || 'memory',\n\t\tdeployments: config.deployments || 'deployments',\n\t\tscripts: config.scripts || 'deploy',\n\t\ttags: config.tags || [],\n\t};\n\treturn resolvedConfig;\n}\n\nexport async function loadAndExecuteDeployments<\n\tArtifacts extends UnknownArtifacts = UnknownArtifacts,\n\tNamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,\n\tDeployments extends UnknownDeployments = UnknownDeployments\n>(config: Config) {\n\tconst resolvedConfig = resolveConfig(config);\n\n\treturn executeDeployScripts<Artifacts, NamedAccounts, Deployments>(resolvedConfig);\n\n\t// TODO\n\t// await this.export(options);\n}\n\nexport async function executeDeployScripts<\n\tArtifacts extends UnknownArtifacts = UnknownArtifacts,\n\tNamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,\n\tDeployments extends UnknownDeployments = UnknownDeployments\n>(config: ResolvedConfig): Promise<Deployments> {\n\tsetLogLevel(typeof config.logLevel === 'undefined' ? 0 : config.logLevel);\n\n\tlet filepaths;\n\tfilepaths = traverseMultipleDirectory([config.scripts]);\n\tfilepaths = filepaths\n\t\t.filter((v) => !path.basename(v).startsWith('_'))\n\t\t.sort((a: string, b: string) => {\n\t\t\tif (a < b) {\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\tif (a > b) {\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\treturn 0;\n\t\t});\n\n\tlet providedContext: ProvidedContext<Artifacts, NamedAccounts> | undefined;\n\n\tconst scriptModuleByFilePath: {[filename: string]: DeployScriptModule} = {};\n\tconst scriptPathBags: {[tag: string]: string[]} = {};\n\tconst scriptFilePaths: string[] = [];\n\n\tfor (const filepath of filepaths) {\n\t\tconst scriptFilePath = path.resolve(filepath);\n\t\tlet scriptModule: DeployScriptModule;\n\t\ttry {\n\t\t\tif (require.cache) {\n\t\t\t\tdelete require.cache[scriptFilePath]; // ensure we reload it every time, so changes are taken in consideration\n\t\t\t}\n\t\t\tscriptModule = require(scriptFilePath);\n\n\t\t\tif ((scriptModule as any).default) {\n\t\t\t\tscriptModule = (scriptModule as any).default as DeployScriptModule;\n\t\t\t\tif ((scriptModule as any).default) {\n\t\t\t\t\tlogger.warn(`double default...`);\n\t\t\t\t\tscriptModule = (scriptModule as any).default as DeployScriptModule;\n\t\t\t\t}\n\t\t\t}\n\t\t\tscriptModuleByFilePath[scriptFilePath] = scriptModule;\n\t\t\tif (providedContext && providedContext !== scriptModule.providedContext) {\n\t\t\t\tthrow new Error(`context between 2 scripts is different, please share the same across them`);\n\t\t\t}\n\t\t\tprovidedContext = scriptModule.providedContext as ProvidedContext<Artifacts, NamedAccounts>;\n\t\t} catch (e) {\n\t\t\tlogger.error(`could not import ${filepath}`);\n\t\t\tthrow e;\n\t\t}\n\n\t\tlet scriptTags = scriptModule.tags;\n\t\tif (scriptTags !== undefined) {\n\t\t\tif (typeof scriptTags === 'string') {\n\t\t\t\tscriptTags = [scriptTags];\n\t\t\t}\n\t\t\tfor (const tag of scriptTags) {\n\t\t\t\tif (tag.indexOf(',') >= 0) {\n\t\t\t\t\tthrow new Error('Tag cannot contains commas');\n\t\t\t\t}\n\t\t\t\tconst bag = scriptPathBags[tag] || [];\n\t\t\t\tscriptPathBags[tag] = bag;\n\t\t\t\tbag.push(scriptFilePath);\n\t\t\t}\n\t\t}\n\n\t\tif (config.tags !== undefined && config.tags.length > 0) {\n\t\t\tlet found = false;\n\t\t\tif (scriptTags !== undefined) {\n\t\t\t\tfor (const tagToFind of config.tags) {\n\t\t\t\t\tfor (const tag of scriptTags) {\n\t\t\t\t\t\tif (tag === tagToFind) {\n\t\t\t\t\t\t\tscriptFilePaths.push(scriptFilePath);\n\t\t\t\t\t\t\tfound = true;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (found) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tscriptFilePaths.push(scriptFilePath);\n\t\t}\n\t}\n\n\tif (!providedContext) {\n\t\tthrow new Error(`no context loaded`);\n\t}\n\n\tconst {internal, external} = await createEnvironment(config, providedContext);\n\n\tawait internal.recoverTransactionsIfAny();\n\n\tconst scriptsRegisteredToRun: {[filename: string]: boolean} = {};\n\tconst scriptsToRun: Array<{\n\t\tfunc: DeployScriptModule;\n\t\tfilePath: string;\n\t}> = [];\n\tconst scriptsToRunAtTheEnd: Array<{\n\t\tfunc: DeployScriptModule;\n\t\tfilePath: string;\n\t}> = [];\n\tfunction recurseDependencies(scriptFilePath: string) {\n\t\tif (scriptsRegisteredToRun[scriptFilePath]) {\n\t\t\treturn;\n\t\t}\n\t\tconst scriptModule = scriptModuleByFilePath[scriptFilePath];\n\t\tif (scriptModule.dependencies) {\n\t\t\tfor (const dependency of scriptModule.dependencies) {\n\t\t\t\tconst scriptFilePathsToAdd = scriptPathBags[dependency];\n\t\t\t\tif (scriptFilePathsToAdd) {\n\t\t\t\t\tfor (const scriptFilenameToAdd of scriptFilePathsToAdd) {\n\t\t\t\t\t\trecurseDependencies(scriptFilenameToAdd);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (!scriptsRegisteredToRun[scriptFilePath]) {\n\t\t\tif (scriptModule.runAtTheEnd) {\n\t\t\t\tscriptsToRunAtTheEnd.push({\n\t\t\t\t\tfilePath: scriptFilePath,\n\t\t\t\t\tfunc: scriptModule,\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tscriptsToRun.push({\n\t\t\t\t\tfilePath: scriptFilePath,\n\t\t\t\t\tfunc: scriptModule,\n\t\t\t\t});\n\t\t\t}\n\t\t\tscriptsRegisteredToRun[scriptFilePath] = true;\n\t\t}\n\t}\n\tfor (const scriptFilePath of scriptFilePaths) {\n\t\trecurseDependencies(scriptFilePath);\n\t}\n\n\tfor (const deployScript of scriptsToRun.concat(scriptsToRunAtTheEnd)) {\n\t\tconst filename = path.basename(deployScript.filePath);\n\t\tconst relativeFilepath = path.relative('.', deployScript.filePath);\n\t\t// if (deployScript.func.id && this.db.migrations[deployScript.func.id]) {\n\t\t// \tlogger.info(`skipping ${filename} as migrations already executed and complete`);\n\t\t// \tcontinue;\n\t\t// }\n\t\tlet skip = false;\n\t\tif (deployScript.func.skip) {\n\t\t\tconst spinner = spin(`Executing skipping function from ${filename}`);\n\t\t\ttry {\n\t\t\t\tskip = await deployScript.func.skip(external);\n\t\t\t\tspinner.succeed(skip ? `skipping ${filename}` : undefined);\n\t\t\t} catch (e) {\n\t\t\t\tspinner.fail();\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t}\n\t\tif (!skip) {\n\t\t\tlet result;\n\t\t\tconst spinner = spin(`Executing ${filename}`);\n\t\t\ttry {\n\t\t\t\tresult = await deployScript.func(external);\n\t\t\t\tspinner.succeed(`${filename} execution complete`);\n\t\t\t} catch (e) {\n\t\t\t\tspinner.fail();\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t\tif (result && typeof result === 'boolean') {\n\t\t\t\t// if (!deployScript.func.id) {\n\t\t\t\t// \tthrow new Error(\n\t\t\t\t// \t\t`${deployScript.filePath} return true to not be executed again, but does not provide an id. the script function needs to have the field \"id\" to be set`\n\t\t\t\t// \t);\n\t\t\t\t// }\n\t\t\t\t// this.db.migrations[deployScript.func.id] = Math.floor(Date.now() / 1000);\n\n\t\t\t\tconst deploymentFolderPath = config.deployments;\n\n\t\t\t\t// TODO refactor to extract this whole path and folder existence stuff\n\t\t\t\t// const toSave = this.db.writeDeploymentsToFiles && this.network.saveDeployments;\n\t\t\t\t// if (toSave) {\n\t\t\t\t// \ttry {\n\t\t\t\t// \t\tfs.mkdirSync(this.deploymentsPath);\n\t\t\t\t// \t} catch (e) {}\n\t\t\t\t// \ttry {\n\t\t\t\t// \t\tfs.mkdirSync(path.join(this.deploymentsPath, deploymentFolderPath));\n\t\t\t\t// \t} catch (e) {}\n\t\t\t\t// \tfs.writeFileSync(\n\t\t\t\t// \t\tpath.join(this.deploymentsPath, deploymentFolderPath, '.migrations.json'),\n\t\t\t\t// \t\tJSON.stringify(this.db.migrations, null, ' ')\n\t\t\t\t// \t);\n\t\t\t\t// }\n\t\t\t}\n\t\t}\n\t}\n\n\treturn external.deployments as Deployments;\n}\n","import fs from 'node:fs';\n\nimport {Transaction, TransactionReceipt, createPublicClient, custom} from 'viem';\nimport {\n\tAccountType,\n\tDeployment,\n\tEnvironment,\n\tNamedSigner,\n\tPendingDeployment,\n\tResolvedAccount,\n\tResolvedConfig,\n\tResolvedNamedAccounts,\n\tResolvedNamedSigners,\n\tUnknownArtifacts,\n\tUnknownDeployments,\n\tUnresolvedUnknownNamedAccounts,\n} from './types';\nimport {JSONRPCHTTPProvider} from 'eip-1193-json-provider';\nimport {Abi} from 'abitype';\nimport {InternalEnvironment} from '../internal/types';\nimport path from 'node:path';\nimport {JSONToString, stringToJSON} from '../utils/json';\nimport {loadDeployments} from './deployments';\nimport {EIP1193Account, EIP1193ProviderWithoutEvents, EIP1193Transaction} from 'eip-1193';\nimport {ProvidedContext} from '../executor/types';\nimport {spin} from '../internal/logging';\n\nexport type EnvironmentExtenstion = (env: Environment) => Environment;\n//we store this globally so this is not lost\n(globalThis as any).extensions = [];\nexport function extendEnvironment(extension: EnvironmentExtenstion): void {\n\t(globalThis as any).extensions.push(extension);\n}\n\nexport type SignerProtocolFunction = (protocolString: string) => Promise<NamedSigner>;\nexport type SignerProtocol = {\n\tgetSigner: SignerProtocolFunction;\n};\n\n//we store this globally so this is not lost\n(globalThis as any).signerProtocols = {};\nexport function handleSignerProtocol(protocol: string, getSigner: SignerProtocolFunction): void {\n\t(globalThis as any).signerProtocols[protocol] = {\n\t\tgetSigner,\n\t};\n}\n\nfunction displayTransaction(transaction: EIP1193Transaction) {\n\tif (transaction.type === '0x2') {\n\t\treturn `(maxFeePerGas: ${BigInt(transaction.maxFeePerGas).toString()}, maxPriorityFeePerGas: ${BigInt(\n\t\t\ttransaction.maxPriorityFeePerGas\n\t\t).toString()})`;\n\t} else {\n\t\treturn `(gasPrice: ${BigInt(transaction.gasPrice).toString()})`;\n\t}\n}\n\nexport async function createEnvironment<\n\tArtifacts extends UnknownArtifacts = UnknownArtifacts,\n\tNamedAccounts extends UnresolvedUnknownNamedAccounts = UnresolvedUnknownNamedAccounts,\n\tDeployments extends UnknownDeployments = UnknownDeployments\n>(\n\tconfig: ResolvedConfig,\n\tprovidedContext: ProvidedContext<Artifacts, NamedAccounts>\n): Promise<{internal: InternalEnvironment; external: Environment}> {\n\tconst provider =\n\t\t'provider' in config ? config.provider : (new JSONRPCHTTPProvider(config.nodeUrl) as EIP1193ProviderWithoutEvents);\n\n\tconst transport = custom(provider);\n\tconst viemClient = createPublicClient({transport});\n\n\tconst chainId = (await viemClient.getChainId()).toString();\n\n\tlet networkName: string;\n\tlet saveDeployments: boolean;\n\tlet tags: {[tag: string]: boolean} = {};\n\tif ('nodeUrl' in config) {\n\t\tnetworkName = config.networkName;\n\t\tsaveDeployments = true;\n\t} else {\n\t\tif (config.networkName) {\n\t\t\tnetworkName = config.networkName;\n\t\t} else {\n\t\t\tnetworkName = 'memory';\n\t\t}\n\t\tif (networkName === 'memory' || networkName === 'hardhat') {\n\t\t\ttags['memory'] = true;\n\t\t\tsaveDeployments = false;\n\t\t} else {\n\t\t\tsaveDeployments = true;\n\t\t}\n\t}\n\n\tconst resolvedAccounts: {[name: string]: ResolvedAccount} = {};\n\n\tconst accountCache: {[name: string]: ResolvedAccount} = {};\n\tasync function getAccount(\n\t\tname: string,\n\t\taccounts: UnresolvedUnknownNamedAccounts,\n\t\taccountDef: AccountType\n\t): Promise<ResolvedAccount | undefined> {\n\t\tif (accountCache[name]) {\n\t\t\treturn accountCache[name];\n\t\t}\n\t\tlet account: ResolvedAccount | undefined;\n\t\tif (typeof accountDef === 'number') {\n\t\t\tconst accounts = await provider.request({method: 'eth_accounts'});\n\t\t\tconst accountPerIndex = accounts[accountDef];\n\t\t\tif (accountPerIndex) {\n\t\t\t\taccountCache[name] = account = {\n\t\t\t\t\ttype: 'remote',\n\t\t\t\t\taddress: accountPerIndex,\n\t\t\t\t\tsigner: provider,\n\t\t\t\t};\n\t\t\t}\n\t\t} else if (typeof accountDef === 'string') {\n\t\t\tif (accountDef.startsWith('0x')) {\n\t\t\t\tif (accountDef.length === 66) {\n\t\t\t\t\tconst privateKeyProtocol: SignerProtocol = (globalThis as any).signerProtocols['privateKey'];\n\t\t\t\t\tif (privateKeyProtocol) {\n\t\t\t\t\t\tconst namedSigner = await privateKeyProtocol.getSigner(`privateKey:${accountDef}`);\n\t\t\t\t\t\tconst [address] = await namedSigner.signer.request({method: 'eth_accounts'});\n\t\t\t\t\t\taccountCache[name] = account = {\n\t\t\t\t\t\t\t...namedSigner,\n\t\t\t\t\t\t\taddress,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\taccountCache[name] = account = {\n\t\t\t\t\t\ttype: 'remote',\n\t\t\t\t\t\taddress: accountDef as `0x${string}`,\n\t\t\t\t\t\tsigner: provider,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (accountDef.indexOf(':') > 0) {\n\t\t\t\t\tconst [protocolID, extra] = accountDef.split(':');\n\t\t\t\t\tconst protocol: SignerProtocol = (globalThis as any).signerProtocols[protocolID];\n\t\t\t\t\tif (!protocol) {\n\t\t\t\t\t\tthrow new Error(`protocol: ${protocol} is not supported`);\n\t\t\t\t\t}\n\t\t\t\t\tconst namedSigner = await protocol.getSigner(accountDef);\n\t\t\t\t\tconst [address] = await namedSigner.signer.request({method: 'eth_accounts'});\n\t\t\t\t\taccountCache[name] = account = {\n\t\t\t\t\t\t...namedSigner,\n\t\t\t\t\t\taddress,\n\t\t\t\t\t};\n\t\t\t\t} else {\n\t\t\t\t\tconst accountFetched = await getAccount(name, accounts, accounts[accountDef]);\n\t\t\t\t\tif (accountFetched) {\n\t\t\t\t\t\taccountCache[name] = account = accountFetched;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconst accountForNetwork = accountDef[networkName] || accountDef[chainId] || accountDef['default'];\n\t\t\tif (typeof accountForNetwork !== undefined) {\n\t\t\t\tconst accountFetched = await getAccount(name, accounts, accountForNetwork);\n\t\t\t\tif (accountFetched) {\n\t\t\t\t\taccountCache[name] = account = accountFetched;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn account;\n\t}\n\n\tif (providedContext.accounts) {\n\t\tconst accountNames = Object.keys(providedContext.accounts);\n\t\tfor (const accountName of accountNames) {\n\t\t\tlet account = await getAccount(accountName, providedContext.accounts, providedContext.accounts[accountName]);\n\t\t\t(resolvedAccounts as any)[accountName] = account;\n\t\t}\n\t}\n\n\tconst context = {\n\t\taccounts: resolvedAccounts,\n\t\tartifacts: providedContext.artifacts as Artifacts,\n\t\tnetwork: {\n\t\t\tname: networkName,\n\t\t\tsaveDeployments,\n\t\t\ttags,\n\t\t},\n\t};\n\n\tconst {deployments} = loadDeployments(config.deployments, context.network.name, false, chainId);\n\n\tconst namedAccounts: {[name: string]: EIP1193Account} = {};\n\tconst namedSigners: {[name: string]: NamedSigner} = {};\n\tconst addressSigners: {[name: `0x${string}`]: NamedSigner} = {};\n\n\tfor (const entry of Object.entries(resolvedAccounts)) {\n\t\tconst name = entry[0];\n\t\tconst {address, ...namedSigner} = entry[1];\n\t\tnamedAccounts[name] = address;\n\t\taddressSigners[address] = namedSigner;\n\t\tnamedSigners[name] = namedSigner;\n\t}\n\n\tconst perliminaryEnvironment = {\n\t\tconfig,\n\t\tdeployments: deployments as Deployments,\n\t\taccounts: namedAccounts as ResolvedNamedAccounts<NamedAccounts>,\n\t\tsigners: namedSigners as ResolvedNamedSigners<ResolvedNamedAccounts<NamedAccounts>>,\n\t\taddressSigners: addressSigners,\n\t\tartifacts: context.artifacts,\n\t\tnetwork: {\n\t\t\tchainId,\n\t\t\tname: context.network.name,\n\t\t\ttags: context.network.tags,\n\t\t\tprovider,\n\t\t},\n\t};\n\n\tfunction ensureDeploymentFolder(): string {\n\t\tconst folderPath = path.join(config.deployments, context.network.name);\n\t\tfs.mkdirSync(folderPath, {recursive: true});\n\t\tconst chainIdFilepath = path.join(folderPath, '.chainId');\n\t\tif (!fs.existsSync(chainIdFilepath)) {\n\t\t\tfs.writeFileSync(chainIdFilepath, chainId);\n\t\t}\n\t\treturn folderPath;\n\t}\n\n\t// const signer = {\n\t// \tasync sendTransaction(\n\t// \t\tprovider: EIP1193ProviderWithoutEvents,\n\t// \t\taccount: {\n\t// \t\t\taddresss: EIP1193Account;\n\t// \t\t\tconfig: unknown;\n\t// \t\t},\n\t// \t\ttransaction: EIP1193TransactionEIP1193DATA\n\t// \t): Promise<EIP1193DATA> {\n\t// \t\treturn '0x';\n\t// \t},\n\t// };\n\n\t// async function sendTransaction(transaction: EIP1193TransactionEIP1193DATA): Promise<EIP1193DATA> {\n\t// \treturn '0x';\n\t// }\n\n\tfunction get<TAbi extends Abi>(name: string): Deployment<TAbi> | undefined {\n\t\treturn deployments[name] as Deployment<TAbi> | undefined;\n\t}\n\n\tasync function save<TAbi extends Abi>(name: string, deployment: Deployment<TAbi>): Promise<Deployment<TAbi>> {\n\t\tdeployments[name] = deployment;\n\t\tif (context.network.saveDeployments) {\n\t\t\tconst folderPath = ensureDeploymentFolder();\n\t\t\tfs.writeFileSync(`${folderPath}/${name}.json`, JSONToString(deployment, 2));\n\t\t}\n\t\treturn deployment;\n\t}\n\n\tasync function recoverTransactionsIfAny<TAbi extends Abi = Abi>(): Promise<void> {\n\t\tconst filepath = path.join(config.deployments, context.network.name, '.pending_transactions.json');\n\t\tlet existingPendingDeployments: {name: string; transaction: PendingDeployment<TAbi>}[];\n\t\ttry {\n\t\t\texistingPendingDeployments = stringToJSON(fs.readFileSync(filepath, 'utf-8'));\n\t\t} catch {\n\t\t\texistingPendingDeployments = [];\n\t\t}\n\t\tif (existingPendingDeployments.length > 0) {\n\t\t\twhile (existingPendingDeployments.length > 0) {\n\t\t\t\tconst pendingTransaction = existingPendingDeployments.shift();\n\t\t\t\tif (pendingTransaction) {\n\t\t\t\t\tconst spinner = spin(\n\t\t\t\t\t\t`recovering ${pendingTransaction.name} with transaction ${pendingTransaction.transaction.txHash}`\n\t\t\t\t\t);\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait waitForTransactionAndSave(pendingTransaction.name, pendingTransaction.transaction);\n\t\t\t\t\t\tconsole.log(`transaction ${pendingTransaction.transaction.txHash} complete`);\n\t\t\t\t\t\tfs.writeFileSync(filepath, JSONToString(existingPendingDeployments, 2));\n\t\t\t\t\t\tspinner.succeed();\n\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\tspinner.fail();\n\t\t\t\t\t\tthrow e;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tfs.rmSync(filepath);\n\t\t}\n\t}\n\n\tasync function saveTransaction<TAbi extends Abi = Abi>(name: string, transaction: PendingDeployment<TAbi>) {\n\t\tif (context.network.saveDeployments) {\n\t\t\tconst folderPath = ensureDeploymentFolder();\n\t\t\tconst filepath = path.join(folderPath, '.pending_transactions.json');\n\t\t\tlet existingPendingDeployments: {name: string; transaction: PendingDeployment<TAbi>}[];\n\t\t\ttry {\n\t\t\t\texistingPendingDeployments = stringToJSON(fs.readFileSync(filepath, 'utf-8'));\n\t\t\t} catch {\n\t\t\t\texistingPendingDeployments = [];\n\t\t\t}\n\t\t\texistingPendingDeployments.push({name, transaction});\n\t\t\tfs.writeFileSync(filepath, JSONToString(existingPendingDeployments, 2));\n\t\t}\n\t\treturn deployments;\n\t}\n\n\tasync function deleteTransaction<TAbi extends Abi = Abi>(hash: string) {\n\t\tif (context.network.saveDeployments) {\n\t\t\tconst filepath = path.join(config.deployments, context.network.name, '.pending_transactions.json');\n\t\t\tlet existingPendingDeployments: {name: string; transaction: PendingDeployment<TAbi>}[];\n\t\t\ttry {\n\t\t\t\texistingPendingDeployments = stringToJSON(fs.readFileSync(filepath, 'utf-8'));\n\t\t\t} catch {\n\t\t\t\texistingPendingDeployments = [];\n\t\t\t}\n\t\t\texistingPendingDeployments = existingPendingDeployments.filter((v) => v.transaction.txHash !== hash);\n\t\t\tif (existingPendingDeployments.length === 0) {\n\t\t\t\tfs.rmSync(filepath);\n\t\t\t} else {\n\t\t\t\tfs.writeFileSync(filepath, JSONToString(existingPendingDeployments, 2));\n\t\t\t}\n\t\t}\n\t}\n\n\tasync function exportDeploymentsAsTypes() {\n\t\tconst folderPath = './generated';\n\t\tfs.mkdirSync(folderPath, {recursive: true});\n\t\tfs.writeFileSync(`${folderPath}/deployments.ts`, `export default ${JSONToString(deployments, 2)} as const;`);\n\t}\n\n\tasync function waitForTransactionAndSave<TAbi extends Abi = Abi>(\n\t\tname: string,\n\t\tpendingDeployment: PendingDeployment<TAbi>,\n\t\ttransaction?: EIP1193Transaction | null\n\t): Promise<Deployment<TAbi>> {\n\t\tconst spinner = spin(`tx ${pendingDeployment.txHash}${transaction ? ` ${displayTransaction(transaction)}` : ''}`);\n\t\tlet receipt: TransactionReceipt;\n\t\ttry {\n\t\t\treceipt = await viemClient.waitForTransactionReceipt({\n\t\t\t\thash: pendingDeployment.txHash,\n\t\t\t});\n\t\t} catch (e) {\n\t\t\tspinner.fail();\n\t\t\tthrow e;\n\t\t}\n\t\tif (!receipt) {\n\t\t\tspinner.fail(`receipt for ${pendingDeployment.txHash} not found`);\n\t\t} else {\n\t\t\tspinner.succeed();\n\t\t}\n\n\t\tif (!receipt.contractAddress) {\n\t\t\tthrow new Error(`failed to deploy contract ${name}`);\n\t\t}\n\t\tconst {abi, ...artifactObjectWithoutABI} = pendingDeployment.partialDeployment;\n\n\t\tif (!artifactObjectWithoutABI.nonce) {\n\t\t\tconst spinner = spin(`fetching nonce for ${pendingDeployment.txHash}`);\n\t\t\tlet transaction: EIP1193Transaction | null = null;\n\t\t\ttry {\n\t\t\t\ttransaction = await provider.request({\n\t\t\t\t\tmethod: 'eth_getTransactionByHash',\n\t\t\t\t\tparams: [pendingDeployment.txHash],\n\t\t\t\t});\n\t\t\t} catch (e) {\n\t\t\t\tspinner.fail();\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t\tif (!transaction) {\n\t\t\t\tspinner.fail(`tx ${pendingDeployment.txHash} not found`);\n\t\t\t} else {\n\t\t\t\tspinner.stop();\n\t\t\t}\n\n\t\t\tif (transaction) {\n\t\t\t\tartifactObjectWithoutABI.nonce = transaction.nonce;\n\t\t\t\tartifactObjectWithoutABI.txOrigin = transaction.from;\n\t\t\t}\n\t\t}\n\n\t\t// TODO options\n\t\tfor (const key of Object.keys(artifactObjectWithoutABI)) {\n\t\t\tif (key.startsWith('_')) {\n\t\t\t\tdelete (artifactObjectWithoutABI as any)[key];\n\t\t\t}\n\t\t\tif (key === 'evm') {\n\t\t\t\tconst {gasEstimates} = artifactObjectWithoutABI.evm;\n\t\t\t\tartifactObjectWithoutABI.evm = {\n\t\t\t\t\tgasEstimates,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tconst deployment = {\n\t\t\taddress: receipt.contractAddress,\n\t\t\ttxHash: pendingDeployment.txHash,\n\t\t\tabi,\n\t\t\t...artifactObjectWithoutABI,\n\t\t};\n\t\treturn save(name, deployment);\n\t}\n\n\tasync function saveWhilePending<TAbi extends Abi = Abi>(name: string, pendingDeployment: PendingDeployment<TAbi>) {\n\t\tawait saveTransaction<TAbi>(name, pendingDeployment);\n\t\tlet transaction: EIP1193Transaction | null = null;\n\t\tconst spinner = spin(`fetching tx from peers ${pendingDeployment.txHash}`);\n\t\ttry {\n\t\t\ttransaction = await provider.request({\n\t\t\t\tmethod: 'eth_getTransactionByHash',\n\t\t\t\tparams: [pendingDeployment.txHash],\n\t\t\t});\n\t\t} catch (e) {\n\t\t\tspinner.fail();\n\t\t\tthrow e;\n\t\t}\n\t\tif (!transaction) {\n\t\t\tspinner.fail(`tx ${pendingDeployment.txHash} not found`);\n\t\t} else {\n\t\t\tspinner.stop();\n\t\t}\n\n\t\tconst deployment = waitForTransactionAndSave<TAbi>(\n\t\t\tname,\n\t\t\ttransaction\n\t\t\t\t? {\n\t\t\t\t\t\t...pendingDeployment,\n\t\t\t\t\t\tnonce: transaction.nonce,\n\t\t\t\t\t\ttxOrigin: transaction.from,\n\t\t\t\t }\n\t\t\t\t: pendingDeployment,\n\t\t\ttransaction\n\t\t);\n\t\tawait deleteTransaction(pendingDeployment.txHash);\n\t\treturn deployment;\n\t}\n\n\tlet env: Environment<Artifacts, NamedAccounts, Deployments> = {\n\t\t...perliminaryEnvironment,\n\t\tsave,\n\t\tsaveWhilePending,\n\t\tget,\n\t};\n\tfor (const extension of (globalThis as any).extensions) {\n\t\tenv = extension(env);\n\t}\n\n\treturn {\n\t\texternal: env,\n\t\tinternal: {\n\t\t\texportDeploymentsAsTypes,\n\t\t\trecoverTransactionsIfAny,\n\t\t},\n\t};\n}\n","// TODO share with db-utils\nexport function bnReplacer(k: string, v: any): any {\n\tif (typeof v === 'bigint') {\n\t\treturn v.toString() + 'n';\n\t}\n\treturn v;\n}\n\nexport function bnReviver(k: string, v: any): any {\n\tif (\n\t\ttypeof v === 'string' &&\n\t\t(v.startsWith('-') ? !isNaN(parseInt(v.charAt(1))) : !isNaN(parseInt(v.charAt(0)))) &&\n\t\tv.charAt(v.length - 1) === 'n'\n\t) {\n\t\treturn BigInt(v.slice(0, -1));\n\t}\n\treturn v;\n}\n\nexport function JSONToString<T = unknown>(json: unknown, space?: string | number) {\n\treturn JSON.stringify(json, bnReplacer, space);\n}\n\nexport function stringToJSON<T = unknown>(str: string): T {\n\treturn JSON.parse(str, bnReviver);\n}\n","import path from 'node:path';\nimport fs from 'node:fs';\nimport {traverse} from '../utils/fs';\nimport {UnknownDeployments} from './types';\n\nexport function loadDeployments(\n\tdeploymentsPath: string,\n\tsubPath: string,\n\tonlyABIAndAddress?: boolean,\n\texpectedChainId?: string\n): {deployments: UnknownDeployments; chainId?: string} {\n\tconst deploymentsFound: UnknownDeployments = {};\n\tconst deployPath = path.join(deploymentsPath, subPath);\n\n\tlet filesStats;\n\ttry {\n\t\tfilesStats = traverse(deployPath, undefined, undefined, (name) => !name.startsWith('.') && name !== 'solcInputs');\n\t} catch (e) {\n\t\t// console.log('no folder at ' + deployPath);\n\t\treturn {deployments: {}};\n\t}\n\tlet chainId: string;\n\tif (filesStats.length > 0) {\n\t\tconst chainIdFilepath = path.join(deployPath, '.chainId');\n\t\tif (fs.existsSync(chainIdFilepath)) {\n\t\t\tchainId = fs.readFileSync(chainIdFilepath).toString().trim();\n\t\t} else {\n\t\t\tthrow new Error(`A .chainId' file is expected to be present in the deployment folder for network ${subPath}`);\n\t\t}\n\n\t\tif (expectedChainId) {\n\t\t\tif (expectedChainId !== chainId) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Loading deployment in folder '${deployPath}' (with chainId: ${chainId}) for a different chainId (${expectedChainId})`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t} else {\n\t\treturn {deployments: {}};\n\t}\n\tlet fileNames = filesStats.map((a) => a.relativePath);\n\tfileNames = fileNames.sort((a, b) => {\n\t\tif (a < b) {\n\t\t\treturn -1;\n\t\t}\n\t\tif (a > b) {\n\t\t\treturn 1;\n\t\t}\n\t\treturn 0;\n\t});\n\n\tfor (const fileName of fileNames) {\n\t\tif (fileName.substring(fileName.length - 5) === '.json') {\n\t\t\tconst deploymentFileName = path.join(deployPath, fileName);\n\t\t\tlet deployment = JSON.parse(fs.readFileSync(deploymentFileName).toString());\n\t\t\t// truffleChainId argument:\n\t\t\t// if (!deployment.address && deployment.networks) {\n\t\t\t// \tif (truffleChainId && deployment.networks[truffleChainId]) {\n\t\t\t// \t\t// TRUFFLE support\n\t\t\t// \t\tconst truffleDeployment = deployment as any; // TruffleDeployment;\n\t\t\t// \t\tdeployment.address = truffleDeployment.networks[truffleChainId].address;\n\t\t\t// \t\tdeployment.transactionHash = truffleDeployment.networks[truffleChainId].transactionHash;\n\t\t\t// \t}\n\t\t\t// }\n\t\t\tif (onlyABIAndAddress) {\n\t\t\t\tdeployment = {\n\t\t\t\t\taddress: deployment.address,\n\t\t\t\t\tabi: deployment.abi,\n\t\t\t\t\tlinkedData: deployment.linkedData,\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst name = fileName.slice(0, fileName.length - 5);\n\t\t\t// console.log('fetching ' + deploymentFileName + ' for ' + name);\n\n\t\t\tdeploymentsFound[name] = deployment;\n\t\t}\n\t}\n\treturn {deployments: deploymentsFound, chainId};\n}\n","import {logs} from 'named-logs';\n\nimport {hookup, logs as Logging} from 'named-logs-console';\nimport ora from 'ora';\nhookup();\n\nexport function setLogLevel(level: number) {\n\tLogging.level = level;\n\tif (Logging.level > 0) {\n\t\tLogging.enable();\n\t} else {\n\t\tLogging.disable();\n\t}\n}\n\nexport const logger = logs('rocketh');\n\ntype PartialOra = {\n\tstop(): PartialOra;\n\tsucceed(msg?: string): PartialOra;\n\tfail(msg?: string): PartialOra;\n};\nconst voidSpinner: PartialOra = {\n\tstop() {\n\t\treturn this;\n\t},\n\tsucceed(msg?: string) {\n\t\treturn this;\n\t},\n\tfail(msg?: string) {\n\t\treturn this;\n\t},\n};\n// export function spin(message: string): PartialOra {\n// \treturn Logging.level > 0 ? ora(message).start() : voidSpinner;\n// }\n\nlet lastSpin = ora('rocketh');\nexport function spin(message: string): PartialOra {\n\tif (Logging.level > 0) {\n\t\tlastSpin = lastSpin.start(message);\n\t\treturn lastSpin;\n\t} else {\n\t\treturn voidSpinner;\n\t}\n}\n","{\n\t\"name\": \"rocketh\",\n\t\"version\": \"0.5.2\",\n\t\"description\": \"deploy smart contract on ethereum-compatible networks\",\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t},\n\t\"type\": \"module\",\n\t\"main\": \"dist/index.cjs\",\n\t\"module\": \"dist/index.js\",\n\t\"types\": \"dist/index.d.ts\",\n\t\"bin\": {\n\t\t\"rocketh\": \"dist/cli.cjs\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@types/figlet\": \"^1.5.5\",\n\t\t\"@types/node\": \"^18.15.5\",\n\t\t\"abitype\": \"^0.7.1\",\n\t\t\"eip-1193\": \"^0.4.7\",\n\t\t\"ipfs-gateway-emulator\": \"4.2.1-ipfs.2\",\n\t\t\"rimraf\": \"^4.4.1\",\n\t\t\"tsup\": \"^6.7.0\",\n\t\t\"typedoc\": \"^0.23.28\",\n\t\t\"typescript\": \"^5.0.4\"\n\t},\n\t\"dependencies\": {\n\t\t\"commander\": \"^10.0.0\",\n\t\t\"eip-1193-json-provider\": \"^0.1.5\",\n\t\t\"esbuild\": \"^0.17.12\",\n\t\t\"esbuild-register\": \"^3.4.2\",\n\t\t\"figlet\": \"^1.5.2\",\n\t\t\"ldenv\": \"^0.3.5\",\n\t\t\"named-logs\": \"^0.2.2\",\n\t\t\"named-logs-console\": \"^0.2.3\",\n\t\t\"ora\": \"^6.3.1\",\n\t\t\"viem\": \"^0.3.50\"\n\t},\n\t\"scripts\": {\n\t\t\"build\": \"rimraf dist && tsup --entry src/index.ts --entry src/cli.ts --dts --format esm,cjs\",\n\t\t\"dev\": \"rimraf dist && tsup --entry src/index.ts --entry src/cli.ts --dts --format esm,cjs --watch\",\n\t\t\"dev-no-reset\": \"tsup --entry src/index.ts --entry src/cli.ts --dts --format esm,cjs --watch\",\n\t\t\"gen-docs\": \"typedoc --out docs src\",\n\t\t\"serve-docs\": \"ipfs-emulator --only -d docs -p 8080\"\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,mBAAsB;;;ACAtB,qBAAe;AACf,uBAAiB;AAwBV,SAAS,0BAA0B,MAA0B;AACnE,QAAM,YAAY,CAAC;AACnB,aAAW,OAAO,MAAM;AACvB,QAAI,aAAa,SAAS,GAAG;AAC7B,iBAAa,WAAW,OAAO,CAAC,MAAM,CAAC,EAAE,SAAS;AAClD,eAAW,YAAY,YAAY;AAClC,gBAAU,KAAK,iBAAAA,QAAK,KAAK,KAAK,SAAS,YAAY,CAAC;AAAA,IACrD;AAAA,EACD;AACA,SAAO;AACR;AAEO,IAAM,WAA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,YAAY;AAAA,IACZ,yBAAyB;AAAA,IACzB,QAAU;AAAA,IACV,MAAQ;AAAA,IACR,SAAW;AAAA,IACX,YAAc;AAAA,EACf;AAAA,EACA,cAAgB;AAAA,IACf,WAAa;AAAA,IACb,0BAA0B;AAAA,IAC1B,SAAW;AAAA,IACX,oBAAoB;AAAA,IACpB,QAAU;AAAA,IACV,OAAS;AAAA,IACT,cAAc;AAAA,IACd,sBAAsB;AAAA,IACtB,KAAO;AAAA,IACP,MAAQ;AAAA,EACT;AAAA,EACA,SAAW;AAAA,IACV,OAAS;AAAA,IACT,KAAO;AAAA,IACP,gBAAgB;AAAA,IAChB,YAAY;AAAA,IACZ,cAAc;AAAA,EACf;AACD;;;IPtCA,sBAAQ;AAER,IAAM,cAAc,gBAAI;AACxB,IAAM,UAAU,IAAI,yBAAQ;AAC5B,QACE,KAAK,WAAW,EAChB,QAAQ,gBAAI,OAAO,EACnB,MAAM,GAAG,aAAa,EACtB,YAAY,kDAAkD,EAC9D,OAAO,yBAAyB,0DAA0D,EAC1F,OAAO,sBAAsB,yCAAyC,EACtE,OAAO,6BAA6B,oCAAoC,EACxE,eAAe,yBAAyB,wBAAwB,EAChE,MAAM,QAAQ,IAAI;AAEpB,IAAM,UAAU,QAAQ,KAAK;AAC7B,IAAM,SAAS,WAAW,OAAc;AAExC,0BAA0B,EAAC,GAAG,QAAQ,UAAU,EAAC,CAAC;","names":["path","fs","import_node_path","import_node_fs","import_node_fs","import_node_path","import_node_path","import_node_fs","path","fs","Logging","ora","config","accounts","path","fs","spinner","transaction","options","fs","config","path"]}
package/dist/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  loadAndExecuteDeployments,
4
4
  readConfig
5
- } from "./chunk-INGRKRCC.js";
5
+ } from "./chunk-DIR22FGH.js";
6
6
 
7
7
  // src/cli.ts
8
8
  import { loadEnv } from "ldenv";
@@ -11,7 +11,7 @@ import { Command } from "commander";
11
11
  // package.json
12
12
  var package_default = {
13
13
  name: "rocketh",
14
- version: "0.5.1",
14
+ version: "0.5.2",
15
15
  description: "deploy smart contract on ethereum-compatible networks",
16
16
  publishConfig: {
17
17
  access: "public"
@@ -27,7 +27,7 @@ var package_default = {
27
27
  "@types/figlet": "^1.5.5",
28
28
  "@types/node": "^18.15.5",
29
29
  abitype: "^0.7.1",
30
- "eip-1193": "^0.4.4",
30
+ "eip-1193": "^0.4.7",
31
31
  "ipfs-gateway-emulator": "4.2.1-ipfs.2",
32
32
  rimraf: "^4.4.1",
33
33
  tsup: "^6.7.0",
@@ -41,26 +41,26 @@ var package_default = {
41
41
  "esbuild-register": "^3.4.2",
42
42
  figlet: "^1.5.2",
43
43
  ldenv: "^0.3.5",
44
+ "named-logs": "^0.2.2",
45
+ "named-logs-console": "^0.2.3",
46
+ ora: "^6.3.1",
44
47
  viem: "^0.3.50"
45
48
  },
46
49
  scripts: {
47
50
  build: "rimraf dist && tsup --entry src/index.ts --entry src/cli.ts --dts --format esm,cjs",
48
51
  dev: "rimraf dist && tsup --entry src/index.ts --entry src/cli.ts --dts --format esm,cjs --watch",
52
+ "dev-no-reset": "tsup --entry src/index.ts --entry src/cli.ts --dts --format esm,cjs --watch",
49
53
  "gen-docs": "typedoc --out docs src",
50
54
  "serve-docs": "ipfs-emulator --only -d docs -p 8080"
51
55
  }
52
56
  };
53
57
 
54
58
  // src/cli.ts
55
- import figlet from "figlet";
56
59
  loadEnv();
57
- console.log(`------------------------------------------------`);
58
- console.log(figlet.textSync("rocketh"));
59
- console.log(`------------------------------------------------`);
60
- var commandName = `rocketh`;
60
+ var commandName = package_default.name;
61
61
  var program = new Command();
62
62
  program.name(commandName).version(package_default.version).usage(`${commandName}`).description("execute deploy scripts and store the deployments").option("-s, --scripts <value>", "path the folder containing the deploy scripts to execute").option("-t, --tags <value>", "comma separated list of tags to execute").option("-d, --deployments <value>", "folder where deployments are saved").requiredOption("-n, --network <value>", "network context to use").parse(process.argv);
63
63
  var options = program.opts();
64
64
  var config = readConfig(options);
65
- loadAndExecuteDeployments(config);
65
+ loadAndExecuteDeployments({ ...config, logLevel: 1 });
66
66
  //# sourceMappingURL=cli.js.map
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli.ts","../package.json"],"sourcesContent":["#! /usr/bin/env node\nimport {loadEnv} from 'ldenv';\nimport {loadAndExecuteDeployments, readConfig} from '.';\nimport {Command, Option} from 'commander';\nimport pkg from '../package.json';\nimport figlet from 'figlet';\n\nloadEnv();\n\nconsole.log(`------------------------------------------------`);\nconsole.log(figlet.textSync('rocketh'));\nconsole.log(`------------------------------------------------`);\n\nconst commandName = `rocketh`;\n\nconst program = new Command();\nprogram\n\t.name(commandName)\n\t.version(pkg.version)\n\t.usage(`${commandName}`)\n\t.description('execute deploy scripts and store the deployments')\n\t.option('-s, --scripts <value>', 'path the folder containing the deploy scripts to execute')\n\t// .addOption(\n\t// \tnew Option('-n, --node-url <value>', `ethereum's node url (fallback on ETHEREUM_NODE env variable)`).env(\n\t// \t\t'ETHEREUM_NODE'\n\t// \t)\n\t// )\n\t.option('-t, --tags <value>', 'comma separated list of tags to execute')\n\t.option('-d, --deployments <value>', 'folder where deployments are saved')\n\t// .option('-w, --watch', 'watch mode')\n\t.requiredOption('-n, --network <value>', 'network context to use')\n\t.parse(process.argv);\n\nconst options = program.opts();\nconst config = readConfig(options as any);\n\nloadAndExecuteDeployments(config);\n","{\n\t\"name\": \"rocketh\",\n\t\"version\": \"0.5.1\",\n\t\"description\": \"deploy smart contract on ethereum-compatible networks\",\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t},\n\t\"type\": \"module\",\n\t\"main\": \"dist/index.cjs\",\n\t\"module\": \"dist/index.js\",\n\t\"types\": \"dist/index.d.ts\",\n\t\"bin\": {\n\t\t\"rocketh\": \"dist/cli.cjs\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@types/figlet\": \"^1.5.5\",\n\t\t\"@types/node\": \"^18.15.5\",\n\t\t\"abitype\": \"^0.7.1\",\n\t\t\"eip-1193\": \"^0.4.4\",\n\t\t\"ipfs-gateway-emulator\": \"4.2.1-ipfs.2\",\n\t\t\"rimraf\": \"^4.4.1\",\n\t\t\"tsup\": \"^6.7.0\",\n\t\t\"typedoc\": \"^0.23.28\",\n\t\t\"typescript\": \"^5.0.4\"\n\t},\n\t\"dependencies\": {\n\t\t\"commander\": \"^10.0.0\",\n\t\t\"eip-1193-json-provider\": \"^0.1.5\",\n\t\t\"esbuild\": \"^0.17.12\",\n\t\t\"esbuild-register\": \"^3.4.2\",\n\t\t\"figlet\": \"^1.5.2\",\n\t\t\"ldenv\": \"^0.3.5\",\n\t\t\"viem\": \"^0.3.50\"\n\t},\n\t\"scripts\": {\n\t\t\"build\": \"rimraf dist && tsup --entry src/index.ts --entry src/cli.ts --dts --format esm,cjs\",\n\t\t\"dev\": \"rimraf dist && tsup --entry src/index.ts --entry src/cli.ts --dts --format esm,cjs --watch\",\n\t\t\"gen-docs\": \"typedoc --out docs src\",\n\t\t\"serve-docs\": \"ipfs-emulator --only -d docs -p 8080\"\n\t}\n}\n"],"mappings":";;;;;;;AACA,SAAQ,eAAc;AAEtB,SAAQ,eAAsB;;;ACH9B;AAAA,EACC,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,eAAiB;AAAA,IAChB,QAAU;AAAA,EACX;AAAA,EACA,MAAQ;AAAA,EACR,MAAQ;AAAA,EACR,QAAU;AAAA,EACV,OAAS;AAAA,EACT,KAAO;AAAA,IACN,SAAW;AAAA,EACZ;AAAA,EACA,iBAAmB;AAAA,IAClB,iBAAiB;AAAA,IACjB,eAAe;AAAA,IACf,SAAW;AAAA,IACX,YAAY;AAAA,IACZ,yBAAyB;AAAA,IACzB,QAAU;AAAA,IACV,MAAQ;AAAA,IACR,SAAW;AAAA,IACX,YAAc;AAAA,EACf;AAAA,EACA,cAAgB;AAAA,IACf,WAAa;AAAA,IACb,0BAA0B;AAAA,IAC1B,SAAW;AAAA,IACX,oBAAoB;AAAA,IACpB,QAAU;AAAA,IACV,OAAS;AAAA,IACT,MAAQ;AAAA,EACT;AAAA,EACA,SAAW;AAAA,IACV,OAAS;AAAA,IACT,KAAO;AAAA,IACP,YAAY;AAAA,IACZ,cAAc;AAAA,EACf;AACD;;;ADnCA,OAAO,YAAY;AAEnB,QAAQ;AAER,QAAQ,IAAI,kDAAkD;AAC9D,QAAQ,IAAI,OAAO,SAAS,SAAS,CAAC;AACtC,QAAQ,IAAI,kDAAkD;AAE9D,IAAM,cAAc;AAEpB,IAAM,UAAU,IAAI,QAAQ;AAC5B,QACE,KAAK,WAAW,EAChB,QAAQ,gBAAI,OAAO,EACnB,MAAM,GAAG,aAAa,EACtB,YAAY,kDAAkD,EAC9D,OAAO,yBAAyB,0DAA0D,EAM1F,OAAO,sBAAsB,yCAAyC,EACtE,OAAO,6BAA6B,oCAAoC,EAExE,eAAe,yBAAyB,wBAAwB,EAChE,MAAM,QAAQ,IAAI;AAEpB,IAAM,UAAU,QAAQ,KAAK;AAC7B,IAAM,SAAS,WAAW,OAAc;AAExC,0BAA0B,MAAM;","names":[]}
1
+ {"version":3,"sources":["../src/cli.ts","../package.json"],"sourcesContent":["#! /usr/bin/env node\nimport {loadEnv} from 'ldenv';\nimport {loadAndExecuteDeployments, readConfig} from '.';\nimport {Command} from 'commander';\nimport pkg from '../package.json';\n\nloadEnv();\n\nconst commandName = pkg.name;\nconst program = new Command();\nprogram\n\t.name(commandName)\n\t.version(pkg.version)\n\t.usage(`${commandName}`)\n\t.description('execute deploy scripts and store the deployments')\n\t.option('-s, --scripts <value>', 'path the folder containing the deploy scripts to execute')\n\t.option('-t, --tags <value>', 'comma separated list of tags to execute')\n\t.option('-d, --deployments <value>', 'folder where deployments are saved')\n\t.requiredOption('-n, --network <value>', 'network context to use')\n\t.parse(process.argv);\n\nconst options = program.opts();\nconst config = readConfig(options as any);\n\nloadAndExecuteDeployments({...config, logLevel: 1});\n","{\n\t\"name\": \"rocketh\",\n\t\"version\": \"0.5.2\",\n\t\"description\": \"deploy smart contract on ethereum-compatible networks\",\n\t\"publishConfig\": {\n\t\t\"access\": \"public\"\n\t},\n\t\"type\": \"module\",\n\t\"main\": \"dist/index.cjs\",\n\t\"module\": \"dist/index.js\",\n\t\"types\": \"dist/index.d.ts\",\n\t\"bin\": {\n\t\t\"rocketh\": \"dist/cli.cjs\"\n\t},\n\t\"devDependencies\": {\n\t\t\"@types/figlet\": \"^1.5.5\",\n\t\t\"@types/node\": \"^18.15.5\",\n\t\t\"abitype\": \"^0.7.1\",\n\t\t\"eip-1193\": \"^0.4.7\",\n\t\t\"ipfs-gateway-emulator\": \"4.2.1-ipfs.2\",\n\t\t\"rimraf\": \"^4.4.1\",\n\t\t\"tsup\": \"^6.7.0\",\n\t\t\"typedoc\": \"^0.23.28\",\n\t\t\"typescript\": \"^5.0.4\"\n\t},\n\t\"dependencies\": {\n\t\t\"commander\": \"^10.0.0\",\n\t\t\"eip-1193-json-provider\": \"^0.1.5\",\n\t\t\"esbuild\": \"^0.17.12\",\n\t\t\"esbuild-register\": \"^3.4.2\",\n\t\t\"figlet\": \"^1.5.2\",\n\t\t\"ldenv\": \"^0.3.5\",\n\t\t\"named-logs\": \"^0.2.2\",\n\t\t\"named-logs-console\": \"^0.2.3\",\n\t\t\"ora\": \"^6.3.1\",\n\t\t\"viem\": \"^0.3.50\"\n\t},\n\t\"scripts\": {\n\t\t\"build\": \"rimraf dist && tsup --entry src/index.ts --entry src/cli.ts --dts --format esm,cjs\",\n\t\t\"dev\": \"rimraf dist && tsup --entry src/index.ts --entry src/cli.ts --dts --format esm,cjs --watch\",\n\t\t\"dev-no-reset\": \"tsup --entry src/index.ts --entry src/cli.ts --dts --format esm,cjs --watch\",\n\t\t\"gen-docs\": \"typedoc --out docs src\",\n\t\t\"serve-docs\": \"ipfs-emulator --only -d docs -p 8080\"\n\t}\n}\n"],"mappings":";;;;;;;AACA,SAAQ,eAAc;AAEtB,SAAQ,eAAc;;;ACHtB;AAAA,EACC,MAAQ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