Skip to content

Commit 0831d85

Browse files
committed
refactor(svm): drop token-2022 and compute-budget deps
Replace @solana-program/compute-budget with @solana/kit built-in setTransactionMessageComputeUnitLimit/Price. Drop @solana-program/token-2022 (only needed for non-USDC assets). Keep @solana-program/token for findAssociatedTokenPda and getTransferCheckedInstruction. Removes the @solana/sysvars peer dep warning on npm install.
1 parent cf47f4e commit 0831d85

6 files changed

Lines changed: 41 additions & 85 deletions

File tree

packages/x402-proxy/CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

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+
1017
## [0.10.0] - 2026-04-01
1118

1219
### Added
@@ -328,7 +335,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
328335
- `appendHistory` / `readHistory` / `calcSpend` - JSONL transaction history
329336
- Re-exports from `@x402/fetch`, `@x402/svm`, `@x402/evm`
330337

331-
[Unreleased]: https://github.com/cascade-protocol/x402-proxy/compare/v0.10.0...HEAD
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
332340
[0.10.0]: https://github.com/cascade-protocol/x402-proxy/compare/v0.9.4...v0.10.0
333341
[0.9.4]: https://github.com/cascade-protocol/x402-proxy/compare/v0.9.3...v0.9.4
334342
[0.9.3]: https://github.com/cascade-protocol/x402-proxy/compare/v0.9.2...v0.9.3

packages/x402-proxy/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "x402-proxy",
3-
"version": "0.10.0",
3+
"version": "0.10.1",
44
"description": "curl for x402 paid APIs. Auto-pays any endpoint on Base, Solana, and Tempo. Also works as an OpenClaw plugin.",
55
"type": "module",
66
"sideEffects": false,
@@ -54,9 +54,7 @@
5454
"@scure/bip32": "^2.0.1",
5555
"@scure/bip39": "^2.0.1",
5656
"@sinclair/typebox": "^0.34.48",
57-
"@solana-program/compute-budget": "^0.15.0",
5857
"@solana-program/token": "^0.12.0",
59-
"@solana-program/token-2022": "^0.9.0",
6058
"@solana/kit": "^6.5.0",
6159
"@stricli/core": "^1.2.6",
6260
"@x402/core": "^2.8.0",

packages/x402-proxy/src/commands/claude.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Examples:
100100
env: {
101101
...process.env,
102102
ANTHROPIC_BASE_URL: `http://127.0.0.1:${started.port}`,
103-
ANTHROPIC_API_KEY: "x402-proxy",
103+
ANTHROPIC_MODEL: flags.model,
104104
ANTHROPIC_CUSTOM_MODEL_OPTION: flags.model,
105105
},
106106
});

packages/x402-proxy/src/lib/optimized-svm-scheme.ts

Lines changed: 26 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,23 @@ import {
99
mainnet,
1010
partiallySignTransactionMessageWithSigners,
1111
pipe,
12-
prependTransactionMessageInstruction,
1312
SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR,
13+
setTransactionMessageComputeUnitLimit,
14+
setTransactionMessageComputeUnitPrice,
1415
setTransactionMessageFeePayer,
1516
setTransactionMessageLifetimeUsingBlockhash,
1617
type TransactionSigner,
1718
} from "@solana/kit";
1819
import {
19-
getSetComputeUnitLimitInstruction,
20-
setTransactionMessageComputeUnitPrice,
21-
} from "@solana-program/compute-budget";
22-
import { TOKEN_PROGRAM_ADDRESS } from "@solana-program/token";
23-
import {
24-
fetchMint,
2520
findAssociatedTokenPda,
2621
getTransferCheckedInstruction,
27-
TOKEN_2022_PROGRAM_ADDRESS,
28-
} from "@solana-program/token-2022";
22+
TOKEN_PROGRAM_ADDRESS,
23+
} from "@solana-program/token";
2924
import type { PaymentRequirements, SchemeNetworkClient } from "@x402/core/types";
3025

3126
const MEMO_PROGRAM_ADDRESS: Address = "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr" as Address;
3227
const COMPUTE_UNIT_LIMIT = 20_000;
33-
const COMPUTE_UNIT_PRICE_MICROLAMPORTS = 1;
28+
const COMPUTE_UNIT_PRICE_MICROLAMPORTS = 1n;
3429

