@layr-labs/ecloud-cli 1.0.0-devep7 → 1.0.0-devep8

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 (51) hide show
  1. package/VERSION +2 -2
  2. package/dist/commands/billing/__tests__/status.test.js +2 -1
  3. package/dist/commands/billing/__tests__/status.test.js.map +1 -1
  4. package/dist/commands/billing/__tests__/subscribe.test.js +2 -1
  5. package/dist/commands/billing/__tests__/subscribe.test.js.map +1 -1
  6. package/dist/commands/billing/__tests__/top-up.test.js +91 -7
  7. package/dist/commands/billing/__tests__/top-up.test.js.map +1 -1
  8. package/dist/commands/billing/cancel.js +2 -1
  9. package/dist/commands/billing/cancel.js.map +1 -1
  10. package/dist/commands/billing/list-cards.js +2 -1
  11. package/dist/commands/billing/list-cards.js.map +1 -1
  12. package/dist/commands/billing/status.js +2 -1
  13. package/dist/commands/billing/status.js.map +1 -1
  14. package/dist/commands/billing/subscribe.js +2 -1
  15. package/dist/commands/billing/subscribe.js.map +1 -1
  16. package/dist/commands/billing/top-up.js +22 -4
  17. package/dist/commands/billing/top-up.js.map +1 -1
  18. package/dist/commands/compute/app/deploy.js +1 -1
  19. package/dist/commands/compute/app/deploy.js.map +1 -1
  20. package/dist/commands/compute/app/info.js +1 -1
  21. package/dist/commands/compute/app/list.js +1 -1
  22. package/dist/commands/compute/app/logs.js +1 -1
  23. package/dist/commands/compute/app/logs.js.map +1 -1
  24. package/dist/commands/compute/app/profile/set.js +1 -1
  25. package/dist/commands/compute/app/profile/set.js.map +1 -1
  26. package/dist/commands/compute/app/releases.js +1 -1
  27. package/dist/commands/compute/app/start.js +1 -1
  28. package/dist/commands/compute/app/start.js.map +1 -1
  29. package/dist/commands/compute/app/stop.js +1 -1
  30. package/dist/commands/compute/app/stop.js.map +1 -1
  31. package/dist/commands/compute/app/terminate.js +1 -1
  32. package/dist/commands/compute/app/terminate.js.map +1 -1
  33. package/dist/commands/compute/app/upgrade.js +1 -1
  34. package/dist/commands/compute/app/upgrade.js.map +1 -1
  35. package/dist/commands/compute/build/info.js +1 -1
  36. package/dist/commands/compute/build/info.js.map +1 -1
  37. package/dist/commands/compute/build/list.js +1 -1
  38. package/dist/commands/compute/build/list.js.map +1 -1
  39. package/dist/commands/compute/build/logs.js +1 -1
  40. package/dist/commands/compute/build/logs.js.map +1 -1
  41. package/dist/commands/compute/build/status.js +1 -1
  42. package/dist/commands/compute/build/status.js.map +1 -1
  43. package/dist/commands/compute/build/submit.js +1 -1
  44. package/dist/commands/compute/build/submit.js.map +1 -1
  45. package/dist/commands/compute/build/verify.js +1 -1
  46. package/dist/commands/compute/build/verify.js.map +1 -1
  47. package/dist/commands/compute/undelegate.js +1 -1
  48. package/dist/commands/compute/undelegate.js.map +1 -1
  49. package/dist/hooks/init/__tests__/version-check.test.js +1 -1
  50. package/dist/hooks/init/version-check.js +1 -1
  51. package/package.json +2 -2
@@ -312,7 +312,8 @@ async function createBillingClient(flags) {
312
312
  walletClient,
313
313
  publicClient,
314
314
  environment,
315
- skipTelemetry: true
315
+ skipTelemetry: true,
316
+ privateKey
316
317
  });
317
318
  }
318
319
 
@@ -411,6 +412,11 @@ var BillingTopUp = class _BillingTopUp extends Command {
411
412
  default: "compute",
412
413
  options: ["compute"],
413
414
  env: "ECLOUD_PRODUCT_ID"
415
+ }),
416
+ chain: Flags2.string({
417
+ required: false,
418
+ description: "Blockchain network for USDC payment: ethereum or base",
419
+ options: ["ethereum", "base"]
414
420
  })
