rocketh 0.10.7 → 0.10.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,20 @@
1
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined")
5
- return require.apply(this, arguments);
6
- throw Error('Dynamic require of "' + x + '" is not supported');
7
- });
1
+ import { createRequire } from 'module';
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import { custom, createPublicClient, formatEther } from 'viem';
5
+ import { JSONRPCHTTPProvider } from 'eip-1193-jsonrpc-provider';
6
+ import { logs } from 'named-logs';
7
+ import { hookup, factory } from 'named-logs-console';
8
+ import chains from 'viem/chains';
9
+ import { FunctionFragment } from 'ethers';
10
+ import prompts from 'prompts';
11
+
12
+ var require$1 = (
13
+ true
14
+ ? /* @__PURE__ */ createRequire(import.meta.url)
15
+ : require
16
+ );
8
17
 
9
- // src/utils/fs.ts
10
- import fs from "fs";
11
- import path from "path";
12
18
  function traverseMultipleDirectory(dirs) {
13
19
  const filepaths = [];
14
20
  for (const dir of dirs) {
@@ -20,7 +26,7 @@ function traverseMultipleDirectory(dirs) {
20
26
  }
21
27
  return filepaths;
22
28
  }
23
- var traverse = function(dir, result = [], topDir, filter) {
29
+ const traverse = function(dir, result = [], topDir, filter) {
24
30
  fs.readdirSync(dir).forEach((name) => {
25
31
  const fPath = path.resolve(dir, name);
26
32
  const stats = fs.statSync(fPath);
@@ -42,17 +48,6 @@ var traverse = function(dir, result = [], topDir, filter) {
42
48
  return result;
43
49
  };
44
50
 
45
- // src/executor/index.ts
46
- import path4 from "path";
47
- import fs4 from "fs";
48
-
49
- // src/environment/index.ts
50
- import fs3 from "fs";
51
- import { createPublicClient, custom } from "viem";
52
- import { JSONRPCHTTPProvider } from "eip-1193-jsonrpc-provider";
53
- import path3 from "path";
54
-
55
- // src/utils/json.ts
56
51
  function bnReplacer(k, v) {
57
52
  if (typeof v === "bigint") {
58
53
  return v.toString() + "n";
@@ -72,12 +67,9 @@ function stringToJSON(str) {
72
67
  return JSON.parse(str, bnReviver);
73
68
  }
74
69
 
75
- // src/environment/deployments.ts
76
- import path2 from "path";
77
- import fs2 from "fs";
78
70
  function loadDeployments(deploymentsPath, networkName, onlyABIAndAddress, expectedChain) {
79
71
  const deploymentsFound = {};
80
- const deployPath = path2.join(deploymentsPath, networkName);
72
+ const deployPath = path.join(deploymentsPath, networkName);
81
73
  let filesStats;
82
74
  try {
83
75
  filesStats = traverse(deployPath, void 0, void 0, (name) => !name.startsWith(".") && name !== "solcInputs");
@@ -87,13 +79,13 @@ function loadDeployments(deploymentsPath, networkName, onlyABIAndAddress, expect
87
79
  let chainId;
88
80
  let genesisHash;
89
81
  if (filesStats.length > 0) {
90
- const chainIdFilepath = path2.join(deployPath, ".chainId");
91
- if (fs2.existsSync(chainIdFilepath)) {
92
- chainId = fs2.readFileSync(chainIdFilepath, "utf-8").trim();
82
+ const chainIdFilepath = path.join(deployPath, ".chainId");
83
+ if (fs.existsSync(chainIdFilepath)) {
84
+ chainId = fs.readFileSync(chainIdFilepath, "utf-8").trim();
93
85
  } else {
94
- const chainFilepath = path2.join(deployPath, ".chain");
95
- if (fs2.existsSync(chainFilepath)) {
96
- const chainSTR = fs2.readFileSync(chainFilepath, "utf-8");
86
+ const chainFilepath = path.join(deployPath, ".chain");
87
+ if (fs.existsSync(chainFilepath)) {
88
+ const chainSTR = fs.readFileSync(chainFilepath, "utf-8");
97
89
  const chainData = JSON.parse(chainSTR);
98
90
  chainId = chainData.chainId;
99
91
  genesisHash = chainData.genesisHash;
@@ -111,7 +103,7 @@ function loadDeployments(deploymentsPath, networkName, onlyABIAndAddress, expect
111
103
  }
112
104
  if (expectedChain.genesisHash && expectedChain.genesisHash !== genesisHash) {
113
105
  if (expectedChain.deleteDeploymentsIfDifferentGenesisHash) {
114
- fs2.rmSync(deployPath, { recursive: true, force: true });
106
+ fs.rmSync(deployPath, { recursive: true, force: true });
115
107
  return { deployments: {} };
116
108
  } else {
117
109
  throw new Error(
@@ -135,8 +127,8 @@ function loadDeployments(deploymentsPath, networkName, onlyABIAndAddress, expect
135
127
  });
136
128
  for (const fileName of fileNames) {
137
129
  if (fileName.substring(fileName.length - 5) === ".json") {
138
- const deploymentFileName = path2.join(deployPath, fileName);
139
- let deployment = JSON.parse(fs2.readFileSync(deploymentFileName).toString());
130
+ const deploymentFileName = path.join(deployPath, fileName);
131
+ let deployment = JSON.parse(fs.readFileSync(deploymentFileName).toString());
140
132
  if (onlyABIAndAddress) {
141
133
  deployment = {
142
134
  address: deployment.address,
@@ -151,20 +143,17 @@ function loadDeployments(deploymentsPath, networkName, onlyABIAndAddress, expect
151
143
  return { deployments: deploymentsFound, chainId, genesisHash };
152
144
  }
153
145
 
154
- // src/internal/logging.ts
155
- import { logs } from "named-logs";
156
- import { hookup, factory as Logging } from "named-logs-console";
157
146
  hookup();
158
147
  function setLogLevel(level) {
159
- Logging.level = level;
160
- if (Logging.level > 0) {
161
- Logging.enable();
148
+ factory.level = level;
149
+ if (factory.level > 0) {
150
+ factory.enable();
162
151
  } else {
163
- Logging.disable();
152
+ factory.disable();
164
153
  }
165
154
  }
166
- var logger = logs("rocketh");
167
- var loggerProgressIndicator = {
155
+ const logger = logs("rocketh");
156
+ const loggerProgressIndicator = {
168
157
  start(msg) {
169
158
  if (msg) {
170
159
  console.log(msg);
@@ -187,7 +176,7 @@ var loggerProgressIndicator = {
187
176
  return this;
188
177
  }
189
178
  };
190
- var voidProgressIndicator = {
179
+ const voidProgressIndicator = {
191
180
  start() {
192
181
  return this;
193
182
  },
@@ -201,9 +190,9 @@ var voidProgressIndicator = {
201
190
  return this;
202
191
  }
203
192
  };
204
- var lastSpin = loggerProgressIndicator;
193
+ let lastSpin = loggerProgressIndicator;
205
194
  function spin(message) {
206
- if (Logging.level > 0) {
195
+ if (factory.level > 0) {
207
196
  lastSpin = lastSpin.start(message);
208
197
  return lastSpin;
209
198
  } else {
@@ -211,18 +200,42 @@ function spin(message) {
211
200
  }
212
201
  }
213
202
  function log(message) {
214
- if (Logging.level > 0) {
203
+ if (factory.level > 0) {
215
204
  console.log(message);
216
205
  }
217
206
  }
218
207
 
219
- // src/environment/utils/chains.ts
220
- import chains from "viem/chains";
221
- var chainById = {};
222
- var allChains = chains.default || chains;
208
+ const chainTypesByNames = {
209
+ base: "op-stack",
210
+ baseGoerli: "op-stack",
211
+ baseSepolia: "op-stack",
212
+ optimism: "op-stack",
213
+ optimismGoerli: "op-stack",
214
+ optimismSepolia: "op-stack",
215
+ pgn: "op-stack",
216
+ pgnTestnet: "op-stack",
217
+ zora: "op-stack",
218
+ zoraSepolia: "op-stack",
219
+ zoraTestnet: "op-stack",
220
+ ancient8: "op-stack",
221
+ ancient8Sepolia: "op-stack",
222
+ celoAlfajores: "celo",
223
+ celo: "celo",
224
+ zkSync: "zksync",
225
+ zkSyncTestnet: "zksync",
226
+ zkSyncSepoliaTestnet: "zksync"
227
+ };
228
+ const chainTypes = {};
229
+ const chainById = {};
230
+ const allChains = chains.default || chains;
223
231
  for (const key of Object.keys(allChains)) {
224
232
  const chain = allChains[key];
225
- chainById[chain.id.toString()] = chain;
233
+ const chainId = chain.id.toString();
234
+ const specificChainType = chainTypesByNames[key];
235
+ if (specificChainType) {
236
+ chainTypes[chainId] = specificChainType;
237
+ }
238
+ chainById[chainId] = chain;
226
239
  }
227
240
  function getChain(id) {
228
241
  const chain = chainById[id];
@@ -246,8 +259,6 @@ function getChain(id) {
246
259
  return chain;
247
260
  }
248
261
 
249
- // src/environment/utils/artifacts.ts
250
- import { FunctionFragment } from "ethers";
251
262
  function deepEqual(obj1, obj2) {
252
263
  function isObject(obj) {
253
264
  if (typeof obj === "object" && obj != null) {
@@ -301,30 +312,23 @@ function mergeArtifacts(list) {
301
312
  }
302
313
  sigJSMap.set(selector, { index: i, routeName: listElem.name, functionName: element.name });
303
314
  const exists = added.has(element.name);
304
- if (exists) {
305
- } else {
315
+ if (exists) ; else {
306
316
  added.set(element.name, element);
307
317
  mergedABI.push(element);
308
318
  }
309
- } else if (element.type === "constructor") {
310
- } else if (element.type === "error") {
319
+ } else if (element.type === "constructor") ; else if (element.type === "error") {
311
320
  const exists = added.has(element.name);
312
- if (exists) {
313
- } else {
321
+ if (exists) ; else {
314
322
  added.set(element.name, element);
315
323
  mergedABI.push(element);
316
324
  }
317
325
  } else if (element.type === "event") {
318
326
  const exists = added.has(element.name);
319
- if (exists) {
320
- } else {
327
+ if (exists) ; else {
321
328
  added.set(element.name, element);
322
329
  mergedABI.push(element);
323
330
  }
324
- } else if (element.type === "fallback") {
325
- } else if (element.type === "receive") {
326
- } else {
327
- }
331
+ } else if (element.type === "fallback") ; else if (element.type === "receive") ; else ;
328
332
  }
329
333
  const devdoc = listElem.artifact.devdoc;
330
334
  if (devdoc) {
@@ -364,18 +368,16 @@ function mergeArtifacts(list) {
364
368
  };
365
369
  }
366
370
 
367
- // src/environment/providers/BaseProvider.ts
368
- var BaseProvider = class {
371
+ class BaseProvider {
369
372
  constructor(provider) {
370
373
  this.provider = provider;
371
374
  }
372
375
  request(args) {
373
376
  return this._request(args);
374
377
  }
375
- };
378
+ }
376
379
 
377
- // src/environment/providers/TransactionHashTracker.ts
378
- var TransactionHashTracker = class extends BaseProvider {
380
+ class TransactionHashTracker extends BaseProvider {
379
381
  constructor(provider) {
380
382
  super(provider);
381
383
  this.transactionHashes = [];
@@ -393,9 +395,8 @@ var TransactionHashTracker = class extends BaseProvider {
393
395
  }
394
396
  return response;
395
397
  }
396
- };
398
+ }
397
399
 
398
- // src/environment/index.ts
399
400
  globalThis.extensions = [];
400
401
  function extendEnvironment(extension) {
401
402
  globalThis.extensions.push(extension);
@@ -576,11 +577,11 @@ async function createEnvironment(config, providedContext) {
576
577
  }
577
578
  };
578
579
  function ensureDeploymentFolder() {
579
- const folderPath = path3.join(config.deployments, context.network.name);
580
- fs3.mkdirSync(folderPath, { recursive: true });
581
- const chainFilepath = path3.join(folderPath, ".chain");
582
- if (!fs3.existsSync(chainFilepath)) {
583
- fs3.writeFileSync(chainFilepath, JSON.stringify({ chainId, genesisHash }));
580
+ const folderPath = path.join(config.deployments, context.network.name);
581
+ fs.mkdirSync(folderPath, { recursive: true });
582
+ const chainFilepath = path.join(folderPath, ".chain");
583
+ if (!fs.existsSync(chainFilepath)) {
584
+ fs.writeFileSync(chainFilepath, JSON.stringify({ chainId, genesisHash }));
584
585
  }
585
586
  return folderPath;
586
587
  }
@@ -622,7 +623,7 @@ async function createEnvironment(config, providedContext) {
622
623
  deployments[name] = deployment;
623
624
  if (context.network.saveDeployments) {
624
625
  const folderPath = ensureDeploymentFolder();
625
- fs3.writeFileSync(`${folderPath}/${name}.json`, JSONToString(deployment, 2));
626
+ fs.writeFileSync(`${folderPath}/${name}.json`, JSONToString(deployment, 2));
626
627
  }
627
628
  return deployment;
628
629
  }
@@ -631,10 +632,10 @@ async function createEnvironment(config, providedContext) {
631
632
  return;
632
633
  }
633
634
  const folderPath = ensureDeploymentFolder();
634
- const filepath = path3.join(folderPath, ".pending_transactions.json");
635
+ const filepath = path.join(folderPath, ".pending_transactions.json");
635
636
  let existingPendingTansactions;
636
637
  try {
637
- existingPendingTansactions = stringToJSON(fs3.readFileSync(filepath, "utf-8"));
638
+ existingPendingTansactions = stringToJSON(fs.readFileSync(filepath, "utf-8"));
638
639
  } catch {
639
640
  existingPendingTansactions = [];
640
641
  }
@@ -648,7 +649,7 @@ async function createEnvironment(config, providedContext) {
648
649
  );
649
650
  try {
650
651
  await waitForDeploymentTransactionAndSave(pendingTransaction);
651
- fs3.writeFileSync(filepath, JSONToString(existingPendingTansactions, 2));
652
+ fs.writeFileSync(filepath, JSONToString(existingPendingTansactions, 2));
652
653
  spinner.succeed();
653
654
  } catch (e) {
654
655
  spinner.fail();
@@ -658,7 +659,7 @@ async function createEnvironment(config, providedContext) {
658
659
  const spinner = spin(`recovering execution's transaction ${pendingTransaction.transaction.hash}`);
659
660
  try {
660
661
  await waitForTransaction(pendingTransaction.transaction.hash);
661
- fs3.writeFileSync(filepath, JSONToString(existingPendingTansactions, 2));
662
+ fs.writeFileSync(filepath, JSONToString(existingPendingTansactions, 2));
662
663
  spinner.succeed();
663
664
  } catch (e) {
664
665
  spinner.fail();
@@ -667,21 +668,21 @@ async function createEnvironment(config, providedContext) {
667
668
  }
668
669
  }
669
670
  }
670
- fs3.rmSync(filepath);
671
+ fs.rmSync(filepath);
671
672
  }
672
673
  }
673
674
  async function savePendingTransaction(pendingTransaction) {
674
675
  if (context.network.saveDeployments) {
675
676
  const folderPath = ensureDeploymentFolder();
676
- const filepath = path3.join(folderPath, ".pending_transactions.json");
677
+ const filepath = path.join(folderPath, ".pending_transactions.json");
677
678
  let existingPendinTransactions;
678
679
  try {
679
- existingPendinTransactions = stringToJSON(fs3.readFileSync(filepath, "utf-8"));
680
+ existingPendinTransactions = stringToJSON(fs.readFileSync(filepath, "utf-8"));
680
681
  } catch {
681
682
  existingPendinTransactions = [];
682
683
  }
683
684
  existingPendinTransactions.push(pendingTransaction);
684
- fs3.writeFileSync(filepath, JSONToString(existingPendinTransactions, 2));
685
+ fs.writeFileSync(filepath, JSONToString(existingPendinTransactions, 2));
685
686
  }
686
687
  return deployments;
687
688
  }
@@ -703,25 +704,25 @@ async function createEnvironment(config, providedContext) {
703
704
  async function deleteTransaction(hash) {
704
705
  if (context.network.saveDeployments) {
705
706
  const folderPath = ensureDeploymentFolder();
706
- const filepath = path3.join(folderPath, ".pending_transactions.json");
707
+ const filepath = path.join(folderPath, ".pending_transactions.json");
707
708
  let existingPendinTransactions;
708
709
  try {
709
- existingPendinTransactions = stringToJSON(fs3.readFileSync(filepath, "utf-8"));
710
+ existingPendinTransactions = stringToJSON(fs.readFileSync(filepath, "utf-8"));
710
711
  } catch {
711
712
  existingPendinTransactions = [];
712
713
  }
713
714
  existingPendinTransactions = existingPendinTransactions.filter((v) => v.transaction.hash !== hash);
714
715
  if (existingPendinTransactions.length === 0) {
715
- fs3.rmSync(filepath);
716
+ fs.rmSync(filepath);
716
717
  } else {
717
- fs3.writeFileSync(filepath, JSONToString(existingPendinTransactions, 2));
718
+ fs.writeFileSync(filepath, JSONToString(existingPendinTransactions, 2));
718
719
  }
719
720
  }
720
721
  }
721
722
  async function exportDeploymentsAsTypes() {
722
723
  const folderPath = "./generated";
723
- fs3.mkdirSync(folderPath, { recursive: true });
724
- fs3.writeFileSync(`${folderPath}/deployments.ts`, `export default ${JSONToString(deployments, 2)} as const;`);
724
+ fs.mkdirSync(folderPath, { recursive: true });
725
+ fs.writeFileSync(`${folderPath}/deployments.ts`, `export default ${JSONToString(deployments, 2)} as const;`);
725
726
  }
726
727
  async function waitForTransaction(hash, info) {
727
728
  const spinner = spin(
@@ -902,7 +903,6 @@ async function createEnvironment(config, providedContext) {
902
903
  };
903
904
  }
904
905
 
905
- // src/utils/eth.ts
906
906
  function avg(arr) {
907
907
  const sum = arr.reduce((a, v) => a + v);
908
908
  return sum / BigInt(arr.length);
@@ -965,11 +965,8 @@ async function getRoughGasPriceEstimate(provider, options) {
965
965
  };
966
966
  }
967
967
 
968
- // src/executor/index.ts
969
- import prompts from "prompts";
970
- import { formatEther } from "viem";
971
968
  if (!process.env["ROCKETH_SKIP_ESBUILD"]) {
972
- __require("esbuild-register/dist/node").register();
969
+ require$1("esbuild-register/dist/node").register();
973
970
  }
974
971
  function execute(context, callback, options) {
975
972
  const scriptModule = (env, args) => callback(env, args);
@@ -981,7 +978,7 @@ function execute(context, callback, options) {
981
978
  function readConfig(options) {
982
979
  let configFile;
983
980
  try {
984
- const configString = fs4.readFileSync("./rocketh.json", "utf-8");
981
+ const configString = fs.readFileSync("./rocketh.json", "utf-8");
985
982
  configFile = JSON.parse(configString);
986
983
  } catch {
987
984
  }
@@ -1100,7 +1097,7 @@ async function executeDeployScripts(config, args) {
1100
1097
  setLogLevel(typeof config.logLevel === "undefined" ? 0 : config.logLevel);
1101
1098
  let filepaths;
1102
1099
  filepaths = traverseMultipleDirectory([config.scripts]);
1103
- filepaths = filepaths.filter((v) => !path4.basename(v).startsWith("_")).sort((a, b) => {
1100
+ filepaths = filepaths.filter((v) => !path.basename(v).startsWith("_")).sort((a, b) => {
1104
1101
  if (a < b) {
1105
1102
  return -1;
1106
1103
  }
@@ -1114,13 +1111,13 @@ async function executeDeployScripts(config, args) {
1114
1111
  const scriptPathBags = {};
1115
1112
  const scriptFilePaths = [];
1116
1113
  for (const filepath of filepaths) {
1117
- const scriptFilePath = path4.resolve(filepath);
1114
+ const scriptFilePath = path.resolve(filepath);
1118
1115
  let scriptModule;
1119
1116
  try {
1120
- if (__require.cache) {
1121
- delete __require.cache[scriptFilePath];
1117
+ if (require$1.cache) {
1118
+ delete require$1.cache[scriptFilePath];
1122
1119
  }
1123
- scriptModule = __require(scriptFilePath);
1120
+ scriptModule = require$1(scriptFilePath);
1124
1121
  if (scriptModule.default) {
1125
1122
  scriptModule = scriptModule.default;
1126
1123
  if (scriptModule.default) {
@@ -1242,8 +1239,8 @@ Do you want to proceed (note that gas price can change for each tx)`
1242
1239
  }
1243
1240
  }
1244
1241
  for (const deployScript of scriptsToRun.concat(scriptsToRunAtTheEnd)) {
1245
- const filename = path4.basename(deployScript.filePath);
1246
- const relativeFilepath = path4.relative(".", deployScript.filePath);
1242
+ const filename = path.basename(deployScript.filePath);
1243
+ path.relative(".", deployScript.filePath);
1247
1244
  let skip = false;
1248
1245
  const spinner = spin(`- Executing ${filename}`);
1249
1246
  if (deployScript.func.skip) {
@@ -1267,7 +1264,7 @@ Do you want to proceed (note that gas price can change for each tx)`
1267
1264
  throw e;
1268
1265
  }
1269
1266
  if (result && typeof result === "boolean") {
1270
- const deploymentFolderPath = config.deployments;
1267
+ config.deployments;
1271
1268
  }
1272
1269
  }
1273
1270
  }
@@ -1287,21 +1284,5 @@ Do you want to proceed (note that gas price can change for each tx)`
1287
1284
  return external;
1288
1285
  }
1289
1286
 
1290
- export {
1291
- loadDeployments,
1292
- chainById,
1293
- getChain,
1294
- mergeArtifacts,
1295
- extendEnvironment,
1296
- handleSignerProtocol,
1297
- getGasPriceEstimate,
1298
- getRoughGasPriceEstimate,
1299
- execute,
1300
- readConfig,
1301
- readAndResolveConfig,
1302
- resolveConfig,
1303
- loadEnvironment,
1304
- loadAndExecuteDeployments,
1305
- executeDeployScripts
1306
- };
1307
- //# sourceMappingURL=chunk-MEL67HDP.js.map
1287
+ export { execute as a, readAndResolveConfig as b, resolveConfig as c, loadEnvironment as d, extendEnvironment as e, loadAndExecuteDeployments as f, executeDeployScripts as g, handleSignerProtocol as h, chainTypes as i, chainById as j, getChain as k, loadDeployments as l, mergeArtifacts as m, getGasPriceEstimate as n, getRoughGasPriceEstimate as o, readConfig as r };
1288
+ //# sourceMappingURL=index-DOSnToHV.mjs.map