@moonpay/cli 0.5.0 → 0.5.1
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-AH5VMN63.js → chunk-PBRXVTTG.js} +299 -253
- package/dist/{chunk-AH5VMN63.js.map → chunk-PBRXVTTG.js.map} +1 -1
- package/dist/index.js +68 -3
- package/dist/index.js.map +1 -1
- package/dist/{mcp-VOEHXIOY.js → mcp-TDQN25MO.js} +5 -119
- package/dist/mcp-TDQN25MO.js.map +1 -0
- package/package.json +1 -1
- package/skills/moonpay-mcp/SKILL.md +4 -6
- package/skills/moonpay-missions/SKILL.md +7 -2
- package/skills/moonpay-swap-tokens/SKILL.md +33 -10
- package/dist/mcp-VOEHXIOY.js.map +0 -1
|
@@ -430,226 +430,6 @@ var schemas_default = [
|
|
|
430
430
|
$schema: "http://json-schema.org/draft-07/schema#"
|
|
431
431
|
}
|
|
432
432
|
},
|
|
433
|
-
{
|
|
434
|
-
name: "solana_balance_check",
|
|
435
|
-
description: "Check if a wallet has enough SOL. Returns success: true if the wallet has sufficient SOL balance, false otherwise.",
|
|
436
|
-
inputSchema: {
|
|
437
|
-
$ref: "#/definitions/solana_balance_check_input",
|
|
438
|
-
definitions: {
|
|
439
|
-
solana_balance_check_input: {
|
|
440
|
-
type: "object",
|
|
441
|
-
properties: {
|
|
442
|
-
wallet: {
|
|
443
|
-
type: "string",
|
|
444
|
-
description: "Wallet address to check the SOL balance for"
|
|
445
|
-
},
|
|
446
|
-
amount: {
|
|
447
|
-
type: "number",
|
|
448
|
-
description: "Required amount of SOL to check against"
|
|
449
|
-
}
|
|
450
|
-
},
|
|
451
|
-
required: [
|
|
452
|
-
"wallet",
|
|
453
|
-
"amount"
|
|
454
|
-
],
|
|
455
|
-
additionalProperties: false
|
|
456
|
-
}
|
|
457
|
-
},
|
|
458
|
-
$schema: "http://json-schema.org/draft-07/schema#"
|
|
459
|
-
},
|
|
460
|
-
outputSchema: {
|
|
461
|
-
$ref: "#/definitions/solana_balance_check_output",
|
|
462
|
-
definitions: {
|
|
463
|
-
solana_balance_check_output: {
|
|
464
|
-
type: "object",
|
|
465
|
-
properties: {
|
|
466
|
-
success: {
|
|
467
|
-
type: "boolean",
|
|
468
|
-
description: "Whether the check passed"
|
|
469
|
-
},
|
|
470
|
-
message: {
|
|
471
|
-
type: "string",
|
|
472
|
-
description: "A message describing the result"
|
|
473
|
-
}
|
|
474
|
-
},
|
|
475
|
-
required: [
|
|
476
|
-
"success",
|
|
477
|
-
"message"
|
|
478
|
-
],
|
|
479
|
-
additionalProperties: false
|
|
480
|
-
}
|
|
481
|
-
},
|
|
482
|
-
$schema: "http://json-schema.org/draft-07/schema#"
|
|
483
|
-
}
|
|
484
|
-
},
|
|
485
|
-
{
|
|
486
|
-
name: "solana_balance_retrieve",
|
|
487
|
-
description: "Get the balance of SOL in a wallet",
|
|
488
|
-
inputSchema: {
|
|
489
|
-
$ref: "#/definitions/solana_balance_retrieve_input",
|
|
490
|
-
definitions: {
|
|
491
|
-
solana_balance_retrieve_input: {
|
|
492
|
-
type: "object",
|
|
493
|
-
properties: {
|
|
494
|
-
wallet: {
|
|
495
|
-
type: "string",
|
|
496
|
-
description: "Wallet address to get the SOL balance of"
|
|
497
|
-
}
|
|
498
|
-
},
|
|
499
|
-
required: [
|
|
500
|
-
"wallet"
|
|
501
|
-
],
|
|
502
|
-
additionalProperties: false
|
|
503
|
-
}
|
|
504
|
-
},
|
|
505
|
-
$schema: "http://json-schema.org/draft-07/schema#"
|
|
506
|
-
},
|
|
507
|
-
outputSchema: {
|
|
508
|
-
$ref: "#/definitions/solana_balance_retrieve_output",
|
|
509
|
-
definitions: {
|
|
510
|
-
solana_balance_retrieve_output: {
|
|
511
|
-
type: "object",
|
|
512
|
-
properties: {
|
|
513
|
-
address: {
|
|
514
|
-
type: "string",
|
|
515
|
-
description: "Address of the token"
|
|
516
|
-
},
|
|
517
|
-
name: {
|
|
518
|
-
type: "string",
|
|
519
|
-
description: "Name of the token"
|
|
520
|
-
},
|
|
521
|
-
symbol: {
|
|
522
|
-
type: "string",
|
|
523
|
-
description: "Symbol of the token"
|
|
524
|
-
},
|
|
525
|
-
image: {
|
|
526
|
-
type: [
|
|
527
|
-
"string",
|
|
528
|
-
"null"
|
|
529
|
-
],
|
|
530
|
-
description: "Image of the token"
|
|
531
|
-
},
|
|
532
|
-
description: {
|
|
533
|
-
type: [
|
|
534
|
-
"string",
|
|
535
|
-
"null"
|
|
536
|
-
],
|
|
537
|
-
description: "Description of the token"
|
|
538
|
-
},
|
|
539
|
-
chain: {
|
|
540
|
-
type: "string",
|
|
541
|
-
enum: [
|
|
542
|
-
"solana",
|
|
543
|
-
"ethereum",
|
|
544
|
-
"base",
|
|
545
|
-
"polygon",
|
|
546
|
-
"arbitrum",
|
|
547
|
-
"optimism",
|
|
548
|
-
"bnb",
|
|
549
|
-
"avalanche",
|
|
550
|
-
"tron",
|
|
551
|
-
"bitcoin"
|
|
552
|
-
],
|
|
553
|
-
description: "Chain of the token"
|
|
554
|
-
},
|
|
555
|
-
decimals: {
|
|
556
|
-
type: "number",
|
|
557
|
-
description: "Number of decimals of the token"
|
|
558
|
-
},
|
|
559
|
-
externalLinks: {
|
|
560
|
-
anyOf: [
|
|
561
|
-
{
|
|
562
|
-
type: "object",
|
|
563
|
-
properties: {
|
|
564
|
-
website: {
|
|
565
|
-
type: [
|
|
566
|
-
"string",
|
|
567
|
-
"null"
|
|
568
|
-
],
|
|
569
|
-
description: "Official website URL"
|
|
570
|
-
},
|
|
571
|
-
twitter: {
|
|
572
|
-
type: [
|
|
573
|
-
"string",
|
|
574
|
-
"null"
|
|
575
|
-
],
|
|
576
|
-
description: "Twitter/X profile URL"
|
|
577
|
-
},
|
|
578
|
-
telegram: {
|
|
579
|
-
type: [
|
|
580
|
-
"string",
|
|
581
|
-
"null"
|
|
582
|
-
],
|
|
583
|
-
description: "Telegram group URL"
|
|
584
|
-
},
|
|
585
|
-
discord: {
|
|
586
|
-
type: [
|
|
587
|
-
"string",
|
|
588
|
-
"null"
|
|
589
|
-
],
|
|
590
|
-
description: "Discord server URL"
|
|
591
|
-
},
|
|
592
|
-
github: {
|
|
593
|
-
type: [
|
|
594
|
-
"string",
|
|
595
|
-
"null"
|
|
596
|
-
],
|
|
597
|
-
description: "GitHub repository URL"
|
|
598
|
-
},
|
|
599
|
-
coingeckoId: {
|
|
600
|
-
type: [
|
|
601
|
-
"string",
|
|
602
|
-
"null"
|
|
603
|
-
],
|
|
604
|
-
description: "CoinGecko token ID"
|
|
605
|
-
}
|
|
606
|
-
},
|
|
607
|
-
additionalProperties: false
|
|
608
|
-
},
|
|
609
|
-
{
|
|
610
|
-
type: "null"
|
|
611
|
-
}
|
|
612
|
-
],
|
|
613
|
-
description: "External links and social media"
|
|
614
|
-
},
|
|
615
|
-
balance: {
|
|
616
|
-
type: "object",
|
|
617
|
-
properties: {
|
|
618
|
-
amount: {
|
|
619
|
-
type: "number",
|
|
620
|
-
description: "Number of tokens owned"
|
|
621
|
-
},
|
|
622
|
-
value: {
|
|
623
|
-
type: "number",
|
|
624
|
-
description: "Total value of the token in USD"
|
|
625
|
-
},
|
|
626
|
-
price: {
|
|
627
|
-
type: "number",
|
|
628
|
-
description: "Current price of the token"
|
|
629
|
-
}
|
|
630
|
-
},
|
|
631
|
-
required: [
|
|
632
|
-
"amount",
|
|
633
|
-
"value",
|
|
634
|
-
"price"
|
|
635
|
-
],
|
|
636
|
-
additionalProperties: false
|
|
637
|
-
}
|
|
638
|
-
},
|
|
639
|
-
required: [
|
|
640
|
-
"address",
|
|
641
|
-
"name",
|
|
642
|
-
"symbol",
|
|
643
|
-
"chain",
|
|
644
|
-
"decimals",
|
|
645
|
-
"balance"
|
|
646
|
-
],
|
|
647
|
-
additionalProperties: false
|
|
648
|
-
}
|
|
649
|
-
},
|
|
650
|
-
$schema: "http://json-schema.org/draft-07/schema#"
|
|
651
|
-
}
|
|
652
|
-
},
|
|
653
433
|
{
|
|
654
434
|
name: "swaps_transaction_build",
|
|
655
435
|
description: "Build a swap or bridge transaction. Returns an unsigned transaction with a human-readable message, amounts, exchange rate, and estimated time. Supports same-chain swaps and cross-chain bridges. Accepts UI amounts (e.g. 0.1 SOL) \u2014 decimal conversion is handled automatically.",
|
|
@@ -3267,6 +3047,135 @@ var schemas_default = [
|
|
|
3267
3047
|
$schema: "http://json-schema.org/draft-07/schema#"
|
|
3268
3048
|
}
|
|
3269
3049
|
},
|
|
3050
|
+
{
|
|
3051
|
+
name: "token_transfer",
|
|
3052
|
+
description: "Build an unsigned transfer transaction. Returns a transaction ready for signing. Handles both native and token transfers.",
|
|
3053
|
+
inputSchema: {
|
|
3054
|
+
$ref: "#/definitions/token_transfer_input",
|
|
3055
|
+
definitions: {
|
|
3056
|
+
token_transfer_input: {
|
|
3057
|
+
type: "object",
|
|
3058
|
+
properties: {
|
|
3059
|
+
wallet: {
|
|
3060
|
+
type: "string",
|
|
3061
|
+
description: "Wallet address to transfer from"
|
|
3062
|
+
},
|
|
3063
|
+
token: {
|
|
3064
|
+
type: "string",
|
|
3065
|
+
description: "Mint address of the token to transfer"
|
|
3066
|
+
},
|
|
3067
|
+
to: {
|
|
3068
|
+
type: "string",
|
|
3069
|
+
description: "Recipient wallet address"
|
|
3070
|
+
},
|
|
3071
|
+
amount: {
|
|
3072
|
+
type: "number",
|
|
3073
|
+
description: "Amount to transfer in human-readable units (e.g. 1.5)"
|
|
3074
|
+
},
|
|
3075
|
+
chain: {
|
|
3076
|
+
type: "string",
|
|
3077
|
+
enum: [
|
|
3078
|
+
"solana",
|
|
3079
|
+
"ethereum",
|
|
3080
|
+
"base",
|
|
3081
|
+
"polygon",
|
|
3082
|
+
"arbitrum",
|
|
3083
|
+
"optimism",
|
|
3084
|
+
"bnb",
|
|
3085
|
+
"avalanche",
|
|
3086
|
+
"tron",
|
|
3087
|
+
"bitcoin"
|
|
3088
|
+
],
|
|
3089
|
+
description: "Blockchain to execute the transfer on"
|
|
3090
|
+
}
|
|
3091
|
+
},
|
|
3092
|
+
required: [
|
|
3093
|
+
"wallet",
|
|
3094
|
+
"token",
|
|
3095
|
+
"to",
|
|
3096
|
+
"amount",
|
|
3097
|
+
"chain"
|
|
3098
|
+
],
|
|
3099
|
+
additionalProperties: false
|
|
3100
|
+
}
|
|
3101
|
+
},
|
|
3102
|
+
$schema: "http://json-schema.org/draft-07/schema#"
|
|
3103
|
+
},
|
|
3104
|
+
outputSchema: {
|
|
3105
|
+
$ref: "#/definitions/token_transfer_output",
|
|
3106
|
+
definitions: {
|
|
3107
|
+
token_transfer_output: {
|
|
3108
|
+
type: "object",
|
|
3109
|
+
properties: {
|
|
3110
|
+
transaction: {
|
|
3111
|
+
anyOf: [
|
|
3112
|
+
{
|
|
3113
|
+
type: "object",
|
|
3114
|
+
properties: {
|
|
3115
|
+
type: {
|
|
3116
|
+
type: "string",
|
|
3117
|
+
const: "solana"
|
|
3118
|
+
},
|
|
3119
|
+
base64: {
|
|
3120
|
+
type: "string",
|
|
3121
|
+
description: "Base64-encoded transaction"
|
|
3122
|
+
}
|
|
3123
|
+
},
|
|
3124
|
+
required: [
|
|
3125
|
+
"type",
|
|
3126
|
+
"base64"
|
|
3127
|
+
],
|
|
3128
|
+
additionalProperties: false
|
|
3129
|
+
},
|
|
3130
|
+
{
|
|
3131
|
+
type: "object",
|
|
3132
|
+
properties: {
|
|
3133
|
+
type: {
|
|
3134
|
+
type: "string",
|
|
3135
|
+
const: "evm"
|
|
3136
|
+
},
|
|
3137
|
+
to: {
|
|
3138
|
+
type: "string",
|
|
3139
|
+
description: "Recipient or contract address"
|
|
3140
|
+
},
|
|
3141
|
+
data: {
|
|
3142
|
+
type: "string",
|
|
3143
|
+
description: "Calldata (0x for native transfers)"
|
|
3144
|
+
},
|
|
3145
|
+
value: {
|
|
3146
|
+
type: "string",
|
|
3147
|
+
description: "Native token value in wei"
|
|
3148
|
+
},
|
|
3149
|
+
chainId: {
|
|
3150
|
+
type: "number",
|
|
3151
|
+
description: "EVM chain ID"
|
|
3152
|
+
}
|
|
3153
|
+
},
|
|
3154
|
+
required: [
|
|
3155
|
+
"type",
|
|
3156
|
+
"to",
|
|
3157
|
+
"data",
|
|
3158
|
+
"value",
|
|
3159
|
+
"chainId"
|
|
3160
|
+
],
|
|
3161
|
+
additionalProperties: false
|
|
3162
|
+
}
|
|
3163
|
+
]
|
|
3164
|
+
},
|
|
3165
|
+
message: {
|
|
3166
|
+
type: "string"
|
|
3167
|
+
}
|
|
3168
|
+
},
|
|
3169
|
+
required: [
|
|
3170
|
+
"transaction",
|
|
3171
|
+
"message"
|
|
3172
|
+
],
|
|
3173
|
+
additionalProperties: false
|
|
3174
|
+
}
|
|
3175
|
+
},
|
|
3176
|
+
$schema: "http://json-schema.org/draft-07/schema#"
|
|
3177
|
+
}
|
|
3178
|
+
},
|
|
3270
3179
|
{
|
|
3271
3180
|
name: "token_trending_list",
|
|
3272
3181
|
description: "Get currently trending tokens on a blockchain. Perfect for discovering what's hot right now.",
|
|
@@ -6423,26 +6332,45 @@ import { encodeFunctionData, maxUint256 } from "viem";
|
|
|
6423
6332
|
|
|
6424
6333
|
// src/tools/token/swap/schema.ts
|
|
6425
6334
|
import { z as z9 } from "zod";
|
|
6335
|
+
var swapOutputSchema = z9.object({
|
|
6336
|
+
signature: z9.string().describe("Transaction hash/signature"),
|
|
6337
|
+
message: z9.string().describe("Human-readable swap description")
|
|
6338
|
+
});
|
|
6426
6339
|
var tokenSwapSchema = defineToolSchema({
|
|
6427
6340
|
name: "token_swap",
|
|
6428
|
-
description: "Swap
|
|
6341
|
+
description: "Swap tokens on the same chain. Builds, signs locally, broadcasts, and registers.",
|
|
6342
|
+
input: z9.object({
|
|
6343
|
+
wallet: z9.string().describe("Local wallet name to sign with"),
|
|
6344
|
+
chain: chainSchema.describe("Chain to swap on"),
|
|
6345
|
+
from: z9.object({
|
|
6346
|
+
token: z9.string().describe("Input token address (selling)"),
|
|
6347
|
+
amount: z9.coerce.number().nullable().describe("Amount to sell (exact-in). Null for exact-out.")
|
|
6348
|
+
}),
|
|
6349
|
+
to: z9.object({
|
|
6350
|
+
token: z9.string().describe("Output token address (buying)"),
|
|
6351
|
+
amount: z9.coerce.number().nullable().describe("Amount to receive (exact-out). Null for exact-in.")
|
|
6352
|
+
})
|
|
6353
|
+
}),
|
|
6354
|
+
output: swapOutputSchema
|
|
6355
|
+
});
|
|
6356
|
+
var tokenBridgeSchema = defineToolSchema({
|
|
6357
|
+
name: "token_bridge",
|
|
6358
|
+
description: "Bridge tokens across chains. Builds, signs locally, broadcasts, and registers.",
|
|
6429
6359
|
input: z9.object({
|
|
6430
6360
|
from: z9.object({
|
|
6431
6361
|
wallet: z9.string().describe("Local wallet name to sign with"),
|
|
6432
6362
|
chain: chainSchema.describe("Source chain"),
|
|
6433
|
-
token: z9.string().describe("
|
|
6434
|
-
amount: z9.number().describe("Amount
|
|
6363
|
+
token: z9.string().describe("Source token address"),
|
|
6364
|
+
amount: z9.coerce.number().nullable().describe("Amount to send (exact-in). Null for exact-out.")
|
|
6435
6365
|
}),
|
|
6436
6366
|
to: z9.object({
|
|
6437
|
-
wallet: z9.string().nullable().describe("Destination wallet (defaults to from wallet)"),
|
|
6438
|
-
chain: chainSchema.
|
|
6439
|
-
token: z9.string().describe("
|
|
6367
|
+
wallet: z9.string().nullable().describe("Destination wallet name or address (defaults to from wallet)"),
|
|
6368
|
+
chain: chainSchema.describe("Destination chain"),
|
|
6369
|
+
token: z9.string().describe("Destination token address"),
|
|
6370
|
+
amount: z9.coerce.number().nullable().describe("Amount to receive (exact-out). Null for exact-in.")
|
|
6440
6371
|
})
|
|
6441
6372
|
}),
|
|
6442
|
-
output:
|
|
6443
|
-
signature: z9.string().describe("Transaction hash/signature"),
|
|
6444
|
-
message: z9.string().describe("Human-readable swap description")
|
|
6445
|
-
})
|
|
6373
|
+
output: swapOutputSchema
|
|
6446
6374
|
});
|
|
6447
6375
|
|
|
6448
6376
|
// src/tools/token/swap/tool.ts
|
|
@@ -6457,29 +6385,30 @@ var ERC20_APPROVE_ABI = [
|
|
|
6457
6385
|
outputs: [{ name: "", type: "bool" }]
|
|
6458
6386
|
}
|
|
6459
6387
|
];
|
|
6460
|
-
var
|
|
6388
|
+
var tokenBridge = createTool(tokenBridgeSchema, async (params) => {
|
|
6389
|
+
if (!params.from.amount && !params.to.amount) {
|
|
6390
|
+
throw new Error("Provide either from.amount or to.amount.");
|
|
6391
|
+
}
|
|
6461
6392
|
const baseUrl = resolveBaseUrl();
|
|
6462
|
-
const fromChain = params.from.chain;
|
|
6463
|
-
const toChain = params.to.chain ?? fromChain;
|
|
6464
6393
|
const wallet = await walletRetrieve.handler({ wallet: params.from.wallet });
|
|
6465
|
-
const fromAddress = wallet.addresses[KEY_CHAIN_MAP[
|
|
6394
|
+
const fromAddress = wallet.addresses[KEY_CHAIN_MAP[params.from.chain]];
|
|
6466
6395
|
if (!fromAddress) {
|
|
6467
|
-
throw new Error(`Wallet "${wallet.name}" has no address on ${
|
|
6396
|
+
throw new Error(`Wallet "${wallet.name}" has no address on ${params.from.chain}.`);
|
|
6468
6397
|
}
|
|
6469
6398
|
let toAddress = fromAddress;
|
|
6470
6399
|
if (params.to.wallet) {
|
|
6471
6400
|
try {
|
|
6472
6401
|
const toWallet = await walletRetrieve.handler({ wallet: params.to.wallet });
|
|
6473
|
-
toAddress = toWallet.addresses[KEY_CHAIN_MAP[
|
|
6402
|
+
toAddress = toWallet.addresses[KEY_CHAIN_MAP[params.to.chain]] ?? params.to.wallet;
|
|
6474
6403
|
} catch {
|
|
6475
6404
|
toAddress = params.to.wallet;
|
|
6476
6405
|
}
|
|
6477
|
-
} else if (
|
|
6478
|
-
toAddress = wallet.addresses[KEY_CHAIN_MAP[
|
|
6406
|
+
} else if (params.from.chain !== params.to.chain) {
|
|
6407
|
+
toAddress = wallet.addresses[KEY_CHAIN_MAP[params.to.chain]] ?? fromAddress;
|
|
6479
6408
|
}
|
|
6480
6409
|
const buildParams = {
|
|
6481
|
-
from: { wallet: fromAddress, chain:
|
|
6482
|
-
to: { wallet: toAddress, chain:
|
|
6410
|
+
from: { wallet: fromAddress, chain: params.from.chain, token: params.from.token, amount: params.from.amount },
|
|
6411
|
+
to: { wallet: toAddress, chain: params.to.chain, token: params.to.token, amount: params.to.amount }
|
|
6483
6412
|
};
|
|
6484
6413
|
let buildResult = await callRemoteTool(baseUrl, "swaps_transaction_build", buildParams);
|
|
6485
6414
|
const tx = buildResult.transaction;
|
|
@@ -6498,13 +6427,13 @@ var tokenSwap = createTool(tokenSwapSchema, async (params) => {
|
|
|
6498
6427
|
};
|
|
6499
6428
|
const { transaction: signedApproval } = await transactionSign.handler({
|
|
6500
6429
|
wallet: wallet.name,
|
|
6501
|
-
chain:
|
|
6430
|
+
chain: params.from.chain,
|
|
6502
6431
|
transaction: JSON.stringify(approveTx)
|
|
6503
6432
|
});
|
|
6504
6433
|
const approvalResult = await callRemoteTool(baseUrl, "transaction_send", {
|
|
6505
6434
|
transaction: signedApproval,
|
|
6506
6435
|
message: `Approve ${buildResult.amountIn.symbol}`,
|
|
6507
|
-
chain:
|
|
6436
|
+
chain: params.from.chain
|
|
6508
6437
|
});
|
|
6509
6438
|
if (!approvalResult.signature) {
|
|
6510
6439
|
throw new Error(`Approval failed: ${approvalResult.message}`);
|
|
@@ -6514,13 +6443,13 @@ var tokenSwap = createTool(tokenSwapSchema, async (params) => {
|
|
|
6514
6443
|
const txPayload = "base64" in buildResult.transaction ? buildResult.transaction.base64 : JSON.stringify(buildResult.transaction);
|
|
6515
6444
|
const { transaction: signedTransaction } = await transactionSign.handler({
|
|
6516
6445
|
wallet: wallet.name,
|
|
6517
|
-
chain:
|
|
6446
|
+
chain: params.from.chain,
|
|
6518
6447
|
transaction: txPayload
|
|
6519
6448
|
});
|
|
6520
6449
|
const sendResult = await callRemoteTool(baseUrl, "transaction_send", {
|
|
6521
6450
|
transaction: signedTransaction,
|
|
6522
6451
|
message: buildResult.message,
|
|
6523
|
-
chain:
|
|
6452
|
+
chain: params.from.chain
|
|
6524
6453
|
});
|
|
6525
6454
|
if (!sendResult.signature) {
|
|
6526
6455
|
throw new Error(`Transaction send failed: ${sendResult.message}`);
|
|
@@ -6530,26 +6459,140 @@ var tokenSwap = createTool(tokenSwapSchema, async (params) => {
|
|
|
6530
6459
|
await callRemoteTool(baseUrl, "transaction_register", {
|
|
6531
6460
|
transactionId: buildResult.transactionId,
|
|
6532
6461
|
transactionHash: signature,
|
|
6533
|
-
chain:
|
|
6462
|
+
chain: params.from.chain
|
|
6534
6463
|
});
|
|
6535
6464
|
} catch {
|
|
6536
6465
|
}
|
|
6537
6466
|
return { signature, message: buildResult.message };
|
|
6538
6467
|
});
|
|
6468
|
+
var tokenSwap = createTool(tokenSwapSchema, async (params) => {
|
|
6469
|
+
return tokenBridge.handler({
|
|
6470
|
+
from: { wallet: params.wallet, chain: params.chain, token: params.from.token, amount: params.from.amount },
|
|
6471
|
+
to: { wallet: null, chain: params.chain, token: params.to.token, amount: params.to.amount }
|
|
6472
|
+
});
|
|
6473
|
+
});
|
|
6539
6474
|
|
|
6540
|
-
// src/tools/
|
|
6475
|
+
// src/tools/x402/request/tool.ts
|
|
6476
|
+
import { Keypair as Keypair4, VersionedTransaction as VersionedTransaction2, VersionedMessage } from "@solana/web3.js";
|
|
6477
|
+
import axios from "axios";
|
|
6478
|
+
import { wrapAxiosWithPayment } from "@x402/axios";
|
|
6479
|
+
import { x402Client } from "@x402/core/client";
|
|
6480
|
+
import { ExactSvmScheme } from "@x402/svm";
|
|
6481
|
+
|
|
6482
|
+
// src/tools/x402/request/schema.ts
|
|
6541
6483
|
import { z as z10 } from "zod";
|
|
6484
|
+
var x402RequestSchema = defineToolSchema({
|
|
6485
|
+
name: "x402_request",
|
|
6486
|
+
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.",
|
|
6487
|
+
input: z10.object({
|
|
6488
|
+
method: z10.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]).describe("HTTP method"),
|
|
6489
|
+
url: z10.string().url().refine((u) => u.startsWith("https://"), { message: "URL must use HTTPS" }).refine(
|
|
6490
|
+
(u) => {
|
|
6491
|
+
try {
|
|
6492
|
+
const host = new URL(u).hostname;
|
|
6493
|
+
return !host.match(/^(localhost|127\.|10\.|172\.(1[6-9]|2\d|3[01])\.|192\.168\.|169\.254\.|0\.0\.0\.0|\[::1\])/);
|
|
6494
|
+
} catch {
|
|
6495
|
+
return false;
|
|
6496
|
+
}
|
|
6497
|
+
},
|
|
6498
|
+
{ message: "URL must not target private/internal addresses" }
|
|
6499
|
+
).describe(
|
|
6500
|
+
"Full HTTPS URL of the x402-protected endpoint (e.g., 'https://agents.moonpay.com/api/x402/tools/market_digest_retrieve')"
|
|
6501
|
+
),
|
|
6502
|
+
body: z10.record(z10.any()).nullable().describe("Request body (for POST, PUT, PATCH)"),
|
|
6503
|
+
params: z10.record(z10.any()).nullable().describe("Query parameters"),
|
|
6504
|
+
wallet: z10.string().describe("Wallet name or address to pay with")
|
|
6505
|
+
}),
|
|
6506
|
+
output: z10.object({
|
|
6507
|
+
status: z10.number().describe("HTTP status code"),
|
|
6508
|
+
data: z10.any().describe("Response data"),
|
|
6509
|
+
headers: z10.record(z10.string()).describe("Response headers")
|
|
6510
|
+
})
|
|
6511
|
+
});
|
|
6512
|
+
|
|
6513
|
+
// src/tools/x402/request/tool.ts
|
|
6514
|
+
var SOLANA_NETWORK = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
|
|
6515
|
+
function createLocalX402Client(walletAddress, secretKey) {
|
|
6516
|
+
const keypair = Keypair4.fromSecretKey(secretKey);
|
|
6517
|
+
const signer = {
|
|
6518
|
+
address: walletAddress,
|
|
6519
|
+
signTransactions: async (transactions) => {
|
|
6520
|
+
return transactions.map((transaction) => {
|
|
6521
|
+
const messageBytes = new Uint8Array(transaction.messageBytes);
|
|
6522
|
+
const message = VersionedMessage.deserialize(messageBytes);
|
|
6523
|
+
const numSigs = Object.keys(transaction.signatures).length;
|
|
6524
|
+
const tx = new VersionedTransaction2(
|
|
6525
|
+
message,
|
|
6526
|
+
new Array(numSigs).fill(new Uint8Array(64))
|
|
6527
|
+
);
|
|
6528
|
+
tx.sign([keypair]);
|
|
6529
|
+
const signerIndex = message.staticAccountKeys.findIndex(
|
|
6530
|
+
(key) => key.toBase58() === walletAddress
|
|
6531
|
+
);
|
|
6532
|
+
if (signerIndex === -1) {
|
|
6533
|
+
throw new Error(
|
|
6534
|
+
`Wallet ${walletAddress} is not a signer for this transaction`
|
|
6535
|
+
);
|
|
6536
|
+
}
|
|
6537
|
+
return {
|
|
6538
|
+
[walletAddress]: tx.signatures[signerIndex]
|
|
6539
|
+
};
|
|
6540
|
+
});
|
|
6541
|
+
}
|
|
6542
|
+
};
|
|
6543
|
+
const client = new x402Client();
|
|
6544
|
+
const svmScheme = new ExactSvmScheme(signer);
|
|
6545
|
+
client.register(SOLANA_NETWORK, svmScheme);
|
|
6546
|
+
client.registerV1("solana", svmScheme);
|
|
6547
|
+
return wrapAxiosWithPayment(axios.create(), client);
|
|
6548
|
+
}
|
|
6549
|
+
var x402Request = createTool(
|
|
6550
|
+
x402RequestSchema,
|
|
6551
|
+
async ({ method, url, body, params, wallet: walletNameOrAddress }) => {
|
|
6552
|
+
const walletMetadata = findWalletOrThrow(walletNameOrAddress);
|
|
6553
|
+
const { privateKey, address } = resolveSigningKey(walletMetadata, "solana");
|
|
6554
|
+
const client = createLocalX402Client(address, privateKey);
|
|
6555
|
+
let response;
|
|
6556
|
+
switch (method) {
|
|
6557
|
+
case "GET":
|
|
6558
|
+
response = await client.get(url, { params });
|
|
6559
|
+
break;
|
|
6560
|
+
case "POST":
|
|
6561
|
+
response = await client.post(url, body || {}, { params });
|
|
6562
|
+
break;
|
|
6563
|
+
case "PUT":
|
|
6564
|
+
response = await client.put(url, body || {}, { params });
|
|
6565
|
+
break;
|
|
6566
|
+
case "PATCH":
|
|
6567
|
+
response = await client.patch(url, body || {}, { params });
|
|
6568
|
+
break;
|
|
6569
|
+
case "DELETE":
|
|
6570
|
+
response = await client.delete(url, { params });
|
|
6571
|
+
break;
|
|
6572
|
+
default:
|
|
6573
|
+
throw new Error(`Unsupported HTTP method: ${method}`);
|
|
6574
|
+
}
|
|
6575
|
+
return {
|
|
6576
|
+
status: response.status,
|
|
6577
|
+
data: response.data,
|
|
6578
|
+
headers: response.headers
|
|
6579
|
+
};
|
|
6580
|
+
}
|
|
6581
|
+
);
|
|
6582
|
+
|
|
6583
|
+
// src/tools/virtual-account/wallet/register/schema.ts
|
|
6584
|
+
import { z as z11 } from "zod";
|
|
6542
6585
|
var virtualAccountWalletRegisterSchema = defineToolSchema({
|
|
6543
6586
|
name: "virtual-account_wallet_register",
|
|
6544
6587
|
description: "Register a local wallet with your virtual account. Creates the verification message, signs it locally, and registers in one step.",
|
|
6545
|
-
input:
|
|
6546
|
-
wallet:
|
|
6588
|
+
input: z11.object({
|
|
6589
|
+
wallet: z11.string().describe("Local wallet name"),
|
|
6547
6590
|
chain: chainSchema.describe("Chain to register (solana, ethereum, etc.)")
|
|
6548
6591
|
}),
|
|
6549
|
-
output:
|
|
6550
|
-
success:
|
|
6551
|
-
address:
|
|
6552
|
-
chain:
|
|
6592
|
+
output: z11.object({
|
|
6593
|
+
success: z11.literal(true),
|
|
6594
|
+
address: z11.string().describe("Registered wallet address"),
|
|
6595
|
+
chain: z11.string().describe("Chain registered on")
|
|
6553
6596
|
})
|
|
6554
6597
|
});
|
|
6555
6598
|
|
|
@@ -6591,6 +6634,7 @@ export {
|
|
|
6591
6634
|
resolveBaseUrl,
|
|
6592
6635
|
login,
|
|
6593
6636
|
callTool,
|
|
6637
|
+
callRemoteTool,
|
|
6594
6638
|
schemas_default,
|
|
6595
6639
|
defineToolSchema,
|
|
6596
6640
|
createTool,
|
|
@@ -6602,7 +6646,9 @@ export {
|
|
|
6602
6646
|
transactionSign,
|
|
6603
6647
|
messageSign,
|
|
6604
6648
|
bitcoinBalanceRetrieve,
|
|
6649
|
+
tokenBridge,
|
|
6605
6650
|
tokenSwap,
|
|
6651
|
+
x402Request,
|
|
6606
6652
|
virtualAccountWalletRegister
|
|
6607
6653
|
};
|
|
6608
|
-
//# sourceMappingURL=chunk-
|
|
6654
|
+
//# sourceMappingURL=chunk-PBRXVTTG.js.map
|