@moonpay/cli 0.6.2 → 0.6.5
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/{chunk-P764SORF.js → chunk-JQEHP3SV.js} +413 -75
- package/dist/chunk-JQEHP3SV.js.map +1 -0
- package/dist/index.js +21 -5
- package/dist/index.js.map +1 -1
- package/dist/{mcp-PNM25UVD.js → mcp-XWTHJES3.js} +4 -2
- package/dist/mcp-XWTHJES3.js.map +1 -0
- package/package.json +3 -2
- package/dist/chunk-P764SORF.js.map +0 -1
- package/dist/mcp-PNM25UVD.js.map +0 -1
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
getEncryptionKey,
|
|
15
15
|
keyChainSchema,
|
|
16
16
|
loadWallets,
|
|
17
|
+
mutateWallets,
|
|
17
18
|
removeWallet,
|
|
18
19
|
resolveSigningKey,
|
|
19
20
|
walletInfoSchema
|
|
@@ -329,6 +330,283 @@ var schemas_default = [
|
|
|
329
330
|
$schema: "http://json-schema.org/draft-07/schema#"
|
|
330
331
|
}
|
|
331
332
|
},
|
|
333
|
+
{
|
|
334
|
+
name: "deposit_create",
|
|
335
|
+
description: "Create a new deposit link that generates multi-chain deposit addresses. Anyone can send crypto to these addresses from Solana, Ethereum, Bitcoin, or Tron \u2014 it automatically converts to USDC and settles to the specified destination wallet and chain.",
|
|
336
|
+
inputSchema: {
|
|
337
|
+
$ref: "#/definitions/deposit_create_input",
|
|
338
|
+
definitions: {
|
|
339
|
+
deposit_create_input: {
|
|
340
|
+
type: "object",
|
|
341
|
+
properties: {
|
|
342
|
+
name: {
|
|
343
|
+
type: "string",
|
|
344
|
+
description: "Human-readable label for this deposit link (e.g. 'Treasury Base USDC')"
|
|
345
|
+
},
|
|
346
|
+
wallet: {
|
|
347
|
+
type: "string",
|
|
348
|
+
description: "Destination wallet address where USDC will be delivered"
|
|
349
|
+
},
|
|
350
|
+
chain: {
|
|
351
|
+
type: "string",
|
|
352
|
+
enum: [
|
|
353
|
+
"solana",
|
|
354
|
+
"ethereum",
|
|
355
|
+
"base",
|
|
356
|
+
"polygon",
|
|
357
|
+
"arbitrum",
|
|
358
|
+
"bnb"
|
|
359
|
+
],
|
|
360
|
+
description: "Blockchain of the destination wallet (determines which USDC the wallet receives)"
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
required: [
|
|
364
|
+
"name",
|
|
365
|
+
"wallet",
|
|
366
|
+
"chain"
|
|
367
|
+
],
|
|
368
|
+
additionalProperties: false
|
|
369
|
+
}
|
|
370
|
+
},
|
|
371
|
+
$schema: "http://json-schema.org/draft-07/schema#"
|
|
372
|
+
},
|
|
373
|
+
outputSchema: {
|
|
374
|
+
$ref: "#/definitions/deposit_create_output",
|
|
375
|
+
definitions: {
|
|
376
|
+
deposit_create_output: {
|
|
377
|
+
type: "object",
|
|
378
|
+
properties: {
|
|
379
|
+
id: {
|
|
380
|
+
type: "string",
|
|
381
|
+
description: "Unique deposit ID \u2014 use with deposit_transaction_list to check incoming payments"
|
|
382
|
+
},
|
|
383
|
+
destinationWallet: {
|
|
384
|
+
type: "string",
|
|
385
|
+
description: "Wallet address that will receive USDC"
|
|
386
|
+
},
|
|
387
|
+
destinationChain: {
|
|
388
|
+
type: "string",
|
|
389
|
+
description: "Chain where USDC will be delivered"
|
|
390
|
+
},
|
|
391
|
+
depositUrl: {
|
|
392
|
+
type: "string",
|
|
393
|
+
description: "Shareable URL \u2014 open in browser or share with senders to deposit funds"
|
|
394
|
+
},
|
|
395
|
+
wallets: {
|
|
396
|
+
type: "array",
|
|
397
|
+
items: {
|
|
398
|
+
type: "object",
|
|
399
|
+
properties: {
|
|
400
|
+
address: {
|
|
401
|
+
type: "string",
|
|
402
|
+
description: "Address to send funds to"
|
|
403
|
+
},
|
|
404
|
+
chain: {
|
|
405
|
+
type: "string",
|
|
406
|
+
description: "Chain this address is on (solana, ethereum, bitcoin, tron)"
|
|
407
|
+
}
|
|
408
|
+
},
|
|
409
|
+
required: [
|
|
410
|
+
"address",
|
|
411
|
+
"chain"
|
|
412
|
+
],
|
|
413
|
+
additionalProperties: false
|
|
414
|
+
},
|
|
415
|
+
description: "Deposit addresses across all supported chains \u2014 send any token to any of these"
|
|
416
|
+
}
|
|
417
|
+
},
|
|
418
|
+
required: [
|
|
419
|
+
"id",
|
|
420
|
+
"destinationWallet",
|
|
421
|
+
"destinationChain",
|
|
422
|
+
"depositUrl",
|
|
423
|
+
"wallets"
|
|
424
|
+
],
|
|
425
|
+
additionalProperties: false
|
|
426
|
+
}
|
|
427
|
+
},
|
|
428
|
+
$schema: "http://json-schema.org/draft-07/schema#"
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
name: "deposit_list",
|
|
433
|
+
description: "List all deposit links belonging to the current user. Each deposit link has multi-chain addresses that auto-convert incoming crypto to USDC.",
|
|
434
|
+
inputSchema: {
|
|
435
|
+
$ref: "#/definitions/deposit_list_input",
|
|
436
|
+
definitions: {
|
|
437
|
+
deposit_list_input: {
|
|
438
|
+
type: "object",
|
|
439
|
+
properties: {},
|
|
440
|
+
additionalProperties: false
|
|
441
|
+
}
|
|
442
|
+
},
|
|
443
|
+
$schema: "http://json-schema.org/draft-07/schema#"
|
|
444
|
+
},
|
|
445
|
+
outputSchema: {
|
|
446
|
+
$ref: "#/definitions/deposit_list_output",
|
|
447
|
+
definitions: {
|
|
448
|
+
deposit_list_output: {
|
|
449
|
+
type: "object",
|
|
450
|
+
properties: {
|
|
451
|
+
items: {
|
|
452
|
+
type: "array",
|
|
453
|
+
items: {
|
|
454
|
+
type: "object",
|
|
455
|
+
properties: {
|
|
456
|
+
id: {
|
|
457
|
+
type: "string",
|
|
458
|
+
description: "Deposit ID \u2014 use with deposit_transaction_list to check payments"
|
|
459
|
+
},
|
|
460
|
+
name: {
|
|
461
|
+
type: "string",
|
|
462
|
+
description: "Human-readable label"
|
|
463
|
+
},
|
|
464
|
+
depositUrl: {
|
|
465
|
+
type: "string",
|
|
466
|
+
description: "Shareable deposit URL"
|
|
467
|
+
},
|
|
468
|
+
wallets: {
|
|
469
|
+
type: "array",
|
|
470
|
+
items: {
|
|
471
|
+
type: "object",
|
|
472
|
+
properties: {
|
|
473
|
+
address: {
|
|
474
|
+
type: "string",
|
|
475
|
+
description: "Address to send funds to"
|
|
476
|
+
},
|
|
477
|
+
chain: {
|
|
478
|
+
type: "string",
|
|
479
|
+
description: "Chain this address is on"
|
|
480
|
+
}
|
|
481
|
+
},
|
|
482
|
+
required: [
|
|
483
|
+
"address",
|
|
484
|
+
"chain"
|
|
485
|
+
],
|
|
486
|
+
additionalProperties: false
|
|
487
|
+
},
|
|
488
|
+
description: "Multi-chain deposit addresses"
|
|
489
|
+
},
|
|
490
|
+
createdAt: {
|
|
491
|
+
type: "string",
|
|
492
|
+
description: "When this deposit link was created"
|
|
493
|
+
}
|
|
494
|
+
},
|
|
495
|
+
required: [
|
|
496
|
+
"id",
|
|
497
|
+
"name",
|
|
498
|
+
"depositUrl",
|
|
499
|
+
"wallets",
|
|
500
|
+
"createdAt"
|
|
501
|
+
],
|
|
502
|
+
additionalProperties: false
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
},
|
|
506
|
+
required: [
|
|
507
|
+
"items"
|
|
508
|
+
],
|
|
509
|
+
additionalProperties: false
|
|
510
|
+
}
|
|
511
|
+
},
|
|
512
|
+
$schema: "http://json-schema.org/draft-07/schema#"
|
|
513
|
+
}
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
name: "deposit_transaction_list",
|
|
517
|
+
description: "List incoming transactions for a deposit link. Shows each payment received \u2014 amount, token, sender, and whether it has settled to USDC.",
|
|
518
|
+
inputSchema: {
|
|
519
|
+
$ref: "#/definitions/deposit_transaction_list_input",
|
|
520
|
+
definitions: {
|
|
521
|
+
deposit_transaction_list_input: {
|
|
522
|
+
type: "object",
|
|
523
|
+
properties: {
|
|
524
|
+
depositId: {
|
|
525
|
+
type: "string",
|
|
526
|
+
description: "Deposit ID from deposit_create or deposit_list"
|
|
527
|
+
}
|
|
528
|
+
},
|
|
529
|
+
required: [
|
|
530
|
+
"depositId"
|
|
531
|
+
],
|
|
532
|
+
additionalProperties: false
|
|
533
|
+
}
|
|
534
|
+
},
|
|
535
|
+
$schema: "http://json-schema.org/draft-07/schema#"
|
|
536
|
+
},
|
|
537
|
+
outputSchema: {
|
|
538
|
+
$ref: "#/definitions/deposit_transaction_list_output",
|
|
539
|
+
definitions: {
|
|
540
|
+
deposit_transaction_list_output: {
|
|
541
|
+
type: "object",
|
|
542
|
+
properties: {
|
|
543
|
+
items: {
|
|
544
|
+
type: "array",
|
|
545
|
+
items: {
|
|
546
|
+
type: "object",
|
|
547
|
+
properties: {
|
|
548
|
+
id: {
|
|
549
|
+
type: "string",
|
|
550
|
+
description: "Transaction ID"
|
|
551
|
+
},
|
|
552
|
+
amount: {
|
|
553
|
+
type: "number",
|
|
554
|
+
description: "Amount received"
|
|
555
|
+
},
|
|
556
|
+
token: {
|
|
557
|
+
type: "string",
|
|
558
|
+
description: "Token symbol received (e.g. SOL, ETH, USDC)"
|
|
559
|
+
},
|
|
560
|
+
from: {
|
|
561
|
+
type: "string",
|
|
562
|
+
description: "Sender's wallet address"
|
|
563
|
+
},
|
|
564
|
+
status: {
|
|
565
|
+
type: "string",
|
|
566
|
+
description: "Transaction status (SUCCESS, PENDING, FAILED)"
|
|
567
|
+
},
|
|
568
|
+
settledAmount: {
|
|
569
|
+
type: [
|
|
570
|
+
"number",
|
|
571
|
+
"null"
|
|
572
|
+
],
|
|
573
|
+
description: "Amount settled in USDC (null if not yet settled)"
|
|
574
|
+
},
|
|
575
|
+
settledCurrency: {
|
|
576
|
+
type: [
|
|
577
|
+
"string",
|
|
578
|
+
"null"
|
|
579
|
+
],
|
|
580
|
+
description: "Settlement currency (usually USDC)"
|
|
581
|
+
},
|
|
582
|
+
timestamp: {
|
|
583
|
+
type: "string",
|
|
584
|
+
description: "When the transaction was received"
|
|
585
|
+
}
|
|
586
|
+
},
|
|
587
|
+
required: [
|
|
588
|
+
"id",
|
|
589
|
+
"amount",
|
|
590
|
+
"token",
|
|
591
|
+
"from",
|
|
592
|
+
"status",
|
|
593
|
+
"settledAmount",
|
|
594
|
+
"settledCurrency",
|
|
595
|
+
"timestamp"
|
|
596
|
+
],
|
|
597
|
+
additionalProperties: false
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
},
|
|
601
|
+
required: [
|
|
602
|
+
"items"
|
|
603
|
+
],
|
|
604
|
+
additionalProperties: false
|
|
605
|
+
}
|
|
606
|
+
},
|
|
607
|
+
$schema: "http://json-schema.org/draft-07/schema#"
|
|
608
|
+
}
|
|
609
|
+
},
|
|
332
610
|
{
|
|
333
611
|
name: "login",
|
|
334
612
|
description: "Send a verification code to the provided email to sign in or create an account.",
|
|
@@ -6045,6 +6323,40 @@ var walletDelete = createTool(walletDeleteSchema, async (params) => {
|
|
|
6045
6323
|
return { name: wallet.name, deleted: true };
|
|
6046
6324
|
});
|
|
6047
6325
|
|
|
6326
|
+
// src/tools/wallet/rename/schema.ts
|
|
6327
|
+
import { z as z6 } from "zod";
|
|
6328
|
+
var walletRenameSchema = defineToolSchema({
|
|
6329
|
+
name: "wallet_rename",
|
|
6330
|
+
description: "Rename a local wallet.",
|
|
6331
|
+
input: z6.object({
|
|
6332
|
+
wallet: z6.string().describe("Current name or address of the wallet"),
|
|
6333
|
+
name: z6.string().describe("New name for the wallet")
|
|
6334
|
+
}),
|
|
6335
|
+
output: z6.object({
|
|
6336
|
+
oldName: z6.string(),
|
|
6337
|
+
newName: z6.string()
|
|
6338
|
+
})
|
|
6339
|
+
});
|
|
6340
|
+
|
|
6341
|
+
// src/tools/wallet/rename/tool.ts
|
|
6342
|
+
var walletRename = createTool(walletRenameSchema, async (params) => {
|
|
6343
|
+
const wallet = findWalletOrThrow(params.wallet);
|
|
6344
|
+
const oldName = wallet.name;
|
|
6345
|
+
if (oldName === params.name) {
|
|
6346
|
+
throw new Error(`Wallet is already named "${params.name}"`);
|
|
6347
|
+
}
|
|
6348
|
+
const existing = loadWallets();
|
|
6349
|
+
if (existing.some((w) => w.name === params.name)) {
|
|
6350
|
+
throw new Error(`Wallet "${params.name}" already exists`);
|
|
6351
|
+
}
|
|
6352
|
+
mutateWallets((wallets) => {
|
|
6353
|
+
const w = wallets.find((w2) => w2.name === oldName);
|
|
6354
|
+
if (!w) throw new Error(`Wallet "${oldName}" not found`);
|
|
6355
|
+
w.name = params.name;
|
|
6356
|
+
});
|
|
6357
|
+
return { oldName, newName: params.name };
|
|
6358
|
+
});
|
|
6359
|
+
|
|
6048
6360
|
// src/tools/transaction/sign/tool.ts
|
|
6049
6361
|
import { createHash } from "crypto";
|
|
6050
6362
|
import { Keypair as Keypair2, VersionedTransaction } from "@solana/web3.js";
|
|
@@ -6055,19 +6367,19 @@ import * as viemChains from "viem/chains";
|
|
|
6055
6367
|
import * as ecc from "tiny-secp256k1";
|
|
6056
6368
|
|
|
6057
6369
|
// src/tools/transaction/sign/schema.ts
|
|
6058
|
-
import { z as
|
|
6370
|
+
import { z as z7 } from "zod";
|
|
6059
6371
|
var transactionSignSchema = defineToolSchema({
|
|
6060
6372
|
name: "transaction_sign",
|
|
6061
6373
|
description: "Sign a transaction with a local wallet. Supports Solana (VersionedTransaction), EVM (RLP-encoded), and Bitcoin (PSBT) transactions.",
|
|
6062
|
-
input:
|
|
6063
|
-
wallet:
|
|
6374
|
+
input: z7.object({
|
|
6375
|
+
wallet: z7.string().describe("Wallet name or address"),
|
|
6064
6376
|
chain: chainSchema.describe(
|
|
6065
6377
|
"Chain: solana, ethereum, base, arbitrum, or bitcoin"
|
|
6066
6378
|
),
|
|
6067
|
-
transaction:
|
|
6379
|
+
transaction: z7.string().describe("Base64-encoded unsigned transaction")
|
|
6068
6380
|
}),
|
|
6069
|
-
output:
|
|
6070
|
-
transaction:
|
|
6381
|
+
output: z7.object({
|
|
6382
|
+
transaction: z7.string().describe("Base64-encoded signed transaction")
|
|
6071
6383
|
})
|
|
6072
6384
|
});
|
|
6073
6385
|
|
|
@@ -6182,19 +6494,19 @@ import { keccak_256 } from "@noble/hashes/sha3";
|
|
|
6182
6494
|
import { privateKeyToAccount as privateKeyToAccount3 } from "viem/accounts";
|
|
6183
6495
|
|
|
6184
6496
|
// src/tools/message/sign/schema.ts
|
|
6185
|
-
import { z as
|
|
6497
|
+
import { z as z8 } from "zod";
|
|
6186
6498
|
var messageSignSchema = defineToolSchema({
|
|
6187
6499
|
name: "message_sign",
|
|
6188
6500
|
description: "Sign a message with a local wallet. Supports Solana (ed25519), EVM (EIP-191 personal sign), and Bitcoin (secp256k1 ECDSA).",
|
|
6189
|
-
input:
|
|
6190
|
-
wallet:
|
|
6501
|
+
input: z8.object({
|
|
6502
|
+
wallet: z8.string().describe("Wallet address or name to sign with"),
|
|
6191
6503
|
chain: chainSchema.describe(
|
|
6192
6504
|
"Chain: solana, ethereum, base, arbitrum, or bitcoin"
|
|
6193
6505
|
),
|
|
6194
|
-
message:
|
|
6506
|
+
message: z8.string().describe("Message text to sign")
|
|
6195
6507
|
}),
|
|
6196
|
-
output:
|
|
6197
|
-
signature:
|
|
6508
|
+
output: z8.object({
|
|
6509
|
+
signature: z8.string().describe(
|
|
6198
6510
|
"Signature: base58 for Solana, hex (0x-prefixed) for EVM/Bitcoin"
|
|
6199
6511
|
)
|
|
6200
6512
|
})
|
|
@@ -6254,26 +6566,26 @@ function signBitcoin2(privateKey, messageBytes) {
|
|
|
6254
6566
|
import https from "https";
|
|
6255
6567
|
|
|
6256
6568
|
// src/tools/bitcoin/balance/schema.ts
|
|
6257
|
-
import { z as
|
|
6569
|
+
import { z as z9 } from "zod";
|
|
6258
6570
|
var bitcoinBalanceRetrieveSchema = defineToolSchema({
|
|
6259
6571
|
name: "bitcoin_balance_retrieve",
|
|
6260
6572
|
description: "Get the BTC balance of a Bitcoin address. Returns confirmed and unconfirmed balances in BTC and satoshis.",
|
|
6261
|
-
input:
|
|
6262
|
-
wallet:
|
|
6573
|
+
input: z9.object({
|
|
6574
|
+
wallet: z9.string().describe("Bitcoin address (bc1...) or wallet name")
|
|
6263
6575
|
}),
|
|
6264
|
-
output:
|
|
6265
|
-
address:
|
|
6266
|
-
confirmed:
|
|
6267
|
-
btc:
|
|
6268
|
-
sats:
|
|
6576
|
+
output: z9.object({
|
|
6577
|
+
address: z9.string().describe("Bitcoin address"),
|
|
6578
|
+
confirmed: z9.object({
|
|
6579
|
+
btc: z9.string().describe("Confirmed balance in BTC"),
|
|
6580
|
+
sats: z9.number().describe("Confirmed balance in satoshis")
|
|
6269
6581
|
}),
|
|
6270
|
-
unconfirmed:
|
|
6271
|
-
btc:
|
|
6272
|
-
sats:
|
|
6582
|
+
unconfirmed: z9.object({
|
|
6583
|
+
btc: z9.string().describe("Unconfirmed (pending) balance in BTC"),
|
|
6584
|
+
sats: z9.number().describe("Unconfirmed (pending) balance in satoshis")
|
|
6273
6585
|
}),
|
|
6274
|
-
total:
|
|
6275
|
-
btc:
|
|
6276
|
-
sats:
|
|
6586
|
+
total: z9.object({
|
|
6587
|
+
btc: z9.string().describe("Total balance in BTC"),
|
|
6588
|
+
sats: z9.number().describe("Total balance in satoshis")
|
|
6277
6589
|
})
|
|
6278
6590
|
})
|
|
6279
6591
|
});
|
|
@@ -6337,24 +6649,24 @@ var bitcoinBalanceRetrieve = createTool(
|
|
|
6337
6649
|
import { encodeFunctionData } from "viem";
|
|
6338
6650
|
|
|
6339
6651
|
// src/tools/token/swap/schema.ts
|
|
6340
|
-
import { z as
|
|
6341
|
-
var swapOutputSchema =
|
|
6342
|
-
signature:
|
|
6343
|
-
message:
|
|
6652
|
+
import { z as z10 } from "zod";
|
|
6653
|
+
var swapOutputSchema = z10.object({
|
|
6654
|
+
signature: z10.string().describe("Transaction hash/signature"),
|
|
6655
|
+
message: z10.string().describe("Human-readable swap description")
|
|
6344
6656
|
});
|
|
6345
6657
|
var tokenSwapSchema = defineToolSchema({
|
|
6346
6658
|
name: "token_swap",
|
|
6347
6659
|
description: "Swap tokens on the same chain. Builds, signs locally, broadcasts, and registers.",
|
|
6348
|
-
input:
|
|
6349
|
-
wallet:
|
|
6660
|
+
input: z10.object({
|
|
6661
|
+
wallet: z10.string().describe("Local wallet name to sign with"),
|
|
6350
6662
|
chain: chainSchema.describe("Chain to swap on"),
|
|
6351
|
-
from:
|
|
6352
|
-
token:
|
|
6353
|
-
amount:
|
|
6663
|
+
from: z10.object({
|
|
6664
|
+
token: z10.string().describe("Input token address (selling)"),
|
|
6665
|
+
amount: z10.coerce.number().nullable().describe("Amount to sell (exact-in). Null for exact-out.")
|
|
6354
6666
|
}),
|
|
6355
|
-
to:
|
|
6356
|
-
token:
|
|
6357
|
-
amount:
|
|
6667
|
+
to: z10.object({
|
|
6668
|
+
token: z10.string().describe("Output token address (buying)"),
|
|
6669
|
+
amount: z10.coerce.number().nullable().describe("Amount to receive (exact-out). Null for exact-in.")
|
|
6358
6670
|
})
|
|
6359
6671
|
}),
|
|
6360
6672
|
output: swapOutputSchema
|
|
@@ -6362,18 +6674,18 @@ var tokenSwapSchema = defineToolSchema({
|
|
|
6362
6674
|
var tokenBridgeSchema = defineToolSchema({
|
|
6363
6675
|
name: "token_bridge",
|
|
6364
6676
|
description: "Bridge tokens across chains. Builds, signs locally, broadcasts, and registers.",
|
|
6365
|
-
input:
|
|
6366
|
-
from:
|
|
6367
|
-
wallet:
|
|
6677
|
+
input: z10.object({
|
|
6678
|
+
from: z10.object({
|
|
6679
|
+
wallet: z10.string().describe("Local wallet name to sign with"),
|
|
6368
6680
|
chain: chainSchema.describe("Source chain"),
|
|
6369
|
-
token:
|
|
6370
|
-
amount:
|
|
6681
|
+
token: z10.string().describe("Source token address"),
|
|
6682
|
+
amount: z10.coerce.number().nullable().describe("Amount to send (exact-in). Null for exact-out.")
|
|
6371
6683
|
}),
|
|
6372
|
-
to:
|
|
6373
|
-
wallet:
|
|
6684
|
+
to: z10.object({
|
|
6685
|
+
wallet: z10.string().nullable().describe("Destination wallet name or address (defaults to from wallet)"),
|
|
6374
6686
|
chain: chainSchema.describe("Destination chain"),
|
|
6375
|
-
token:
|
|
6376
|
-
amount:
|
|
6687
|
+
token: z10.string().describe("Destination token address"),
|
|
6688
|
+
amount: z10.coerce.number().nullable().describe("Amount to receive (exact-out). Null for exact-in.")
|
|
6377
6689
|
})
|
|
6378
6690
|
}),
|
|
6379
6691
|
output: swapOutputSchema
|
|
@@ -6484,15 +6796,20 @@ import axios from "axios";
|
|
|
6484
6796
|
import { wrapAxiosWithPayment } from "@x402/axios";
|
|
6485
6797
|
import { x402Client } from "@x402/core/client";
|
|
6486
6798
|
import { ExactSvmScheme } from "@x402/svm";
|
|
6799
|
+
import { registerExactEvmScheme } from "@x402/evm/exact/client";
|
|
6800
|
+
import { toClientEvmSigner } from "@x402/evm";
|
|
6801
|
+
import { privateKeyToAccount as privateKeyToAccount4 } from "viem/accounts";
|
|
6802
|
+
import { createPublicClient as createPublicClient2, http as http2 } from "viem";
|
|
6803
|
+
import * as viemChains2 from "viem/chains";
|
|
6487
6804
|
|
|
6488
6805
|
// src/tools/x402/request/schema.ts
|
|
6489
|
-
import { z as
|
|
6806
|
+
import { z as z11 } from "zod";
|
|
6490
6807
|
var x402RequestSchema = defineToolSchema({
|
|
6491
6808
|
name: "x402_request",
|
|
6492
6809
|
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.",
|
|
6493
|
-
input:
|
|
6494
|
-
method:
|
|
6495
|
-
url:
|
|
6810
|
+
input: z11.object({
|
|
6811
|
+
method: z11.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]).describe("HTTP method"),
|
|
6812
|
+
url: z11.string().url().refine((u) => u.startsWith("https://"), { message: "URL must use HTTPS" }).refine(
|
|
6496
6813
|
(u) => {
|
|
6497
6814
|
try {
|
|
6498
6815
|
const host = new URL(u).hostname;
|
|
@@ -6505,20 +6822,28 @@ var x402RequestSchema = defineToolSchema({
|
|
|
6505
6822
|
).describe(
|
|
6506
6823
|
"Full HTTPS URL of the x402-protected endpoint (e.g., 'https://agents.moonpay.com/api/x402/tools/market_digest_retrieve')"
|
|
6507
6824
|
),
|
|
6508
|
-
body:
|
|
6509
|
-
params:
|
|
6510
|
-
wallet:
|
|
6825
|
+
body: z11.record(z11.any()).nullable().describe("Request body (for POST, PUT, PATCH)"),
|
|
6826
|
+
params: z11.record(z11.any()).nullable().describe("Query parameters"),
|
|
6827
|
+
wallet: z11.string().describe("Wallet name or address to pay with"),
|
|
6828
|
+
chain: z11.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.")
|
|
6511
6829
|
}),
|
|
6512
|
-
output:
|
|
6513
|
-
status:
|
|
6514
|
-
data:
|
|
6515
|
-
headers:
|
|
6830
|
+
output: z11.object({
|
|
6831
|
+
status: z11.number().describe("HTTP status code"),
|
|
6832
|
+
data: z11.any().describe("Response data"),
|
|
6833
|
+
headers: z11.record(z11.any()).describe("Response headers")
|
|
6516
6834
|
})
|
|
6517
6835
|
});
|
|
6518
6836
|
|
|
6519
6837
|
// src/tools/x402/request/tool.ts
|
|
6520
6838
|
var SOLANA_NETWORK = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
|
|
6521
|
-
|
|
6839
|
+
var CHAIN_TO_VIEM = {
|
|
6840
|
+
ethereum: viemChains2.mainnet,
|
|
6841
|
+
base: viemChains2.base,
|
|
6842
|
+
polygon: viemChains2.polygon,
|
|
6843
|
+
arbitrum: viemChains2.arbitrum,
|
|
6844
|
+
optimism: viemChains2.optimism
|
|
6845
|
+
};
|
|
6846
|
+
function createSolanaX402Client(walletAddress, secretKey) {
|
|
6522
6847
|
const keypair = Keypair4.fromSecretKey(secretKey);
|
|
6523
6848
|
const signer = {
|
|
6524
6849
|
address: walletAddress,
|
|
@@ -6550,28 +6875,40 @@ function createLocalX402Client(walletAddress, secretKey) {
|
|
|
6550
6875
|
client.registerV1("solana", svmScheme);
|
|
6551
6876
|
return wrapAxiosWithPayment(axios.create(), client);
|
|
6552
6877
|
}
|
|
6878
|
+
function createEvmX402Client(privateKey, chain) {
|
|
6879
|
+
const account = privateKeyToAccount4(
|
|
6880
|
+
`0x${Buffer.from(privateKey).toString("hex")}`
|
|
6881
|
+
);
|
|
6882
|
+
const viemChain = CHAIN_TO_VIEM[chain] ?? viemChains2.base;
|
|
6883
|
+
const publicClient = createPublicClient2({ chain: viemChain, transport: http2() });
|
|
6884
|
+
const signer = toClientEvmSigner(account, publicClient);
|
|
6885
|
+
const client = new x402Client();
|
|
6886
|
+
registerExactEvmScheme(client, { signer });
|
|
6887
|
+
return wrapAxiosWithPayment(axios.create(), client);
|
|
6888
|
+
}
|
|
6553
6889
|
var x402Request = createTool(
|
|
6554
6890
|
x402RequestSchema,
|
|
6555
|
-
async ({ method, url, body, params, wallet: walletNameOrAddress }) => {
|
|
6891
|
+
async ({ method, url, body, params, wallet: walletNameOrAddress, chain }) => {
|
|
6556
6892
|
const walletMetadata = findWalletOrThrow(walletNameOrAddress);
|
|
6557
|
-
const
|
|
6558
|
-
const
|
|
6893
|
+
const resolvedChain = chain ?? "solana";
|
|
6894
|
+
const { privateKey, address } = resolveSigningKey(walletMetadata, resolvedChain);
|
|
6895
|
+
const httpClient = resolvedChain === "solana" ? createSolanaX402Client(address, privateKey) : createEvmX402Client(privateKey, resolvedChain);
|
|
6559
6896
|
let response;
|
|
6560
6897
|
switch (method) {
|
|
6561
6898
|
case "GET":
|
|
6562
|
-
response = await
|
|
6899
|
+
response = await httpClient.get(url, { params });
|
|
6563
6900
|
break;
|
|
6564
6901
|
case "POST":
|
|
6565
|
-
response = await
|
|
6902
|
+
response = await httpClient.post(url, body || {}, { params });
|
|
6566
6903
|
break;
|
|
6567
6904
|
case "PUT":
|
|
6568
|
-
response = await
|
|
6905
|
+
response = await httpClient.put(url, body || {}, { params });
|
|
6569
6906
|
break;
|
|
6570
6907
|
case "PATCH":
|
|
6571
|
-
response = await
|
|
6908
|
+
response = await httpClient.patch(url, body || {}, { params });
|
|
6572
6909
|
break;
|
|
6573
6910
|
case "DELETE":
|
|
6574
|
-
response = await
|
|
6911
|
+
response = await httpClient.delete(url, { params });
|
|
6575
6912
|
break;
|
|
6576
6913
|
default:
|
|
6577
6914
|
throw new Error(`Unsupported HTTP method: ${method}`);
|
|
@@ -6585,18 +6922,18 @@ var x402Request = createTool(
|
|
|
6585
6922
|
);
|
|
6586
6923
|
|
|
6587
6924
|
// src/tools/virtual-account/wallet/register/schema.ts
|
|
6588
|
-
import { z as
|
|
6925
|
+
import { z as z12 } from "zod";
|
|
6589
6926
|
var virtualAccountWalletRegisterSchema = defineToolSchema({
|
|
6590
6927
|
name: "virtual-account_wallet_register",
|
|
6591
6928
|
description: "Register a local wallet with your virtual account. Creates the verification message, signs it locally, and registers in one step.",
|
|
6592
|
-
input:
|
|
6593
|
-
wallet:
|
|
6929
|
+
input: z12.object({
|
|
6930
|
+
wallet: z12.string().describe("Local wallet name"),
|
|
6594
6931
|
chain: chainSchema.describe("Chain to register (solana, ethereum, etc.)")
|
|
6595
6932
|
}),
|
|
6596
|
-
output:
|
|
6597
|
-
success:
|
|
6598
|
-
address:
|
|
6599
|
-
chain:
|
|
6933
|
+
output: z12.object({
|
|
6934
|
+
success: z12.literal(true),
|
|
6935
|
+
address: z12.string().describe("Registered wallet address"),
|
|
6936
|
+
chain: z12.string().describe("Chain registered on")
|
|
6600
6937
|
})
|
|
6601
6938
|
});
|
|
6602
6939
|
|
|
@@ -6648,6 +6985,7 @@ export {
|
|
|
6648
6985
|
walletList,
|
|
6649
6986
|
walletRetrieve,
|
|
6650
6987
|
walletDelete,
|
|
6988
|
+
walletRename,
|
|
6651
6989
|
transactionSign,
|
|
6652
6990
|
messageSign,
|
|
6653
6991
|
bitcoinBalanceRetrieve,
|
|
@@ -6656,4 +6994,4 @@ export {
|
|
|
6656
6994
|
x402Request,
|
|
6657
6995
|
virtualAccountWalletRegister
|
|
6658
6996
|
};
|
|
6659
|
-
//# sourceMappingURL=chunk-
|
|
6997
|
+
//# sourceMappingURL=chunk-JQEHP3SV.js.map
|