@layr-labs/ecloud-cli 0.2.0-dev.3 → 0.2.1-dev

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.
Files changed (48) hide show
  1. package/VERSION +2 -2
  2. package/dist/commands/auth/whoami.js +16 -3
  3. package/dist/commands/auth/whoami.js.map +1 -1
  4. package/dist/commands/billing/cancel.js +44 -5
  5. package/dist/commands/billing/cancel.js.map +1 -1
  6. package/dist/commands/billing/status.js +44 -5
  7. package/dist/commands/billing/status.js.map +1 -1
  8. package/dist/commands/billing/subscribe.js +44 -5
  9. package/dist/commands/billing/subscribe.js.map +1 -1
  10. package/dist/commands/compute/app/create.js +16 -3
  11. package/dist/commands/compute/app/create.js.map +1 -1
  12. package/dist/commands/compute/app/deploy.js +111 -24
  13. package/dist/commands/compute/app/deploy.js.map +1 -1
  14. package/dist/commands/compute/app/info.js +107 -33
  15. package/dist/commands/compute/app/info.js.map +1 -1
  16. package/dist/commands/compute/app/list.js +70 -13
  17. package/dist/commands/compute/app/list.js.map +1 -1
  18. package/dist/commands/compute/app/logs.js +68 -27
  19. package/dist/commands/compute/app/logs.js.map +1 -1
  20. package/dist/commands/compute/app/profile/set.js +107 -38
  21. package/dist/commands/compute/app/profile/set.js.map +1 -1
  22. package/dist/commands/compute/app/releases.js +68 -24
  23. package/dist/commands/compute/app/releases.js.map +1 -1
  24. package/dist/commands/compute/app/start.js +76 -34
  25. package/dist/commands/compute/app/start.js.map +1 -1
  26. package/dist/commands/compute/app/stop.js +76 -34
  27. package/dist/commands/compute/app/stop.js.map +1 -1
  28. package/dist/commands/compute/app/terminate.js +76 -34
  29. package/dist/commands/compute/app/terminate.js.map +1 -1
  30. package/dist/commands/compute/app/upgrade.js +106 -36
  31. package/dist/commands/compute/app/upgrade.js.map +1 -1
  32. package/dist/commands/compute/build/info.js +52 -13
  33. package/dist/commands/compute/build/info.js.map +1 -1
  34. package/dist/commands/compute/build/list.js +52 -13
  35. package/dist/commands/compute/build/list.js.map +1 -1
  36. package/dist/commands/compute/build/logs.js +52 -13
  37. package/dist/commands/compute/build/logs.js.map +1 -1
  38. package/dist/commands/compute/build/status.js +52 -13
  39. package/dist/commands/compute/build/status.js.map +1 -1
  40. package/dist/commands/compute/build/submit.js +65 -9
  41. package/dist/commands/compute/build/submit.js.map +1 -1
  42. package/dist/commands/compute/build/verify.js +52 -13
  43. package/dist/commands/compute/build/verify.js.map +1 -1
  44. package/dist/commands/compute/environment/set.js +20 -7
  45. package/dist/commands/compute/environment/set.js.map +1 -1
  46. package/dist/commands/compute/undelegate.js +46 -10
  47. package/dist/commands/compute/undelegate.js.map +1 -1
  48. package/package.json +2 -2
@@ -8,7 +8,7 @@ import {
8
8
  createComputeModule,
9
9
  createBillingModule,
10
10
  createBuildModule,
11
- getEnvironmentConfig as getEnvironmentConfig2,
11
+ getEnvironmentConfig as getEnvironmentConfig3,
12
12
  requirePrivateKey,
13
13
  getPrivateKeyWithSource
14
14
  } from "@layr-labs/ecloud-sdk";
@@ -23,9 +23,9 @@ import fs3 from "fs";
23
23
  import path3 from "path";
24
24
  import os3 from "os";
25
25
  import { isAddress as isAddress2 } from "viem";
