@heyanon/sdk 2.3.4 → 2.3.5

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.
@@ -1,7 +1,79 @@
1
1
  import { WalletType } from '../blockchain';
2
+ /**
3
+ * Result object returned by the isAddress function
4
+ * @interface IsAddressResult
5
+ */
2
6
  interface IsAddressResult {
7
+ /** Whether the address is valid for any supported blockchain */
3
8
  valid: boolean;
9
+ /** The type of wallet/blockchain the address belongs to (EVM, Solana, or TON) */
4
10
  walletType?: WalletType;
5
11
  }
12
+ /**
13
+ * Validates a blockchain address and determines its type across multiple blockchain networks
14
+ *
15
+ * This function checks if a given string is a valid blockchain address for any of the
16
+ * supported networks: EVM-compatible chains (Ethereum, Polygon, BSC, etc.), Solana, or TON.
17
+ * It returns both the validation result and the detected wallet type.
18
+ *
19
+ * @param value - The address string to validate
20
+ * @returns Object containing validation result and wallet type
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * // EVM address validation
25
+ * const evmResult = isAddress('0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb0');
26
+ * // Returns: { valid: true, walletType: WalletType.EVM }
27
+ *
28
+ * // Solana address validation
29
+ * const solanaResult = isAddress('DYw8jCTfwHNRJhhmFcbXvVDTqWMEVFBX6ZKUmG5CNSKK');
30
+ * // Returns: { valid: true, walletType: WalletType.SOLANA }
31
+ *
32
+ * // TON address validation
33
+ * const tonResult = isAddress('EQD4FPq-PRDieyQKkizFTRtSDyucUIqrj0v_zXJmqaDp6_0t');
34
+ * // Returns: { valid: true, walletType: WalletType.TON }
35
+ *
36
+ * // Invalid address
37
+ * const invalidResult = isAddress('invalid-address');
38
+ * // Returns: { valid: false }
39
+ *
40
+ * // Routing transactions based on address type
41
+ * async function sendTokens(recipientAddress: string, amount: bigint) {
42
+ * const { valid, walletType } = isAddress(recipientAddress);
43
+ *
44
+ * if (!valid) {
45
+ * throw new Error('Invalid recipient address');
46
+ * }
47
+ *
48
+ * switch (walletType) {
49
+ * case WalletType.EVM:
50
+ * return await options.evm.sendTransactions({
51
+ * transactions: [{ to: recipientAddress, value: amount }]
52
+ * });
53
+ *
54
+ * case WalletType.SOLANA:
55
+ * return await options.solana.sendTransactions({
56
+ * transactions: [{ instructions: [...] }]
57
+ * });
58
+ *
59
+ * case WalletType.TON:
60
+ * return await options.ton.sendTransactions({
61
+ * transactions: [{ to: recipientAddress, value: amount }]
62
+ * });
63
+ * }
64
+ * }
65
+ *
66
+ * // User input validation
67
+ * function validateUserInput(userAddress: string) {
68
+ * const { valid, walletType } = isAddress(userAddress);
69
+ *
70
+ * if (!valid) {
71
+ * return { success: false, error: 'Invalid address format' };
72
+ * }
73
+ *
74
+ * return { success: true, walletType, address: userAddress };
75
+ * }
76
+ * ```
77
+ */
6
78
  export declare function isAddress(value: string): IsAddressResult;
7
79
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heyanon/sdk",
3
- "version": "2.3.4",
3
+ "version": "2.3.5",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",