genlayer 0.26.0 → 0.27.0

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/index.js CHANGED
@@ -4340,15 +4340,15 @@ var require_streams = __commonJS({
4340
4340
  var POOL_SIZE2 = 65536;
4341
4341
  if (!globalThis.ReadableStream) {
4342
4342
  try {
4343
- const process15 = __require("node:process");
4344
- const { emitWarning } = process15;
4343
+ const process16 = __require("node:process");
4344
+ const { emitWarning } = process16;
4345
4345
  try {
4346
- process15.emitWarning = () => {
4346
+ process16.emitWarning = () => {
4347
4347
  };
4348
4348
  Object.assign(globalThis, __require("node:stream/web"));
4349
- process15.emitWarning = emitWarning;
4349
+ process16.emitWarning = emitWarning;
4350
4350
  } catch (error) {
4351
- process15.emitWarning = emitWarning;
4351
+ process16.emitWarning = emitWarning;
4352
4352
  throw error;
4353
4353
  }
4354
4354
  } catch (error) {
@@ -7715,7 +7715,7 @@ var version3;
7715
7715
  var init_version2 = __esm({
7716
7716
  "node_modules/viem/_esm/errors/version.js"() {
7717
7717
  "use strict";
7718
- version3 = "2.31.7";
7718
+ version3 = "2.33.1";
7719
7719
  }
7720
7720
  });
7721
7721
 
@@ -15731,7 +15731,7 @@ var init_ccip2 = __esm({
15731
15731
 
15732
15732
  // node_modules/viem/_esm/actions/public/call.js
15733
15733
  async function call(client, args) {
15734
- const { account: account_ = client.account, authorizationList, batch = Boolean(client.batch?.multicall), blockNumber, blockTag = "latest", accessList, blobs, blockOverrides, code, data: data_, factory, factoryData, gas, gasPrice, maxFeePerBlobGas, maxFeePerGas, maxPriorityFeePerGas, nonce, to, value, stateOverride, ...rest } = args;
15734
+ const { account: account_ = client.account, authorizationList, batch = Boolean(client.batch?.multicall), blockNumber, blockTag = client.experimental_blockTag ?? "latest", accessList, blobs, blockOverrides, code, data: data_, factory, factoryData, gas, gasPrice, maxFeePerBlobGas, maxFeePerGas, maxPriorityFeePerGas, nonce, to, value, stateOverride, ...rest } = args;
15735
15735
  const account = account_ ? parseAccount(account_) : void 0;
15736
15736
  if (code && (factory || factoryData))
15737
15737
  throw new BaseError2("Cannot provide both `code` & `factory`/`factoryData` as parameters.");
@@ -15840,7 +15840,7 @@ function shouldPerformMulticall({ request }) {
15840
15840
  }
15841
15841
  async function scheduleMulticall(client, args) {
15842
15842
  const { batchSize = 1024, wait: wait2 = 0 } = typeof client.batch?.multicall === "object" ? client.batch.multicall : {};
15843
- const { blockNumber, blockTag = "latest", data, multicallAddress: multicallAddress_, to } = args;
15843
+ const { blockNumber, blockTag = client.experimental_blockTag ?? "latest", data, multicallAddress: multicallAddress_, to } = args;
15844
15844
  let multicallAddress = multicallAddress_;
15845
15845
  if (!multicallAddress) {
15846
15846
  if (!client.chain)
@@ -17856,7 +17856,7 @@ var require_semver2 = __commonJS({
17856
17856
  import { program } from "commander";
17857
17857
 
17858
17858
  // package.json
17859
- var version = "0.26.0";
17859
+ var version = "0.27.0";
17860
17860
  var package_default = {
17861
17861
  name: "genlayer",
17862
17862
  version,
@@ -17925,6 +17925,7 @@ var package_default = {
17925
17925
  "fs-extra": "^11.3.0",
17926
17926
  "genlayer-js": "^0.11.0",
17927
17927
  inquirer: "^12.0.0",
17928
+ keytar: "^7.9.0",
17928
17929
  "node-fetch": "^3.0.0",
17929
17930
  open: "^10.1.0",
17930
17931
  ora: "^8.2.0",
@@ -19372,18 +19373,14 @@ var rpcClient = new JsonRpcClient(DEFAULT_JSON_RPC_URL);
19372
19373
  import path from "path";
19373
19374
  import os from "os";
19374
19375
  import fs2 from "fs";
19375
- var _ConfigFileManager = class _ConfigFileManager {
19376
- // 5 minutes
19376
+ var ConfigFileManager = class {
19377
19377
  constructor(baseFolder = ".genlayer/", configFileName = "genlayer-config.json") {
19378
19378
  __publicField(this, "folderPath");
19379
19379
  __publicField(this, "configFilePath");
19380
- __publicField(this, "tempFolderPath");
19381
19380
  this.folderPath = path.resolve(os.homedir(), baseFolder);
19382
19381
  this.configFilePath = path.resolve(this.folderPath, configFileName);
19383
- this.tempFolderPath = path.resolve(os.tmpdir(), "genlayer-temp");
19384
19382
  this.ensureFolderExists();
19385
19383
  this.ensureConfigFileExists();
19386
- this.ensureTempFolderExists();
19387
19384
  }
19388
19385
  ensureFolderExists() {
19389
19386
  if (!fs2.existsSync(this.folderPath)) {
@@ -19395,11 +19392,6 @@ var _ConfigFileManager = class _ConfigFileManager {
19395
19392
  fs2.writeFileSync(this.configFilePath, JSON.stringify({}, null, 2));
19396
19393
  }
19397
19394
  }
19398
- ensureTempFolderExists() {
19399
- if (!fs2.existsSync(this.tempFolderPath)) {
19400
- fs2.mkdirSync(this.tempFolderPath, { recursive: true, mode: 448 });
19401
- }
19402
- }
19403
19395
  getFolderPath() {
19404
19396
  return this.folderPath;
19405
19397
  }
@@ -19419,59 +19411,34 @@ var _ConfigFileManager = class _ConfigFileManager {
19419
19411
  config[key] = value;
19420
19412
  fs2.writeFileSync(this.configFilePath, JSON.stringify(config, null, 2));
19421
19413
  }
19422
- storeTempFile(fileName, content) {
19423
- this.ensureTempFolderExists();
19424
- const filePath = path.resolve(this.tempFolderPath, fileName);
19425
- const tempData = {
19426
- content,
19427
- timestamp: Date.now()
19428
- };
19429
- fs2.writeFileSync(filePath, JSON.stringify(tempData), { mode: 384 });
19414
+ };
19415
+
19416
+ // src/lib/config/KeychainManager.ts
19417
+ import { default as keytar } from "keytar";
19418
+ var _KeychainManager = class _KeychainManager {
19419
+ constructor() {
19430
19420
  }
19431
- getTempFile(fileName) {
19432
- const filePath = path.resolve(this.tempFolderPath, fileName);
19433
- if (!fs2.existsSync(filePath)) {
19434
- return null;
19435
- }
19436
- const fileContent = fs2.readFileSync(filePath, "utf-8");
19437
- const tempData = JSON.parse(fileContent);
19438
- if (Date.now() - tempData.timestamp > _ConfigFileManager.TEMP_FILE_EXPIRATION_MS) {
19439
- this.clearTempFile(fileName);
19440
- return null;
19421
+ async isKeychainAvailable() {
19422
+ try {
19423
+ await keytar.findCredentials("test-service");
19424
+ return true;
19425
+ } catch {
19426
+ return false;
19441
19427
  }
19442
- return tempData.content;
19443
19428
  }
19444
- hasTempFile(fileName) {
19445
- return this.getTempFile(fileName) !== null;
19429
+ async storePrivateKey(privateKey) {
19430
+ return await keytar.setPassword(_KeychainManager.SERVICE, _KeychainManager.ACCOUNT, privateKey);
19446
19431
  }
19447
- clearTempFile(fileName) {
19448
- const filePath = path.resolve(this.tempFolderPath, fileName);
19449
- if (fs2.existsSync(filePath)) {
19450
- fs2.unlinkSync(filePath);
19451
- }
19432
+ async getPrivateKey() {
19433
+ return await keytar.getPassword(_KeychainManager.SERVICE, _KeychainManager.ACCOUNT);
19452
19434
  }
19453
- cleanupExpiredTempFiles() {
19454
- if (!fs2.existsSync(this.tempFolderPath)) {
19455
- return;
19456
- }
19457
- const files = fs2.readdirSync(this.tempFolderPath);
19458
- const now = Date.now();
19459
- for (const file of files) {
19460
- const filePath = path.resolve(this.tempFolderPath, file);
19461
- try {
19462
- const fileContent = fs2.readFileSync(filePath, "utf-8");
19463
- const tempData = JSON.parse(fileContent);
19464
- if (now - tempData.timestamp > _ConfigFileManager.TEMP_FILE_EXPIRATION_MS) {
19465
- fs2.unlinkSync(filePath);
19466
- }
19467
- } catch (error) {
19468
- fs2.unlinkSync(filePath);
19469
- }
19470
- }
19435
+ async removePrivateKey() {
19436
+ return await keytar.deletePassword(_KeychainManager.SERVICE, _KeychainManager.ACCOUNT);
19471
19437
  }
19472
19438
  };
19473
- __publicField(_ConfigFileManager, "TEMP_FILE_EXPIRATION_MS", 5 * 60 * 1e3);
19474
- var ConfigFileManager = _ConfigFileManager;
19439
+ __publicField(_KeychainManager, "SERVICE", "genlayer-cli");
19440
+ __publicField(_KeychainManager, "ACCOUNT", "default-user");
19441
+ var KeychainManager = _KeychainManager;
19475
19442
 
19476
19443
  // node_modules/ora/index.js
19477
19444
  import process9 from "node:process";
@@ -20073,7 +20040,7 @@ if (process.platform === "linux") {
20073
20040
  }
20074
20041
 
20075
20042
  // node_modules/signal-exit/dist/mjs/index.js
20076
- var processOk = (process15) => !!process15 && typeof process15 === "object" && typeof process15.removeListener === "function" && typeof process15.emit === "function" && typeof process15.reallyExit === "function" && typeof process15.listeners === "function" && typeof process15.kill === "function" && typeof process15.pid === "number" && typeof process15.on === "function";
20043
+ var processOk = (process16) => !!process16 && typeof process16 === "object" && typeof process16.removeListener === "function" && typeof process16.emit === "function" && typeof process16.reallyExit === "function" && typeof process16.listeners === "function" && typeof process16.kill === "function" && typeof process16.pid === "number" && typeof process16.on === "function";
20077
20044
  var kExitEmitter = Symbol.for("signal-exit emitter");
20078
20045
  var global2 = globalThis;
20079
20046
  var ObjectDefineProperty = Object.defineProperty.bind(Object);
@@ -20156,7 +20123,7 @@ var SignalExitFallback = class extends SignalExitBase {
20156
20123
  };
20157
20124
  var _hupSig, _emitter, _process, _originalProcessEmit, _originalProcessReallyExit, _sigListeners, _loaded, _SignalExit_instances, processReallyExit_fn, processEmit_fn;
20158
20125
  var SignalExit = class extends SignalExitBase {
20159
- constructor(process15) {
20126
+ constructor(process16) {
20160
20127
  super();
20161
20128
  __privateAdd(this, _SignalExit_instances);
20162
20129
  // "SIGHUP" throws an `ENOSYS` error on Windows,
@@ -20170,13 +20137,13 @@ var SignalExit = class extends SignalExitBase {
20170
20137
  __privateAdd(this, _originalProcessReallyExit);
20171
20138
  __privateAdd(this, _sigListeners, {});
20172
20139
  __privateAdd(this, _loaded, false);
20173
- __privateSet(this, _process, process15);
20140
+ __privateSet(this, _process, process16);
20174
20141
  __privateSet(this, _sigListeners, {});
20175
20142
  for (const sig of signals) {
20176
20143
  __privateGet(this, _sigListeners)[sig] = () => {
20177
20144
  const listeners = __privateGet(this, _process).listeners(sig);
20178
20145
  let { count } = __privateGet(this, _emitter);
20179
- const p = process15;
20146
+ const p = process16;
20180
20147
  if (typeof p.__signal_exit_emitter__ === "object" && typeof p.__signal_exit_emitter__.count === "number") {
20181
20148
  count += p.__signal_exit_emitter__.count;
20182
20149
  }
@@ -20185,12 +20152,12 @@ var SignalExit = class extends SignalExitBase {
20185
20152
  const ret = __privateGet(this, _emitter).emit("exit", null, sig);
20186
20153
  const s2 = sig === "SIGHUP" ? __privateGet(this, _hupSig) : sig;
20187
20154
  if (!ret)
20188
- process15.kill(process15.pid, s2);
20155
+ process16.kill(process16.pid, s2);
20189
20156
  }
20190
20157
  };
20191
20158
  }
20192
- __privateSet(this, _originalProcessReallyExit, process15.reallyExit);
20193
- __privateSet(this, _originalProcessEmit, process15.emit);
20159
+ __privateSet(this, _originalProcessReallyExit, process16.reallyExit);
20160
+ __privateSet(this, _originalProcessEmit, process16.emit);
20194
20161
  }
20195
20162
  onExit(cb, opts) {
20196
20163
  if (!processOk(__privateGet(this, _process))) {
@@ -21395,8 +21362,7 @@ function formatBlock(block) {
21395
21362
  }
21396
21363
 
21397
21364
  // node_modules/viem/_esm/actions/public/getBlock.js
21398
- async function getBlock(client, { blockHash, blockNumber, blockTag: blockTag_, includeTransactions: includeTransactions_ } = {}) {
21399
- const blockTag = blockTag_ ?? "latest";
21365
+ async function getBlock(client, { blockHash, blockNumber, blockTag = client.experimental_blockTag ?? "latest", includeTransactions: includeTransactions_ } = {}) {
21400
21366
  const includeTransactions = includeTransactions_ ?? false;
21401
21367
  const blockNumberHex = blockNumber !== void 0 ? numberToHex(blockNumber) : void 0;
21402
21368
  let block = null;
@@ -21866,7 +21832,7 @@ async function prepareTransactionRequest(client, args) {
21866
21832
 
21867
21833
  // node_modules/viem/_esm/actions/public/getBalance.js
21868
21834
  init_toHex();
21869
- async function getBalance(client, { address, blockNumber, blockTag = "latest" }) {
21835
+ async function getBalance(client, { address, blockNumber, blockTag = client.experimental_blockTag ?? "latest" }) {
21870
21836
  const blockNumberHex = typeof blockNumber === "bigint" ? numberToHex(blockNumber) : void 0;
21871
21837
  const balance = await client.request({
21872
21838
  method: "eth_getBalance",
@@ -21884,7 +21850,11 @@ async function estimateGas(client, args) {
21884
21850
  const { block: block2, request: request2, rpcStateOverride: rpcStateOverride2 } = parameters;
21885
21851
  return client.request({
21886
21852
  method: "eth_estimateGas",
21887
- params: rpcStateOverride2 ? [request2, block2 ?? "latest", rpcStateOverride2] : block2 ? [request2, block2] : [request2]
21853
+ params: rpcStateOverride2 ? [
21854
+ request2,
21855
+ block2 ?? client.experimental_blockTag ?? "latest",
21856
+ rpcStateOverride2
21857
+ ] : block2 ? [request2, block2] : [request2]
21888
21858
  });
21889
21859
  };
21890
21860
  var estimateGas_rpc = estimateGas_rpc2;
@@ -23167,6 +23137,7 @@ function uid(length = 11) {
23167
23137
  // node_modules/viem/_esm/clients/createClient.js
23168
23138
  function createClient(parameters) {
23169
23139
  const { batch, chain, ccipRead, key = "base", name = "Base Client", type = "base" } = parameters;
23140
+ const experimental_blockTag = parameters.experimental_blockTag ?? (typeof chain?.experimental_preconfirmationTime === "number" ? "pending" : void 0);
23170
23141
  const blockTime = chain?.blockTime ?? 12e3;
23171
23142
  const defaultPollingInterval = Math.min(Math.max(Math.floor(blockTime / 2), 500), 4e3);
23172
23143
  const pollingInterval = parameters.pollingInterval ?? defaultPollingInterval;
@@ -23189,7 +23160,8 @@ function createClient(parameters) {
23189
23160
  request,
23190
23161
  transport,
23191
23162
  type,
23192
- uid: uid()
23163
+ uid: uid(),
23164
+ ...experimental_blockTag ? { experimental_blockTag } : {}
23193
23165
  };
23194
23166
  function extend(base) {
23195
23167
  return (extendFn) => {
@@ -25211,7 +25183,7 @@ init_transactionRequest();
25211
25183
  init_stateOverride2();
25212
25184
  init_assertRequest();
25213
25185
  async function simulateBlocks(client, parameters) {
25214
- const { blockNumber, blockTag = "latest", blocks, returnFullTransactions, traceTransfers, validation } = parameters;
25186
+ const { blockNumber, blockTag = client.experimental_blockTag ?? "latest", blocks, returnFullTransactions, traceTransfers, validation } = parameters;
25215
25187
  try {
25216
25188
  const blockStateCalls = [];
25217
25189
  for (const block2 of blocks) {
@@ -26798,17 +26770,25 @@ function watchBlockNumber(client, { emitOnBegin = false, emitMissed = false, onB
26798
26770
  }
26799
26771
 
26800
26772
  // node_modules/viem/_esm/actions/public/waitForTransactionReceipt.js
26801
- async function waitForTransactionReceipt(client, {
26802
- confirmations = 1,
26803
- hash: hash2,
26804
- onReplaced,
26805
- pollingInterval = client.pollingInterval,
26806
- retryCount = 6,
26807
- retryDelay = ({ count }) => ~~(1 << count) * 200,
26808
- // exponential backoff
26809
- timeout = 18e4
26810
- }) {
26773
+ async function waitForTransactionReceipt(client, parameters) {
26774
+ const {
26775
+ checkReplacement = true,
26776
+ confirmations = 1,
26777
+ hash: hash2,
26778
+ onReplaced,
26779
+ retryCount = 6,
26780
+ retryDelay = ({ count }) => ~~(1 << count) * 200,
26781
+ // exponential backoff
26782
+ timeout = 18e4
26783
+ } = parameters;
26811
26784
  const observerId = stringify(["waitForTransactionReceipt", client.uid, hash2]);
26785
+ const pollingInterval = (() => {
26786
+ if (parameters.pollingInterval)
26787
+ return parameters.pollingInterval;
26788
+ if (client.chain?.experimental_preconfirmationTime)
26789
+ return client.chain.experimental_preconfirmationTime;
26790
+ return client.pollingInterval;
26791
+ })();
26812
26792
  let transaction;
26813
26793
  let replacedTransaction;
26814
26794
  let receipt;
@@ -26821,7 +26801,14 @@ async function waitForTransactionReceipt(client, {
26821
26801
  _unobserve();
26822
26802
  reject(new WaitForTransactionReceiptTimeoutError({ hash: hash2 }));
26823
26803
  }, timeout) : void 0;
26824
- _unobserve = observe(observerId, { onReplaced, resolve: resolve2, reject }, (emit) => {
26804
+ _unobserve = observe(observerId, { onReplaced, resolve: resolve2, reject }, async (emit) => {
26805
+ receipt = await getAction(client, getTransactionReceipt, "getTransactionReceipt")({ hash: hash2 }).catch(() => void 0);
26806
+ if (receipt && confirmations <= 1) {
26807
+ clearTimeout(timer);
26808
+ emit.resolve(receipt);
26809
+ _unobserve();
26810
+ return;
26811
+ }
26825
26812
  _unwatch = getAction(client, watchBlockNumber, "watchBlockNumber")({
26826
26813
  emitMissed: true,
26827
26814
  emitOnBegin: true,
@@ -26844,7 +26831,7 @@ async function waitForTransactionReceipt(client, {
26844
26831
  done(() => emit.resolve(receipt));
26845
26832
  return;
26846
26833
  }
26847
- if (!transaction) {
26834
+ if (checkReplacement && !transaction) {
26848
26835
  retrying = true;
26849
26836
  await withRetry(async () => {
26850
26837
  transaction = await getAction(client, getTransaction, "getTransaction")({ hash: hash2 });
@@ -26916,7 +26903,7 @@ async function waitForTransactionReceipt(client, {
26916
26903
 
26917
26904
  // node_modules/viem/_esm/actions/public/watchBlocks.js
26918
26905
  init_stringify();
26919
- function watchBlocks(client, { blockTag = "latest", emitMissed = false, emitOnBegin = false, onBlock, onError, includeTransactions: includeTransactions_, poll: poll_, pollingInterval = client.pollingInterval }) {
26906
+ function watchBlocks(client, { blockTag = client.experimental_blockTag ?? "latest", emitMissed = false, emitOnBegin = false, onBlock, onError, includeTransactions: includeTransactions_, poll: poll_, pollingInterval = client.pollingInterval }) {
26920
26907
  const enablePolling = (() => {
26921
26908
  if (typeof poll_ !== "undefined")
26922
26909
  return poll_;
@@ -40773,23 +40760,25 @@ var _decodeLocalnetTransaction = (tx) => {
40773
40760
  try {
40774
40761
  const leaderReceipt = tx.consensus_data?.leader_receipt;
40775
40762
  if (leaderReceipt) {
40776
- if (leaderReceipt.result && typeof leaderReceipt.result === "string") {
40777
- leaderReceipt.result = resultToUserFriendlyJson(leaderReceipt.result);
40778
- }
40779
- if (leaderReceipt.calldata && typeof leaderReceipt.calldata === "string") {
40780
- leaderReceipt.calldata = {
40781
- base64: leaderReceipt.calldata,
40782
- ...calldataToUserFriendlyJson(b64ToArray(leaderReceipt.calldata))
40783
- };
40784
- }
40785
- if (leaderReceipt.eq_outputs) {
40786
- leaderReceipt.eq_outputs = Object.fromEntries(
40787
- Object.entries(leaderReceipt.eq_outputs).map(([key, value]) => {
40788
- const decodedValue = new TextDecoder().decode(b64ToArray(String(value)));
40789
- return [key, resultToUserFriendlyJson(decodedValue)];
40790
- })
40791
- );
40792
- }
40763
+ const receipts = Array.isArray(leaderReceipt) ? leaderReceipt : [leaderReceipt];
40764
+ receipts.forEach((receipt) => {
40765
+ if (receipt.result && typeof receipt.result === "string") {
40766
+ receipt.result = resultToUserFriendlyJson(receipt.result);
40767
+ }
40768
+ if (receipt.calldata && typeof receipt.calldata === "string") {
40769
+ receipt.calldata = {
40770
+ base64: receipt.calldata,
40771
+ ...calldataToUserFriendlyJson(b64ToArray(receipt.calldata))
40772
+ };
40773
+ }
40774
+ if (receipt.eq_outputs) {
40775
+ receipt.eq_outputs = Object.fromEntries(
40776
+ Object.entries(receipt.eq_outputs).map(([key, value]) => {
40777
+ return [key, resultToUserFriendlyJson(String(value))];
40778
+ })
40779
+ );
40780
+ }
40781
+ });
40793
40782
  }
40794
40783
  if (tx.data?.calldata && typeof tx.data.calldata === "string") {
40795
40784
  tx.data.calldata = {
@@ -41018,15 +41007,15 @@ var _BaseAction = class _BaseAction extends ConfigFileManager {
41018
41007
  super();
41019
41008
  __publicField(this, "spinner");
41020
41009
  __publicField(this, "_genlayerClient", null);
41010
+ __publicField(this, "keychainManager");
41021
41011
  this.spinner = ora({ text: "", spinner: "dots" });
41022
- this.cleanupExpiredTempFiles();
41012
+ this.keychainManager = new KeychainManager();
41023
41013
  }
41024
41014
  async decryptKeystore(keystoreData, attempt = 1) {
41025
41015
  try {
41026
41016
  const message = attempt === 1 ? "Enter password to decrypt keystore:" : `Invalid password. Attempt ${attempt}/${_BaseAction.MAX_PASSWORD_ATTEMPTS} - Enter password to decrypt keystore:`;
41027
41017
  const password = await this.promptPassword(message);
41028
41018
  const wallet = await ethers.Wallet.fromEncryptedJson(keystoreData.encrypted, password);
41029
- this.storeTempFile(_BaseAction.TEMP_KEY_FILENAME, wallet.privateKey);
41030
41019
  return wallet.privateKey;
41031
41020
  } catch (error) {
41032
41021
  if (attempt >= _BaseAction.MAX_PASSWORD_ATTEMPTS) {
@@ -41081,7 +41070,7 @@ var _BaseAction = class _BaseAction extends ConfigFileManager {
41081
41070
  return this.getAddress(keystoreData);
41082
41071
  }
41083
41072
  if (!decryptedPrivateKey) {
41084
- const cachedKey = this.getTempFile(_BaseAction.TEMP_KEY_FILENAME);
41073
+ const cachedKey = await this.keychainManager.getPrivateKey();
41085
41074
  decryptedPrivateKey = cachedKey ? cachedKey : await this.decryptKeystore(keystoreData);
41086
41075
  }
41087
41076
  return createAccount(decryptedPrivateKey);
@@ -41115,7 +41104,7 @@ var _BaseAction = class _BaseAction extends ConfigFileManager {
41115
41104
  };
41116
41105
  writeFileSync(finalOutputPath, JSON.stringify(keystoreData, null, 2));
41117
41106
  this.writeConfig("keyPairPath", finalOutputPath);
41118
- this.clearTempFile(_BaseAction.TEMP_KEY_FILENAME);
41107
+ await this.keychainManager.removePrivateKey();
41119
41108
  return wallet.privateKey;
41120
41109
  }
41121
41110
  async promptPassword(message) {
@@ -41198,7 +41187,6 @@ ${message}`));
41198
41187
  __publicField(_BaseAction, "DEFAULT_KEYSTORE_PATH", "./keypair.json");
41199
41188
  __publicField(_BaseAction, "MAX_PASSWORD_ATTEMPTS", 3);
41200
41189
  __publicField(_BaseAction, "MIN_PASSWORD_LENGTH", 8);
41201
- __publicField(_BaseAction, "TEMP_KEY_FILENAME", "decrypted_private_key");
41202
41190
  var BaseAction = _BaseAction;
41203
41191
 
41204
41192
  // src/commands/update/ollama.ts
@@ -41289,23 +41277,27 @@ var OllamaAction = class extends BaseAction {
41289
41277
  // src/lib/services/simulator.ts
41290
41278
  var semver = __toESM(require_semver2(), 1);
41291
41279
  import Docker2 from "dockerode";
41292
- import * as fs7 from "fs";
41280
+ import * as fs8 from "fs";
41293
41281
  import * as dotenv from "dotenv";
41294
41282
  import * as path3 from "path";
41295
41283
  import updateCheck from "update-check";
41296
41284
  import { fileURLToPath as fileURLToPath2 } from "url";
41297
41285
 
41298
41286
  // src/lib/clients/system.ts
41299
- import util2 from "node:util";
41287
+ import util from "node:util";
41300
41288
  import { exec } from "child_process";
41301
41289
 
41302
41290
  // node_modules/open/index.js
41303
- import process14 from "node:process";
41291
+ import process15 from "node:process";
41304
41292
  import { Buffer as Buffer4 } from "node:buffer";
41305
41293
  import path2 from "node:path";
41306
41294
  import { fileURLToPath } from "node:url";
41307
- import util from "node:util";
41295
+ import { promisify as promisify6 } from "node:util";
41308
41296
  import childProcess from "node:child_process";
41297
+ import fs7, { constants as fsConstants2 } from "node:fs/promises";
41298
+
41299
+ // node_modules/wsl-utils/index.js
41300
+ import process11 from "node:process";
41309
41301
  import fs6, { constants as fsConstants } from "node:fs/promises";
41310
41302
 
41311
41303
  // node_modules/is-wsl/index.js
@@ -41377,6 +41369,45 @@ var isWsl = () => {
41377
41369
  };
41378
41370
  var is_wsl_default = process10.env.__IS_WSL_TEST__ ? isWsl : isWsl();
41379
41371
 
41372
+ // node_modules/wsl-utils/index.js
41373
+ var wslDrivesMountPoint = /* @__PURE__ */ (() => {
41374
+ const defaultMountPoint = "/mnt/";
41375
+ let mountPoint;
41376
+ return async function() {
41377
+ if (mountPoint) {
41378
+ return mountPoint;
41379
+ }
41380
+ const configFilePath = "/etc/wsl.conf";
41381
+ let isConfigFileExists = false;
41382
+ try {
41383
+ await fs6.access(configFilePath, fsConstants.F_OK);
41384
+ isConfigFileExists = true;
41385
+ } catch {
41386
+ }
41387
+ if (!isConfigFileExists) {
41388
+ return defaultMountPoint;
41389
+ }
41390
+ const configContent = await fs6.readFile(configFilePath, { encoding: "utf8" });
41391
+ const configMountPoint = /(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(configContent);
41392
+ if (!configMountPoint) {
41393
+ return defaultMountPoint;
41394
+ }
41395
+ mountPoint = configMountPoint.groups.mountPoint.trim();
41396
+ mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
41397
+ return mountPoint;
41398
+ };
41399
+ })();
41400
+ var powerShellPathFromWsl = async () => {
41401
+ const mountPoint = await wslDrivesMountPoint();
41402
+ return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
41403
+ };
41404
+ var powerShellPath = async () => {
41405
+ if (is_wsl_default) {
41406
+ return powerShellPathFromWsl();
41407
+ }
41408
+ return `${process11.env.SYSTEMROOT || process11.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
41409
+ };
41410
+
41380
41411
  // node_modules/define-lazy-prop/index.js
41381
41412
  function defineLazyProperty(object, propertyName, valueGetter) {
41382
41413
  const define2 = (value) => Object.defineProperty(object, propertyName, { value, enumerable: true, writable: true });
@@ -41397,16 +41428,16 @@ function defineLazyProperty(object, propertyName, valueGetter) {
41397
41428
 
41398
41429
  // node_modules/default-browser/index.js
41399
41430
  import { promisify as promisify5 } from "node:util";
41400
- import process13 from "node:process";
41431
+ import process14 from "node:process";
41401
41432
  import { execFile as execFile4 } from "node:child_process";
41402
41433
 
41403
41434
  // node_modules/default-browser-id/index.js
41404
41435
  import { promisify as promisify2 } from "node:util";
41405
- import process11 from "node:process";
41436
+ import process12 from "node:process";
41406
41437
  import { execFile } from "node:child_process";
41407
41438
  var execFileAsync = promisify2(execFile);
41408
41439
  async function defaultBrowserId() {
41409
- if (process11.platform !== "darwin") {
41440
+ if (process12.platform !== "darwin") {
41410
41441
  throw new Error("macOS only");
41411
41442
  }
41412
41443
  const { stdout } = await execFileAsync("defaults", ["read", "com.apple.LaunchServices/com.apple.launchservices.secure", "LSHandlers"]);
@@ -41415,12 +41446,12 @@ async function defaultBrowserId() {
41415
41446
  }
41416
41447
 
41417
41448
  // node_modules/run-applescript/index.js
41418
- import process12 from "node:process";
41449
+ import process13 from "node:process";
41419
41450
  import { promisify as promisify3 } from "node:util";
41420
41451
  import { execFile as execFile2, execFileSync } from "node:child_process";
41421
41452
  var execFileAsync2 = promisify3(execFile2);
41422
41453
  async function runAppleScript(script, { humanReadableOutput = true } = {}) {
41423
- if (process12.platform !== "darwin") {
41454
+ if (process13.platform !== "darwin") {
41424
41455
  throw new Error("macOS only");
41425
41456
  }
41426
41457
  const outputArguments = humanReadableOutput ? [] : ["-ss"];
@@ -41476,62 +41507,31 @@ async function defaultBrowser(_execFileAsync = execFileAsync3) {
41476
41507
  var execFileAsync4 = promisify5(execFile4);
41477
41508
  var titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x2) => x2.toUpperCase());
41478
41509
  async function defaultBrowser2() {
41479
- if (process13.platform === "darwin") {
41510
+ if (process14.platform === "darwin") {
41480
41511
  const id = await defaultBrowserId();
41481
41512
  const name = await bundleName(id);
41482
41513
  return { name, id };
41483
41514
  }
41484
- if (process13.platform === "linux") {
41515
+ if (process14.platform === "linux") {
41485
41516
  const { stdout } = await execFileAsync4("xdg-mime", ["query", "default", "x-scheme-handler/http"]);
41486
41517
  const id = stdout.trim();
41487
41518
  const name = titleize(id.replace(/.desktop$/, "").replace("-", " "));
41488
41519
  return { name, id };
41489
41520
  }
41490
- if (process13.platform === "win32") {
41521
+ if (process14.platform === "win32") {
41491
41522
  return defaultBrowser();
41492
41523
  }
41493
41524
  throw new Error("Only macOS, Linux, and Windows are supported");
41494
41525
  }
41495
41526
 
41496
41527
  // node_modules/open/index.js
41497
- var execFile5 = util.promisify(childProcess.execFile);
41528
+ var execFile5 = promisify6(childProcess.execFile);
41498
41529
  var __dirname = path2.dirname(fileURLToPath(import.meta.url));
41499
41530
  var localXdgOpenPath = path2.join(__dirname, "xdg-open");
41500
- var { platform, arch } = process14;
41501
- var getWslDrivesMountPoint = /* @__PURE__ */ (() => {
41502
- const defaultMountPoint = "/mnt/";
41503
- let mountPoint;
41504
- return async function() {
41505
- if (mountPoint) {
41506
- return mountPoint;
41507
- }
41508
- const configFilePath = "/etc/wsl.conf";
41509
- let isConfigFileExists = false;
41510
- try {
41511
- await fs6.access(configFilePath, fsConstants.F_OK);
41512
- isConfigFileExists = true;
41513
- } catch {
41514
- }
41515
- if (!isConfigFileExists) {
41516
- return defaultMountPoint;
41517
- }
41518
- const configContent = await fs6.readFile(configFilePath, { encoding: "utf8" });
41519
- const configMountPoint = /(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(configContent);
41520
- if (!configMountPoint) {
41521
- return defaultMountPoint;
41522
- }
41523
- mountPoint = configMountPoint.groups.mountPoint.trim();
41524
- mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
41525
- return mountPoint;
41526
- };
41527
- })();
41528
- var getPowershellPathFromWsl = async () => {
41529
- const mountPoint = await getWslDrivesMountPoint();
41530
- return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
41531
- };
41531
+ var { platform, arch } = process15;
41532
41532
  async function getWindowsDefaultBrowserFromWsl() {
41533
- const powershellPath = await getPowershellPathFromWsl();
41534
- const rawCommand = '(Get-ItemProperty -Path "HKCU:\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice").ProgId';
41533
+ const powershellPath = await powerShellPath();
41534
+ const rawCommand = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`;
41535
41535
  const encodedCommand = Buffer4.from(rawCommand, "utf16le").toString("base64");
41536
41536
  const { stdout } = await execFile5(
41537
41537
  powershellPath,
@@ -41548,6 +41548,7 @@ async function getWindowsDefaultBrowserFromWsl() {
41548
41548
  const progId = stdout.trim();
41549
41549
  const browserMap = {
41550
41550
  ChromeHTML: "com.google.chrome",
41551
+ BraveHTML: "com.brave.Browser",
41551
41552
  MSEdgeHTM: "com.microsoft.edge",
41552
41553
  FirefoxURL: "org.mozilla.firefox"
41553
41554
  };
@@ -41593,6 +41594,7 @@ var baseOpen = async (options) => {
41593
41594
  const ids = {
41594
41595
  "com.google.chrome": "chrome",
41595
41596
  "google-chrome.desktop": "chrome",
41597
+ "com.brave.Browser": "brave",
41596
41598
  "org.mozilla.firefox": "firefox",
41597
41599
  "firefox.desktop": "firefox",
41598
41600
  "com.microsoft.msedge": "edge",
@@ -41602,6 +41604,7 @@ var baseOpen = async (options) => {
41602
41604
  };
41603
41605
  const flags = {
41604
41606
  chrome: "--incognito",
41607
+ brave: "--incognito",
41605
41608
  firefox: "--private-window",
41606
41609
  edge: "--inPrivate"
41607
41610
  };
@@ -41639,7 +41642,7 @@ var baseOpen = async (options) => {
41639
41642
  cliArguments.push("-a", app);
41640
41643
  }
41641
41644
  } else if (platform === "win32" || is_wsl_default && !isInsideContainer() && !app) {
41642
- command = is_wsl_default ? await getPowershellPathFromWsl() : `${process14.env.SYSTEMROOT || process14.env.windir || "C:\\Windows"}\\System32\\WindowsPowerShell\\v1.0\\powershell`;
41645
+ command = await powerShellPath();
41643
41646
  cliArguments.push(
41644
41647
  "-NoProfile",
41645
41648
  "-NonInteractive",
@@ -41674,11 +41677,11 @@ var baseOpen = async (options) => {
41674
41677
  const isBundled = !__dirname || __dirname === "/";
41675
41678
  let exeLocalXdgOpen = false;
41676
41679
  try {
41677
- await fs6.access(localXdgOpenPath, fsConstants.X_OK);
41680
+ await fs7.access(localXdgOpenPath, fsConstants2.X_OK);
41678
41681
  exeLocalXdgOpen = true;
41679
41682
  } catch {
41680
41683
  }
41681
- const useSystemXdgOpen = process14.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen);
41684
+ const useSystemXdgOpen = process15.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen);
41682
41685
  command = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath;
41683
41686
  }
41684
41687
  if (appArguments.length > 0) {
@@ -41750,9 +41753,19 @@ defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
41750
41753
  x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
41751
41754
  }
41752
41755
  }));
41756
+ defineLazyProperty(apps, "brave", () => detectPlatformBinary({
41757
+ darwin: "brave browser",
41758
+ win32: "brave",
41759
+ linux: ["brave-browser", "brave"]
41760
+ }, {
41761
+ wsl: {
41762
+ ia32: "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",
41763
+ x64: ["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe", "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]
41764
+ }
41765
+ }));
41753
41766
  defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
41754
41767
  darwin: "firefox",
41755
- win32: "C:\\Program Files\\Mozilla Firefox\\firefox.exe",
41768
+ win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
41756
41769
  linux: "firefox"
41757
41770
  }, {
41758
41771
  wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"
@@ -41781,7 +41794,7 @@ var MissingRequirementError = class extends Error {
41781
41794
  // src/lib/clients/system.ts
41782
41795
  async function checkCommand(command, toolName) {
41783
41796
  try {
41784
- await util2.promisify(exec)(command);
41797
+ await util.promisify(exec)(command);
41785
41798
  } catch (error) {
41786
41799
  if (error.stderr) {
41787
41800
  throw new MissingRequirementError(toolName);
@@ -41792,7 +41805,7 @@ async function executeCommand(cmdsByPlatform, toolName) {
41792
41805
  const runningPlatform = getPlatform();
41793
41806
  const command = cmdsByPlatform[runningPlatform];
41794
41807
  try {
41795
- return await util2.promisify(exec)(command);
41808
+ return await util.promisify(exec)(command);
41796
41809
  } catch (error) {
41797
41810
  throw new Error(`Error executing ${toolName || command}: ${error.message}.`);
41798
41811
  }
@@ -41809,7 +41822,7 @@ function openUrl(url) {
41809
41822
  }
41810
41823
  async function getVersion2(toolName) {
41811
41824
  try {
41812
- const toolResponse = await util2.promisify(exec)(`${toolName} --version`);
41825
+ const toolResponse = await util.promisify(exec)(`${toolName} --version`);
41813
41826
  if (toolResponse.stderr) {
41814
41827
  throw new Error(toolResponse.stderr);
41815
41828
  }
@@ -41853,7 +41866,7 @@ var SimulatorService = class {
41853
41866
  }
41854
41867
  readEnvConfigValue(key) {
41855
41868
  const envFilePath = path3.join(this.location, ".env");
41856
- const envConfig = dotenv.parse(fs7.readFileSync(envFilePath, "utf8"));
41869
+ const envConfig = dotenv.parse(fs8.readFileSync(envFilePath, "utf8"));
41857
41870
  return envConfig[key];
41858
41871
  }
41859
41872
  async getGenlayerContainers() {
@@ -41879,14 +41892,14 @@ var SimulatorService = class {
41879
41892
  }
41880
41893
  addConfigToEnvFile(newConfig) {
41881
41894
  const envFilePath = path3.join(this.location, ".env");
41882
- const envConfig = dotenv.parse(fs7.readFileSync(envFilePath, "utf8"));
41895
+ const envConfig = dotenv.parse(fs8.readFileSync(envFilePath, "utf8"));
41883
41896
  Object.keys(newConfig).forEach((key) => {
41884
41897
  envConfig[key] = newConfig[key];
41885
41898
  });
41886
41899
  const updatedConfig = Object.keys(envConfig).map((key) => {
41887
41900
  return `${key}=${envConfig[key]}`;
41888
41901
  }).join("\n");
41889
- fs7.writeFileSync(envFilePath, updatedConfig);
41902
+ fs8.writeFileSync(envFilePath, updatedConfig);
41890
41903
  }
41891
41904
  setComposeOptions(headless, ollama = false) {
41892
41905
  let profiles = [];
@@ -42360,6 +42373,65 @@ var KeypairCreator = class extends BaseAction {
42360
42373
  }
42361
42374
  };
42362
42375
 
42376
+ // src/commands/keygen/unlock.ts
42377
+ import { readFileSync as readFileSync3, existsSync as existsSync2 } from "fs";
42378
+ import { ethers as ethers2 } from "ethers";
42379
+ var UnlockAction = class extends BaseAction {
42380
+ async execute() {
42381
+ this.startSpinner("Checking keychain availability...");
42382
+ const keychainAvailable = await this.keychainManager.isKeychainAvailable();
42383
+ if (!keychainAvailable) {
42384
+ this.failSpinner("OS keychain is not available. This command requires a supported keychain (e.g. macOS Keychain, Windows Credential Manager, or GNOME Keyring).");
42385
+ return;
42386
+ }
42387
+ this.setSpinnerText("Checking for existing keystore...");
42388
+ const keypairPath = this.getConfigByKey("keyPairPath");
42389
+ if (!keypairPath || !existsSync2(keypairPath)) {
42390
+ this.failSpinner("No keystore file found. Please create a keypair first using 'genlayer keygen create'.");
42391
+ return;
42392
+ }
42393
+ const keystoreData = JSON.parse(readFileSync3(keypairPath, "utf-8"));
42394
+ if (!this.isValidKeystoreFormat(keystoreData)) {
42395
+ this.failSpinner("Invalid keystore format. Expected encrypted keystore file.");
42396
+ return;
42397
+ }
42398
+ this.stopSpinner();
42399
+ try {
42400
+ const password = await this.promptPassword("Enter password to decrypt keystore:");
42401
+ const wallet = await ethers2.Wallet.fromEncryptedJson(keystoreData.encrypted, password);
42402
+ await this.keychainManager.storePrivateKey(wallet.privateKey);
42403
+ this.succeedSpinner("Wallet unlocked successfully! Your private key is now stored securely in the OS keychain.");
42404
+ } catch (error) {
42405
+ this.failSpinner("Failed to unlock wallet.", error);
42406
+ }
42407
+ }
42408
+ };
42409
+
42410
+ // src/commands/keygen/lock.ts
42411
+ var LockAction = class extends BaseAction {
42412
+ async execute() {
42413
+ this.startSpinner("Checking keychain availability...");
42414
+ const keychainAvailable = await this.keychainManager.isKeychainAvailable();
42415
+ if (!keychainAvailable) {
42416
+ this.failSpinner("OS keychain is not available. This command requires a supported keychain (e.g. macOS Keychain, Windows Credential Manager, or GNOME Keyring).");
42417
+ return;
42418
+ }
42419
+ this.setSpinnerText("Checking for cached private key...");
42420
+ const hasCachedKey = await this.keychainManager.getPrivateKey();
42421
+ if (!hasCachedKey) {
42422
+ this.succeedSpinner("Wallet is already locked (no cached key found in OS keychain).");
42423
+ return;
42424
+ }
42425
+ this.setSpinnerText("Removing private key from OS keychain...");
42426
+ try {
42427
+ await this.keychainManager.removePrivateKey();
42428
+ this.succeedSpinner("Wallet locked successfully! Your private key has been removed from the OS keychain.");
42429
+ } catch (error) {
42430
+ this.failSpinner("Failed to lock wallet.", error);
42431
+ }
42432
+ }
42433
+ };
42434
+
42363
42435
  // src/commands/keygen/index.ts
42364
42436
  function initializeKeygenCommands(program2) {
42365
42437
  const keygenCommand = program2.command("keygen").description("Manage keypair generation");
@@ -42367,11 +42439,19 @@ function initializeKeygenCommands(program2) {
42367
42439
  const keypairCreator = new KeypairCreator();
42368
42440
  await keypairCreator.createKeypairAction(options);
42369
42441
  });
42442
+ keygenCommand.command("unlock").description("Unlock your wallet by storing the decrypted private key in OS keychain").action(async () => {
42443
+ const unlockAction = new UnlockAction();
42444
+ await unlockAction.execute();
42445
+ });
42446
+ keygenCommand.command("lock").description("Lock your wallet by removing the decrypted private key from OS keychain").action(async () => {
42447
+ const lockAction = new LockAction();
42448
+ await lockAction.execute();
42449
+ });
42370
42450
  return program2;
42371
42451
  }
42372
42452
 
42373
42453
  // src/commands/contracts/deploy.ts
42374
- import fs8 from "fs";
42454
+ import fs9 from "fs";
42375
42455
  import path4 from "path";
42376
42456
  import { pathToFileURL } from "url";
42377
42457
  import { buildSync } from "esbuild";
@@ -42381,10 +42461,10 @@ var DeployAction = class extends BaseAction {
42381
42461
  __publicField(this, "deployDir", path4.resolve(process.cwd(), "deploy"));
42382
42462
  }
42383
42463
  readContractCode(contractPath) {
42384
- if (!fs8.existsSync(contractPath)) {
42464
+ if (!fs9.existsSync(contractPath)) {
42385
42465
  throw new Error(`Contract file not found: ${contractPath}`);
42386
42466
  }
42387
- return fs8.readFileSync(contractPath, "utf-8");
42467
+ return fs9.readFileSync(contractPath, "utf-8");
42388
42468
  }
42389
42469
  async executeTsScript(filePath, rpcUrl) {
42390
42470
  const outFile = filePath.replace(/\.ts$/, ".compiled.js");
@@ -42403,7 +42483,7 @@ var DeployAction = class extends BaseAction {
42403
42483
  } catch (error) {
42404
42484
  this.failSpinner(`Error executing: ${filePath}`, error);
42405
42485
  } finally {
42406
- fs8.unlinkSync(outFile);
42486
+ fs9.unlinkSync(outFile);
42407
42487
  }
42408
42488
  }
42409
42489
  async executeJsScript(filePath, transpiledFilePath, rpcUrl) {
@@ -42423,11 +42503,11 @@ var DeployAction = class extends BaseAction {
42423
42503
  }
42424
42504
  async deployScripts(options) {
42425
42505
  this.startSpinner("Searching for deploy scripts...");
42426
- if (!fs8.existsSync(this.deployDir)) {
42506
+ if (!fs9.existsSync(this.deployDir)) {
42427
42507
  this.failSpinner("No deploy folder found.");
42428
42508
  return;
42429
42509
  }
42430
- const files = fs8.readdirSync(this.deployDir).filter((file) => file.endsWith(".ts") || file.endsWith(".js")).sort((a, b) => {
42510
+ const files = fs9.readdirSync(this.deployDir).filter((file) => file.endsWith(".ts") || file.endsWith(".js")).sort((a, b) => {
42431
42511
  const numA = parseInt(a.split("_")[0]);
42432
42512
  const numB = parseInt(b.split("_")[0]);
42433
42513
  if (!isNaN(numA) && !isNaN(numB)) return numA - numB;
@@ -42933,7 +43013,7 @@ function initializeUpdateCommands(program2) {
42933
43013
  }
42934
43014
 
42935
43015
  // src/commands/scaffold/new.ts
42936
- import fs9 from "fs-extra";
43016
+ import fs10 from "fs-extra";
42937
43017
  import path5 from "path";
42938
43018
  import { fileURLToPath as fileURLToPath3 } from "url";
42939
43019
  var NewAction = class extends BaseAction {
@@ -42946,14 +43026,14 @@ var NewAction = class extends BaseAction {
42946
43026
  }
42947
43027
  async createProject(projectName, options) {
42948
43028
  const targetPath = path5.resolve(options.path, projectName);
42949
- if (fs9.existsSync(targetPath) && !options.overwrite) {
43029
+ if (fs10.existsSync(targetPath) && !options.overwrite) {
42950
43030
  return this.failSpinner(
42951
43031
  `Project directory "${targetPath}" already exists. Use --overwrite to replace it.`
42952
43032
  );
42953
43033
  }
42954
43034
  this.startSpinner(`Creating new GenLayer project: ${projectName}`);
42955
43035
  try {
42956
- fs9.copySync(this.templatePath, targetPath);
43036
+ fs10.copySync(this.templatePath, targetPath);
42957
43037
  this.succeedSpinner(`Project "${projectName}" created successfully at ${targetPath}`);
42958
43038
  } catch (error) {
42959
43039
  this.failSpinner(`Error creating project "${projectName}"`, error);