26
- import { privateKeyToAccount as privateKeyToAccount2 } from "viem/accounts";
26
+ import { privateKeyToAccount as privateKeyToAccount3 } from "viem/accounts";
27
27
  import {
28
- getEnvironmentConfig,
28
+ getEnvironmentConfig as getEnvironmentConfig2,
29
29
  getAvailableEnvironments,
30
30
  isEnvironmentAvailable,
31
31
  getAllAppsByDeveloper as getAllAppsByDeveloper2,
@@ -42,12 +42,43 @@ import {
42
42
 
43
43
  // src/utils/appResolver.ts
44
44
  import { isAddress } from "viem";
45
- import { privateKeyToAccount } from "viem/accounts";
45
+ import { privateKeyToAccount as privateKeyToAccount2 } from "viem/accounts";
46
46
  import {
47
47
  UserApiClient,
48
48
  getAllAppsByDeveloper
49
49
  } from "@layr-labs/ecloud-sdk";
50
50
 
51
+ // src/utils/viemClients.ts
52
+ import {
53
+ createPublicClient,
54
+ http
55
+ } from "viem";
56
+ import { privateKeyToAccount } from "viem/accounts";
57
+ import {
58
+ getEnvironmentConfig,
59
+ addHexPrefix,
60
+ createViemClients as sdkCreateViemClients,
61
+ getChainFromID
62
+ } from "@layr-labs/ecloud-sdk";
63
+ function createViemClients(options) {
64
+ const privateKey = addHexPrefix(options.privateKey);
65
+ const environmentConfig = getEnvironmentConfig(options.environment);
66
+ const rpcUrl = options.rpcUrl || environmentConfig.defaultRPCURL;
67
+ const chain = getChainFromID(environmentConfig.chainID);
68
+ const { publicClient, walletClient } = sdkCreateViemClients({
69
+ privateKey,
70
+ rpcUrl,
71
+ chainId: environmentConfig.chainID
72
+ });
73
+ const account = privateKeyToAccount(privateKey);
74
+ return {
75
+ publicClient,
76
+ walletClient,
77
+ chain,
78
+ address: account.address
79
+ };
80
+ }
81
+
51
82
  // src/utils/globalConfig.ts
52
83
  import * as fs from "fs";
53
84
  import * as path from "path";
@@ -214,7 +245,7 @@ function listApps(environment) {
214
245
 
215
246
  // src/utils/version.ts
216
247
  function getCliVersion() {
217
- return true ? "0.2.0-dev.3" : "0.0.0";
248
+ return true ? "0.2.1-dev" : "0.0.0";
218
249
  }
219
250
  function getClientId() {
220
251
  return `ecloud-cli/v${getCliVersion()}`;
@@ -237,7 +268,7 @@ async function getAppInfosChunked(userApiClient, appIds, addressCount) {
237
268
  }
238
269
 
239
270
  // src/utils/prompts.ts
240
- function addHexPrefix(value) {
271
+ function addHexPrefix2(value) {
241
272
  if (value.startsWith("0x")) {
242
273
  return value;
243
274
  }
@@ -301,7 +332,7 @@ async function getOrPromptAppID(appIDOrOptions, environment) {
301
332
  };
302
333
  }
303
334
  if (options.appID) {
304
- const normalized = typeof options.appID === "string" ? addHexPrefix(options.appID) : options.appID;
335
+ const normalized = typeof options.appID === "string" ? addHexPrefix2(options.appID) : options.appID;
305
336
  if (isAddress2(normalized)) {
306
337
  return normalized;
307
338
  }
@@ -317,7 +348,7 @@ async function getOrPromptAppID(appIDOrOptions, environment) {
317
348
  const apps = listApps(options.environment);
318
349
  const foundAppID = apps[options.appID];
319
350
  if (foundAppID) {
320
- return addHexPrefix(foundAppID);
351
+ return addHexPrefix2(foundAppID);
321
352
  }
322
353
  throw new Error(
323
354
  `App name '${options.appID}' not found in environment '${options.environment}'`
@@ -328,18 +359,23 @@ async function getOrPromptAppID(appIDOrOptions, environment) {
328
359
  async function getAppIDInteractive(options) {
329
360
  const action = options.action || "view";
330
361
  const environment = options.environment || "sepolia";
331
- const environmentConfig = getEnvironmentConfig(environment);
362
+ const environmentConfig = getEnvironmentConfig2(environment);
332
363
  if (!options.privateKey || !options.rpcUrl) {
333
364
  return getAppIDInteractiveFromRegistry(environment, action);
334
365
  }
335
366
  console.log(`
336
367
  Select an app to ${action}:
337
368
  `);
338
- const privateKeyHex = addHexPrefix(options.privateKey);
339
- const account = privateKeyToAccount2(privateKeyHex);
369
+ const privateKeyHex = addHexPrefix2(options.privateKey);
370
+ const account = privateKeyToAccount3(privateKeyHex);
340
371
  const developerAddr = account.address;
372
+ const { publicClient, walletClient } = createViemClients({
373
+ privateKey: options.privateKey,
374
+ rpcUrl: options.rpcUrl,
375
+ environment
376
+ });
341
377
  const { apps, appConfigs } = await getAllAppsByDeveloper2(
342
- options.rpcUrl,
378
+ publicClient,
343
379
  environmentConfig,
344
380
  developerAddr
345
381
  );
@@ -352,8 +388,8 @@ Select an app to ${action}:
352
388
  try {
353
389
  const userApiClient = new UserApiClient2(
354
390
  environmentConfig,
355
- options.privateKey,
356
- options.rpcUrl,
391
+ walletClient,
392
+ publicClient,
357
393
  getClientId()
358
394
  );
359
395
  const appInfos = await getAppInfosChunked(userApiClient, apps);
@@ -478,14 +514,14 @@ async function getAppIDInteractiveFromRegistry(environment, action) {
478
514
  if (!value) {
479
515
  return "App ID or name cannot be empty";
480
516
  }
481
- const normalized2 = addHexPrefix(value);
517
+ const normalized2 = addHexPrefix2(value);
482
518
  if (isAddress2(normalized2)) {
483
519
  return true;
484
520
  }
485
521
  return "Invalid app ID address";
486
522
  }
487
523
  });
488
- const normalized = addHexPrefix(appIDInput);
524
+ const normalized = addHexPrefix2(appIDInput);
489
525
  if (isAddress2(normalized)) {
490
526
  return normalized;
491
527
  }
@@ -521,7 +557,7 @@ Select an app to ${action}:`);
521
557
  if (!value) {
522
558
  return "App ID or name cannot be empty";
523
559
  }
524
- const normalized2 = addHexPrefix(value);
560
+ const normalized2 = addHexPrefix2(value);
525
561
  if (isAddress2(normalized2)) {
526
562
  return true;
527
563
  }
@@ -531,17 +567,17 @@ Select an app to ${action}:`);
531
567
  return "Invalid app ID or name not found";
532
568
  }
533
569
  });
534
- const normalized = addHexPrefix(appIDInput);
570
+ const normalized = addHexPrefix2(appIDInput);
535
571
  if (isAddress2(normalized)) {
536
572
  return normalized;
537
573
  }
538
574
  const foundAppID = allApps[appIDInput];
539
575
  if (foundAppID) {
540
- return addHexPrefix(foundAppID);
576
+ return addHexPrefix2(foundAppID);
541
577
  }
542
578
  throw new Error(`Failed to resolve app ID from input: ${appIDInput}`);
543
579
  }
544
- return addHexPrefix(selected);
580
+ return addHexPrefix2(selected);
545
581
  }
546
582
  async function confirm(prompt) {
547
583
  return confirmWithDefault(prompt, false);
@@ -582,7 +618,7 @@ async function getPrivateKeyInteractive(privateKey) {
582
618
  async function getEnvironmentInteractive(environment) {
583
619
  if (environment) {
584
620
  try {
585
- getEnvironmentConfig(environment);
621
+ getEnvironmentConfig2(environment);
586
622
  if (!isEnvironmentAvailable(environment)) {
587
623
  throw new Error(`Environment ${environment} is not available in this build`);
588
624
  }
@@ -595,7 +631,7 @@ async function getEnvironmentInteractive(environment) {
595
631
  const configDefaultEnv = getDefaultEnvironment();
596
632
  if (configDefaultEnv && availableEnvs.includes(configDefaultEnv)) {
597
633
  try {
598
- getEnvironmentConfig(configDefaultEnv);
634
+ getEnvironmentConfig2(configDefaultEnv);
599
635
  defaultEnv = configDefaultEnv;
600
636
  } catch {
601
637
  }
@@ -661,7 +697,7 @@ async function validateCommonFlags(flags, options) {
661
697
  async function createComputeClient(flags) {
662
698
  flags = await validateCommonFlags(flags);
663
699
  const environment = flags.environment;
664
- const environmentConfig = getEnvironmentConfig2(environment);
700
+ const environmentConfig = getEnvironmentConfig3(environment);
665
701
  const rpcUrl = flags["rpc-url"] || environmentConfig.defaultRPCURL;
666
702
  const { key: privateKey, source } = await requirePrivateKey({
667
703
  privateKey: flags["private-key"]
@@ -669,10 +705,15 @@ async function createComputeClient(flags) {
669
705
  if (flags.verbose) {
670
706
  console.log(`Using private key from: ${source}`);
671
707
  }
672
- return createComputeModule({
673
- verbose: flags.verbose,
708
+ const { walletClient, publicClient } = createViemClients({
674
709
  privateKey,
675
710
  rpcUrl,
711
+ environment
712
+ });
713
+ return createComputeModule({
714
+ verbose: flags.verbose,
715
+ walletClient,
716
+ publicClient,
676
717
  environment,
677
718
  clientId: getClientId(),
678
719
  skipTelemetry: true
@@ -682,7 +723,7 @@ async function createComputeClient(flags) {
682
723
 
683
724
  // src/commands/compute/app/start.ts
684
725
  import {
685
- getEnvironmentConfig as getEnvironmentConfig3,
726
+ getEnvironmentConfig as getEnvironmentConfig4,
686
727
  estimateTransactionGas,
687
728
  encodeStartAppData,
688
729
  isMainnet
@@ -764,7 +805,7 @@ var AppLifecycleStart = class _AppLifecycleStart extends Command {
764
805
  const { args, flags } = await this.parse(_AppLifecycleStart);
765
806
  const compute = await createComputeClient(flags);
766
807
  const environment = flags.environment;
767
- const environmentConfig = getEnvironmentConfig3(environment);
808
+ const environmentConfig = getEnvironmentConfig4(environment);
768
809
  const rpcUrl = flags.rpcUrl || environmentConfig.defaultRPCURL;
769
810
  const privateKey = flags["private-key"] || await getPrivateKeyInteractive(environment);
770
811
  const appId = await getOrPromptAppID({
@@ -774,11 +815,15 @@ var AppLifecycleStart = class _AppLifecycleStart extends Command {
774
815
  rpcUrl,
775
816
  action: "start"
776
817
  });
777
- const callData = encodeStartAppData(appId);
778
- const estimate = await estimateTransactionGas({
818
+ const { publicClient, address } = createViemClients({
779
819
  privateKey,
780
820
  rpcUrl,
781
- environmentConfig,
821
+ environment
822
+ });
823
+ const callData = encodeStartAppData(appId);
824
+ const estimate = await estimateTransactionGas({
825
+ publicClient,
826
+ from: address,
782
827
  to: environmentConfig.appControllerAddress,
783
828
  data: callData
784
829
  });
@@ -793,10 +838,7 @@ ${chalk.gray(`Start cancelled`)}`);
793
838
  }
794
839
  }
795
840
  const res = await compute.app.start(appId, {
796
- gas: {
797
- maxFeePerGas: estimate.maxFeePerGas,
798
- maxPriorityFeePerGas: estimate.maxPriorityFeePerGas
799
- }
841
+ gas: estimate
800
842
  });
801
843
  if (!res.tx) {
802
844
  this.log(`