@heyanon/sdk 2.3.4 → 2.3.6

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/dist/index.js CHANGED
@@ -580,20 +580,20 @@ function isAddress(value) {
580
580
  try {
581
581
  result.valid = viem.isAddress(value);
582
582
  if (result.valid) {
583
- result.walletType = "evm" /* EVM */;
583
+ result.type = "evm" /* EVM */;
584
584
  }
585
585
  } catch (_error) {
586
586
  }
587
587
  try {
588
588
  solana_exports.utils.toPublicKey(value);
589
589
  result.valid = true;
590
- result.walletType = "solana" /* SOLANA */;
590
+ result.type = "solana" /* SOLANA */;
591
591
  } catch (_error) {
592
592
  }
593
593
  try {
594
594
  ton.Address.parse(value);
595
595
  result.valid = true;
596
- result.walletType = "ton" /* TON */;
596
+ result.type = "ton" /* TON */;
597
597
  } catch (_error) {
598
598
  }
599
599
  return result;
package/dist/index.mjs CHANGED
@@ -578,20 +578,20 @@ function isAddress(value) {
578
578
  try {
579
579
  result.valid = isAddress$1(value);
580
580
  if (result.valid) {
581
- result.walletType = "evm" /* EVM */;
581
+ result.type = "evm" /* EVM */;
582
582
  }
583
583
  } catch (_error) {
584
584
  }
585
585
  try {
586
586
  solana_exports.utils.toPublicKey(value);
587
587
  result.valid = true;
588
- result.walletType = "solana" /* SOLANA */;
588
+ result.type = "solana" /* SOLANA */;
589
589
  } catch (_error) {
590
590
  }
591
591
  try {
592
592
  Address.parse(value);
593
593
  result.valid = true;
594
- result.walletType = "ton" /* TON */;
594
+ result.type = "ton" /* TON */;
595
595
  } catch (_error) {
596
596
  }
597
597
  return result;
@@ -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;
4
- walletType?: WalletType;
9
+ /** The type of wallet/blockchain the address belongs to (EVM, Solana, or TON) */
10
+ type?: 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, type: WalletType.EVM }
27
+ *
28
+ * // Solana address validation
29
+ * const solanaResult = isAddress('DYw8jCTfwHNRJhhmFcbXvVDTqWMEVFBX6ZKUmG5CNSKK');
30
+ * // Returns: { valid: true, type: WalletType.SOLANA }
31
+ *
32
+ * // TON address validation
33
+ * const tonResult = isAddress('EQD4FPq-PRDieyQKkizFTRtSDyucUIqrj0v_zXJmqaDp6_0t');
34
+ * // Returns: { valid: true, type: 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, type } = isAddress(recipientAddress);
43
+ *
44
+ * if (!valid) {
45
+ * throw new Error('Invalid recipient address');
46
+ * }
47
+ *
48
+ * switch (type) {
49
+ * case type.EVM:
50
+ * return await options.evm.sendTransactions({
51
+ * transactions: [{ to: recipientAddress, value: amount }]
52
+ * });
53
+ *
54
+ * case type.SOLANA:
55
+ * return await options.solana.sendTransactions({
56
+ * transactions: [{ instructions: [...] }]
57
+ * });
58
+ *
59
+ * case type.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, type } = isAddress(userAddress);
69
+ *
70
+ * if (!valid) {
71
+ * return { success: false, error: 'Invalid address format' };
72
+ * }
73
+ *
74
+ * return { success: true, type, 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.6",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",