uvd-x402-sdk 2.0.1 → 2.0.3
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/README.md +63 -9
- package/dist/{index-DJ4Cvrev.d.mts → index-D0N_SYpK.d.mts} +1 -1
- package/dist/{index-BrBqP1I8.d.ts → index-Db8dWNam.d.ts} +1 -1
- package/dist/{index-D6Sr4ARD.d.mts → index-MTBgC_SL.d.mts} +1 -1
- package/dist/{index-D6Sr4ARD.d.ts → index-MTBgC_SL.d.ts} +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -29
- package/dist/index.mjs.map +1 -1
- package/dist/providers/evm/index.d.mts +1 -1
- package/dist/providers/evm/index.d.ts +1 -1
- package/dist/providers/evm/index.js +1 -29
- package/dist/providers/evm/index.js.map +1 -1
- package/dist/providers/evm/index.mjs +1 -29
- package/dist/providers/evm/index.mjs.map +1 -1
- package/dist/providers/near/index.d.mts +1 -1
- package/dist/providers/near/index.d.ts +1 -1
- package/dist/providers/near/index.js +0 -1
- package/dist/providers/near/index.js.map +1 -1
- package/dist/providers/near/index.mjs +0 -1
- package/dist/providers/near/index.mjs.map +1 -1
- package/dist/providers/solana/index.d.mts +5 -1
- package/dist/providers/solana/index.d.ts +5 -1
- package/dist/providers/solana/index.js +10 -33
- package/dist/providers/solana/index.js.map +1 -1
- package/dist/providers/solana/index.mjs +10 -33
- package/dist/providers/solana/index.mjs.map +1 -1
- package/dist/providers/stellar/index.d.mts +1 -1
- package/dist/providers/stellar/index.d.ts +1 -1
- package/dist/providers/stellar/index.js +0 -1
- package/dist/providers/stellar/index.js.map +1 -1
- package/dist/providers/stellar/index.mjs +0 -1
- package/dist/providers/stellar/index.mjs.map +1 -1
- package/dist/react/index.d.mts +3 -3
- package/dist/react/index.d.ts +3 -3
- package/dist/react/index.js +1 -29
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +1 -29
- package/dist/react/index.mjs.map +1 -1
- package/dist/utils/index.d.mts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -29
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +1 -29
- package/dist/utils/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/chains/index.ts +1 -27
- package/src/index.ts +2 -2
- package/src/providers/solana/index.ts +20 -7
- package/src/types/index.ts +1 -2
package/src/chains/index.ts
CHANGED
|
@@ -25,7 +25,7 @@ export const DEFAULT_FACILITATOR_URL = 'https://facilitator.ultravioletadao.xyz'
|
|
|
25
25
|
*/
|
|
26
26
|
export const SUPPORTED_CHAINS: Record<string, ChainConfig> = {
|
|
27
27
|
// ============================================================================
|
|
28
|
-
// EVM CHAINS (
|
|
28
|
+
// EVM CHAINS (10 networks)
|
|
29
29
|
// ============================================================================
|
|
30
30
|
|
|
31
31
|
base: {
|
|
@@ -278,32 +278,6 @@ export const SUPPORTED_CHAINS: Record<string, ChainConfig> = {
|
|
|
278
278
|
},
|
|
279
279
|
},
|
|
280
280
|
|
|
281
|
-
// BSC disabled: USDC doesn't support ERC-3009 transferWithAuthorization
|
|
282
|
-
bsc: {
|
|
283
|
-
chainId: 56,
|
|
284
|
-
chainIdHex: '0x38',
|
|
285
|
-
name: 'bsc',
|
|
286
|
-
displayName: 'BNB Smart Chain',
|
|
287
|
-
networkType: 'evm',
|
|
288
|
-
rpcUrl: 'https://binance.llamarpc.com',
|
|
289
|
-
explorerUrl: 'https://bscscan.com',
|
|
290
|
-
nativeCurrency: {
|
|
291
|
-
name: 'Binance Coin',
|
|
292
|
-
symbol: 'BNB',
|
|
293
|
-
decimals: 18,
|
|
294
|
-
},
|
|
295
|
-
usdc: {
|
|
296
|
-
address: '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d',
|
|
297
|
-
decimals: 18, // BSC USDC uses 18 decimals
|
|
298
|
-
name: 'USD Coin',
|
|
299
|
-
version: '2',
|
|
300
|
-
},
|
|
301
|
-
x402: {
|
|
302
|
-
facilitatorUrl: DEFAULT_FACILITATOR_URL,
|
|
303
|
-
enabled: false, // Disabled: BSC USDC doesn't support ERC-3009
|
|
304
|
-
},
|
|
305
|
-
},
|
|
306
|
-
|
|
307
281
|
// ============================================================================
|
|
308
282
|
// SVM CHAINS (2 networks) - Solana Virtual Machine
|
|
309
283
|
// ============================================================================
|
package/src/index.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* x402 Payment SDK - Gasless crypto payments using the Ultravioleta facilitator.
|
|
5
5
|
*
|
|
6
|
-
* Supports
|
|
7
|
-
* - EVM (
|
|
6
|
+
* Supports 14 blockchain networks:
|
|
7
|
+
* - EVM (10): Base, Ethereum, Polygon, Arbitrum, Optimism, Avalanche, Celo, HyperEVM, Unichain, Monad
|
|
8
8
|
* - SVM (2): Solana, Fogo
|
|
9
9
|
* - Stellar (1): Stellar
|
|
10
10
|
* - NEAR (1): NEAR Protocol
|
|
@@ -318,9 +318,11 @@ export class SVMProvider implements WalletAdapter {
|
|
|
318
318
|
);
|
|
319
319
|
|
|
320
320
|
// Instruction 1: SetComputeUnitPrice
|
|
321
|
+
// Use 100k microlamports/CU for fast landing on mainnet
|
|
322
|
+
// Lower values (like 1) cause transactions to be deprioritized and time out
|
|
321
323
|
instructions.push(
|
|
322
324
|
ComputeBudgetProgram.setComputeUnitPrice({
|
|
323
|
-
microLamports:
|
|
325
|
+
microLamports: 100_000,
|
|
324
326
|
})
|
|
325
327
|
);
|
|
326
328
|
|
|
@@ -362,6 +364,9 @@ export class SVMProvider implements WalletAdapter {
|
|
|
362
364
|
const transaction = new VersionedTransaction(messageV0);
|
|
363
365
|
|
|
364
366
|
// User signs (partial signature - facilitator will co-sign)
|
|
367
|
+
// IMPORTANT: Phantom may modify the transaction (add memo instruction).
|
|
368
|
+
// We send the FULL signed transaction to the facilitator, which will use it
|
|
369
|
+
// exactly as signed (not reconstruct it). This ensures signature validity.
|
|
365
370
|
let signedTransaction: InstanceType<typeof VersionedTransaction>;
|
|
366
371
|
try {
|
|
367
372
|
signedTransaction = await this.provider.signTransaction(transaction);
|
|
@@ -376,7 +381,8 @@ export class SVMProvider implements WalletAdapter {
|
|
|
376
381
|
);
|
|
377
382
|
}
|
|
378
383
|
|
|
379
|
-
// Serialize
|
|
384
|
+
// Serialize the FULL signed transaction (including any wallet modifications)
|
|
385
|
+
// The facilitator will use this exact transaction, adding only its signature
|
|
380
386
|
const serialized = signedTransaction.serialize();
|
|
381
387
|
|
|
382
388
|
const payload: SolanaPaymentPayload = {
|
|
@@ -446,6 +452,10 @@ export class SVMProvider implements WalletAdapter {
|
|
|
446
452
|
|
|
447
453
|
/**
|
|
448
454
|
* Get or create a connection for a specific chain
|
|
455
|
+
*
|
|
456
|
+
* IMPORTANT: Caches by RPC URL, not chain name. This allows consumers to
|
|
457
|
+
* override the RPC URL (e.g., use Helius instead of public RPC) and get
|
|
458
|
+
* a fresh connection with their custom RPC.
|
|
449
459
|
*/
|
|
450
460
|
private async getConnection(chainConfig?: ChainConfig): Promise<InstanceType<typeof Connection>> {
|
|
451
461
|
await loadSolanaDeps();
|
|
@@ -455,14 +465,17 @@ export class SVMProvider implements WalletAdapter {
|
|
|
455
465
|
throw new X402Error('Chain config not found', 'CHAIN_NOT_SUPPORTED');
|
|
456
466
|
}
|
|
457
467
|
|
|
458
|
-
//
|
|
459
|
-
|
|
460
|
-
|
|
468
|
+
// Cache by RPC URL, not chain name - allows custom RPC overrides
|
|
469
|
+
const cacheKey = config.rpcUrl;
|
|
470
|
+
|
|
471
|
+
// Check if we already have a connection for this RPC
|
|
472
|
+
if (this.connections.has(cacheKey)) {
|
|
473
|
+
return this.connections.get(cacheKey)!;
|
|
461
474
|
}
|
|
462
475
|
|
|
463
|
-
// Create new connection for this
|
|
476
|
+
// Create new connection for this RPC
|
|
464
477
|
const connection = new Connection(config.rpcUrl, 'confirmed');
|
|
465
|
-
this.connections.set(
|
|
478
|
+
this.connections.set(cacheKey, connection);
|
|
466
479
|
|
|
467
480
|
return connection;
|
|
468
481
|
}
|
package/src/types/index.ts
CHANGED
|
@@ -26,7 +26,7 @@ export type NetworkType = 'evm' | 'svm' | 'solana' | 'stellar' | 'near';
|
|
|
26
26
|
export interface USDCConfig {
|
|
27
27
|
/** Contract/mint address */
|
|
28
28
|
address: string;
|
|
29
|
-
/** Token decimals (6 for most chains, 7 for Stellar
|
|
29
|
+
/** Token decimals (6 for most chains, 7 for Stellar) */
|
|
30
30
|
decimals: number;
|
|
31
31
|
/** Token name for EIP-712 domain (e.g., "USD Coin" or "USDC") */
|
|
32
32
|
name: string;
|
|
@@ -298,7 +298,6 @@ export const CAIP2_IDENTIFIERS: Record<string, string> = {
|
|
|
298
298
|
hyperevm: 'eip155:999',
|
|
299
299
|
unichain: 'eip155:130',
|
|
300
300
|
monad: 'eip155:143',
|
|
301
|
-
bsc: 'eip155:56',
|
|
302
301
|
// SVM chains
|
|
303
302
|
solana: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
|
|
304
303
|
fogo: 'svm:fogo',
|