@voyage_ai/v402-web-ts 0.2.1 → 1.0.0

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 CHANGED
@@ -868,9 +868,12 @@ const response = await handleEvmPayment(endpoint, {
868
868
  ```json
869
869
  {
870
870
  "react": ">=18.0.0",
871
- "@solana/web3.js": "^1.95.0",
872
- "@solana/spl-token": "^0.4.0",
873
- "antd": "^5.0.0" // For V402Checkout component
871
+ "@solana/kit": "^3.0.0",
872
+ "@solana-program/token": "^0.6.0",
873
+ "@solana-program/token-2022": "^0.4.0",
874
+ "@solana-program/compute-budget": "^0.8.0",
875
+ "@solana-program/system": "^0.8.0",
876
+ "antd": "^5.0.0"
874
877
  }
875
878
  ```
876
879
 
@@ -878,13 +881,14 @@ const response = await handleEvmPayment(endpoint, {
878
881
 
879
882
  ```json
880
883
  {
881
- "ethers": "^6.0.0" // Only needed if using EVM networks
884
+ "ethers": "^6.0.0"
882
885
  }
883
886
  ```
884
887
 
885
888
  **Note**:
886
889
  - If you only use `V402Checkout` component, all dependencies are included
887
890
  - For custom integration, install only the wallets you need (Solana or EVM)
891
+ - Solana dependencies use the new `@solana/kit` unified SDK for better performance and smaller bundle size
888
892
 
889
893
  ## 🤝 Contributing
890
894
 
package/dist/index.d.mts CHANGED
@@ -1,23 +1,21 @@
1
1
  import { PaymentRequirements } from 'x402/types';
2
2
  export { PaymentRequirements, SPLTokenAmount, SettleResponse, VerifyResponse, x402Response } from 'x402/types';
3
- import { VersionedTransaction } from '@solana/web3.js';
4
3
  import { z } from 'zod';
5
4
 
6
5
  /**
7
6
  * Common types for x402 SDK
8
7
  * Framework-agnostic types that work across different wallet implementations
9
8
  */
10
-
11
9
  /**
12
10
  * Generic wallet adapter interface - works with any wallet provider
13
- * Compatible with Anza wallet-adapter, Privy, and custom implementations
11
+ * Compatible with Anza wallet-adapter, Privy, @solana/kit, and custom implementations
14
12
  */
15
13
  interface WalletAdapter {
16
14
  publicKey?: {
17
15
  toString(): string;
18
16
  };
19
17
  address?: string;
20
- signTransaction: (tx: VersionedTransaction) => Promise<VersionedTransaction>;
18
+ signTransaction: <T>(tx: T) => Promise<T>;
21
19
  }
22
20
  /**
23
21
  * EVM wallet adapter interface
@@ -235,6 +233,8 @@ declare function getChainId(network: string): number;
235
233
  *
236
234
  * Low-level API: Creates X-PAYMENT header for Solana transactions
237
235
  * Use this when you want to build the payment header yourself and handle fetch separately
236
+ *
237
+ * Uses @solana/web3.js and @solana/spl-token packages
238
238
  */
239
239
 
240
240
  /**
@@ -443,6 +443,7 @@ declare function getWalletDisplayName(networkType: NetworkType): string;
443
443
  * @param networkType - Network type (from useWallet)
444
444
  * @param merchantId - @see our website to apply
445
445
  * @param additionalParams - Optional additional parameters to send with the request (default: {})
446
+ * @param expectedAddress - Optional expected wallet address for validation
446
447
  * @returns Response from the payment
447
448
  *
448
449
  * @example
@@ -453,16 +454,17 @@ declare function getWalletDisplayName(networkType: NetworkType): string;
453
454
  *
454
455
  * @example
455
456
  * ```tsx
456
- * // With additional parameters
457
+ * // With additional parameters and address validation
457
458
  * const response = await makePayment(
458
459
  * '/api/endpoint',
459
460
  * networkType,
460
461
  * merchantId,
461
- * { userId: '123', customField: 'value' }
462
+ * { userId: '123', customField: 'value' },
463
+ * walletAddress // Pass the expected address for validation
462
464
  * );
463
465
  * ```
464
466
  */
465
- declare function makePayment(networkType: NetworkType, merchantId: string, endpoint?: string, additionalParams?: Record<string, any>): Promise<Response>;
467
+ declare function makePayment(networkType: NetworkType, merchantId: string, endpoint?: string, additionalParams?: Record<string, any>, expectedAddress?: string): Promise<Response>;
466
468
 
467
469
  /**
468
470
  * Network utilities
package/dist/index.d.ts CHANGED
@@ -1,23 +1,21 @@
1
1
  import { PaymentRequirements } from 'x402/types';
2
2
  export { PaymentRequirements, SPLTokenAmount, SettleResponse, VerifyResponse, x402Response } from 'x402/types';
3
- import { VersionedTransaction } from '@solana/web3.js';
4
3
  import { z } from 'zod';
5
4
 
6
5
  /**
7
6
  * Common types for x402 SDK
8
7
  * Framework-agnostic types that work across different wallet implementations
9
8
  */
10
-
11
9
  /**
12
10
  * Generic wallet adapter interface - works with any wallet provider
13
- * Compatible with Anza wallet-adapter, Privy, and custom implementations
11
+ * Compatible with Anza wallet-adapter, Privy, @solana/kit, and custom implementations
14
12
  */
15
13
  interface WalletAdapter {
16
14
  publicKey?: {
17
15
  toString(): string;
18
16
  };
19
17
  address?: string;
20
- signTransaction: (tx: VersionedTransaction) => Promise<VersionedTransaction>;
18
+ signTransaction: <T>(tx: T) => Promise<T>;
21
19
  }
22
20
  /**
23
21
  * EVM wallet adapter interface
@@ -235,6 +233,8 @@ declare function getChainId(network: string): number;
235
233
  *
236
234
  * Low-level API: Creates X-PAYMENT header for Solana transactions
237
235
  * Use this when you want to build the payment header yourself and handle fetch separately
236
+ *
237
+ * Uses @solana/web3.js and @solana/spl-token packages
238
238
  */
239
239
 
240
240
  /**
@@ -443,6 +443,7 @@ declare function getWalletDisplayName(networkType: NetworkType): string;
443
443
  * @param networkType - Network type (from useWallet)
444
444
  * @param merchantId - @see our website to apply
445
445
  * @param additionalParams - Optional additional parameters to send with the request (default: {})
446
+ * @param expectedAddress - Optional expected wallet address for validation
446
447
  * @returns Response from the payment
447
448
  *
448
449
  * @example
@@ -453,16 +454,17 @@ declare function getWalletDisplayName(networkType: NetworkType): string;
453
454
  *
454
455
  * @example
455
456
  * ```tsx
456
- * // With additional parameters
457
+ * // With additional parameters and address validation
457
458
  * const response = await makePayment(
458
459
  * '/api/endpoint',
459
460
  * networkType,
460
461
  * merchantId,
461
- * { userId: '123', customField: 'value' }
462
+ * { userId: '123', customField: 'value' },
463
+ * walletAddress // Pass the expected address for validation
462
464
  * );
463
465
  * ```
464
466
  */
465
- declare function makePayment(networkType: NetworkType, merchantId: string, endpoint?: string, additionalParams?: Record<string, any>): Promise<Response>;
467
+ declare function makePayment(networkType: NetworkType, merchantId: string, endpoint?: string, additionalParams?: Record<string, any>, expectedAddress?: string): Promise<Response>;
466
468
 
467
469
  /**
468
470
  * Network utilities