@moonpay/cli 0.2.1 → 0.2.3

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
@@ -2771,102 +2771,52 @@ function startVersionCheck(currentVersion) {
2771
2771
  var schemas_default = [
2772
2772
  {
2773
2773
  name: "buy",
2774
- description: "Generate a buy link for purchasing crypto with fiat. Specify either from.amount (fiat to spend) or to.amount (tokens to buy), not both.",
2774
+ description: "Buy crypto with fiat via MoonPay. Returns a checkout URL to complete the purchase.",
2775
2775
  inputSchema: {
2776
2776
  $ref: "#/definitions/buy_input",
2777
2777
  definitions: {
2778
2778
  buy_input: {
2779
2779
  type: "object",
2780
2780
  properties: {
2781
+ token: {
2782
+ type: "string",
2783
+ enum: [
2784
+ "sol",
2785
+ "usdc",
2786
+ "usdc_arbitrum",
2787
+ "usdc_base",
2788
+ "usdc_optimism",
2789
+ "usdc_sol",
2790
+ "usdc_polygon",
2791
+ "eth",
2792
+ "eth_polygon",
2793
+ "eth_optimism",
2794
+ "eth_base",
2795
+ "eth_arbitrum"
2796
+ ],
2797
+ description: "MoonPay currency code: sol (Solana), usdc_sol (USDC on Solana), eth (Ethereum), usdc (USDC on Ethereum), usdc_base (USDC on Base), etc."
2798
+ },
2799
+ amount: {
2800
+ type: "number",
2801
+ description: "Amount of token to buy (e.g. 1.5 for 1.5 SOL)"
2802
+ },
2803
+ wallet: {
2804
+ type: "string",
2805
+ description: "Destination wallet address to receive the tokens"
2806
+ },
2781
2807
  email: {
2782
2808
  type: [
2783
2809
  "string",
2784
2810
  "null"
2785
2811
  ],
2786
- description: "Email address for the buyer"
2787
- },
2788
- from: {
2789
- type: "object",
2790
- properties: {
2791
- currency: {
2792
- type: "string",
2793
- enum: [
2794
- "usd",
2795
- "eur",
2796
- "gbp"
2797
- ],
2798
- description: "Payment currency to spend (e.g., usd, eur, gbp)"
2799
- },
2800
- amount: {
2801
- anyOf: [
2802
- {
2803
- type: "number",
2804
- minimum: 20
2805
- },
2806
- {
2807
- type: "null"
2808
- }
2809
- ],
2810
- description: "Amount in payment currency to spend"
2811
- }
2812
- },
2813
- required: [
2814
- "currency",
2815
- "amount"
2816
- ],
2817
- additionalProperties: false,
2818
- description: "Payment currency and amount to spend"
2819
- },
2820
- to: {
2821
- type: "object",
2822
- properties: {
2823
- chain: {
2824
- type: "string",
2825
- enum: [
2826
- "solana",
2827
- "ethereum",
2828
- "base",
2829
- "polygon",
2830
- "arbitrum",
2831
- "optimism"
2832
- ],
2833
- description: "Destination blockchain network"
2834
- },
2835
- currency: {
2836
- type: "string",
2837
- enum: [
2838
- "sol",
2839
- "usdc",
2840
- "eth"
2841
- ],
2842
- description: "The crypto currency to buy"
2843
- },
2844
- amount: {
2845
- type: [
2846
- "number",
2847
- "null"
2848
- ],
2849
- description: "Amount of tokens to buy"
2850
- },
2851
- wallet: {
2852
- type: "string",
2853
- description: "Destination wallet address"
2854
- }
2855
- },
2856
- required: [
2857
- "chain",
2858
- "currency",
2859
- "amount",
2860
- "wallet"
2861
- ],
2862
- additionalProperties: false,
2863
- description: "Destination chain, currency, token amount, and wallet"
2812
+ description: "Buyer email to pre-fill on the checkout page"
2864
2813
  }
2865
2814
  },
2866
2815
  required: [
2867
- "email",
2868
- "from",
2869
- "to"
2816
+ "token",
2817
+ "amount",
2818
+ "wallet",
2819
+ "email"
2870
2820
  ],
2871
2821
  additionalProperties: false
2872
2822
  }
@@ -3086,7 +3036,7 @@ var schemas_default = [
3086
3036
  },
3087
3037
  {
3088
3038
  name: "user_retrieve",
3089
- description: "Retrieve the currently authenticated user from the session context.",
3039
+ description: "Get the currently authenticated user",
3090
3040
  inputSchema: {
3091
3041
  $ref: "#/definitions/user_retrieve_input",
3092
3042
  definitions: {
@@ -4105,16 +4055,17 @@ function saveWallet(wallet) {
4105
4055
  writeFileSync3(tmpPath, JSON.stringify(wallet, null, 2), { mode: 384 });
4106
4056
  renameSync2(tmpPath, filePath);
4107
4057
  }
4108
- function loadWallet(address) {
4058
+ function loadWallet(nameOrAddress) {
4109
4059
  ensureWalletsDir();
4110
4060
  const files = readdirSync(WALLETS_DIR).filter((f) => f.endsWith(".json"));
4111
4061
  for (const file of files) {
4112
4062
  const wallet = JSON.parse(
4113
4063
  readFileSync3(join3(WALLETS_DIR, file), "utf-8")
4114
4064
  );
4115
- if (wallet.address === address) return wallet;
4065
+ if (wallet.name === nameOrAddress || wallet.address === nameOrAddress)
4066
+ return wallet;
4116
4067
  }
4117
- throw new Error(`Wallet "${address}" not found`);
4068
+ throw new Error(`Wallet "${nameOrAddress}" not found`);
4118
4069
  }
4119
4070
 
4120
4071
  // src/tools/wallet/create/schema.ts
@@ -4247,7 +4198,7 @@ var walletRetrieveSchema = defineToolSchema({
4247
4198
  name: "wallet_retrieve",
4248
4199
  description: "Get details of a specific wallet",
4249
4200
  input: z5.object({
4250
- name: z5.string().describe("Wallet name")
4201
+ wallet: z5.string().describe("Wallet name or address")
4251
4202
  }),
4252
4203
  output: walletInfoSchema
4253
4204
  });
@@ -4256,7 +4207,7 @@ var walletRetrieveSchema = defineToolSchema({
4256
4207
  var walletRetrieve = createTool(
4257
4208
  walletRetrieveSchema,
4258
4209
  async (params) => {
4259
- const wallet = loadWallet(params.name);
4210
+ const wallet = loadWallet(params.wallet);
4260
4211
  return {
4261
4212
  name: wallet.name,
4262
4213
  address: wallet.address,
@@ -4275,7 +4226,7 @@ var walletDeleteSchema = defineToolSchema({
4275
4226
  name: "wallet_delete",
4276
4227
  description: "Permanently delete a local wallet. This removes the private key file and cannot be undone.",
4277
4228
  input: z6.object({
4278
- name: z6.string().describe("Name of the wallet to delete"),
4229
+ wallet: z6.string().describe("Name or address of the wallet to delete"),
4279
4230
  confirm: z6.boolean().describe("Must be true to confirm deletion")
4280
4231
  }),
4281
4232
  output: z6.object({
@@ -4291,9 +4242,9 @@ var walletDelete = createTool(walletDeleteSchema, async (params) => {
4291
4242
  "Deletion not confirmed. Pass --confirm to permanently delete this wallet."
4292
4243
  );
4293
4244
  }
4294
- await walletRetrieve.handler({ name: params.name });
4295
- unlinkSync2(getWalletPath(params.name));
4296
- return { name: params.name, deleted: true };
4245
+ const wallet = await walletRetrieve.handler({ wallet: params.wallet });
4246
+ unlinkSync2(getWalletPath(wallet.name));
4247
+ return { name: wallet.name, deleted: true };
4297
4248
  });
4298
4249
 
4299
4250
  // src/tools/transaction/sign/tool.ts
@@ -4537,34 +4488,8 @@ function registerRemoteTools(parent, remoteSchemas) {
4537
4488
  });
4538
4489
  }
4539
4490
  }
4540
- var TOKENS = ["sol", "usdc", "eth"];
4541
- var CHAINS = ["solana", "ethereum", "base", "polygon", "arbitrum", "optimism"];
4542
- program.command("buy").description("Buy crypto with fiat via MoonPay").requiredOption("--email <email>", "Buyer email address").requiredOption("--token <token>", `Token to buy (${TOKENS.join(", ")})`).requiredOption("--amount <amount>", "Amount of token to buy").requiredOption("--wallet <wallet>", "Destination wallet address").option("--chain <chain>", `Blockchain (${CHAINS.join(", ")})`, "solana").action(async (options) => {
4543
- try {
4544
- const baseUrl = resolveBaseUrl();
4545
- const result = await callTool(baseUrl, "buy", {
4546
- email: options.email,
4547
- from: { currency: "usd", amount: null },
4548
- to: {
4549
- chain: options.chain,
4550
- currency: options.token,
4551
- amount: Number(options.amount),
4552
- wallet: options.wallet
4553
- }
4554
- });
4555
- printResult(result);
4556
- printUpdateNotice();
4557
- } catch (error) {
4558
- console.error(error.message);
4559
- process.exit(1);
4560
- }
4561
- });
4562
- var CUSTOM_TOOLS = /* @__PURE__ */ new Set(["buy"]);
4563
4491
  registerLocalTools(program, LOCAL_TOOLS);
4564
- registerRemoteTools(
4565
- program,
4566
- schemas_default.filter((s) => !CUSTOM_TOOLS.has(s.name))
4567
- );
4492
+ registerRemoteTools(program, schemas_default);
4568
4493
  program.command("tools").description("List available tools").action(() => {
4569
4494
  const allTools = [
4570
4495
  ...LOCAL_TOOLS.map((t) => ({