@moonpay/cli 0.6.14 → 0.6.15

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.
@@ -236,7 +236,8 @@ async function callTool(baseUrl, toolName, params) {
236
236
  }
237
237
  }
238
238
  if (res.status === 429) {
239
- throw new Error("Rate limit exceeded. Please wait a moment and try again.");
239
+ const hint = token ? "" : " Log in with `mp login` for higher limits.";
240
+ throw new Error(`Rate limit exceeded. Please wait a moment and try again.${hint}`);
240
241
  }
241
242
  if (res.status === 401) {
242
243
  throw new Error("This command requires a MoonPay CLI account. Run `moonpay login` first.");
@@ -7287,32 +7288,11 @@ var skillInstall = createTool(skillInstallSchema, async (params) => {
7287
7288
  return installSkills(params.force, params.dir ?? void 0);
7288
7289
  });
7289
7290
 
7290
- // src/tools/token/swap/tool.ts
7291
+ // src/tools/token/bridge/tool.ts
7291
7292
  import { encodeFunctionData } from "viem";
7292
7293
 
7293
- // src/tools/token/swap/schema.ts
7294
+ // src/tools/token/bridge/schema.ts
7294
7295
  import { z as z15 } from "zod";
7295
- var swapOutputSchema = z15.object({
7296
- signature: z15.string().describe("Transaction hash/signature"),
7297
- message: z15.string().describe("Human-readable swap description")
7298
- });
7299
- var tokenSwapSchema = defineToolSchema({
7300
- name: "token_swap",
7301
- description: "Swap tokens on the same chain. Builds, signs locally, broadcasts, and registers.",
7302
- input: z15.object({
7303
- wallet: z15.string().describe("Local wallet name to sign with"),
7304
- chain: chainSchema.describe("Chain to swap on"),
7305
- from: z15.object({
7306
- token: z15.string().describe("Input token address (selling)"),
7307
- amount: z15.coerce.number().nullable().describe("Amount to sell (exact-in). Null for exact-out.")
7308
- }),
7309
- to: z15.object({
7310
- token: z15.string().describe("Output token address (buying)"),
7311
- amount: z15.coerce.number().nullable().describe("Amount to receive (exact-out). Null for exact-in.")
7312
- })
7313
- }),
7314
- output: swapOutputSchema
7315
- });
7316
7296
  var tokenBridgeSchema = defineToolSchema({
7317
7297
  name: "token_bridge",
7318
7298
  description: "Bridge tokens across chains. Builds, signs locally, broadcasts, and registers.",
@@ -7330,10 +7310,13 @@ var tokenBridgeSchema = defineToolSchema({
7330
7310
  amount: z15.coerce.number().nullable().describe("Amount to receive (exact-out). Null for exact-in.")
7331
7311
  })
7332
7312
  }),
7333
- output: swapOutputSchema
7313
+ output: z15.object({
7314
+ signature: z15.string().describe("Transaction hash/signature"),
7315
+ message: z15.string().describe("Human-readable bridge description")
7316
+ })
7334
7317
  });
7335
7318
 
