uvd-x402-sdk 2.0.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/LICENSE +21 -0
- package/README.md +782 -0
- package/dist/index-BrBqP1I8.d.ts +199 -0
- package/dist/index-D6Sr4ARD.d.mts +429 -0
- package/dist/index-D6Sr4ARD.d.ts +429 -0
- package/dist/index-DJ4Cvrev.d.mts +199 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1178 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1146 -0
- package/dist/index.mjs.map +1 -0
- package/dist/providers/evm/index.d.mts +84 -0
- package/dist/providers/evm/index.d.ts +84 -0
- package/dist/providers/evm/index.js +740 -0
- package/dist/providers/evm/index.js.map +1 -0
- package/dist/providers/evm/index.mjs +735 -0
- package/dist/providers/evm/index.mjs.map +1 -0
- package/dist/providers/near/index.d.mts +99 -0
- package/dist/providers/near/index.d.ts +99 -0
- package/dist/providers/near/index.js +483 -0
- package/dist/providers/near/index.js.map +1 -0
- package/dist/providers/near/index.mjs +478 -0
- package/dist/providers/near/index.mjs.map +1 -0
- package/dist/providers/solana/index.d.mts +115 -0
- package/dist/providers/solana/index.d.ts +115 -0
- package/dist/providers/solana/index.js +771 -0
- package/dist/providers/solana/index.js.map +1 -0
- package/dist/providers/solana/index.mjs +765 -0
- package/dist/providers/solana/index.mjs.map +1 -0
- package/dist/providers/stellar/index.d.mts +67 -0
- package/dist/providers/stellar/index.d.ts +67 -0
- package/dist/providers/stellar/index.js +306 -0
- package/dist/providers/stellar/index.js.map +1 -0
- package/dist/providers/stellar/index.mjs +301 -0
- package/dist/providers/stellar/index.mjs.map +1 -0
- package/dist/react/index.d.mts +73 -0
- package/dist/react/index.d.ts +73 -0
- package/dist/react/index.js +1218 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/index.mjs +1211 -0
- package/dist/react/index.mjs.map +1 -0
- package/dist/utils/index.d.mts +103 -0
- package/dist/utils/index.d.ts +103 -0
- package/dist/utils/index.js +575 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +562 -0
- package/dist/utils/index.mjs.map +1 -0
- package/package.json +149 -0
- package/src/chains/index.ts +539 -0
- package/src/client/X402Client.ts +663 -0
- package/src/client/index.ts +1 -0
- package/src/index.ts +166 -0
- package/src/providers/evm/index.ts +394 -0
- package/src/providers/near/index.ts +664 -0
- package/src/providers/solana/index.ts +489 -0
- package/src/providers/stellar/index.ts +376 -0
- package/src/react/index.tsx +417 -0
- package/src/types/index.ts +561 -0
- package/src/utils/index.ts +20 -0
- package/src/utils/x402.ts +295 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { b as WalletAdapter, C as ChainConfig, P as PaymentInfo } from '../../index-D6Sr4ARD.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* uvd-x402-sdk - SVM Provider (Solana Virtual Machine)
|
|
5
|
+
*
|
|
6
|
+
* Provides wallet connection and payment creation for SVM-based chains via Phantom.
|
|
7
|
+
* Supports: Solana, Fogo
|
|
8
|
+
* Uses partially-signed transactions where the facilitator is the fee payer.
|
|
9
|
+
*
|
|
10
|
+
* @example Solana
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { SVMProvider } from 'uvd-x402-sdk/solana';
|
|
13
|
+
* import { getChainByName } from 'uvd-x402-sdk';
|
|
14
|
+
*
|
|
15
|
+
* const svm = new SVMProvider();
|
|
16
|
+
*
|
|
17
|
+
* // Connect
|
|
18
|
+
* const address = await svm.connect();
|
|
19
|
+
*
|
|
20
|
+
* // Create Solana payment
|
|
21
|
+
* const chainConfig = getChainByName('solana')!;
|
|
22
|
+
* const paymentPayload = await svm.signPayment(paymentInfo, chainConfig);
|
|
23
|
+
* const header = svm.encodePaymentHeader(paymentPayload, chainConfig);
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example Fogo
|
|
27
|
+
* ```ts
|
|
28
|
+
* import { SVMProvider } from 'uvd-x402-sdk/solana';
|
|
29
|
+
* import { getChainByName } from 'uvd-x402-sdk';
|
|
30
|
+
*
|
|
31
|
+
* const svm = new SVMProvider();
|
|
32
|
+
*
|
|
33
|
+
* // Connect (same wallet works for all SVM chains)
|
|
34
|
+
* const address = await svm.connect();
|
|
35
|
+
*
|
|
36
|
+
* // Create Fogo payment
|
|
37
|
+
* const chainConfig = getChainByName('fogo')!;
|
|
38
|
+
* const paymentPayload = await svm.signPayment(paymentInfo, chainConfig);
|
|
39
|
+
* const header = svm.encodePaymentHeader(paymentPayload, chainConfig);
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* SVMProvider - Wallet adapter for SVM chains (Solana, Fogo) via Phantom
|
|
45
|
+
*
|
|
46
|
+
* @alias SolanaProvider for backward compatibility
|
|
47
|
+
*/
|
|
48
|
+
declare class SVMProvider implements WalletAdapter {
|
|
49
|
+
readonly id = "phantom";
|
|
50
|
+
readonly name = "Phantom";
|
|
51
|
+
readonly networkType: "svm";
|
|
52
|
+
private provider;
|
|
53
|
+
private publicKey;
|
|
54
|
+
private connections;
|
|
55
|
+
private address;
|
|
56
|
+
/**
|
|
57
|
+
* Check if Phantom wallet is available
|
|
58
|
+
*/
|
|
59
|
+
isAvailable(): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Connect to Phantom wallet
|
|
62
|
+
*/
|
|
63
|
+
connect(): Promise<string>;
|
|
64
|
+
/**
|
|
65
|
+
* Disconnect from Phantom
|
|
66
|
+
*/
|
|
67
|
+
disconnect(): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Get current address
|
|
70
|
+
*/
|
|
71
|
+
getAddress(): string | null;
|
|
72
|
+
/**
|
|
73
|
+
* Get USDC balance
|
|
74
|
+
*/
|
|
75
|
+
getBalance(chainConfig: ChainConfig): Promise<string>;
|
|
76
|
+
/**
|
|
77
|
+
* Create SVM payment (partially-signed transaction)
|
|
78
|
+
*
|
|
79
|
+
* Works for both Solana and Fogo chains.
|
|
80
|
+
*
|
|
81
|
+
* Transaction structure required by facilitator:
|
|
82
|
+
* 1. SetComputeUnitLimit
|
|
83
|
+
* 2. SetComputeUnitPrice
|
|
84
|
+
* 3. (Optional) CreateAssociatedTokenAccount if recipient ATA doesn't exist
|
|
85
|
+
* 4. TransferChecked (USDC transfer)
|
|
86
|
+
*
|
|
87
|
+
* Fee payer: Facilitator (not user)
|
|
88
|
+
* User pays: ZERO SOL/FOGO
|
|
89
|
+
*/
|
|
90
|
+
signPayment(paymentInfo: PaymentInfo, chainConfig: ChainConfig): Promise<string>;
|
|
91
|
+
/**
|
|
92
|
+
* Encode SVM payment as X-PAYMENT header
|
|
93
|
+
*
|
|
94
|
+
* @param paymentPayload - The payment payload JSON string
|
|
95
|
+
* @param chainConfig - Optional chain config (defaults to 'solana' if not provided)
|
|
96
|
+
*/
|
|
97
|
+
encodePaymentHeader(paymentPayload: string, chainConfig?: ChainConfig): string;
|
|
98
|
+
private getPhantomProvider;
|
|
99
|
+
/**
|
|
100
|
+
* Get or create a connection for a specific chain
|
|
101
|
+
*/
|
|
102
|
+
private getConnection;
|
|
103
|
+
/**
|
|
104
|
+
* @deprecated Use getConnection instead
|
|
105
|
+
*/
|
|
106
|
+
private initConnection;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* @deprecated Use SVMProvider instead
|
|
110
|
+
*/
|
|
111
|
+
declare class SolanaProvider extends SVMProvider {
|
|
112
|
+
constructor();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export { SVMProvider, SolanaProvider, SVMProvider as default };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { b as WalletAdapter, C as ChainConfig, P as PaymentInfo } from '../../index-D6Sr4ARD.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* uvd-x402-sdk - SVM Provider (Solana Virtual Machine)
|
|
5
|
+
*
|
|
6
|
+
* Provides wallet connection and payment creation for SVM-based chains via Phantom.
|
|
7
|
+
* Supports: Solana, Fogo
|
|
8
|
+
* Uses partially-signed transactions where the facilitator is the fee payer.
|
|
9
|
+
*
|
|
10
|
+
* @example Solana
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { SVMProvider } from 'uvd-x402-sdk/solana';
|
|
13
|
+
* import { getChainByName } from 'uvd-x402-sdk';
|
|
14
|
+
*
|
|
15
|
+
* const svm = new SVMProvider();
|
|
16
|
+
*
|
|
17
|
+
* // Connect
|
|
18
|
+
* const address = await svm.connect();
|
|
19
|
+
*
|
|
20
|
+
* // Create Solana payment
|
|
21
|
+
* const chainConfig = getChainByName('solana')!;
|
|
22
|
+
* const paymentPayload = await svm.signPayment(paymentInfo, chainConfig);
|
|
23
|
+
* const header = svm.encodePaymentHeader(paymentPayload, chainConfig);
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example Fogo
|
|
27
|
+
* ```ts
|
|
28
|
+
* import { SVMProvider } from 'uvd-x402-sdk/solana';
|
|
29
|
+
* import { getChainByName } from 'uvd-x402-sdk';
|
|
30
|
+
*
|
|
31
|
+
* const svm = new SVMProvider();
|
|
32
|
+
*
|
|
33
|
+
* // Connect (same wallet works for all SVM chains)
|
|
34
|
+
* const address = await svm.connect();
|
|
35
|
+
*
|
|
36
|
+
* // Create Fogo payment
|
|
37
|
+
* const chainConfig = getChainByName('fogo')!;
|
|
38
|
+
* const paymentPayload = await svm.signPayment(paymentInfo, chainConfig);
|
|
39
|
+
* const header = svm.encodePaymentHeader(paymentPayload, chainConfig);
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* SVMProvider - Wallet adapter for SVM chains (Solana, Fogo) via Phantom
|
|
45
|
+
*
|
|
46
|
+
* @alias SolanaProvider for backward compatibility
|
|
47
|
+
*/
|
|
48
|
+
declare class SVMProvider implements WalletAdapter {
|
|
49
|
+
readonly id = "phantom";
|
|
50
|
+
readonly name = "Phantom";
|
|
51
|
+
readonly networkType: "svm";
|
|
52
|
+
private provider;
|
|
53
|
+
private publicKey;
|
|
54
|
+
private connections;
|
|
55
|
+
private address;
|
|
56
|
+
/**
|
|
57
|
+
* Check if Phantom wallet is available
|
|
58
|
+
*/
|
|
59
|
+
isAvailable(): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Connect to Phantom wallet
|
|
62
|
+
*/
|
|
63
|
+
connect(): Promise<string>;
|
|
64
|
+
/**
|
|
65
|
+
* Disconnect from Phantom
|
|
66
|
+
*/
|
|
67
|
+
disconnect(): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Get current address
|
|
70
|
+
*/
|
|
71
|
+
getAddress(): string | null;
|
|
72
|
+
/**
|
|
73
|
+
* Get USDC balance
|
|
74
|
+
*/
|
|
75
|
+
getBalance(chainConfig: ChainConfig): Promise<string>;
|
|
76
|
+
/**
|
|
77
|
+
* Create SVM payment (partially-signed transaction)
|
|
78
|
+
*
|
|
79
|
+
* Works for both Solana and Fogo chains.
|
|
80
|
+
*
|
|
81
|
+
* Transaction structure required by facilitator:
|
|
82
|
+
* 1. SetComputeUnitLimit
|
|
83
|
+
* 2. SetComputeUnitPrice
|
|
84
|
+
* 3. (Optional) CreateAssociatedTokenAccount if recipient ATA doesn't exist
|
|
85
|
+
* 4. TransferChecked (USDC transfer)
|
|
86
|
+
*
|
|
87
|
+
* Fee payer: Facilitator (not user)
|
|
88
|
+
* User pays: ZERO SOL/FOGO
|
|
89
|
+
*/
|
|
90
|
+
signPayment(paymentInfo: PaymentInfo, chainConfig: ChainConfig): Promise<string>;
|
|
91
|
+
/**
|
|
92
|
+
* Encode SVM payment as X-PAYMENT header
|
|
93
|
+
*
|
|
94
|
+
* @param paymentPayload - The payment payload JSON string
|
|
95
|
+
* @param chainConfig - Optional chain config (defaults to 'solana' if not provided)
|
|
96
|
+
*/
|
|
97
|
+
encodePaymentHeader(paymentPayload: string, chainConfig?: ChainConfig): string;
|
|
98
|
+
private getPhantomProvider;
|
|
99
|
+
/**
|
|
100
|
+
* Get or create a connection for a specific chain
|
|
101
|
+
*/
|
|
102
|
+
private getConnection;
|
|
103
|
+
/**
|
|
104
|
+
* @deprecated Use getConnection instead
|
|
105
|
+
*/
|
|
106
|
+
private initConnection;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* @deprecated Use SVMProvider instead
|
|
110
|
+
*/
|
|
111
|
+
declare class SolanaProvider extends SVMProvider {
|
|
112
|
+
constructor();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export { SVMProvider, SolanaProvider, SVMProvider as default };
|