@heyanon/sdk 2.3.1 → 2.3.3
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/adapter/misc.d.ts +35 -0
- package/dist/adapter/transformers/toResult.d.ts +24 -0
- package/dist/adapter/types.d.ts +123 -7
- package/dist/blockchain/constants/chains.d.ts +96 -2
- package/dist/blockchain/constants/types.d.ts +33 -0
- package/dist/blockchain/evm/constants/chains.d.ts +57 -0
- package/dist/blockchain/evm/constants/misc.d.ts +69 -0
- package/dist/blockchain/evm/constants/weth9.d.ts +77 -1
- package/dist/blockchain/evm/types.d.ts +273 -0
- package/dist/blockchain/evm/utils/checkToApprove.d.ts +86 -0
- package/dist/blockchain/evm/utils/getChainFromName.d.ts +81 -0
- package/dist/blockchain/evm/utils/getChainName.d.ts +114 -0
- package/dist/blockchain/evm/utils/getUnwrapData.d.ts +114 -0
- package/dist/blockchain/evm/utils/getWrapAddress.d.ts +147 -0
- package/dist/blockchain/evm/utils/getWrapData.d.ts +189 -0
- package/dist/blockchain/evm/utils/getWrappedNative.d.ts +198 -0
- package/dist/blockchain/evm/utils/isEvmChain.d.ts +183 -0
- package/dist/blockchain/evm/utils/isNativeAddress.d.ts +221 -0
- package/dist/blockchain/evm/utils/isNativeAddress.test.d.ts +1 -0
- package/dist/blockchain/solana/types.d.ts +291 -0
- package/dist/blockchain/solana/utils/buildV0Transaction.d.ts +184 -0
- package/dist/blockchain/solana/utils/toPublicKey.d.ts +194 -0
- package/dist/blockchain/ton/types.d.ts +410 -0
- package/dist/index.js +37 -2
- package/dist/index.mjs +37 -2
- package/dist/utils/retry.d.ts +218 -0
- package/dist/utils/sleep.d.ts +239 -0
- package/dist/utils/stringify.d.ts +235 -0
- package/dist/utils/stringify.spec.d.ts +1 -0
- package/package.json +1 -1
|
@@ -2,20 +2,430 @@ import { SenderArguments } from '@ton/core';
|
|
|
2
2
|
import { TonApiClient } from '@ton-api/client';
|
|
3
3
|
import { ContractAdapter } from '@ton-api/ton-adapter';
|
|
4
4
|
import { Address, TonClient, TonClient4 } from '@ton/ton';
|
|
5
|
+
/**
|
|
6
|
+
* Data returned for each executed TON transaction
|
|
7
|
+
* @interface TransactionReturnData
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* // Successful transaction result
|
|
11
|
+
* const successData: TransactionReturnData = {
|
|
12
|
+
* message: "Transaction confirmed",
|
|
13
|
+
* hash: "a1b2c3d4e5f6789012345678901234567890abcdef1234567890abcdef123456"
|
|
14
|
+
* };
|
|
15
|
+
*
|
|
16
|
+
* // Failed transaction result
|
|
17
|
+
* const failedData: TransactionReturnData = {
|
|
18
|
+
* message: "Transaction failed: Insufficient balance",
|
|
19
|
+
* hash: "b2c3d4e5f6789012345678901234567890abcdef1234567890abcdef1234567a"
|
|
20
|
+
* };
|
|
21
|
+
*
|
|
22
|
+
* // Process transaction result
|
|
23
|
+
* function handleTonTransactionResult(result: TransactionReturnData) {
|
|
24
|
+
* console.log(`Status: ${result.message}`);
|
|
25
|
+
* console.log(`Transaction: https://tonscan.org/tx/${result.hash}`);
|
|
26
|
+
*
|
|
27
|
+
* if (result.message.includes('confirmed')) {
|
|
28
|
+
* // Handle success
|
|
29
|
+
* showSuccessNotification(`Transaction confirmed: ${result.hash}`);
|
|
30
|
+
* } else {
|
|
31
|
+
* // Handle error
|
|
32
|
+
* showErrorNotification(result.message);
|
|
33
|
+
* }
|
|
34
|
+
* }
|
|
35
|
+
*
|
|
36
|
+
* // Extract transaction details
|
|
37
|
+
* function parseTransactionResult(result: TransactionReturnData) {
|
|
38
|
+
* return {
|
|
39
|
+
* isSuccess: result.message.includes('confirmed') || result.message.includes('successful'),
|
|
40
|
+
* transactionId: result.hash,
|
|
41
|
+
* explorerUrl: `https://tonscan.org/tx/${result.hash}`,
|
|
42
|
+
* statusMessage: result.message
|
|
43
|
+
* };
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
5
47
|
export interface TransactionReturnData {
|
|
48
|
+
/** Status message or error description */
|
|
6
49
|
readonly message: string;
|
|
50
|
+
/** Transaction hash on TON blockchain */
|
|
7
51
|
readonly hash: string;
|
|
8
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Complete result of TON transaction execution containing all transaction results
|
|
55
|
+
* @interface TransactionReturn
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* // Batch transaction result
|
|
59
|
+
* const batchResult: TransactionReturn = {
|
|
60
|
+
* data: [
|
|
61
|
+
* {
|
|
62
|
+
* message: "TON transfer confirmed",
|
|
63
|
+
* hash: "a1b2c3d4e5f6789012345678901234567890abcdef1234567890abcdef123456"
|
|
64
|
+
* },
|
|
65
|
+
* {
|
|
66
|
+
* message: "Jetton transfer completed",
|
|
67
|
+
* hash: "b2c3d4e5f6789012345678901234567890abcdef1234567890abcdef1234567a"
|
|
68
|
+
* }
|
|
69
|
+
* ]
|
|
70
|
+
* };
|
|
71
|
+
*
|
|
72
|
+
* // Single transaction result
|
|
73
|
+
* const singleResult: TransactionReturn = {
|
|
74
|
+
* data: [{
|
|
75
|
+
* message: "Smart contract deployment successful",
|
|
76
|
+
* hash: "c3d4e5f6789012345678901234567890abcdef1234567890abcdef1234567ab2"
|
|
77
|
+
* }]
|
|
78
|
+
* };
|
|
79
|
+
*
|
|
80
|
+
* // Process all results
|
|
81
|
+
* function processTonBatchResults(result: TransactionReturn) {
|
|
82
|
+
* const successful = result.data.filter(tx =>
|
|
83
|
+
* tx.message.includes('confirmed') ||
|
|
84
|
+
* tx.message.includes('successful') ||
|
|
85
|
+
* tx.message.includes('completed')
|
|
86
|
+
* );
|
|
87
|
+
*
|
|
88
|
+
* const failed = result.data.filter(tx =>
|
|
89
|
+
* tx.message.includes('failed') ||
|
|
90
|
+
* tx.message.includes('error') ||
|
|
91
|
+
* tx.message.includes('rejected')
|
|
92
|
+
* );
|
|
93
|
+
*
|
|
94
|
+
* console.log(`TON Transactions - Successful: ${successful.length}, Failed: ${failed.length}`);
|
|
95
|
+
*
|
|
96
|
+
* // Create comprehensive summary
|
|
97
|
+
* return {
|
|
98
|
+
* totalTransactions: result.data.length,
|
|
99
|
+
* successCount: successful.length,
|
|
100
|
+
* failureCount: failed.length,
|
|
101
|
+
* successfulHashes: successful.map(tx => tx.hash),
|
|
102
|
+
* failedHashes: failed.map(tx => tx.hash),
|
|
103
|
+
* explorerLinks: result.data.map(tx => `https://tonscan.org/tx/${tx.hash}`)
|
|
104
|
+
* };
|
|
105
|
+
* }
|
|
106
|
+
*
|
|
107
|
+
* // Calculate transaction fees
|
|
108
|
+
* async function calculateTransactionCosts(result: TransactionReturn, client: Client) {
|
|
109
|
+
* const costs = await Promise.all(
|
|
110
|
+
* result.data.map(async (tx) => {
|
|
111
|
+
* try {
|
|
112
|
+
* const txData = await client.api.blockchain.getBlockchainTransaction(tx.hash);
|
|
113
|
+
* return {
|
|
114
|
+
* hash: tx.hash,
|
|
115
|
+
* fee: txData.fee.total,
|
|
116
|
+
* success: tx.message.includes('confirmed')
|
|
117
|
+
* };
|
|
118
|
+
* } catch (error) {
|
|
119
|
+
* return {
|
|
120
|
+
* hash: tx.hash,
|
|
121
|
+
* fee: 0,
|
|
122
|
+
* success: false,
|
|
123
|
+
* error: error.message
|
|
124
|
+
* };
|
|
125
|
+
* }
|
|
126
|
+
* })
|
|
127
|
+
* );
|
|
128
|
+
*
|
|
129
|
+
* return costs;
|
|
130
|
+
* }
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
9
133
|
export interface TransactionReturn {
|
|
134
|
+
/** Array of transaction results */
|
|
10
135
|
readonly data: TransactionReturnData[];
|
|
11
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* Properties for sending one or multiple TON transactions
|
|
139
|
+
* @interface SendTransactionProps
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* // Simple TON transfer
|
|
143
|
+
* const transferProps: SendTransactionProps = {
|
|
144
|
+
* account: Address.parse('EQD4FPq-PRDieyQKkizFTRtSDyucUIqrj0v_zXJmqaDp6_0t'),
|
|
145
|
+
* transactions: [{
|
|
146
|
+
* to: Address.parse('EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N'),
|
|
147
|
+
* value: toNano('1'), // 1 TON
|
|
148
|
+
* body: beginCell().endCell(), // Empty body for simple transfer
|
|
149
|
+
* bounce: false
|
|
150
|
+
* }]
|
|
151
|
+
* };
|
|
152
|
+
*
|
|
153
|
+
* // Jetton (TON token) transfer
|
|
154
|
+
* const jettonTransferProps: SendTransactionProps = {
|
|
155
|
+
* account: senderAddress,
|
|
156
|
+
* transactions: [{
|
|
157
|
+
* to: jettonWalletAddress,
|
|
158
|
+
* value: toNano('0.1'), // Gas fee
|
|
159
|
+
* body: beginCell()
|
|
160
|
+
* .storeUint(0xf8a7ea5, 32) // Jetton transfer opcode
|
|
161
|
+
* .storeUint(0, 64) // Query ID
|
|
162
|
+
* .storeCoins(toNano('100')) // Jetton amount
|
|
163
|
+
* .storeAddress(recipientAddress)
|
|
164
|
+
* .storeAddress(senderAddress) // Response address
|
|
165
|
+
* .storeBit(0) // Custom payload
|
|
166
|
+
* .storeCoins(toNano('0.01')) // Forward amount
|
|
167
|
+
* .storeBit(0) // Forward payload
|
|
168
|
+
* .endCell(),
|
|
169
|
+
* bounce: false
|
|
170
|
+
* }]
|
|
171
|
+
* };
|
|
172
|
+
*
|
|
173
|
+
* // Smart contract deployment
|
|
174
|
+
* const deployProps: SendTransactionProps = {
|
|
175
|
+
* account: deployerAddress,
|
|
176
|
+
* transactions: [{
|
|
177
|
+
* to: contractAddress,
|
|
178
|
+
* value: toNano('0.5'), // Initial contract balance
|
|
179
|
+
* body: beginCell()
|
|
180
|
+
* .storeRef(contractCode) // Contract code
|
|
181
|
+
* .storeRef(contractData) // Initial data
|
|
182
|
+
* .endCell(),
|
|
183
|
+
* bounce: false,
|
|
184
|
+
* init: {
|
|
185
|
+
* code: contractCode,
|
|
186
|
+
* data: contractData
|
|
187
|
+
* }
|
|
188
|
+
* }]
|
|
189
|
+
* };
|
|
190
|
+
*
|
|
191
|
+
* // Batch operations (multiple transactions)
|
|
192
|
+
* const batchProps: SendTransactionProps = {
|
|
193
|
+
* account: userAddress,
|
|
194
|
+
* transactions: [
|
|
195
|
+
* {
|
|
196
|
+
* to: Address.parse('EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N'),
|
|
197
|
+
* value: toNano('0.5'),
|
|
198
|
+
* body: beginCell().endCell(),
|
|
199
|
+
* bounce: false
|
|
200
|
+
* },
|
|
201
|
+
* {
|
|
202
|
+
* to: jettonMasterAddress,
|
|
203
|
+
* value: toNano('0.1'),
|
|
204
|
+
* body: buildJettonMintBody({
|
|
205
|
+
* recipient: userAddress,
|
|
206
|
+
* amount: toNano('1000'),
|
|
207
|
+
* queryId: Date.now()
|
|
208
|
+
* }),
|
|
209
|
+
* bounce: true
|
|
210
|
+
* }
|
|
211
|
+
* ]
|
|
212
|
+
* };
|
|
213
|
+
*
|
|
214
|
+
* // DEX operations (DeDust swap)
|
|
215
|
+
* const swapProps: SendTransactionProps = {
|
|
216
|
+
* account: await options.ton.getAddress(),
|
|
217
|
+
* transactions: [{
|
|
218
|
+
* to: poolAddress,
|
|
219
|
+
* value: toNano('1.5'), // TON amount + gas
|
|
220
|
+
* body: beginCell()
|
|
221
|
+
* .storeUint(0xea06185d, 32) // Swap opcode
|
|
222
|
+
* .storeUint(0, 64) // Query ID
|
|
223
|
+
* .storeCoins(toNano('1')) // Amount in
|
|
224
|
+
* .storeAddress(jettonAddressOut)
|
|
225
|
+
* .storeCoins(minAmountOut)
|
|
226
|
+
* .storeAddress(userAddress) // Recipient
|
|
227
|
+
* .endCell(),
|
|
228
|
+
* bounce: true
|
|
229
|
+
* }]
|
|
230
|
+
* };
|
|
231
|
+
*
|
|
232
|
+
* // NFT operations
|
|
233
|
+
* const nftTransferProps: SendTransactionProps = {
|
|
234
|
+
* account: nftOwnerAddress,
|
|
235
|
+
* transactions: [{
|
|
236
|
+
* to: nftItemAddress,
|
|
237
|
+
* value: toNano('0.1'),
|
|
238
|
+
* body: beginCell()
|
|
239
|
+
* .storeUint(0x5fcc3d14, 32) // NFT transfer opcode
|
|
240
|
+
* .storeUint(0, 64) // Query ID
|
|
241
|
+
* .storeAddress(newOwnerAddress)
|
|
242
|
+
* .storeAddress(nftOwnerAddress) // Response address
|
|
243
|
+
* .storeBit(0) // Custom payload
|
|
244
|
+
* .storeCoins(toNano('0.01')) // Forward amount
|
|
245
|
+
* .endCell(),
|
|
246
|
+
* bounce: false
|
|
247
|
+
* }]
|
|
248
|
+
* };
|
|
249
|
+
*
|
|
250
|
+
* // Usage in adapter function
|
|
251
|
+
* async function executeTonTransactions(props: SendTransactionProps) {
|
|
252
|
+
* const result = await options.ton.sendTransactions(props);
|
|
253
|
+
*
|
|
254
|
+
* // Log all transaction hashes
|
|
255
|
+
* result.data.forEach((tx, index) => {
|
|
256
|
+
* console.log(`TON Transaction ${index + 1}: ${tx.hash}`);
|
|
257
|
+
* console.log(`Status: ${tx.message}`);
|
|
258
|
+
* });
|
|
259
|
+
*
|
|
260
|
+
* return result;
|
|
261
|
+
* }
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
12
264
|
export interface SendTransactionProps {
|
|
265
|
+
/** Account that will execute the transactions */
|
|
13
266
|
readonly account: Address;
|
|
267
|
+
/** Array of TON transaction arguments */
|
|
14
268
|
readonly transactions: SenderArguments[];
|
|
15
269
|
}
|
|
270
|
+
/**
|
|
271
|
+
* TON blockchain client configuration with multiple client types and adapters
|
|
272
|
+
* @interface Client
|
|
273
|
+
* @example
|
|
274
|
+
* ```typescript
|
|
275
|
+
* // Create TON client configuration
|
|
276
|
+
* const tonClient: Client = {
|
|
277
|
+
* api: new TonApiClient({
|
|
278
|
+
* baseUrl: 'https://tonapi.io',
|
|
279
|
+
* apiKey: 'your-api-key'
|
|
280
|
+
* }),
|
|
281
|
+
* client: new TonClient({
|
|
282
|
+
* endpoint: 'https://toncenter.com/api/v2/jsonRPC'
|
|
283
|
+
* }),
|
|
284
|
+
* client4: new TonClient4({
|
|
285
|
+
* endpoint: 'https://mainnet-v4.tonhubapi.com'
|
|
286
|
+
* }),
|
|
287
|
+
* adapter: new ContractAdapter()
|
|
288
|
+
* };
|
|
289
|
+
*
|
|
290
|
+
* // Use different clients for different operations
|
|
291
|
+
* async function getTonAccountInfo(address: Address, client: Client) {
|
|
292
|
+
* // Use TonApiClient for rich API data
|
|
293
|
+
* const accountInfo = await client.api.accounts.getAccount(address.toString());
|
|
294
|
+
*
|
|
295
|
+
* // Use TonClient for basic operations
|
|
296
|
+
* const balance = await client.client.getBalance(address);
|
|
297
|
+
*
|
|
298
|
+
* // Use TonClient4 for v4 API features
|
|
299
|
+
* const accountState = await client.client4.getAccount(
|
|
300
|
+
* client.client4.provider.block.lastSeqno,
|
|
301
|
+
* address
|
|
302
|
+
* );
|
|
303
|
+
*
|
|
304
|
+
* return {
|
|
305
|
+
* address: address.toString(),
|
|
306
|
+
* balance: balance.toString(),
|
|
307
|
+
* status: accountInfo.status,
|
|
308
|
+
* lastActivity: accountInfo.lastActivity,
|
|
309
|
+
* interfaces: accountInfo.interfaces
|
|
310
|
+
* };
|
|
311
|
+
* }
|
|
312
|
+
*
|
|
313
|
+
* // Smart contract interaction
|
|
314
|
+
* async function interactWithContract(
|
|
315
|
+
* contractAddress: Address,
|
|
316
|
+
* method: string,
|
|
317
|
+
* params: any[],
|
|
318
|
+
* client: Client
|
|
319
|
+
* ) {
|
|
320
|
+
* // Use adapter for contract interactions
|
|
321
|
+
* const contract = client.adapter.open(
|
|
322
|
+
* Contract.create({
|
|
323
|
+
* workchain: contractAddress.workChain,
|
|
324
|
+
* address: contractAddress.hash
|
|
325
|
+
* }, contractCode)
|
|
326
|
+
* );
|
|
327
|
+
*
|
|
328
|
+
* // Call contract method
|
|
329
|
+
* const result = await contract.get(method, params);
|
|
330
|
+
* return result;
|
|
331
|
+
* }
|
|
332
|
+
*
|
|
333
|
+
* // Jetton operations using different clients
|
|
334
|
+
* async function getJettonInfo(jettonMaster: Address, client: Client) {
|
|
335
|
+
* // Get jetton data using API client
|
|
336
|
+
* const jettonInfo = await client.api.jettons.getJetton(jettonMaster.toString());
|
|
337
|
+
*
|
|
338
|
+
* // Get on-chain data using TonClient
|
|
339
|
+
* const jettonData = await client.client.runMethod(jettonMaster, 'get_jetton_data');
|
|
340
|
+
*
|
|
341
|
+
* return {
|
|
342
|
+
* name: jettonInfo.metadata?.name,
|
|
343
|
+
* symbol: jettonInfo.metadata?.symbol,
|
|
344
|
+
* decimals: jettonInfo.metadata?.decimals,
|
|
345
|
+
* totalSupply: jettonData.stack.readBigNumber(),
|
|
346
|
+
* mintable: jettonData.stack.readBoolean(),
|
|
347
|
+
* adminAddress: jettonData.stack.readAddress()
|
|
348
|
+
* };
|
|
349
|
+
* }
|
|
350
|
+
*
|
|
351
|
+
* // Transaction tracking
|
|
352
|
+
* async function trackTransaction(hash: string, client: Client) {
|
|
353
|
+
* try {
|
|
354
|
+
* // Use API client for detailed transaction info
|
|
355
|
+
* const txInfo = await client.api.blockchain.getBlockchainTransaction(hash);
|
|
356
|
+
*
|
|
357
|
+
* return {
|
|
358
|
+
* hash: txInfo.hash,
|
|
359
|
+
* success: txInfo.success,
|
|
360
|
+
* fee: txInfo.fee.total,
|
|
361
|
+
* timestamp: txInfo.utime,
|
|
362
|
+
* inMsg: txInfo.inMsg,
|
|
363
|
+
* outMsgs: txInfo.outMsgs
|
|
364
|
+
* };
|
|
365
|
+
* } catch (error) {
|
|
366
|
+
* console.error('Failed to track transaction:', error);
|
|
367
|
+
* return null;
|
|
368
|
+
* }
|
|
369
|
+
* }
|
|
370
|
+
*
|
|
371
|
+
* // Multi-client balance checking
|
|
372
|
+
* async function getComprehensiveBalance(address: Address, client: Client) {
|
|
373
|
+
* const [apiBalance, clientBalance, client4Balance] = await Promise.allSettled([
|
|
374
|
+
* client.api.accounts.getAccount(address.toString())
|
|
375
|
+
* .then(acc => acc.balance),
|
|
376
|
+
* client.client.getBalance(address),
|
|
377
|
+
* client.client4.getAccount(
|
|
378
|
+
* await client.client4.provider.block.lastSeqno,
|
|
379
|
+
* address
|
|
380
|
+
* ).then(acc => acc.account.balance?.coins || 0n)
|
|
381
|
+
* ]);
|
|
382
|
+
*
|
|
383
|
+
* return {
|
|
384
|
+
* api: apiBalance.status === 'fulfilled' ? apiBalance.value : null,
|
|
385
|
+
* client: clientBalance.status === 'fulfilled' ? clientBalance.value : null,
|
|
386
|
+
* client4: client4Balance.status === 'fulfilled' ? client4Balance.value : null
|
|
387
|
+
* };
|
|
388
|
+
* }
|
|
389
|
+
*
|
|
390
|
+
* // Initialize client with configuration
|
|
391
|
+
* function createTonClient(config: {
|
|
392
|
+
* apiKey?: string;
|
|
393
|
+
* network?: 'mainnet' | 'testnet';
|
|
394
|
+
* endpoints?: {
|
|
395
|
+
* api?: string;
|
|
396
|
+
* client?: string;
|
|
397
|
+
* client4?: string;
|
|
398
|
+
* };
|
|
399
|
+
* }): Client {
|
|
400
|
+
* const isTestnet = config.network === 'testnet';
|
|
401
|
+
*
|
|
402
|
+
* return {
|
|
403
|
+
* api: new TonApiClient({
|
|
404
|
+
* baseUrl: config.endpoints?.api || (isTestnet ? 'https://testnet.tonapi.io' : 'https://tonapi.io'),
|
|
405
|
+
* apiKey: config.apiKey
|
|
406
|
+
* }),
|
|
407
|
+
* client: new TonClient({
|
|
408
|
+
* endpoint: config.endpoints?.client || (isTestnet
|
|
409
|
+
* ? 'https://testnet.toncenter.com/api/v2/jsonRPC'
|
|
410
|
+
* : 'https://toncenter.com/api/v2/jsonRPC')
|
|
411
|
+
* }),
|
|
412
|
+
* client4: new TonClient4({
|
|
413
|
+
* endpoint: config.endpoints?.client4 || (isTestnet
|
|
414
|
+
* ? 'https://testnet-v4.tonhubapi.com'
|
|
415
|
+
* : 'https://mainnet-v4.tonhubapi.com')
|
|
416
|
+
* }),
|
|
417
|
+
* adapter: new ContractAdapter()
|
|
418
|
+
* };
|
|
419
|
+
* }
|
|
420
|
+
* ```
|
|
421
|
+
*/
|
|
16
422
|
export interface Client {
|
|
423
|
+
/** TON API client for rich blockchain data and operations */
|
|
17
424
|
readonly api: TonApiClient;
|
|
425
|
+
/** Standard TON client for basic blockchain operations */
|
|
18
426
|
readonly client: TonClient;
|
|
427
|
+
/** TON v4 client for advanced features and better performance */
|
|
19
428
|
readonly client4: TonClient4;
|
|
429
|
+
/** Contract adapter for smart contract interactions */
|
|
20
430
|
readonly adapter: ContractAdapter;
|
|
21
431
|
}
|
package/dist/index.js
CHANGED
|
@@ -89,7 +89,9 @@ __export(utils_exports, {
|
|
|
89
89
|
isEvmChain: () => isEvmChain
|
|
90
90
|
});
|
|
91
91
|
var ZERO_ALLOWANCE = {
|
|
92
|
+
/** Ethereum mainnet tokens requiring zero allowance reset */
|
|
92
93
|
1: ["0xdAC17F958D2ee523a2206206994597C13D831ec7"]
|
|
94
|
+
// USDT
|
|
93
95
|
};
|
|
94
96
|
async function checkToApprove({ args, transactions, provider }) {
|
|
95
97
|
const { account, target, spender, amount } = args;
|
|
@@ -158,6 +160,7 @@ var Chain = /* @__PURE__ */ ((Chain2) => {
|
|
|
158
160
|
Chain2["SOLANA"] = "solana";
|
|
159
161
|
Chain2["TON"] = "ton";
|
|
160
162
|
Chain2["HYPEREVM"] = "hyperevm";
|
|
163
|
+
Chain2["PLASMA"] = "plasma";
|
|
161
164
|
return Chain2;
|
|
162
165
|
})(Chain || {});
|
|
163
166
|
var allChains = Object.values(Chain);
|
|
@@ -173,38 +176,70 @@ var WalletType = /* @__PURE__ */ ((WalletType2) => {
|
|
|
173
176
|
|
|
174
177
|
// src/blockchain/evm/constants/chains.ts
|
|
175
178
|
var ChainIds = {
|
|
179
|
+
/** Ethereum Mainnet - Chain ID: 1 */
|
|
176
180
|
["ethereum" /* ETHEREUM */]: 1,
|
|
181
|
+
/** Optimism - Chain ID: 10 */
|
|
177
182
|
["optimism" /* OPTIMISM */]: 10,
|
|
183
|
+
/** Binance Smart Chain - Chain ID: 56 */
|
|
178
184
|
["bsc" /* BSC */]: 56,
|
|
185
|
+
/** Gnosis Chain - Chain ID: 100 */
|
|
179
186
|
["gnosis" /* GNOSIS */]: 100,
|
|
187
|
+
/** Polygon - Chain ID: 137 */
|
|
180
188
|
["polygon" /* POLYGON */]: 137,
|
|
189
|
+
/** Sonic - Chain ID: 146 */
|
|
181
190
|
["sonic" /* SONIC */]: 146,
|
|
191
|
+
/** zkSync Era - Chain ID: 324 */
|
|
182
192
|
["zksync" /* ZKSYNC */]: 324,
|
|
193
|
+
/** Metis Andromeda - Chain ID: 1088 */
|
|
183
194
|
["metis" /* METIS */]: 1088,
|
|
195
|
+
/** Kava EVM - Chain ID: 2222 */
|
|
184
196
|
["kava_evm" /* KAVA_EVM */]: 2222,
|
|
197
|
+
/** Base - Chain ID: 8453 */
|
|
185
198
|
["base" /* BASE */]: 8453,
|
|
199
|
+
/** Avalanche C-Chain - Chain ID: 43114 */
|
|
186
200
|
["avalanche" /* AVALANCHE */]: 43114,
|
|
201
|
+
/** Arbitrum One - Chain ID: 42161 */
|
|
187
202
|
["arbitrum" /* ARBITRUM */]: 42161,
|
|
203
|
+
/** Scroll - Chain ID: 534352 */
|
|
188
204
|
["scroll" /* SCROLL */]: 534352,
|
|
189
|
-
|
|
205
|
+
/** HyperEVM - Chain ID: 999 */
|
|
206
|
+
["hyperevm" /* HYPEREVM */]: 999,
|
|
207
|
+
/** Plasma - Chain ID: 9745 */
|
|
208
|
+
["plasma" /* PLASMA */]: 9745
|
|
190
209
|
};
|
|
191
210
|
|
|
192
211
|
// src/blockchain/evm/constants/weth9.ts
|
|
193
212
|
var WETH9 = {
|
|
213
|
+
/** Wrapped Ether (WETH) on Ethereum */
|
|
194
214
|
["ethereum" /* ETHEREUM */]: sdk.ethereumTokens.weth,
|
|
215
|
+
/** Wrapped Ether (WETH) on Optimism */
|
|
195
216
|
["optimism" /* OPTIMISM */]: sdk.optimismTokens.weth,
|
|
217
|
+
/** Wrapped BNB (WBNB) on Binance Smart Chain */
|
|
196
218
|
["bsc" /* BSC */]: sdk.bscTokens.wbnb,
|
|
219
|
+
/** Wrapped POL (WPOL) on Polygon */
|
|
197
220
|
["polygon" /* POLYGON */]: sdk.polygonTokens.wpol,
|
|
221
|
+
/** Wrapped Ether (WETH) on zkSync Era */
|
|
198
222
|
["zksync" /* ZKSYNC */]: sdk.zkSyncTokens.weth,
|
|
223
|
+
/** Wrapped KAVA (WKAVA) on Kava EVM */
|
|
199
224
|
["kava_evm" /* KAVA_EVM */]: sdk.kavaTokens.wkava,
|
|
225
|
+
/** Wrapped AVAX (WAVAX) on Avalanche */
|
|
200
226
|
["avalanche" /* AVALANCHE */]: sdk.avalancheTokens.wavax,
|
|
227
|
+
/** Wrapped Ether (WETH) on Arbitrum */
|
|
201
228
|
["arbitrum" /* ARBITRUM */]: sdk.arbitrumTokens.weth,
|
|
229
|
+
/** Wrapped METIS (WMETIS) on Metis */
|
|
202
230
|
["metis" /* METIS */]: sdk.metisTokens.wmetis,
|
|
231
|
+
/** Wrapped Ether (WETH) on Base */
|
|
203
232
|
["base" /* BASE */]: sdk.baseTokens.weth,
|
|
233
|
+
/** Wrapped S (WS) on Sonic */
|
|
204
234
|
["sonic" /* SONIC */]: sdk.sonicTokens.ws,
|
|
235
|
+
/** Wrapped Ether (WETH) on Scroll */
|
|
205
236
|
["scroll" /* SCROLL */]: new sdk.Token(ChainIds["scroll" /* SCROLL */], "0x5300000000000000000000000000000000000004", 18, "WETH", "Wrapped Ether"),
|
|
237
|
+
/** Wrapped xDAI (WXDAI) on Gnosis Chain */
|
|
206
238
|
["gnosis" /* GNOSIS */]: new sdk.Token(ChainIds["gnosis" /* GNOSIS */], "0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d", 18, "WXDAI", "Wrapped XDAI"),
|
|
207
|
-
|
|
239
|
+
/** Wrapped HYPE (WHYPE) on HyperEVM */
|
|
240
|
+
["hyperevm" /* HYPEREVM */]: new sdk.Token(ChainIds["hyperevm" /* HYPEREVM */], "0x5555555555555555555555555555555555555555", 18, "WHYPE", "Wrapped HYPE"),
|
|
241
|
+
/** Wrapped XPL (WXPL) on Plasma */
|
|
242
|
+
["plasma" /* PLASMA */]: new sdk.Token(ChainIds["plasma" /* PLASMA */], "0x6100E367285b01F48D07953803A2d8dCA5D19873", 18, "WXPL", "Wrapped XPL")
|
|
208
243
|
};
|
|
209
244
|
|
|
210
245
|
// src/blockchain/evm/utils/getChainFromName.ts
|
package/dist/index.mjs
CHANGED
|
@@ -87,7 +87,9 @@ __export(utils_exports, {
|
|
|
87
87
|
isEvmChain: () => isEvmChain
|
|
88
88
|
});
|
|
89
89
|
var ZERO_ALLOWANCE = {
|
|
90
|
+
/** Ethereum mainnet tokens requiring zero allowance reset */
|
|
90
91
|
1: ["0xdAC17F958D2ee523a2206206994597C13D831ec7"]
|
|
92
|
+
// USDT
|
|
91
93
|
};
|
|
92
94
|
async function checkToApprove({ args, transactions, provider }) {
|
|
93
95
|
const { account, target, spender, amount } = args;
|
|
@@ -156,6 +158,7 @@ var Chain = /* @__PURE__ */ ((Chain2) => {
|
|
|
156
158
|
Chain2["SOLANA"] = "solana";
|
|
157
159
|
Chain2["TON"] = "ton";
|
|
158
160
|
Chain2["HYPEREVM"] = "hyperevm";
|
|
161
|
+
Chain2["PLASMA"] = "plasma";
|
|
159
162
|
return Chain2;
|
|
160
163
|
})(Chain || {});
|
|
161
164
|
var allChains = Object.values(Chain);
|
|
@@ -171,38 +174,70 @@ var WalletType = /* @__PURE__ */ ((WalletType2) => {
|
|
|
171
174
|
|
|
172
175
|
// src/blockchain/evm/constants/chains.ts
|
|
173
176
|
var ChainIds = {
|
|
177
|
+
/** Ethereum Mainnet - Chain ID: 1 */
|
|
174
178
|
["ethereum" /* ETHEREUM */]: 1,
|
|
179
|
+
/** Optimism - Chain ID: 10 */
|
|
175
180
|
["optimism" /* OPTIMISM */]: 10,
|
|
181
|
+
/** Binance Smart Chain - Chain ID: 56 */
|
|
176
182
|
["bsc" /* BSC */]: 56,
|
|
183
|
+
/** Gnosis Chain - Chain ID: 100 */
|
|
177
184
|
["gnosis" /* GNOSIS */]: 100,
|
|
185
|
+
/** Polygon - Chain ID: 137 */
|
|
178
186
|
["polygon" /* POLYGON */]: 137,
|
|
187
|
+
/** Sonic - Chain ID: 146 */
|
|
179
188
|
["sonic" /* SONIC */]: 146,
|
|
189
|
+
/** zkSync Era - Chain ID: 324 */
|
|
180
190
|
["zksync" /* ZKSYNC */]: 324,
|
|
191
|
+
/** Metis Andromeda - Chain ID: 1088 */
|
|
181
192
|
["metis" /* METIS */]: 1088,
|
|
193
|
+
/** Kava EVM - Chain ID: 2222 */
|
|
182
194
|
["kava_evm" /* KAVA_EVM */]: 2222,
|
|
195
|
+
/** Base - Chain ID: 8453 */
|
|
183
196
|
["base" /* BASE */]: 8453,
|
|
197
|
+
/** Avalanche C-Chain - Chain ID: 43114 */
|
|
184
198
|
["avalanche" /* AVALANCHE */]: 43114,
|
|
199
|
+
/** Arbitrum One - Chain ID: 42161 */
|
|
185
200
|
["arbitrum" /* ARBITRUM */]: 42161,
|
|
201
|
+
/** Scroll - Chain ID: 534352 */
|
|
186
202
|
["scroll" /* SCROLL */]: 534352,
|
|
187
|
-
|
|
203
|
+
/** HyperEVM - Chain ID: 999 */
|
|
204
|
+
["hyperevm" /* HYPEREVM */]: 999,
|
|
205
|
+
/** Plasma - Chain ID: 9745 */
|
|
206
|
+
["plasma" /* PLASMA */]: 9745
|
|
188
207
|
};
|
|
189
208
|
|
|
190
209
|
// src/blockchain/evm/constants/weth9.ts
|
|
191
210
|
var WETH9 = {
|
|
211
|
+
/** Wrapped Ether (WETH) on Ethereum */
|
|
192
212
|
["ethereum" /* ETHEREUM */]: ethereumTokens.weth,
|
|
213
|
+
/** Wrapped Ether (WETH) on Optimism */
|
|
193
214
|
["optimism" /* OPTIMISM */]: optimismTokens.weth,
|
|
215
|
+
/** Wrapped BNB (WBNB) on Binance Smart Chain */
|
|
194
216
|
["bsc" /* BSC */]: bscTokens.wbnb,
|
|
217
|
+
/** Wrapped POL (WPOL) on Polygon */
|
|
195
218
|
["polygon" /* POLYGON */]: polygonTokens.wpol,
|
|
219
|
+
/** Wrapped Ether (WETH) on zkSync Era */
|
|
196
220
|
["zksync" /* ZKSYNC */]: zkSyncTokens.weth,
|
|
221
|
+
/** Wrapped KAVA (WKAVA) on Kava EVM */
|
|
197
222
|
["kava_evm" /* KAVA_EVM */]: kavaTokens.wkava,
|
|
223
|
+
/** Wrapped AVAX (WAVAX) on Avalanche */
|
|
198
224
|
["avalanche" /* AVALANCHE */]: avalancheTokens.wavax,
|
|
225
|
+
/** Wrapped Ether (WETH) on Arbitrum */
|
|
199
226
|
["arbitrum" /* ARBITRUM */]: arbitrumTokens.weth,
|
|
227
|
+
/** Wrapped METIS (WMETIS) on Metis */
|
|
200
228
|
["metis" /* METIS */]: metisTokens.wmetis,
|
|
229
|
+
/** Wrapped Ether (WETH) on Base */
|
|
201
230
|
["base" /* BASE */]: baseTokens.weth,
|
|
231
|
+
/** Wrapped S (WS) on Sonic */
|
|
202
232
|
["sonic" /* SONIC */]: sonicTokens.ws,
|
|
233
|
+
/** Wrapped Ether (WETH) on Scroll */
|
|
203
234
|
["scroll" /* SCROLL */]: new Token(ChainIds["scroll" /* SCROLL */], "0x5300000000000000000000000000000000000004", 18, "WETH", "Wrapped Ether"),
|
|
235
|
+
/** Wrapped xDAI (WXDAI) on Gnosis Chain */
|
|
204
236
|
["gnosis" /* GNOSIS */]: new Token(ChainIds["gnosis" /* GNOSIS */], "0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d", 18, "WXDAI", "Wrapped XDAI"),
|
|
205
|
-
|
|
237
|
+
/** Wrapped HYPE (WHYPE) on HyperEVM */
|
|
238
|
+
["hyperevm" /* HYPEREVM */]: new Token(ChainIds["hyperevm" /* HYPEREVM */], "0x5555555555555555555555555555555555555555", 18, "WHYPE", "Wrapped HYPE"),
|
|
239
|
+
/** Wrapped XPL (WXPL) on Plasma */
|
|
240
|
+
["plasma" /* PLASMA */]: new Token(ChainIds["plasma" /* PLASMA */], "0x6100E367285b01F48D07953803A2d8dCA5D19873", 18, "WXPL", "Wrapped XPL")
|
|
206
241
|
};
|
|
207
242
|
|
|
208
243
|
// src/blockchain/evm/utils/getChainFromName.ts
|