x402-proxy 0.4.0 → 0.4.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/bin/cli.js +9 -9
- package/dist/{status-0rAVbrke.js → status-DrC0uxCS.js} +1 -1
- package/dist/{status-B7iFmj8f.js → status-DxW72Hx6.js} +1 -1
- package/dist/{wallet-Vp9zRQzC.js → wallet-BHywTzdN.js} +19 -17
- package/dist/wallet-DFhJWn3o.js +4 -0
- package/package.json +1 -1
- package/dist/wallet-BX5vQtUz.js +0 -4
package/dist/bin/cli.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as buildX402Client, c as error, d as warn, f as appendHistory, g as readHistory, h as formatTxLine, i as walletInfoCommand, l as info, m as displayNetwork, o as resolveWallet, p as calcSpend, s as dim, u as isTTY } from "../wallet-
|
|
2
|
+
import { a as buildX402Client, c as error, d as warn, f as appendHistory, g as readHistory, h as formatTxLine, i as walletInfoCommand, l as info, m as displayNetwork, o as resolveWallet, p as calcSpend, s as dim, u as isTTY } from "../wallet-BHywTzdN.js";
|
|
3
3
|
import { c as isConfigured, i as ensureConfigDir, l as loadConfig, o as getHistoryPath, u as loadWalletFile } from "../derive-CISr_ond.js";
|
|
4
4
|
import { n as setupCommand } from "../setup-gla-Qyqi.js";
|
|
5
|
-
import { n as statusCommand } from "../status-
|
|
5
|
+
import { n as statusCommand } from "../status-DxW72Hx6.js";
|
|
6
6
|
import { buildApplication, buildCommand, buildRouteMap, run } from "@stricli/core";
|
|
7
7
|
import pc from "picocolors";
|
|
8
8
|
import { decodePaymentResponseHeader, wrapFetchWithPayment } from "@x402/fetch";
|
|
@@ -118,7 +118,7 @@ Examples:
|
|
|
118
118
|
async func(flags, url) {
|
|
119
119
|
if (!url) {
|
|
120
120
|
if (isConfigured()) {
|
|
121
|
-
const { displayStatus } = await import("../status-
|
|
121
|
+
const { displayStatus } = await import("../status-DrC0uxCS.js");
|
|
122
122
|
await displayStatus();
|
|
123
123
|
console.log();
|
|
124
124
|
console.log(pc.dim(" Commands:"));
|
|
@@ -179,7 +179,7 @@ Examples:
|
|
|
179
179
|
const config = loadConfig();
|
|
180
180
|
let preferredNetwork = config?.defaultNetwork;
|
|
181
181
|
if (!preferredNetwork && wallet.evmAddress && wallet.solanaAddress) {
|
|
182
|
-
const { fetchEvmBalances, fetchSolanaBalances } = await import("../wallet-
|
|
182
|
+
const { fetchEvmBalances, fetchSolanaBalances } = await import("../wallet-DFhJWn3o.js");
|
|
183
183
|
const [evmBal, solBal] = await Promise.allSettled([fetchEvmBalances(wallet.evmAddress), fetchSolanaBalances(wallet.solanaAddress)]);
|
|
184
184
|
const evmUsdc = evmBal.status === "fulfilled" ? Number(evmBal.value?.usdc ?? 0) : 0;
|
|
185
185
|
const solUsdc = solBal.status === "fulfilled" ? Number(solBal.value?.usdc ?? 0) : 0;
|
|
@@ -231,7 +231,7 @@ Examples:
|
|
|
231
231
|
const hasEvm = accepts.some((a) => a.network.startsWith("eip155:"));
|
|
232
232
|
const hasSolana = accepts.some((a) => a.network.startsWith("solana:"));
|
|
233
233
|
const hasOther = accepts.some((a) => !a.network.startsWith("eip155:") && !a.network.startsWith("solana:"));
|
|
234
|
-
const { fetchEvmBalances, fetchSolanaBalances } = await import("../wallet-
|
|
234
|
+
const { fetchEvmBalances, fetchSolanaBalances } = await import("../wallet-DFhJWn3o.js");
|
|
235
235
|
let evmUsdc = 0;
|
|
236
236
|
let solUsdc = 0;
|
|
237
237
|
if (hasEvm && wallet.evmAddress) try {
|
|
@@ -383,7 +383,7 @@ Add to your MCP client config (Claude, Cursor, etc.):
|
|
|
383
383
|
const config = loadConfig();
|
|
384
384
|
let preferredNetwork = config?.defaultNetwork;
|
|
385
385
|
if (!preferredNetwork && wallet.evmAddress && wallet.solanaAddress) {
|
|
386
|
-
const { fetchEvmBalances, fetchSolanaBalances } = await import("../wallet-
|
|
386
|
+
const { fetchEvmBalances, fetchSolanaBalances } = await import("../wallet-DFhJWn3o.js");
|
|
387
387
|
const [evmBal, solBal] = await Promise.allSettled([fetchEvmBalances(wallet.evmAddress), fetchSolanaBalances(wallet.solanaAddress)]);
|
|
388
388
|
const evmUsdc = evmBal.status === "fulfilled" ? Number(evmBal.value?.usdc ?? 0) : 0;
|
|
389
389
|
const solUsdc = solBal.status === "fulfilled" ? Number(solBal.value?.usdc ?? 0) : 0;
|
|
@@ -404,7 +404,7 @@ Add to your MCP client config (Claude, Cursor, etc.):
|
|
|
404
404
|
const { x402MCPClient } = await import("@x402/mcp");
|
|
405
405
|
const x402Mcp = new x402MCPClient(new Client({
|
|
406
406
|
name: "x402-proxy",
|
|
407
|
-
version: "0.4.
|
|
407
|
+
version: "0.4.1"
|
|
408
408
|
}), x402PaymentClient, {
|
|
409
409
|
autoPayment: true,
|
|
410
410
|
onPaymentRequested: (ctx) => {
|
|
@@ -451,7 +451,7 @@ Add to your MCP client config (Claude, Cursor, etc.):
|
|
|
451
451
|
dim(` ${tools.length} tools available`);
|
|
452
452
|
const localServer = new McpServer({
|
|
453
453
|
name: "x402-proxy",
|
|
454
|
-
version: "0.4.
|
|
454
|
+
version: "0.4.1"
|
|
455
455
|
});
|
|
456
456
|
for (const tool of tools) localServer.tool(tool.name, tool.description ?? "", tool.inputSchema?.properties ? Object.fromEntries(Object.entries(tool.inputSchema.properties).map(([k, v]) => [k, v])) : {}, async (args) => {
|
|
457
457
|
const result = await x402Mcp.callTool(tool.name, args);
|
|
@@ -608,7 +608,7 @@ const routes = buildRouteMap({
|
|
|
608
608
|
});
|
|
609
609
|
const app = buildApplication(routes, {
|
|
610
610
|
name: "x402-proxy",
|
|
611
|
-
versionInfo: { currentVersion: "0.4.
|
|
611
|
+
versionInfo: { currentVersion: "0.4.1" },
|
|
612
612
|
scanner: { caseStyle: "allow-kebab-for-camel" }
|
|
613
613
|
});
|
|
614
614
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { g as readHistory, h as formatTxLine, n as fetchEvmBalances, o as resolveWallet, p as calcSpend, r as fetchSolanaBalances, s as dim, t as balanceLine } from "./wallet-
|
|
2
|
+
import { g as readHistory, h as formatTxLine, n as fetchEvmBalances, o as resolveWallet, p as calcSpend, r as fetchSolanaBalances, s as dim, t as balanceLine } from "./wallet-BHywTzdN.js";
|
|
3
3
|
import { a as getConfigDirShort, l as loadConfig, o as getHistoryPath } from "./derive-CISr_ond.js";
|
|
4
4
|
import { buildCommand } from "@stricli/core";
|
|
5
5
|
import pc from "picocolors";
|
|
@@ -225,16 +225,28 @@ function networkToCaipPrefix(name) {
|
|
|
225
225
|
default: return name;
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
|
+
function createNetworkFilter(network) {
|
|
229
|
+
const prefix = networkToCaipPrefix(network);
|
|
230
|
+
return (_version, reqs) => {
|
|
231
|
+
const filtered = reqs.filter((r) => r.network.startsWith(prefix));
|
|
232
|
+
if (filtered.length === 0) {
|
|
233
|
+
const available = [...new Set(reqs.map((r) => displayNetwork(r.network)))].join(", ");
|
|
234
|
+
throw new Error(`Network '${network}' not accepted. Available: ${available}`);
|
|
235
|
+
}
|
|
236
|
+
return filtered;
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
function createNetworkPreference(network) {
|
|
240
|
+
const prefix = networkToCaipPrefix(network);
|
|
241
|
+
return (_version, accepts) => {
|
|
242
|
+
return accepts.find((r) => r.network.startsWith(prefix)) || accepts[0];
|
|
243
|
+
};
|
|
244
|
+
}
|
|
228
245
|
/**
|
|
229
246
|
* Build a configured x402Client from resolved wallet keys.
|
|
230
247
|
*/
|
|
231
248
|
async function buildX402Client(wallet, opts) {
|
|
232
|
-
const client = new x402Client(opts?.preferredNetwork ? (
|
|
233
|
-
const prefix = networkToCaipPrefix(opts.preferredNetwork);
|
|
234
|
-
return (_version, accepts) => {
|
|
235
|
-
return accepts.find((r) => r.network.startsWith(prefix)) || accepts[0];
|
|
236
|
-
};
|
|
237
|
-
})() : void 0);
|
|
249
|
+
const client = new x402Client(opts?.preferredNetwork ? createNetworkPreference(opts.preferredNetwork) : void 0);
|
|
238
250
|
if (wallet.evmKey) {
|
|
239
251
|
const hex = wallet.evmKey;
|
|
240
252
|
registerExactEvmScheme(client, { signer: toClientEvmSigner(privateKeyToAccount(hex), createPublicClient({
|
|
@@ -246,17 +258,7 @@ async function buildX402Client(wallet, opts) {
|
|
|
246
258
|
const { createKeyPairSignerFromBytes } = await import("@solana/kit");
|
|
247
259
|
registerExactSvmScheme(client, { signer: await createKeyPairSignerFromBytes(wallet.solanaKey) });
|
|
248
260
|
}
|
|
249
|
-
if (opts?.network)
|
|
250
|
-
const prefix = networkToCaipPrefix(opts.network);
|
|
251
|
-
client.registerPolicy((_version, reqs) => {
|
|
252
|
-
const filtered = reqs.filter((r) => r.network.startsWith(prefix));
|
|
253
|
-
if (filtered.length === 0) {
|
|
254
|
-
const available = [...new Set(reqs.map((r) => displayNetwork(r.network)))].join(", ");
|
|
255
|
-
throw new Error(`Network '${opts.network}' not accepted. Available: ${available}`);
|
|
256
|
-
}
|
|
257
|
-
return filtered;
|
|
258
|
-
});
|
|
259
|
-
}
|
|
261
|
+
if (opts?.network) client.registerPolicy(createNetworkFilter(opts.network));
|
|
260
262
|
const daily = opts?.spendLimitDaily;
|
|
261
263
|
const perTx = opts?.spendLimitPerTx;
|
|
262
264
|
if (daily || perTx) client.registerPolicy((_version, reqs) => {
|
package/package.json
CHANGED
package/dist/wallet-BX5vQtUz.js
DELETED