415
421
  };
416
422
  async run() {
@@ -454,14 +460,25 @@ ${chalk2.bold("Purchase EigenCompute credits")}`);
454
460
  });
455
461
  }
456
462
  async handleUsdc(billing, flags, walletAddress, targetAccount, baselineTotal) {
457
- const onChainState = await billing.getTopUpInfo();
463
+ let selectedChain = "ethereum";
464
+ if (billing.hasBaseSupport()) {
465
+ selectedChain = flags.chain ?? await select2({
466
+ message: "Which network?",
467
+ choices: [
468
+ { value: "ethereum", name: "Ethereum" },
469
+ { value: "base", name: "Base" }
470
+ ]
471
+ });
472
+ }
473
+ const onChainState = await billing.getTopUpInfo({ chain: selectedChain });
458
474
  const { usdcBalance, minimumPurchase } = onChainState;
459
475
  const balanceFormatted = formatUnits(usdcBalance, 6);
460
476
  this.log(` ${chalk2.bold("USDC:")} ${balanceFormatted} USDC`);
461
477
  if (usdcBalance === BigInt(0)) {
478
+ const networkName = selectedChain === "base" ? "Base Sepolia" : "Sepolia";
462
479
  this.log(`
463
480
  ${chalk2.yellow(" No USDC in wallet.")}`);
464
- this.log(` Send USDC on Sepolia to: ${chalk2.cyan(walletAddress)}`);
481
+ this.log(` Send USDC on ${networkName} to: ${chalk2.cyan(walletAddress)}`);
465
482
  this.log(` Then re-run: ${chalk2.cyan("ecloud billing top-up")}
466
483
  `);
467
484
  return;
@@ -494,7 +511,8 @@ ${chalk2.yellow(" No USDC in wallet.")}`);
494
511
  Purchasing ${chalk2.bold(`$${amountFloat.toFixed(2)}`)} in credits...`);
495
512
  const { txHash } = await billing.topUp({
496
513
  amount: amountRaw,
497
- account: targetAccount
514
+ account: targetAccount,
515
+ chain: selectedChain
498
516
  });
499
517
  this.log(` ${chalk2.green("\u2713")} Transaction confirmed: ${txHash}`);
500
518
  await this.pollForCredits(billing, flags, baselineTotal, amountFloat);
@@ -619,8 +637,10 @@ describe("ecloud billing top-up", () => {
619
637
  getTopUpInfo: vi.fn(),
620
638
  topUp: vi.fn(),
621
639
  getPaymentMethods: vi.fn(),
622
- purchaseCredits: vi.fn()
640
+ purchaseCredits: vi.fn(),
641
+ hasBaseSupport: vi.fn()
623
642
  };
643
+ mockBilling.hasBaseSupport.mockReturnValue(false);
624
644
  createBillingClient.mockResolvedValue(mockBilling);
625
645
  input3.mockResolvedValue("50");
626
646
  });
@@ -680,7 +700,8 @@ describe("ecloud billing top-up", () => {
680
700
  expect(fullOutput).toContain("$60.00");
681
701
  expect(mockBilling.topUp).toHaveBeenCalledWith({
682
702
  amount: BigInt(5e7),
683
- account: WALLET_ADDRESS
703
+ account: WALLET_ADDRESS,
704
+ chain: "ethereum"
684
705
  });
685
706
  });
686
707
  it("zero USDC balance: exits with fund wallet message", async () => {
@@ -715,7 +736,8 @@ describe("ecloud billing top-up", () => {
715
736
  expect(fullOutput).toContain(targetAccount);
716
737
  expect(mockBilling.topUp).toHaveBeenCalledWith({
717
738
  amount: BigInt(5e7),
718
- account: targetAccount
739
+ account: targetAccount,
740
+ chain: "ethereum"
719
741
  });
720
742
  });
721
743
  it("billing API poll timeout: shows timeout message", async () => {
@@ -758,6 +780,68 @@ describe("ecloud billing top-up", () => {
758
780
  expect(fullOutput).toContain("Transaction confirmed");
759
781
  expect(fullOutput).toContain("Credits haven't appeared yet");
760
782
  });
783
+ it("usdc: prompts for chain selection when Base is available", async () => {
784
+ mockBilling.hasBaseSupport.mockReturnValue(true);
785
+ setupOnChainState();
786
+ mockBilling.topUp.mockResolvedValue({ txHash: TX_HASH, walletAddress: WALLET_ADDRESS });
787
+ mockBilling.getStatus.mockResolvedValueOnce({ subscriptionStatus: "active", remainingCredits: 10 }).mockResolvedValueOnce({ subscriptionStatus: "active", remainingCredits: 60 });
788
+ select3.mockResolvedValue("base");
789
+ const cmd = createCommand({ amount: "50", method: "usdc" });
790
+ const promise = cmd.run();
791
+ for (let i = 0; i < 10; i++) {
792
+ await vi.advanceTimersByTimeAsync(5e3);
793
+ }
794
+ await promise;
795
+ expect(select3).toHaveBeenCalledWith(
796
+ expect.objectContaining({
797
+ message: "Which network?",
798
+ choices: expect.arrayContaining([
799
+ expect.objectContaining({ value: "base" }),
800
+ expect.objectContaining({ value: "ethereum" })
801
+ ])
802
+ })
803
+ );
804
+ expect(mockBilling.getTopUpInfo).toHaveBeenCalledWith({ chain: "base" });
805
+ expect(mockBilling.topUp).toHaveBeenCalledWith({
806
+ amount: BigInt(5e7),
807
+ account: WALLET_ADDRESS,
808
+ chain: "base"
809
+ });
810
+ });
811
+ it("usdc: skips chain prompt when Base is not configured", async () => {
812
+ mockBilling.hasBaseSupport.mockReturnValue(false);
813
+ setupOnChainState();
814
+ mockBilling.topUp.mockResolvedValue({ txHash: TX_HASH, walletAddress: WALLET_ADDRESS });
815
+ mockBilling.getStatus.mockResolvedValueOnce({ subscriptionStatus: "active", remainingCredits: 10 }).mockResolvedValueOnce({ subscriptionStatus: "active", remainingCredits: 60 });
816
+ const cmd = createCommand({ amount: "50", method: "usdc" });
817
+ const promise = cmd.run();
818
+ for (let i = 0; i < 10; i++) {
819
+ await vi.advanceTimersByTimeAsync(5e3);
820
+ }
821
+ await promise;
822
+ expect(mockBilling.topUp).toHaveBeenCalledWith({
823
+ amount: BigInt(5e7),
824
+ account: WALLET_ADDRESS,
825
+ chain: "ethereum"
826
+ });
827
+ });
828
+ it("usdc: --chain flag skips network prompt", async () => {
829
+ mockBilling.hasBaseSupport.mockReturnValue(true);
830
+ setupOnChainState();
831
+ mockBilling.topUp.mockResolvedValue({ txHash: TX_HASH, walletAddress: WALLET_ADDRESS });
832
+ mockBilling.getStatus.mockResolvedValueOnce({ subscriptionStatus: "active", remainingCredits: 10 }).mockResolvedValueOnce({ subscriptionStatus: "active", remainingCredits: 60 });
833
+ const cmd = createCommand({ amount: "50", method: "usdc", chain: "base" });
834
+ const promise = cmd.run();
835
+ for (let i = 0; i < 10; i++) {
836
+ await vi.advanceTimersByTimeAsync(5e3);
837
+ }
838
+ await promise;
839
+ expect(mockBilling.topUp).toHaveBeenCalledWith({
840
+ amount: BigInt(5e7),
841
+ account: WALLET_ADDRESS,
842
+ chain: "base"
843
+ });
844
+ });
761
845
  it("credit card: charges selected card on file", async () => {
762
846
  mockBilling.getStatus.mockResolvedValueOnce({ subscriptionStatus: "active", remainingCredits: 10 }).mockResolvedValueOnce({ subscriptionStatus: "active", remainingCredits: 35 });
763
847
  mockBilling.getPaymentMethods.mockResolvedValue({