x402-proxy 0.10.0 → 0.10.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/CHANGELOG.md +9 -1
- package/dist/bin/cli.js +12 -12
- package/dist/openclaw/plugin.js +13 -26
- package/dist/{status-Bp3X6QEg.js → status-B5oH1nHv.js} +1 -1
- package/dist/status-DlR8yBrK.js +3 -0
- package/dist/wallet-7XKcknNZ.js +3 -0
- package/dist/{wallet-DY0t1t16.js → wallet-DqGROXlC.js} +12 -25
- package/package.json +1 -3
- package/dist/status-DKNWF6WB.js +0 -3
- package/dist/wallet-Cty0AnYk.js +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.10.1] - 2026-04-01
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- Dropped `@solana-program/compute-budget` and `@solana-program/token-2022` dependencies - compute budget instructions now use `@solana/kit` built-ins, non-USDC asset path removed (only USDC is supported)
|
|
14
|
+
- Kept `@solana-program/token` (clean peer deps) for `findAssociatedTokenPda` and `getTransferCheckedInstruction`
|
|
15
|
+
- Eliminates `@solana/sysvars` peer dependency warning on `npm install`
|
|
16
|
+
|
|
10
17
|
## [0.10.0] - 2026-04-01
|
|
11
18
|
|
|
12
19
|
### Added
|
|
@@ -328,7 +335,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
328
335
|
- `appendHistory` / `readHistory` / `calcSpend` - JSONL transaction history
|
|
329
336
|
- Re-exports from `@x402/fetch`, `@x402/svm`, `@x402/evm`
|
|
330
337
|
|
|
331
|
-
[Unreleased]: https://github.com/cascade-protocol/x402-proxy/compare/v0.10.
|
|
338
|
+
[Unreleased]: https://github.com/cascade-protocol/x402-proxy/compare/v0.10.1...HEAD
|
|
339
|
+
[0.10.1]: https://github.com/cascade-protocol/x402-proxy/compare/v0.10.0...v0.10.1
|
|
332
340
|
[0.10.0]: https://github.com/cascade-protocol/x402-proxy/compare/v0.9.4...v0.10.0
|
|
333
341
|
[0.9.4]: https://github.com/cascade-protocol/x402-proxy/compare/v0.9.3...v0.9.4
|
|
334
342
|
[0.9.3]: https://github.com/cascade-protocol/x402-proxy/compare/v0.9.2...v0.9.3
|
package/dist/bin/cli.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { _ as error, b as success, c as resolveWallet, d as displayNetwork, f as formatAmount, g as dim, h as readHistory, l as appendHistory, m as formatUsdcValue, n as fetchAllBalances, o as walletInfoCommand, p as formatTxLine, s as buildX402Client, u as calcSpend, v as info, x as warn, y as isTTY } from "../wallet-
|
|
2
|
+
import { _ as error, b as success, c as resolveWallet, d as displayNetwork, f as formatAmount, g as dim, h as readHistory, l as appendHistory, m as formatUsdcValue, n as fetchAllBalances, o as walletInfoCommand, p as formatTxLine, s as buildX402Client, u as calcSpend, v as info, x as warn, y as isTTY } from "../wallet-DqGROXlC.js";
|
|
3
3
|
import { a as getHistoryPath, c as loadConfig, i as getConfigDirShort, l as loadWalletFile, s as isConfigured, u as saveConfig } from "../derive-CY0En_Y3.js";
|
|
4
4
|
import { n as setupCommand, t as runSetup } from "../setup-DtKrojW1.js";
|
|
5
|
-
import { n as statusCommand } from "../status-
|
|
5
|
+
import { n as statusCommand } from "../status-B5oH1nHv.js";
|
|
6
6
|
import { dirname, join, normalize, resolve } from "node:path";
|
|
7
7
|
import { buildApplication, buildCommand, buildRouteMap, run } from "@stricli/core";
|
|
8
8
|
import { spawn } from "node:child_process";
|
|
@@ -1025,7 +1025,7 @@ Examples:
|
|
|
1025
1025
|
env: {
|
|
1026
1026
|
...process.env,
|
|
1027
1027
|
ANTHROPIC_BASE_URL: `http://127.0.0.1:${started.port}`,
|
|
1028
|
-
|
|
1028
|
+
ANTHROPIC_MODEL: flags.model,
|
|
1029
1029
|
ANTHROPIC_CUSTOM_MODEL_OPTION: flags.model
|
|
1030
1030
|
}
|
|
1031
1031
|
});
|
|
@@ -1306,7 +1306,7 @@ Examples:
|
|
|
1306
1306
|
};
|
|
1307
1307
|
if (!url) {
|
|
1308
1308
|
if (isConfigured()) {
|
|
1309
|
-
const { displayStatus } = await import("../status-
|
|
1309
|
+
const { displayStatus } = await import("../status-DlR8yBrK.js");
|
|
1310
1310
|
await displayStatus();
|
|
1311
1311
|
console.log();
|
|
1312
1312
|
console.log(pc.dim(" Commands:"));
|
|
@@ -1371,7 +1371,7 @@ Examples:
|
|
|
1371
1371
|
verbose(`protocol: ${resolvedProtocol ?? "auto-detect"}, maxDeposit: ${maxDeposit}`);
|
|
1372
1372
|
let preferredNetwork = config?.defaultNetwork;
|
|
1373
1373
|
if (!preferredNetwork && wallet.evmAddress && wallet.solanaAddress) {
|
|
1374
|
-
const { fetchAllBalances } = await import("../wallet-
|
|
1374
|
+
const { fetchAllBalances } = await import("../wallet-7XKcknNZ.js");
|
|
1375
1375
|
const balances = await fetchAllBalances(wallet.evmAddress, wallet.solanaAddress);
|
|
1376
1376
|
const evmUsdc = balances.evm ? Number(balances.evm.usdc) : 0;
|
|
1377
1377
|
const solUsdc = balances.sol ? Number(balances.sol.usdc) : 0;
|
|
@@ -1538,7 +1538,7 @@ Examples:
|
|
|
1538
1538
|
const hasSolana = accepts.some((a) => a.network.startsWith("solana:"));
|
|
1539
1539
|
const hasMpp = detected.mpp;
|
|
1540
1540
|
const hasOther = accepts.some((a) => !a.network.startsWith("eip155:") && !a.network.startsWith("solana:"));
|
|
1541
|
-
const { fetchAllBalances } = await import("../wallet-
|
|
1541
|
+
const { fetchAllBalances } = await import("../wallet-7XKcknNZ.js");
|
|
1542
1542
|
const balances = await fetchAllBalances(wallet.evmAddress, wallet.solanaAddress);
|
|
1543
1543
|
const evmUsdc = hasEvm && balances.evm ? Number(balances.evm.usdc) : 0;
|
|
1544
1544
|
const solUsdc = hasSolana && balances.sol ? Number(balances.sol.usdc) : 0;
|
|
@@ -1758,7 +1758,7 @@ Wallet is auto-generated on first run. No env vars needed.`
|
|
|
1758
1758
|
async function startX402Proxy() {
|
|
1759
1759
|
let preferredNetwork = config?.defaultNetwork;
|
|
1760
1760
|
if (!preferredNetwork && wallet.evmAddress && wallet.solanaAddress) {
|
|
1761
|
-
const { fetchAllBalances } = await import("../wallet-
|
|
1761
|
+
const { fetchAllBalances } = await import("../wallet-7XKcknNZ.js");
|
|
1762
1762
|
const balances = await fetchAllBalances(wallet.evmAddress, wallet.solanaAddress);
|
|
1763
1763
|
const evmUsdc = balances.evm ? Number(balances.evm.usdc) : 0;
|
|
1764
1764
|
const solUsdc = balances.sol ? Number(balances.sol.usdc) : 0;
|
|
@@ -1778,7 +1778,7 @@ Wallet is auto-generated on first run. No env vars needed.`
|
|
|
1778
1778
|
}
|
|
1779
1779
|
const remoteClient = new Client({
|
|
1780
1780
|
name: "x402-proxy",
|
|
1781
|
-
version: "0.10.
|
|
1781
|
+
version: "0.10.1"
|
|
1782
1782
|
});
|
|
1783
1783
|
const x402Mcp = new x402MCPClient(remoteClient, x402PaymentClient, {
|
|
1784
1784
|
autoPayment: true,
|
|
@@ -1816,7 +1816,7 @@ Wallet is auto-generated on first run. No env vars needed.`
|
|
|
1816
1816
|
}
|
|
1817
1817
|
const localServer = new Server({
|
|
1818
1818
|
name: "x402-proxy",
|
|
1819
|
-
version: "0.10.
|
|
1819
|
+
version: "0.10.1"
|
|
1820
1820
|
}, { capabilities: {
|
|
1821
1821
|
tools: tools.length > 0 ? {} : void 0,
|
|
1822
1822
|
resources: remoteResources.length > 0 ? {} : void 0
|
|
@@ -1911,7 +1911,7 @@ Wallet is auto-generated on first run. No env vars needed.`
|
|
|
1911
1911
|
}));
|
|
1912
1912
|
const remoteClient = new Client({
|
|
1913
1913
|
name: "x402-proxy",
|
|
1914
|
-
version: "0.10.
|
|
1914
|
+
version: "0.10.1"
|
|
1915
1915
|
});
|
|
1916
1916
|
await connectTransport(remoteClient);
|
|
1917
1917
|
const mppClient = McpClient.wrap(remoteClient, { methods: wrappedMethods });
|
|
@@ -1926,7 +1926,7 @@ Wallet is auto-generated on first run. No env vars needed.`
|
|
|
1926
1926
|
}
|
|
1927
1927
|
const localServer = new Server({
|
|
1928
1928
|
name: "x402-proxy",
|
|
1929
|
-
version: "0.10.
|
|
1929
|
+
version: "0.10.1"
|
|
1930
1930
|
}, { capabilities: {
|
|
1931
1931
|
tools: tools.length > 0 ? {} : void 0,
|
|
1932
1932
|
resources: remoteResources.length > 0 ? {} : void 0
|
|
@@ -2325,7 +2325,7 @@ const app = buildApplication(buildRouteMap({
|
|
|
2325
2325
|
docs: { brief: "curl for x402 paid APIs" }
|
|
2326
2326
|
}), {
|
|
2327
2327
|
name: "x402-proxy",
|
|
2328
|
-
versionInfo: { currentVersion: "0.10.
|
|
2328
|
+
versionInfo: { currentVersion: "0.10.1" },
|
|
2329
2329
|
scanner: { caseStyle: "allow-kebab-for-camel" }
|
|
2330
2330
|
});
|
|
2331
2331
|
//#endregion
|
package/dist/openclaw/plugin.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import os, { homedir } from "node:os";
|
|
2
2
|
import path, { dirname, join } from "node:path";
|
|
3
|
-
import { SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR, address, appendTransactionMessageInstructions, createDefaultRpcTransport, createKeyPairSignerFromBytes, createSolanaRpc, createSolanaRpcFromTransport, createTransactionMessage, getAddressEncoder, getBase64EncodedWireTransaction, getProgramDerivedAddress, isSolanaError, mainnet, partiallySignTransactionMessageWithSigners, pipe,
|
|
3
|
+
import { SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR, address, appendTransactionMessageInstructions, createDefaultRpcTransport, createKeyPairSignerFromBytes, createSolanaRpc, createSolanaRpcFromTransport, createTransactionMessage, getAddressEncoder, getBase64EncodedWireTransaction, getProgramDerivedAddress, isSolanaError, mainnet, partiallySignTransactionMessageWithSigners, pipe, setTransactionMessageComputeUnitLimit, setTransactionMessageComputeUnitPrice, setTransactionMessageFeePayer, setTransactionMessageLifetimeUsingBlockhash } from "@solana/kit";
|
|
4
4
|
import { decodePaymentResponseHeader, wrapFetchWithPayment, x402Client } from "@x402/fetch";
|
|
5
5
|
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
|
6
6
|
import fs, { appendFileSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
7
7
|
import "yaml";
|
|
8
|
-
import {
|
|
9
|
-
import { TOKEN_PROGRAM_ADDRESS } from "@solana-program/token";
|
|
10
|
-
import { TOKEN_2022_PROGRAM_ADDRESS, fetchMint, findAssociatedTokenPda, getTransferCheckedInstruction } from "@solana-program/token-2022";
|
|
8
|
+
import { TOKEN_PROGRAM_ADDRESS, findAssociatedTokenPda, getTransferCheckedInstruction } from "@solana-program/token";
|
|
11
9
|
import { ed25519 } from "@noble/curves/ed25519.js";
|
|
12
10
|
import { base58 } from "@scure/base";
|
|
13
11
|
import "@x402/evm";
|
|
@@ -178,7 +176,7 @@ function loadWalletFile() {
|
|
|
178
176
|
//#region src/lib/optimized-svm-scheme.ts
|
|
179
177
|
const MEMO_PROGRAM_ADDRESS = "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr";
|
|
180
178
|
const COMPUTE_UNIT_LIMIT = 2e4;
|
|
181
|
-
const COMPUTE_UNIT_PRICE_MICROLAMPORTS =
|
|
179
|
+
const COMPUTE_UNIT_PRICE_MICROLAMPORTS = 1n;
|
|
182
180
|
const USDC_MINT$1 = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
183
181
|
const USDC_DECIMALS$1 = 6;
|
|
184
182
|
const MAINNET_RPC_URLS = ["https://api.mainnet.solana.com", "https://public.rpc.solanavibestation.com"];
|
|
@@ -224,35 +222,24 @@ var OptimizedSvmScheme = class {
|
|
|
224
222
|
async createPaymentPayload(x402Version, paymentRequirements) {
|
|
225
223
|
const rpc = this.rpc;
|
|
226
224
|
const asset = paymentRequirements.asset;
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
if (asset === USDC_MINT$1) {
|
|
230
|
-
tokenProgramAddress = TOKEN_PROGRAM_ADDRESS;
|
|
231
|
-
decimals = USDC_DECIMALS$1;
|
|
232
|
-
} else {
|
|
233
|
-
const tokenMint = await fetchMint(rpc, asset);
|
|
234
|
-
tokenProgramAddress = tokenMint.programAddress;
|
|
235
|
-
if (tokenProgramAddress !== TOKEN_PROGRAM_ADDRESS && tokenProgramAddress !== TOKEN_2022_PROGRAM_ADDRESS) throw new Error("Asset was not created by a known token program");
|
|
236
|
-
decimals = tokenMint.data.decimals;
|
|
237
|
-
}
|
|
238
|
-
const [sourceATA] = await findAssociatedTokenPda({
|
|
225
|
+
if (asset !== USDC_MINT$1) throw new Error(`Unsupported asset: ${asset}. Only USDC is supported.`);
|
|
226
|
+
const [[sourceATA], [destinationATA]] = await Promise.all([findAssociatedTokenPda({
|
|
239
227
|
mint: asset,
|
|
240
228
|
owner: this.signer.address,
|
|
241
|
-
tokenProgram:
|
|
242
|
-
})
|
|
243
|
-
const [destinationATA] = await findAssociatedTokenPda({
|
|
229
|
+
tokenProgram: TOKEN_PROGRAM_ADDRESS
|
|
230
|
+
}), findAssociatedTokenPda({
|
|
244
231
|
mint: asset,
|
|
245
232
|
owner: paymentRequirements.payTo,
|
|
246
|
-
tokenProgram:
|
|
247
|
-
});
|
|
233
|
+
tokenProgram: TOKEN_PROGRAM_ADDRESS
|
|
234
|
+
})]);
|
|
248
235
|
const transferIx = getTransferCheckedInstruction({
|
|
249
236
|
source: sourceATA,
|
|
250
237
|
mint: asset,
|
|
251
238
|
destination: destinationATA,
|
|
252
239
|
authority: this.signer,
|
|
253
240
|
amount: BigInt(paymentRequirements.amount),
|
|
254
|
-
decimals
|
|
255
|
-
}
|
|
241
|
+
decimals: USDC_DECIMALS$1
|
|
242
|
+
});
|
|
256
243
|
const feePayer = paymentRequirements.extra?.feePayer;
|
|
257
244
|
if (!feePayer) throw new Error("feePayer is required in paymentRequirements.extra for SVM transactions");
|
|
258
245
|
const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();
|
|
@@ -264,7 +251,7 @@ var OptimizedSvmScheme = class {
|
|
|
264
251
|
};
|
|
265
252
|
return {
|
|
266
253
|
x402Version,
|
|
267
|
-
payload: { transaction: getBase64EncodedWireTransaction(await partiallySignTransactionMessageWithSigners(pipe(createTransactionMessage({ version: 0 }), (tx) => setTransactionMessageComputeUnitPrice(COMPUTE_UNIT_PRICE_MICROLAMPORTS, tx), (tx) =>
|
|
254
|
+
payload: { transaction: getBase64EncodedWireTransaction(await partiallySignTransactionMessageWithSigners(pipe(createTransactionMessage({ version: 0 }), (tx) => setTransactionMessageComputeUnitPrice(COMPUTE_UNIT_PRICE_MICROLAMPORTS, tx), (tx) => setTransactionMessageComputeUnitLimit(COMPUTE_UNIT_LIMIT, tx), (tx) => setTransactionMessageFeePayer(feePayer, tx), (tx) => appendTransactionMessageInstructions([transferIx, memoIx], tx), (tx) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, tx)))) }
|
|
268
255
|
};
|
|
269
256
|
}
|
|
270
257
|
};
|
|
@@ -1163,7 +1150,7 @@ function createWalletCommand(ctx) {
|
|
|
1163
1150
|
if (parts[0]?.toLowerCase() === "send") return { text: "Use `/x_send <amount|all> <address>` for transfers." };
|
|
1164
1151
|
try {
|
|
1165
1152
|
const snap = await getWalletSnapshot(ctx.rpcUrl, solanaWallet, evmWallet, ctx.historyPath);
|
|
1166
|
-
const lines = [`x402-proxy v0.10.
|
|
1153
|
+
const lines = [`x402-proxy v0.10.1`];
|
|
1167
1154
|
const defaultModel = ctx.allModels[0];
|
|
1168
1155
|
if (defaultModel) lines.push("", `**Model** - ${defaultModel.name} (${defaultModel.provider})`);
|
|
1169
1156
|
lines.push("", `**Protocol** - ${ctx.getDefaultRequestProtocol()}`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { c as resolveWallet, f as formatAmount, g as dim, h as readHistory, m as formatUsdcValue, n as fetchAllBalances, p as formatTxLine, t as balanceLine, u as calcSpend } from "./wallet-
|
|
2
|
+
import { c as resolveWallet, f as formatAmount, g as dim, h as readHistory, m as formatUsdcValue, n as fetchAllBalances, p as formatTxLine, t as balanceLine, u as calcSpend } from "./wallet-DqGROXlC.js";
|
|
3
3
|
import { a as getHistoryPath, c as loadConfig, i as getConfigDirShort } from "./derive-CY0En_Y3.js";
|
|
4
4
|
import { buildCommand } from "@stricli/core";
|
|
5
5
|
import pc from "picocolors";
|
|
@@ -12,10 +12,8 @@ import { registerExactEvmScheme } from "@x402/evm/exact/client";
|
|
|
12
12
|
import { createPublicClient, http } from "viem";
|
|
13
13
|
import { privateKeyToAccount } from "viem/accounts";
|
|
14
14
|
import { base } from "viem/chains";
|
|
15
|
-
import { SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR, address, appendTransactionMessageInstructions, createDefaultRpcTransport, createSolanaRpcFromTransport, createTransactionMessage, getAddressEncoder, getBase64EncodedWireTransaction, getProgramDerivedAddress, isSolanaError, mainnet, partiallySignTransactionMessageWithSigners, pipe,
|
|
16
|
-
import {
|
|
17
|
-
import { TOKEN_PROGRAM_ADDRESS } from "@solana-program/token";
|
|
18
|
-
import { TOKEN_2022_PROGRAM_ADDRESS, fetchMint, findAssociatedTokenPda, getTransferCheckedInstruction } from "@solana-program/token-2022";
|
|
15
|
+
import { SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR, address, appendTransactionMessageInstructions, createDefaultRpcTransport, createSolanaRpcFromTransport, createTransactionMessage, getAddressEncoder, getBase64EncodedWireTransaction, getProgramDerivedAddress, isSolanaError, mainnet, partiallySignTransactionMessageWithSigners, pipe, setTransactionMessageComputeUnitLimit, setTransactionMessageComputeUnitPrice, setTransactionMessageFeePayer, setTransactionMessageLifetimeUsingBlockhash } from "@solana/kit";
|
|
16
|
+
import { TOKEN_PROGRAM_ADDRESS, findAssociatedTokenPda, getTransferCheckedInstruction } from "@solana-program/token";
|
|
19
17
|
//#region src/lib/output.ts
|
|
20
18
|
function isTTY() {
|
|
21
19
|
return !!process.stderr.isTTY;
|
|
@@ -160,7 +158,7 @@ function formatTxLine(r, opts) {
|
|
|
160
158
|
//#region src/lib/optimized-svm-scheme.ts
|
|
161
159
|
const MEMO_PROGRAM_ADDRESS = "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr";
|
|
162
160
|
const COMPUTE_UNIT_LIMIT = 2e4;
|
|
163
|
-
const COMPUTE_UNIT_PRICE_MICROLAMPORTS =
|
|
161
|
+
const COMPUTE_UNIT_PRICE_MICROLAMPORTS = 1n;
|
|
164
162
|
const USDC_MINT = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
165
163
|
const USDC_DECIMALS = 6;
|
|
166
164
|
const MAINNET_RPC_URLS = ["https://api.mainnet.solana.com", "https://public.rpc.solanavibestation.com"];
|
|
@@ -206,35 +204,24 @@ var OptimizedSvmScheme = class {
|
|
|
206
204
|
async createPaymentPayload(x402Version, paymentRequirements) {
|
|
207
205
|
const rpc = this.rpc;
|
|
208
206
|
const asset = paymentRequirements.asset;
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
if (asset === USDC_MINT) {
|
|
212
|
-
tokenProgramAddress = TOKEN_PROGRAM_ADDRESS;
|
|
213
|
-
decimals = USDC_DECIMALS;
|
|
214
|
-
} else {
|
|
215
|
-
const tokenMint = await fetchMint(rpc, asset);
|
|
216
|
-
tokenProgramAddress = tokenMint.programAddress;
|
|
217
|
-
if (tokenProgramAddress !== TOKEN_PROGRAM_ADDRESS && tokenProgramAddress !== TOKEN_2022_PROGRAM_ADDRESS) throw new Error("Asset was not created by a known token program");
|
|
218
|
-
decimals = tokenMint.data.decimals;
|
|
219
|
-
}
|
|
220
|
-
const [sourceATA] = await findAssociatedTokenPda({
|
|
207
|
+
if (asset !== USDC_MINT) throw new Error(`Unsupported asset: ${asset}. Only USDC is supported.`);
|
|
208
|
+
const [[sourceATA], [destinationATA]] = await Promise.all([findAssociatedTokenPda({
|
|
221
209
|
mint: asset,
|
|
222
210
|
owner: this.signer.address,
|
|
223
|
-
tokenProgram:
|
|
224
|
-
})
|
|
225
|
-
const [destinationATA] = await findAssociatedTokenPda({
|
|
211
|
+
tokenProgram: TOKEN_PROGRAM_ADDRESS
|
|
212
|
+
}), findAssociatedTokenPda({
|
|
226
213
|
mint: asset,
|
|
227
214
|
owner: paymentRequirements.payTo,
|
|
228
|
-
tokenProgram:
|
|
229
|
-
});
|
|
215
|
+
tokenProgram: TOKEN_PROGRAM_ADDRESS
|
|
216
|
+
})]);
|
|
230
217
|
const transferIx = getTransferCheckedInstruction({
|
|
231
218
|
source: sourceATA,
|
|
232
219
|
mint: asset,
|
|
233
220
|
destination: destinationATA,
|
|
234
221
|
authority: this.signer,
|
|
235
222
|
amount: BigInt(paymentRequirements.amount),
|
|
236
|
-
decimals
|
|
237
|
-
}
|
|
223
|
+
decimals: USDC_DECIMALS
|
|
224
|
+
});
|
|
238
225
|
const feePayer = paymentRequirements.extra?.feePayer;
|
|
239
226
|
if (!feePayer) throw new Error("feePayer is required in paymentRequirements.extra for SVM transactions");
|
|
240
227
|
const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();
|
|
@@ -246,7 +233,7 @@ var OptimizedSvmScheme = class {
|
|
|
246
233
|
};
|
|
247
234
|
return {
|
|
248
235
|
x402Version,
|
|
249
|
-
payload: { transaction: getBase64EncodedWireTransaction(await partiallySignTransactionMessageWithSigners(pipe(createTransactionMessage({ version: 0 }), (tx) => setTransactionMessageComputeUnitPrice(COMPUTE_UNIT_PRICE_MICROLAMPORTS, tx), (tx) =>
|
|
236
|
+
payload: { transaction: getBase64EncodedWireTransaction(await partiallySignTransactionMessageWithSigners(pipe(createTransactionMessage({ version: 0 }), (tx) => setTransactionMessageComputeUnitPrice(COMPUTE_UNIT_PRICE_MICROLAMPORTS, tx), (tx) => setTransactionMessageComputeUnitLimit(COMPUTE_UNIT_LIMIT, tx), (tx) => setTransactionMessageFeePayer(feePayer, tx), (tx) => appendTransactionMessageInstructions([transferIx, memoIx], tx), (tx) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, tx)))) }
|
|
250
237
|
};
|
|
251
238
|
}
|
|
252
239
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "x402-proxy",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "curl for x402 paid APIs. Auto-pays any endpoint on Base, Solana, and Tempo. Also works as an OpenClaw plugin.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -46,9 +46,7 @@
|
|
|
46
46
|
"@scure/bip32": "^2.0.1",
|
|
47
47
|
"@scure/bip39": "^2.0.1",
|
|
48
48
|
"@sinclair/typebox": "^0.34.48",
|
|
49
|
-
"@solana-program/compute-budget": "^0.15.0",
|
|
50
49
|
"@solana-program/token": "^0.12.0",
|
|
51
|
-
"@solana-program/token-2022": "^0.9.0",
|
|
52
50
|
"@solana/kit": "^6.5.0",
|
|
53
51
|
"@stricli/core": "^1.2.6",
|
|
54
52
|
"@x402/core": "^2.8.0",
|
package/dist/status-DKNWF6WB.js
DELETED
package/dist/wallet-Cty0AnYk.js
DELETED