7336
- // src/tools/token/swap/tool.ts
7319
+ // src/tools/token/bridge/tool.ts
7337
7320
  var ERC20_APPROVE_ABI = [
7338
7321
  {
7339
7322
  name: "approve",
@@ -7398,7 +7381,19 @@ var tokenBridge = createTool(tokenBridgeSchema, async (params) => {
7398
7381
  if (!approvalResult.signature) {
7399
7382
  throw new Error(`Approval failed: ${approvalResult.message}`);
7400
7383
  }
7401
- buildResult = await callRemoteTool(baseUrl, "swaps_transaction_build", buildParams);
7384
+ process.stderr.write("Waiting for approval confirmation...\n");
7385
+ for (let i = 0; i < 30; i++) {
7386
+ await new Promise((r) => setTimeout(r, 2e3));
7387
+ try {
7388
+ const rebuilt = await callRemoteTool(baseUrl, "swaps_transaction_build", buildParams);
7389
+ if (!rebuilt.requiresApproval) {
7390
+ buildResult = rebuilt;
7391
+ break;
7392
+ }
7393
+ } catch {
7394
+ }
7395
+ if (i === 29) throw new Error("Approval not confirmed after 60 seconds.");
7396
+ }
7402
7397
  }
7403
7398
  const txPayload = "base64" in buildResult.transaction ? buildResult.transaction.base64 : JSON.stringify(buildResult.transaction);
7404
7399
  const { transaction: signedTransaction } = await transactionSign.handler({
@@ -7414,17 +7409,41 @@ var tokenBridge = createTool(tokenBridgeSchema, async (params) => {
7414
7409
  if (!sendResult.signature) {
7415
7410
  throw new Error(`Transaction send failed: ${sendResult.message}`);
7416
7411
  }
7417
- const signature = sendResult.signature;
7418
7412
  try {
7419
7413
  await callRemoteTool(baseUrl, "transaction_register", {
7420
7414
  transactionId: buildResult.transactionId,
7421
- transactionHash: signature,
7415
+ transactionHash: sendResult.signature,
7422
7416
  chain: params.from.chain
7423
7417
  });
7424
7418
  } catch {
7425
7419
  }
7426
- return { signature, message: buildResult.message };
7420
+ return { signature: sendResult.signature, message: buildResult.message };
7427
7421
  });
7422
+
7423
+ // src/tools/token/swap/schema.ts
7424
+ import { z as z16 } from "zod";
7425
+ var tokenSwapSchema = defineToolSchema({
7426
+ name: "token_swap",
7427
+ description: "Swap tokens on the same chain. Builds, signs locally, broadcasts, and registers.",
7428
+ input: z16.object({
7429
+ wallet: z16.string().describe("Local wallet name to sign with"),
7430
+ chain: chainSchema.describe("Chain to swap on"),
7431
+ from: z16.object({
7432
+ token: z16.string().describe("Input token address (selling)"),
7433
+ amount: z16.coerce.number().nullable().describe("Amount to sell (exact-in). Null for exact-out.")
7434
+ }),
7435
+ to: z16.object({
7436
+ token: z16.string().describe("Output token address (buying)"),
7437
+ amount: z16.coerce.number().nullable().describe("Amount to receive (exact-out). Null for exact-in.")
7438
+ })
7439
+ }),
7440
+ output: z16.object({
7441
+ signature: z16.string().describe("Transaction hash/signature"),
7442
+ message: z16.string().describe("Human-readable swap description")
7443
+ })
7444
+ });
7445
+
7446
+ // src/tools/token/swap/tool.ts
7428
7447
  var tokenSwap = createTool(tokenSwapSchema, async (params) => {
7429
7448
  return tokenBridge.handler({
7430
7449
  from: { wallet: params.wallet, chain: params.chain, token: params.from.token, amount: params.from.amount },
@@ -7433,20 +7452,20 @@ var tokenSwap = createTool(tokenSwapSchema, async (params) => {
7433
7452
  });
7434
7453
 
7435
7454
  // src/tools/token/transfer/schema.ts
7436
- import { z as z16 } from "zod";
7455
+ import { z as z17 } from "zod";
7437
7456
  var tokenTransferSchema = defineToolSchema({
7438
7457
  name: "token_transfer",
7439
7458
  description: "Transfer tokens to another wallet on the same chain. Builds, signs locally, and broadcasts.",
7440
- input: z16.object({
7441
- wallet: z16.string().describe("Local wallet name to sign with"),
7459
+ input: z17.object({
7460
+ wallet: z17.string().describe("Local wallet name to sign with"),
7442
7461
  chain: chainSchema.describe("Chain to transfer on"),
7443
- token: z16.string().describe("Token address to transfer"),
7444
- amount: z16.coerce.number().describe("Amount to transfer"),
7445
- to: z16.string().describe("Recipient wallet name or address")
7462
+ token: z17.string().describe("Token address to transfer"),
7463
+ amount: z17.coerce.number().describe("Amount to transfer"),
7464
+ to: z17.string().describe("Recipient wallet name or address")
7446
7465
  }),
7447
- output: z16.object({
7448
- signature: z16.string().describe("Transaction hash/signature"),
7449
- message: z16.string().describe("Human-readable transfer description")
7466
+ output: z17.object({
7467
+ signature: z17.string().describe("Transaction hash/signature"),
7468
+ message: z17.string().describe("Human-readable transfer description")
7450
7469
  })
7451
7470
  });
7452
7471
 
@@ -7501,13 +7520,13 @@ import { createPublicClient as createPublicClient2, http as http2 } from "viem";
7501
7520
  import * as viemChains2 from "viem/chains";
7502
7521
 
7503
7522
  // src/tools/x402/request/schema.ts
7504
- import { z as z17 } from "zod";
7523
+ import { z as z18 } from "zod";
7505
7524
  var x402RequestSchema = defineToolSchema({
7506
7525
  name: "x402_request",
7507
7526
  description: "Make an HTTP request to an x402-protected endpoint. Automatically handles payment when a 402 Payment Required response is received, signing the payment transaction with the local wallet.",
7508
- input: z17.object({
7509
- method: z17.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]).describe("HTTP method"),
7510
- url: z17.string().url().refine((u) => u.startsWith("https://"), { message: "URL must use HTTPS" }).refine(
7527
+ input: z18.object({
7528
+ method: z18.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]).describe("HTTP method"),
7529
+ url: z18.string().url().refine((u) => u.startsWith("https://"), { message: "URL must use HTTPS" }).refine(
7511
7530
  (u) => {
7512
7531
  try {
7513
7532
  const host = new URL(u).hostname;
@@ -7520,15 +7539,15 @@ var x402RequestSchema = defineToolSchema({
7520
7539
  ).describe(
7521
7540
  "Full HTTPS URL of the x402-protected endpoint (e.g., 'https://agents.moonpay.com/api/x402/tools/market_digest_retrieve')"
7522
7541
  ),
7523
- body: z17.record(z17.any()).nullable().describe("Request body (for POST, PUT, PATCH)"),
7524
- params: z17.record(z17.any()).nullable().describe("Query parameters"),
7525
- wallet: z17.string().describe("Wallet name or address to pay with"),
7526
- chain: z17.enum(["solana", "base", "ethereum", "arbitrum", "polygon", "optimism"]).nullable().describe("Chain to pay from (default: solana). Use an EVM chain like 'base' to pay with an EVM wallet.")
7542
+ body: z18.record(z18.any()).nullable().describe("Request body (for POST, PUT, PATCH)"),
7543
+ params: z18.record(z18.any()).nullable().describe("Query parameters"),
7544
+ wallet: z18.string().describe("Wallet name or address to pay with"),
7545
+ chain: z18.enum(["solana", "base", "ethereum", "arbitrum", "polygon", "optimism"]).nullable().describe("Chain to pay from (default: solana). Use an EVM chain like 'base' to pay with an EVM wallet.")
7527
7546
  }),
7528
- output: z17.object({
7529
- status: z17.number().describe("HTTP status code"),
7530
- data: z17.any().describe("Response data"),
7531
- headers: z17.record(z17.any()).describe("Response headers")
7547
+ output: z18.object({
7548
+ status: z18.number().describe("HTTP status code"),
7549
+ data: z18.any().describe("Response data"),
7550
+ headers: z18.record(z18.any()).describe("Response headers")
7532
7551
  })
7533
7552
  });
7534
7553
 
@@ -7620,18 +7639,18 @@ var x402Request = createTool(
7620
7639
  );
7621
7640
 
7622
7641
  // src/tools/virtual-account/wallet/register/schema.ts
7623
- import { z as z18 } from "zod";
7642
+ import { z as z19 } from "zod";
7624
7643
  var virtualAccountWalletRegisterSchema = defineToolSchema({
7625
7644
  name: "virtual-account_wallet_register",
7626
7645
  description: "Register a local wallet with your virtual account. Creates the verification message, signs it locally, and registers in one step.",
7627
- input: z18.object({
7628
- wallet: z18.string().describe("Local wallet name"),
7646
+ input: z19.object({
7647
+ wallet: z19.string().describe("Local wallet name"),
7629
7648
  chain: chainSchema.describe("Chain to register (solana, ethereum, etc.)")
7630
7649
  }),
7631
- output: z18.object({
7632
- success: z18.literal(true),
7633
- address: z18.string().describe("Registered wallet address"),
7634
- chain: z18.string().describe("Chain registered on")
7650
+ output: z19.object({
7651
+ success: z19.literal(true),
7652
+ address: z19.string().describe("Registered wallet address"),
7653
+ chain: z19.string().describe("Chain registered on")
7635
7654
  })
7636
7655
  });
7637
7656
 
@@ -7673,14 +7692,14 @@ import * as os3 from "os";
7673
7692
  import * as path3 from "path";
7674
7693
 
7675
7694
  // src/tools/consent/accept/schema.ts
7676
- import { z as z19 } from "zod";
7695
+ import { z as z20 } from "zod";
7677
7696
  var consentAcceptSchema = defineToolSchema({
7678
7697
  name: "consent_accept",
7679
7698
  description: "Accept the MoonPay Terms of Service and Privacy Policy. Required before using any CLI command.",
7680
- input: z19.object({}),
7681
- output: z19.object({
7682
- tosVersion: z19.string(),
7683
- acceptedAt: z19.string()
7699
+ input: z20.object({}),
7700
+ output: z20.object({
7701
+ tosVersion: z20.string(),
7702
+ acceptedAt: z20.string()
7684
7703
  })
7685
7704
  });
7686
7705
 
@@ -7704,16 +7723,16 @@ var consentAccept = createTool(consentAcceptSchema, async () => {
7704
7723
  });
7705
7724
 
7706
7725
  // src/tools/login/schema.ts
7707
- import { z as z20 } from "zod";
7726
+ import { z as z21 } from "zod";
7708
7727
  var loginSchema = defineToolSchema({
7709
7728
  name: "login",
7710
7729
  description: "Send a login verification code to your email.",
7711
- input: z20.object({
7712
- email: z20.string().describe("Email address")
7730
+ input: z21.object({
7731
+ email: z21.string().describe("Email address")
7713
7732
  }),
7714
- output: z20.object({
7715
- email: z20.string(),
7716
- message: z20.string()
7733
+ output: z21.object({
7734
+ email: z21.string(),
7735
+ message: z21.string()
7717
7736
  })
7718
7737
  });
7719
7738
 
@@ -7732,17 +7751,17 @@ Then run: mp verify --email ${params.email} --code <code>`
7732
7751
  });
7733
7752
 
7734
7753
  // src/tools/verify/schema.ts
7735
- import { z as z21 } from "zod";
7754
+ import { z as z22 } from "zod";
7736
7755
  var verifySchema = defineToolSchema({
7737
7756
  name: "verify",
7738
7757
  description: "Verify login code and store encrypted credentials.",
7739
- input: z21.object({
7740
- email: z21.string().describe("Email address"),
7741
- code: z21.string().describe("Verification code")
7758
+ input: z22.object({
7759
+ email: z22.string().describe("Email address"),
7760
+ code: z22.string().describe("Verification code")
7742
7761
  }),
7743
- output: z21.object({
7744
- email: z21.string(),
7745
- message: z21.string()
7762
+ output: z22.object({
7763
+ email: z22.string(),
7764
+ message: z22.string()
7746
7765
  })
7747
7766
  });
7748
7767
 
@@ -7764,14 +7783,14 @@ var verify = createTool(verifySchema, async (params) => {
7764
7783
  });
7765
7784
 
7766
7785
  // src/tools/logout/schema.ts
7767
- import { z as z22 } from "zod";
7786
+ import { z as z23 } from "zod";
7768
7787
  var logoutSchema = defineToolSchema({
7769
7788
  name: "logout",
7770
7789
  description: "Log out and clear stored credentials.",
7771
- input: z22.object({}),
7772
- output: z22.object({
7773
- success: z22.literal(true),
7774
- message: z22.string()
7790
+ input: z23.object({}),
7791
+ output: z23.object({
7792
+ success: z23.literal(true),
7793
+ message: z23.string()
7775
7794
  })
7776
7795
  });
7777
7796
 
@@ -7785,15 +7804,15 @@ var logout = createTool(logoutSchema, async () => {
7785
7804
  import { createRequire } from "module";
7786
7805
 
7787
7806
  // src/tools/qr/schema.ts
7788
- import { z as z23 } from "zod";
7807
+ import { z as z24 } from "zod";
7789
7808
  var qrGenerateSchema = defineToolSchema({
7790
7809
  name: "qr_generate",
7791
7810
  description: "Display a QR code in the terminal. Pass any text \u2014 wallet address, URL, token address, etc.",
7792
- input: z23.object({
7793
- value: z23.string().describe("Text to encode as a QR code")
7811
+ input: z24.object({
7812
+ value: z24.string().describe("Text to encode as a QR code")
7794
7813
  }),
7795
- output: z23.object({
7796
- value: z23.string()
7814
+ output: z24.object({
7815
+ value: z24.string()
7797
7816
  })
7798
7817
  });
7799
7818
 
@@ -7844,4 +7863,4 @@ export {
7844
7863
  consentCheck,
7845
7864
  LOCAL_TOOLS
7846
7865
  };
7847
- //# sourceMappingURL=chunk-CTYZ36RZ.js.map
7866
+ //# sourceMappingURL=chunk-7KJP7F5Q.js.map