3530
const USDC_MINT: Address = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" as Address;
3631
const USDC_DECIMALS = 6;
@@ -107,50 +102,34 @@ export class OptimizedSvmScheme implements SchemeNetworkClient {
107102

108103
async createPaymentPayload(x402Version: number, paymentRequirements: PaymentRequirements) {
109104
const rpc = this.rpc;
110-
111105
const asset = paymentRequirements.asset as Address;
112106

113-
let tokenProgramAddress: Address;
114-
let decimals: number;
115-
if (asset === USDC_MINT) {
116-
tokenProgramAddress = TOKEN_PROGRAM_ADDRESS;
117-
decimals = USDC_DECIMALS;
118-
} else {
119-
const tokenMint = await fetchMint(rpc, asset);
120-
tokenProgramAddress = tokenMint.programAddress;
121-
if (
122-
tokenProgramAddress !== TOKEN_PROGRAM_ADDRESS &&
123-
tokenProgramAddress !== TOKEN_2022_PROGRAM_ADDRESS
124-
) {
125-
throw new Error("Asset was not created by a known token program");
126-
}
127-
decimals = tokenMint.data.decimals;
107+
if (asset !== USDC_MINT) {
108+
throw new Error(`Unsupported asset: ${asset}. Only USDC is supported.`);
128109
}
129110

130-
const [sourceATA] = await findAssociatedTokenPda({
131-
mint: asset,
132-
owner: this.signer.address,
133-
tokenProgram: tokenProgramAddress,
134-
});
111+
const [[sourceATA], [destinationATA]] = await Promise.all([
112+
findAssociatedTokenPda({
113+
mint: asset,
114+
owner: this.signer.address,
115+
tokenProgram: TOKEN_PROGRAM_ADDRESS,
116+
}),
117+
findAssociatedTokenPda({
118+
mint: asset,
119+
owner: paymentRequirements.payTo as Address,
120+
tokenProgram: TOKEN_PROGRAM_ADDRESS,
121+
}),
122+
]);
135123

136-
const [destinationATA] = await findAssociatedTokenPda({
124+
const transferIx = getTransferCheckedInstruction({
125+
source: sourceATA,
137126
mint: asset,
138-
owner: paymentRequirements.payTo as Address,
139-
tokenProgram: tokenProgramAddress,
127+
destination: destinationATA,
128+
authority: this.signer,
129+
amount: BigInt(paymentRequirements.amount),
130+
decimals: USDC_DECIMALS,
140131
});
141132

142-
const transferIx = getTransferCheckedInstruction(
143-
{
144-
source: sourceATA,
145-
mint: asset,
146-
destination: destinationATA,
147-
authority: this.signer,
148-
amount: BigInt(paymentRequirements.amount),
149-
decimals,
150-
},
151-
{ programAddress: tokenProgramAddress },
152-
);
153-
154133
const feePayer = paymentRequirements.extra?.feePayer as Address;
155134
if (!feePayer) {
156135
throw new Error("feePayer is required in paymentRequirements.extra for SVM transactions");
@@ -172,12 +151,8 @@ export class OptimizedSvmScheme implements SchemeNetworkClient {
172151
const tx = pipe(
173152
createTransactionMessage({ version: 0 }),
174153
(tx) => setTransactionMessageComputeUnitPrice(COMPUTE_UNIT_PRICE_MICROLAMPORTS, tx),
154+
(tx) => setTransactionMessageComputeUnitLimit(COMPUTE_UNIT_LIMIT, tx),
175155
(tx) => setTransactionMessageFeePayer(feePayer, tx),
176-
(tx) =>
177-
prependTransactionMessageInstruction(
178-
getSetComputeUnitLimitInstruction({ units: COMPUTE_UNIT_LIMIT }),
179-
tx,
180-
),
181156
(tx) => appendTransactionMessageInstructions([transferIx, memoIx], tx),
182157
(tx) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, tx),
183158
);

pnpm-lock.yaml

Lines changed: 3 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ packages:
33

44
onlyBuiltDependencies:
55
- '@whiskeysockets/baileys'
6+
- esbuild
67
- koffi
78
- protobufjs
89
- sharp

0 commit comments

Comments
 (0)