@heyanon/sdk 2.3.5 → 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 +3 -3
- package/dist/index.mjs +3 -3
- package/dist/utils/is-address.d.ts +11 -11
- package/package.json +1 -1
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
594
|
+
result.type = "ton" /* TON */;
|
|
595
595
|
} catch (_error) {
|
|
596
596
|
}
|
|
597
597
|
return result;
|
|
@@ -7,7 +7,7 @@ interface IsAddressResult {
|
|
|
7
7
|
/** Whether the address is valid for any supported blockchain */
|
|
8
8
|
valid: boolean;
|
|
9
9
|
/** The type of wallet/blockchain the address belongs to (EVM, Solana, or TON) */
|
|
10
|
-
|
|
10
|
+
type?: WalletType;
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* Validates a blockchain address and determines its type across multiple blockchain networks
|
|
@@ -23,15 +23,15 @@ interface IsAddressResult {
|
|
|
23
23
|
* ```typescript
|
|
24
24
|
* // EVM address validation
|
|
25
25
|
* const evmResult = isAddress('0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb0');
|
|
26
|
-
* // Returns: { valid: true,
|
|
26
|
+
* // Returns: { valid: true, type: WalletType.EVM }
|
|
27
27
|
*
|
|
28
28
|
* // Solana address validation
|
|
29
29
|
* const solanaResult = isAddress('DYw8jCTfwHNRJhhmFcbXvVDTqWMEVFBX6ZKUmG5CNSKK');
|
|
30
|
-
* // Returns: { valid: true,
|
|
30
|
+
* // Returns: { valid: true, type: WalletType.SOLANA }
|
|
31
31
|
*
|
|
32
32
|
* // TON address validation
|
|
33
33
|
* const tonResult = isAddress('EQD4FPq-PRDieyQKkizFTRtSDyucUIqrj0v_zXJmqaDp6_0t');
|
|
34
|
-
* // Returns: { valid: true,
|
|
34
|
+
* // Returns: { valid: true, type: WalletType.TON }
|
|
35
35
|
*
|
|
36
36
|
* // Invalid address
|
|
37
37
|
* const invalidResult = isAddress('invalid-address');
|
|
@@ -39,24 +39,24 @@ interface IsAddressResult {
|
|
|
39
39
|
*
|
|
40
40
|
* // Routing transactions based on address type
|
|
41
41
|
* async function sendTokens(recipientAddress: string, amount: bigint) {
|
|
42
|
-
* const { valid,
|
|
42
|
+
* const { valid, type } = isAddress(recipientAddress);
|
|
43
43
|
*
|
|
44
44
|
* if (!valid) {
|
|
45
45
|
* throw new Error('Invalid recipient address');
|
|
46
46
|
* }
|
|
47
47
|
*
|
|
48
|
-
* switch (
|
|
49
|
-
* case
|
|
48
|
+
* switch (type) {
|
|
49
|
+
* case type.EVM:
|
|
50
50
|
* return await options.evm.sendTransactions({
|
|
51
51
|
* transactions: [{ to: recipientAddress, value: amount }]
|
|
52
52
|
* });
|
|
53
53
|
*
|
|
54
|
-
* case
|
|
54
|
+
* case type.SOLANA:
|
|
55
55
|
* return await options.solana.sendTransactions({
|
|
56
56
|
* transactions: [{ instructions: [...] }]
|
|
57
57
|
* });
|
|
58
58
|
*
|
|
59
|
-
* case
|
|
59
|
+
* case type.TON:
|
|
60
60
|
* return await options.ton.sendTransactions({
|
|
61
61
|
* transactions: [{ to: recipientAddress, value: amount }]
|
|
62
62
|
* });
|
|
@@ -65,13 +65,13 @@ interface IsAddressResult {
|
|
|
65
65
|
*
|
|
66
66
|
* // User input validation
|
|
67
67
|
* function validateUserInput(userAddress: string) {
|
|
68
|
-
* const { valid,
|
|
68
|
+
* const { valid, type } = isAddress(userAddress);
|
|
69
69
|
*
|
|
70
70
|
* if (!valid) {
|
|
71
71
|
* return { success: false, error: 'Invalid address format' };
|
|
72
72
|
* }
|
|
73
73
|
*
|
|
74
|
-
* return { success: true,
|
|
74
|
+
* return { success: true, type, address: userAddress };
|
|
75
75
|
* }
|
|
76
76
|
* ```
|
|
77
77
|
*/
|