@clawcard/cli 3.0.10 → 3.0.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawcard/cli",
3
- "version": "3.0.10",
3
+ "version": "3.0.14",
4
4
  "description": "The ClawCard CLI — manage your agent keys, billing, and setup from the terminal",
5
5
  "bin": {
6
6
  "clawcard": "./bin/clawcard.mjs"
@@ -571,47 +571,100 @@ export async function agentWalletTransactionsCmd(options) {
571
571
  }
572
572
 
573
573
  export async function agentWalletFundCmd(options) {
574
- if (!options.amount) {
575
- const err = "--amount is required (in dollars, e.g., 10.00)";
576
- if (options.json) return output({ success: false, error: err }, true);
577
- console.log(` Error: ${err}`);
578
- return;
574
+ // JSON mode — pass through to API directly
575
+ if (options.json) {
576
+ if (!options.amount) return output({ success: false, error: "--amount required" }, true);
577
+ const agentId = await getAgentId();
578
+ try {
579
+ const result = await walletFund(agentId, options.amount);
580
+ return output(result, true);
581
+ } catch (err) {
582
+ return output({ success: false, error: err.message }, true);
583
+ }
579
584
  }
580
585
 
586
+ // Interactive wizard
587
+ const prompts = await import("@clack/prompts");
581
588
  const agentId = await getAgentId();
589
+
590
+ console.log();
591
+ console.log(` ${orange.bold("Fund Your Agent's Wallet")}`);
592
+ console.log();
593
+ console.log(chalk.dim(" Your agent's wallet uses USDC (a stablecoin pegged to $1) on the Base network."));
594
+ console.log(chalk.dim(" To send USDC, your wallet also needs a tiny bit of ETH for transaction fees."));
595
+ console.log(chalk.dim(" $1 of ETH covers thousands of transactions."));
596
+ console.log();
597
+
598
+ // Step 1: What to buy
599
+ const asset = await prompts.select({
600
+ message: "What would you like to purchase?",
601
+ options: [
602
+ { value: "eth", label: "ETH (for gas fees)", hint: "buy this first — $1-2 is plenty" },
603
+ { value: "usdc", label: "USDC (spending money)", hint: "your agent uses this to pay for things" },
604
+ ],
605
+ });
606
+
607
+ if (prompts.isCancel(asset)) return;
608
+
609
+ // Step 2: Amount
610
+ const defaultAmount = asset === "eth" ? "2" : "10";
611
+ const amountInput = await prompts.text({
612
+ message: `How much $ of ${asset === "eth" ? "ETH" : "USDC"} do you want to buy?`,
613
+ placeholder: defaultAmount,
614
+ defaultValue: defaultAmount,
615
+ validate: (v) => {
616
+ const n = parseFloat(v);
617
+ if (isNaN(n) || n < 1) return "Minimum is $1.00";
618
+ },
619
+ });
620
+
621
+ if (prompts.isCancel(amountInput)) return;
622
+
623
+ const amount = parseFloat(amountInput);
624
+
625
+ // Step 3: Open Coinbase
626
+ const s = prompts.spinner();
627
+ s.start("Preparing Coinbase checkout...");
628
+
582
629
  try {
583
- const result = await walletFund(agentId, options.amount);
584
- if (options.json) return output(result, true);
630
+ const result = await walletFund(agentId, String(amount));
631
+ s.stop("");
585
632
 
586
- if (result.success) {
587
- console.log();
588
- console.log(` ${chalk.green("Fund your wallet:")}`);
589
- console.log();
590
- console.log(` ${result.instructions}`);
591
- console.log();
592
- console.log(` ${orange(result.url)}`);
593
- console.log();
594
- console.log(chalk.dim(` Tip: Buy both USDC and a small amount of ETH (~$1) for gas fees.`));
595
- console.log(chalk.dim(` Or send USDC + ETH directly to ${result.walletAddress} on Base.`));
596
- console.log();
633
+ if (!result.success) {
634
+ console.log(` Error: ${result.error}`);
635
+ return;
636
+ }
597
637
 
598
- // Try to open the URL in the browser
599
- try {
600
- const { default: open } = await import("open");
601
- await open(result.url);
602
- console.log(chalk.dim(" Opened in browser."));
603
- } catch {
604
- // open is optional — user can copy the URL
605
- }
606
- console.log();
607
- console.log(` ${orange("After purchasing, wait ~30 seconds then verify:")}`);
608
- console.log(` ${chalk.dim("$ clawcard agent wallet balance --json")}`);
609
- console.log();
638
+ // Swap the default asset in the URL if they chose ETH
639
+ let url = result.url;
640
+ if (asset === "eth") {
641
+ url = url.replace("defaultAsset=USDC", "defaultAsset=ETH");
642
+ }
643
+
644
+ console.log();
645
+ console.log(` ${chalk.green("Opening Coinbase...")} Buy $${amount.toFixed(2)} of ${asset === "eth" ? "ETH" : "USDC"}`);
646
+ console.log();
647
+ console.log(` ${orange(url)}`);
648
+ console.log();
649
+
650
+ try {
651
+ const { default: open } = await import("open");
652
+ await open(url);
653
+ } catch {}
654
+
655
+ console.log(chalk.dim(` After purchasing, wait ~30 seconds for it to arrive.`));
656
+ console.log();
657
+
658
+ // Prompt for next step
659
+ if (asset === "eth") {
660
+ console.log(` ${orange("Next step:")} Run this command again and choose USDC to add spending money.`);
610
661
  } else {
611
- console.log(` Error: ${result.error}`);
662
+ console.log(` ${orange("Verify your balance:")}`);
663
+ console.log(` ${chalk.dim("$ clawcard agent wallet balance --json")}`);
612
664
  }
665
+ console.log();
613
666
  } catch (err) {
614
- if (options.json) return output({ success: false, error: err.message }, true);
667
+ s.stop("Failed");
615
668
  console.log(` Error: ${err.message}`);
616
669
  }
617
670
  }
package/src/index.js CHANGED
@@ -248,8 +248,8 @@ agentWallet
248
248
  });
249
249
  agentWallet
250
250
  .command("fund")
251
- .description("Fund wallet with USDC from FIAT balance")
252
- .requiredOption("--amount <dollars>", "Amount in dollars to convert (e.g., 10.00)")
251
+ .description("Fund wallet buy USDC and ETH via Coinbase")
252
+ .option("--amount <dollars>", "Amount in dollars (skips wizard)")
253
253
  .option("--json", "Output as JSON")
254
254
  .action(async (options) => {
255
255
  const { agentWalletFundCmd } = await import("./commands/agent.js");