@heyanon/sdk 2.3.3 → 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.
- package/dist/index.js +51 -26
- package/dist/index.mjs +52 -28
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/is-address.d.ts +79 -0
- package/dist/utils/is-address.spec.d.ts +1 -0
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var viem = require('viem');
|
|
4
4
|
var sdk = require('@real-wagmi/sdk');
|
|
5
5
|
var web3_js = require('@solana/web3.js');
|
|
6
|
+
var ton = require('@ton/ton');
|
|
6
7
|
|
|
7
8
|
var __defProp = Object.defineProperty;
|
|
8
9
|
var __export = (target, all) => {
|
|
@@ -38,32 +39,6 @@ function stringify(value, space) {
|
|
|
38
39
|
return JSON.stringify(value, (_key, value2) => typeof value2 === "bigint" ? value2.toString() : value2, space);
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
// src/adapter/transformers/toResult.ts
|
|
42
|
-
function toResult(data, error = false) {
|
|
43
|
-
const formatedData = typeof data === "string" ? data : stringify(data);
|
|
44
|
-
return {
|
|
45
|
-
success: !error,
|
|
46
|
-
data: error ? `ERROR: ${formatedData}` : formatedData
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// src/adapter/misc.ts
|
|
51
|
-
var AdapterTag = /* @__PURE__ */ ((AdapterTag2) => {
|
|
52
|
-
AdapterTag2["ALM"] = "ALM";
|
|
53
|
-
AdapterTag2["STAKE"] = "Stake";
|
|
54
|
-
AdapterTag2["LENDING"] = "Lending";
|
|
55
|
-
AdapterTag2["FARM"] = "Farm";
|
|
56
|
-
AdapterTag2["PERPETUALS"] = "Perpetuals";
|
|
57
|
-
AdapterTag2["BRIDGE"] = "Bridge";
|
|
58
|
-
AdapterTag2["LIMIT_ORDER"] = "Limit orders";
|
|
59
|
-
AdapterTag2["DEX"] = "DEX";
|
|
60
|
-
AdapterTag2["LP"] = "LP";
|
|
61
|
-
AdapterTag2["GAMES"] = "Games";
|
|
62
|
-
AdapterTag2["CEX"] = "CEX";
|
|
63
|
-
AdapterTag2["LAUNCHPAD"] = "Launchpad";
|
|
64
|
-
return AdapterTag2;
|
|
65
|
-
})(AdapterTag || {});
|
|
66
|
-
|
|
67
42
|
// src/blockchain/evm/index.ts
|
|
68
43
|
var evm_exports = {};
|
|
69
44
|
__export(evm_exports, {
|
|
@@ -600,6 +575,55 @@ __export(ton_exports, {
|
|
|
600
575
|
|
|
601
576
|
// src/blockchain/ton/types.ts
|
|
602
577
|
var types_exports3 = {};
|
|
578
|
+
function isAddress(value) {
|
|
579
|
+
let result = { valid: false };
|
|
580
|
+
try {
|
|
581
|
+
result.valid = viem.isAddress(value);
|
|
582
|
+
if (result.valid) {
|
|
583
|
+
result.walletType = "evm" /* EVM */;
|
|
584
|
+
}
|
|
585
|
+
} catch (_error) {
|
|
586
|
+
}
|
|
587
|
+
try {
|
|
588
|
+
solana_exports.utils.toPublicKey(value);
|
|
589
|
+
result.valid = true;
|
|
590
|
+
result.walletType = "solana" /* SOLANA */;
|
|
591
|
+
} catch (_error) {
|
|
592
|
+
}
|
|
593
|
+
try {
|
|
594
|
+
ton.Address.parse(value);
|
|
595
|
+
result.valid = true;
|
|
596
|
+
result.walletType = "ton" /* TON */;
|
|
597
|
+
} catch (_error) {
|
|
598
|
+
}
|
|
599
|
+
return result;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
// src/adapter/transformers/toResult.ts
|
|
603
|
+
function toResult(data, error = false) {
|
|
604
|
+
const formatedData = typeof data === "string" ? data : stringify(data);
|
|
605
|
+
return {
|
|
606
|
+
success: !error,
|
|
607
|
+
data: error ? `ERROR: ${formatedData}` : formatedData
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
// src/adapter/misc.ts
|
|
612
|
+
var AdapterTag = /* @__PURE__ */ ((AdapterTag2) => {
|
|
613
|
+
AdapterTag2["ALM"] = "ALM";
|
|
614
|
+
AdapterTag2["STAKE"] = "Stake";
|
|
615
|
+
AdapterTag2["LENDING"] = "Lending";
|
|
616
|
+
AdapterTag2["FARM"] = "Farm";
|
|
617
|
+
AdapterTag2["PERPETUALS"] = "Perpetuals";
|
|
618
|
+
AdapterTag2["BRIDGE"] = "Bridge";
|
|
619
|
+
AdapterTag2["LIMIT_ORDER"] = "Limit orders";
|
|
620
|
+
AdapterTag2["DEX"] = "DEX";
|
|
621
|
+
AdapterTag2["LP"] = "LP";
|
|
622
|
+
AdapterTag2["GAMES"] = "Games";
|
|
623
|
+
AdapterTag2["CEX"] = "CEX";
|
|
624
|
+
AdapterTag2["LAUNCHPAD"] = "Launchpad";
|
|
625
|
+
return AdapterTag2;
|
|
626
|
+
})(AdapterTag || {});
|
|
603
627
|
|
|
604
628
|
exports.AdapterTag = AdapterTag;
|
|
605
629
|
exports.Chain = Chain;
|
|
@@ -609,6 +633,7 @@ exports.TON = ton_exports;
|
|
|
609
633
|
exports.WalletType = WalletType;
|
|
610
634
|
exports.allChains = allChains;
|
|
611
635
|
exports.allEvmChains = allEvmChains;
|
|
636
|
+
exports.isAddress = isAddress;
|
|
612
637
|
exports.retry = retry;
|
|
613
638
|
exports.sleep = sleep;
|
|
614
639
|
exports.stringify = stringify;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { erc20Abi, getAddress, encodeFunctionData } from 'viem';
|
|
1
|
+
import { erc20Abi, getAddress, encodeFunctionData, isAddress as isAddress$1 } from 'viem';
|
|
2
2
|
import { ethereumTokens, optimismTokens, bscTokens, polygonTokens, zkSyncTokens, kavaTokens, avalancheTokens, arbitrumTokens, metisTokens, baseTokens, sonicTokens, Token } from '@real-wagmi/sdk';
|
|
3
3
|
import { TransactionMessage, VersionedTransaction, PublicKey } from '@solana/web3.js';
|
|
4
|
+
import { Address } from '@ton/ton';
|
|
4
5
|
|
|
5
6
|
var __defProp = Object.defineProperty;
|
|
6
7
|
var __export = (target, all) => {
|
|
@@ -36,32 +37,6 @@ function stringify(value, space) {
|
|
|
36
37
|
return JSON.stringify(value, (_key, value2) => typeof value2 === "bigint" ? value2.toString() : value2, space);
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
// src/adapter/transformers/toResult.ts
|
|
40
|
-
function toResult(data, error = false) {
|
|
41
|
-
const formatedData = typeof data === "string" ? data : stringify(data);
|
|
42
|
-
return {
|
|
43
|
-
success: !error,
|
|
44
|
-
data: error ? `ERROR: ${formatedData}` : formatedData
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// src/adapter/misc.ts
|
|
49
|
-
var AdapterTag = /* @__PURE__ */ ((AdapterTag2) => {
|
|
50
|
-
AdapterTag2["ALM"] = "ALM";
|
|
51
|
-
AdapterTag2["STAKE"] = "Stake";
|
|
52
|
-
AdapterTag2["LENDING"] = "Lending";
|
|
53
|
-
AdapterTag2["FARM"] = "Farm";
|
|
54
|
-
AdapterTag2["PERPETUALS"] = "Perpetuals";
|
|
55
|
-
AdapterTag2["BRIDGE"] = "Bridge";
|
|
56
|
-
AdapterTag2["LIMIT_ORDER"] = "Limit orders";
|
|
57
|
-
AdapterTag2["DEX"] = "DEX";
|
|
58
|
-
AdapterTag2["LP"] = "LP";
|
|
59
|
-
AdapterTag2["GAMES"] = "Games";
|
|
60
|
-
AdapterTag2["CEX"] = "CEX";
|
|
61
|
-
AdapterTag2["LAUNCHPAD"] = "Launchpad";
|
|
62
|
-
return AdapterTag2;
|
|
63
|
-
})(AdapterTag || {});
|
|
64
|
-
|
|
65
40
|
// src/blockchain/evm/index.ts
|
|
66
41
|
var evm_exports = {};
|
|
67
42
|
__export(evm_exports, {
|
|
@@ -598,5 +573,54 @@ __export(ton_exports, {
|
|
|
598
573
|
|
|
599
574
|
// src/blockchain/ton/types.ts
|
|
600
575
|
var types_exports3 = {};
|
|
576
|
+
function isAddress(value) {
|
|
577
|
+
let result = { valid: false };
|
|
578
|
+
try {
|
|
579
|
+
result.valid = isAddress$1(value);
|
|
580
|
+
if (result.valid) {
|
|
581
|
+
result.walletType = "evm" /* EVM */;
|
|
582
|
+
}
|
|
583
|
+
} catch (_error) {
|
|
584
|
+
}
|
|
585
|
+
try {
|
|
586
|
+
solana_exports.utils.toPublicKey(value);
|
|
587
|
+
result.valid = true;
|
|
588
|
+
result.walletType = "solana" /* SOLANA */;
|
|
589
|
+
} catch (_error) {
|
|
590
|
+
}
|
|
591
|
+
try {
|
|
592
|
+
Address.parse(value);
|
|
593
|
+
result.valid = true;
|
|
594
|
+
result.walletType = "ton" /* TON */;
|
|
595
|
+
} catch (_error) {
|
|
596
|
+
}
|
|
597
|
+
return result;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
// src/adapter/transformers/toResult.ts
|
|
601
|
+
function toResult(data, error = false) {
|
|
602
|
+
const formatedData = typeof data === "string" ? data : stringify(data);
|
|
603
|
+
return {
|
|
604
|
+
success: !error,
|
|
605
|
+
data: error ? `ERROR: ${formatedData}` : formatedData
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
// src/adapter/misc.ts
|
|
610
|
+
var AdapterTag = /* @__PURE__ */ ((AdapterTag2) => {
|
|
611
|
+
AdapterTag2["ALM"] = "ALM";
|
|
612
|
+
AdapterTag2["STAKE"] = "Stake";
|
|
613
|
+
AdapterTag2["LENDING"] = "Lending";
|
|
614
|
+
AdapterTag2["FARM"] = "Farm";
|
|
615
|
+
AdapterTag2["PERPETUALS"] = "Perpetuals";
|
|
616
|
+
AdapterTag2["BRIDGE"] = "Bridge";
|
|
617
|
+
AdapterTag2["LIMIT_ORDER"] = "Limit orders";
|
|
618
|
+
AdapterTag2["DEX"] = "DEX";
|
|
619
|
+
AdapterTag2["LP"] = "LP";
|
|
620
|
+
AdapterTag2["GAMES"] = "Games";
|
|
621
|
+
AdapterTag2["CEX"] = "CEX";
|
|
622
|
+
AdapterTag2["LAUNCHPAD"] = "Launchpad";
|
|
623
|
+
return AdapterTag2;
|
|
624
|
+
})(AdapterTag || {});
|
|
601
625
|
|
|
602
|
-
export { AdapterTag, Chain, evm_exports as EVM, solana_exports as Solana, ton_exports as TON, WalletType, allChains, allEvmChains, retry, sleep, stringify, toResult };
|
|
626
|
+
export { AdapterTag, Chain, evm_exports as EVM, solana_exports as Solana, ton_exports as TON, WalletType, allChains, allEvmChains, isAddress, retry, sleep, stringify, toResult };
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { WalletType } from '../blockchain';
|
|
2
|
+
/**
|
|
3
|
+
* Result object returned by the isAddress function
|
|
4
|
+
* @interface IsAddressResult
|
|
5
|
+
*/
|
|
6
|
+
interface IsAddressResult {
|
|
7
|
+
/** Whether the address is valid for any supported blockchain */
|
|
8
|
+
valid: boolean;
|
|
9
|
+
/** The type of wallet/blockchain the address belongs to (EVM, Solana, or TON) */
|
|
10
|
+
walletType?: WalletType;
|
|
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
|
+
*/
|
|
78
|
+
export declare function isAddress(value: string): IsAddressResult;
|
|
79
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heyanon/sdk",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"@ton-api/client": "0.3.1",
|
|
47
47
|
"@ton-api/ton-adapter": "0.3.0",
|
|
48
48
|
"@ton/core": "0.60.0",
|
|
49
|
+
"@ton/crypto": "^3.3.0",
|
|
49
50
|
"@ton/ton": "15.2.0",
|
|
50
51
|
"ccxt": "4.4.78",
|
|
51
52
|
"openai": "5.12.1",
|