@layerzerolabs/lz-corekit-tron 3.0.15 → 3.0.17

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.d.mts CHANGED
@@ -10,29 +10,130 @@ declare class TronProvider implements Provider {
10
10
  url: string;
11
11
  nativeProvider: ethers.providers.StaticJsonRpcProvider;
12
12
  /**
13
+ * Creates an instance of TronProvider.
13
14
  *
14
- * @param url RPC endpoint of the Tron full node, e.g. 'https://api.trongrid.io'
15
- * @param apiKey
15
+ * @param {string} url - RPC endpoint of the Tron full node, e.g. 'https://api.trongrid.io'
16
+ * @param {string} [apiKey] - The API key for accessing the Tron full node (optional).
16
17
  */
17
18
  private constructor();
19
+ /**
20
+ * Creates an instance of TronProvider from the given URL and API key.
21
+ *
22
+ * @param {string} url - The URL of the Tron node.
23
+ * @param {string} [apiKey] - The API key for accessing the Tron node (optional).
24
+ * @returns {TronProvider} The created TronProvider instance.
25
+ */
18
26
  static from(url: string, apiKey?: string): TronProvider;
27
+ /**
28
+ * Creates an instance of TronProvider from a TronWeb client.
29
+ *
30
+ * @param {TronWeb} client - The TronWeb client to create the provider from.
31
+ * @returns {TronProvider} The created TronProvider instance.
32
+ */
19
33
  static from(client: TronWeb): TronProvider;
20
34
  /**
21
- * Returns the native provider
35
+ * Returns the native provider.
36
+ *
37
+ * @returns {unknown} The native provider.
22
38
  */
23
39
  get native(): unknown;
40
+ /**
41
+ * Builds a TronWeb instance from the given provider.
42
+ * The result will be cached based on the provider's URL and API key.
43
+ *
44
+ * @param {ethers.providers.Provider} provider - The provider to build the TronWeb instance from.
45
+ * @returns {TronWeb} The built TronWeb instance.
46
+ * @throws {Error} If the provider is not supported.
47
+ */
24
48
  private buildTronWebFrom;
49
+ /**
50
+ * Gets the balance of the specified address.
51
+ *
52
+ * @param {string} address - The address to get the balance of.
53
+ * @returns {Promise<string>} A promise that resolves to the balance of the address.
54
+ */
25
55
  getBalance(address: string): Promise<string>;
56
+ /**
57
+ * Gets the block specified by blockTag.
58
+ *
59
+ * @param {BlockTag} blockTag - The block tag to specify the block.
60
+ * @returns {Promise<Block>} A promise that resolves to the block.
61
+ */
26
62
  getBlock(blockTag: string | number): Promise<Block>;
63
+ /**
64
+ * Gets the block with transactions specified by blockTag.
65
+ *
66
+ * @param {BlockTag} blockTag - The block tag to specify the block.
67
+ * @returns {Promise<BlockWithTransactions>} A promise that resolves to the block with transactions.
68
+ */
27
69
  getBlockWithTransactions(blockTag: string | number): Promise<BlockWithTransactions>;
70
+ /**
71
+ * Gets the current block number.
72
+ *
73
+ * @returns {Promise<number>} A promise that resolves to the current block number.
74
+ */
28
75
  getBlockNumber(): Promise<number>;
76
+ /**
77
+ * Gets the UNIX timestamp for the block identified by blockTag.
78
+ *
79
+ * @param {BlockTag} blockTag - The block tag to specify the block.
80
+ * @returns {Promise<number>} A promise that resolves to the UNIX timestamp of the block.
81
+ */
29
82
  getBlockTimestamp(blockTag: string | number): Promise<number>;
83
+ /**
84
+ * Gets the current slot number for commitment, not suitable for Tron.
85
+ *
86
+ * @param {Finality} [finality] - The commitment level (optional).
87
+ * @returns {Promise<number>} A promise that resolves to the current slot number.
88
+ * @throws {Error} Method not implemented.
89
+ */
30
90
  getSlot(_finality?: Finality): Promise<number>;
91
+ /**
92
+ * Gets information about a transaction.
93
+ *
94
+ * @param {string} txHash - The hash of the transaction.
95
+ * @returns {Promise<TransactionResponse>} A promise that resolves to the transaction response.
96
+ */
31
97
  getTransaction(txHash: string): Promise<TransactionResponse>;
98
+ /**
99
+ * Gets the receipt of a transaction.
100
+ *
101
+ * @param {string} txHash - The hash of the transaction.
102
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
103
+ */
32
104
  getTransactionReceipt(txHash: string): Promise<TransactionReceipt>;
105
+ /**
106
+ * Gets the number of transactions sent from the specified address.
107
+ *
108
+ * @param {string | Promise<string>} _addressOrName - The address to get the number of transactions from.
109
+ * @param {BlockTag | Promise<BlockTag>} [_blockTag] - The block tag to get the number of transactions from (optional).
110
+ * @returns {Promise<number>} A promise that resolves to the number of transactions sent from the address.
111
+ * @throws {Error} Method not supported in Tron.
112
+ */
33
113
  getTransactionCount(_addressOrName: string | Promise<string>, _blockTag?: BlockTag | Promise<BlockTag>): Promise<number>;
114
+ /**
115
+ * Sends a signed transaction to the blockchain.
116
+ *
117
+ * @param {SignedTransaction} transaction - The signed transaction to send.
118
+ * @param {object} [sendOptions] - Optional parameters for sending the transaction.
119
+ * @returns {Promise<TransactionPending>} A promise that resolves to the pending transaction.
120
+ */
34
121
  sendTransaction(transaction: SignedTransaction, _sendOptions?: object): Promise<TransactionPending>;
122
+ /**
123
+ * Confirms a pending transaction.
124
+ *
125
+ * @param {TransactionPending} pending - The pending transaction to confirm.
126
+ * @param {object} [opts] - Optional parameters for the confirmation.
127
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
128
+ */
35
129
  confirmTransaction(pending: TransactionPending, _opts?: object): Promise<TransactionReceipt>;
130
+ /**
131
+ * Sends a signed transaction and waits for confirmation.
132
+ *
133
+ * @param {SignedTransaction} transaction - The signed transaction to send.
134
+ * @param {object} [opts] - Optional parameters for sending and confirming the transaction.
135
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
136
+ */
36
137
  sendAndConfirm(transaction: SignedTransaction, opts?: object): Promise<TransactionReceipt>;
37
138
  }
38
139
 
@@ -49,28 +150,118 @@ declare class TronWebProvider implements Provider {
49
150
  private apiKey?;
50
151
  nativeProvider: TronWeb;
51
152
  /**
52
- * Create a new TronProvider
53
- * @param url RPC endpoint of the Tron full node, e.g. 'https://api.trongrid.io'
54
- * @param apiKey
153
+ * Creates a new TronWebProvider.
154
+ *
155
+ * @param {string} url - The RPC endpoint of the Tron full node, e.g., 'https://api.trongrid.io'.
156
+ * @param {string} [apiKey] - The API key for accessing the Tron full node (optional).
55
157
  */
56
158
  constructor(url: string, apiKey?: string | undefined);
159
+ /**
160
+ * Creates an instance of TronWebProvider from the given URL and API key.
161
+ *
162
+ * @param {string} url - The URL of the Tron node.
163
+ * @param {string} [apiKey] - The API key for accessing the Tron node (optional).
164
+ * @returns {TronWebProvider} The created TronWebProvider instance.
165
+ */
57
166
  static from(url: string, apiKey?: string): TronWebProvider;
167
+ /**
168
+ * Gets the native TronWeb provider instance.
169
+ *
170
+ * @returns {TronWeb} The native TronWeb provider instance.
171
+ */
58
172
  get native(): unknown;
173
+ /**
174
+ * Gets the balance of the specified address.
175
+ *
176
+ * @param {string} address - The address to get the balance of.
177
+ * @returns {Promise<string>} A promise that resolves to the balance of the address.
178
+ */
59
179
  getBalance(address: string): Promise<string>;
180
+ /**
181
+ * Gets the block specified by blockTag.
182
+ *
183
+ * @param {BlockTag} blockTag - The block tag to specify the block.
184
+ * @returns {Promise<Block>} A promise that resolves to the block.
185
+ */
60
186
  getBlock(blockTag: string | number): Promise<Block>;
187
+ /**
188
+ * Gets the block with transactions specified by blockTag.
189
+ *
190
+ * @param {BlockTag} blockTag - The block tag to specify the block.
191
+ * @returns {Promise<BlockWithTransactions>} A promise that resolves to the block with transactions.
192
+ */
61
193
  getBlockWithTransactions(blockTag: string | number): Promise<BlockWithTransactions>;
194
+ /**
195
+ * Gets the current block number.
196
+ *
197
+ * @returns {Promise<number>} A promise that resolves to the current block number.
198
+ */
62
199
  getBlockNumber(): Promise<number>;
200
+ /**
201
+ * Gets the UNIX timestamp for the block identified by blockTag.
202
+ *
203
+ * @param {BlockTag} blockTag - The block tag to specify the block.
204
+ * @returns {Promise<number>} A promise that resolves to the UNIX timestamp of the block.
205
+ */
63
206
  getBlockTimestamp(blockTag: string | number): Promise<number>;
207
+ /**
208
+ * Gets the current slot number for commitment, not suitable for Tron.
209
+ *
210
+ * @param {Finality} [finality] - The commitment level (optional).
211
+ * @returns {Promise<number>} A promise that resolves to the current slot number.
212
+ * @throws {Error} Method not implemented.
213
+ */
64
214
  getSlot(_finality?: Finality): Promise<number>;
215
+ /**
216
+ * Gets information about a transaction.
217
+ *
218
+ * @param {string} txHash - The hash of the transaction.
219
+ * @returns {Promise<TransactionResponse>} A promise that resolves to the transaction response.
220
+ */
65
221
  getTransaction(txHash: string): Promise<TransactionResponse>;
222
+ /**
223
+ * Gets the receipt of a transaction.
224
+ *
225
+ * @param {string} txHash - The hash of the transaction.
226
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
227
+ */
66
228
  getTransactionReceipt(txHash: string): Promise<TransactionReceipt>;
229
+ /**
230
+ * Gets the number of transactions sent from the specified address.
231
+ *
232
+ * @param {string | Promise<string>} _addressOrName - The address to get the number of transactions from.
233
+ * @param {BlockTag | Promise<BlockTag>} [_blockTag] - The block tag to get the number of transactions from (optional).
234
+ * @returns {Promise<number>} A promise that resolves to the number of transactions sent from the address.
235
+ * @throws {Error} Method not supported in Tron.
236
+ */
67
237
  getTransactionCount(_addressOrName: string | Promise<string>, _blockTag?: BlockTag | Promise<BlockTag>): Promise<number>;
238
+ /**
239
+ * Sends a signed transaction to the blockchain.
240
+ *
241
+ * @param {SignedTransaction} transaction - The signed transaction to send.
242
+ * @param {object} [sendOptions] - Optional parameters for sending the transaction.
243
+ * @returns {Promise<TransactionPending>} A promise that resolves to the pending transaction.
244
+ */
68
245
  sendTransaction(transaction: SignedTransaction, sendOptions?: {
69
246
  confirmations?: number;
70
247
  }): Promise<TransactionPending>;
248
+ /**
249
+ * Confirms a pending transaction.
250
+ *
251
+ * @param {TransactionPending} pending - The pending transaction to confirm.
252
+ * @param {object} [opts] - Optional parameters for the confirmation.
253
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
254
+ */
71
255
  confirmTransaction(pending: TransactionPending, opts?: {
72
256
  confirmations?: number;
73
257
  }): Promise<TransactionReceipt>;
258
+ /**
259
+ * Sends a signed transaction and waits for confirmation.
260
+ *
261
+ * @param {SignedTransaction} transaction - The signed transaction to send.
262
+ * @param {object} [opts] - Optional parameters for sending and confirming the transaction.
263
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
264
+ */
74
265
  sendAndConfirm(transaction: SignedTransaction, opts?: {
75
266
  confirmations?: number;
76
267
  }): Promise<TransactionReceipt>;
@@ -82,22 +273,120 @@ declare class TronWebProvider implements Provider {
82
273
  */
83
274
  declare class TronSigner implements Signer {
84
275
  private readonly nativeSigner;
276
+ /**
277
+ * Creates an instance of TronSigner.
278
+ *
279
+ * @param {ethers.Signer} signer - The Ethers signer to use.
280
+ */
85
281
  private constructor();
282
+ /**
283
+ * Creates an instance of TronSigner from an Ethers signer.
284
+ *
285
+ * @param {ethers.Signer} source - The Ethers signer to create the TronSigner from.
286
+ * @returns {Signer} The created TronSigner instance.
287
+ */
86
288
  static from(source: ethers.Signer): Signer;
289
+ /**
290
+ * Creates an instance of TronSigner from a TronWeb client.
291
+ *
292
+ * @param {TronWeb} client - The TronWeb client to create the TronSigner from.
293
+ * @returns {Signer} The created TronSigner instance.
294
+ */
87
295
  static from(client: TronWeb): Signer;
296
+ /**
297
+ * Creates an instance of TronSigner from a private key.
298
+ *
299
+ * @param {string} privKey - The private key to create the TronSigner from.
300
+ * @returns {Signer} The created TronSigner instance.
301
+ */
88
302
  static from(privKey: string): Signer;
303
+ /**
304
+ * Creates an instance of TronSigner from a mnemonic and derivation path.
305
+ *
306
+ * @param {string} mnemonic - The mnemonic to create the TronSigner from.
307
+ * @param {string} path - The derivation path (e.g., m/44'/195'/0'/0/0).
308
+ * @returns {Signer} The created TronSigner instance.
309
+ */
89
310
  static from(mnemonic: string, path: string): Signer;
311
+ /**
312
+ * Gets the native signer instance.
313
+ *
314
+ * @returns {unknown} The native signer instance.
315
+ */
90
316
  get native(): unknown;
317
+ /**
318
+ * Connects the signer to a provider.
319
+ * IMPORTANT: native provider must be an instance of ethers.providers.JsonRpcProvider.
320
+ *
321
+ * @param {Provider} provider - The provider to connect to.
322
+ * @returns {Signer} The connected signer.
323
+ * @throws {Error} If the provider is not an instance of JsonRpcProvider.
324
+ */
91
325
  connect(provider: Provider): Signer;
326
+ /**
327
+ * Builds a TronWeb instance from the given signer.
328
+ * IMPORTANT: signer must be an instance of ethers.Wallet.
329
+ *
330
+ * @param {ethers.Signer} signer - The signer to build the TronWeb instance from.
331
+ * @returns {TronWeb} The built TronWeb instance.
332
+ * @throws {Error} If the signer is not supported.
333
+ */
92
334
  static buildTronWebFrom(signer: ethers.Signer): TronWeb;
93
- static createTronWeb: (url: string, privateKey: string, apiKey?: string) => TronWeb;
335
+ /**
336
+ * Creates a TronWeb instance.
337
+ * The result will be cached based on the arguments.
338
+ *
339
+ * @param {string} url - The URL of the Tron node.
340
+ * @param {string} privateKey - The private key to use.
341
+ * @param {string} [apiKey] - The API key for accessing the Tron node (optional).
342
+ * @returns {TronWeb} The created TronWeb instance.
343
+ */
344
+ static createTronWeb(url: string, privateKey: string, apiKey?: string): TronWeb;
345
+ /**
346
+ * Gets the address of the signer.
347
+ *
348
+ * @returns {Promise<string>} A promise that resolves to the address of the signer.
349
+ */
94
350
  getAddress(): Promise<string>;
351
+ /**
352
+ * Sends a signed transaction and waits for confirmation.
353
+ *
354
+ * @param {SignedTransaction} transaction - The signed transaction to send.
355
+ * @param {object} [opts] - Optional parameters for sending and confirming the transaction.
356
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
357
+ */
95
358
  sendAndConfirm(transaction: SignedTransaction, _opts?: object): Promise<TransactionReceipt>;
359
+ /**
360
+ * Signs a transaction.
361
+ *
362
+ * @param {TransactionRequest} transaction - The transaction request to sign.
363
+ * @returns {Promise<SignedTransaction>} A promise that resolves to the signed transaction.
364
+ * @throws {Error} If the transaction is invalid.
365
+ */
96
366
  signTransaction(transaction: TransactionRequest): Promise<SignedTransaction>;
367
+ /**
368
+ * Sends a signed transaction.
369
+ *
370
+ * @param {SignedTransaction} transaction - The signed transaction to send.
371
+ * @param {object} [sendOptions] - Optional parameters for sending the transaction.
372
+ * @returns {Promise<TransactionPending>} A promise that resolves to the pending transaction.
373
+ */
97
374
  sendTransaction(transaction: SignedTransaction, _sendOptions?: object): Promise<TransactionPending>;
375
+ /**
376
+ * Signs a buffer (e.g., a message hash) using the native Tron signer.
377
+ *
378
+ * @param {Uint8Array} buffer - The buffer to sign.
379
+ * @returns {Promise<Uint8Array>} A promise that resolves to the signed buffer as a Uint8Array.
380
+ */
98
381
  signBuffer(buffer: Uint8Array): Promise<Uint8Array>;
382
+ /**
383
+ * Validates a transaction.
384
+ *
385
+ * @param {ethers.PopulatedTransaction} transaction - The transaction to validate.
386
+ * @returns {boolean} True if the transaction is valid, false otherwise.
387
+ * @throws {Error} If the transaction is invalid.
388
+ */
99
389
  static validateTransaction(transaction: ethers.PopulatedTransaction): boolean;
100
- buildTransaction(buildTxRequest: unknown): Promise<TransactionRequest>;
101
390
  }
102
391
 
103
392
  /**
@@ -111,15 +400,76 @@ declare class TronSigner implements Signer {
111
400
  */
112
401
  declare class TronWebSigner implements Signer {
113
402
  private readonly nativeSigner;
403
+ /**
404
+ * Creates an instance of TronWebSigner.
405
+ *
406
+ * @param {TronWeb} signer - The TronWeb signer to use.
407
+ */
114
408
  private constructor();
409
+ /**
410
+ * Creates an instance of TronWebSigner from a TronWeb client.
411
+ *
412
+ * @param {TronWeb} signer - The TronWeb client to create the TronWebSigner from.
413
+ * @returns {Signer} The created TronWebSigner instance.
414
+ */
115
415
  static from(signer: TronWeb): Signer;
416
+ /**
417
+ * Creates an instance of TronWebSigner from a private key.
418
+ *
419
+ * @param {string} privKey - The private key to create the TronWebSigner from.
420
+ * @returns {Signer} The created TronWebSigner instance.
421
+ */
116
422
  static from(privKey: string): Signer;
423
+ /**
424
+ * Creates an instance of TronWebSigner from a mnemonic and derivation path.
425
+ *
426
+ * @param {string} mnemonic - The mnemonic to create the TronWebSigner from.
427
+ * @param {string} [path] - The derivation path (optional).
428
+ * @returns {Signer} The created TronWebSigner instance.
429
+ */
117
430
  static from(mnemonic: string, path?: string): Signer;
431
+ /**
432
+ * Gets the native TronWeb signer instance.
433
+ *
434
+ * @returns {unknown} The native TronWeb signer instance.
435
+ */
118
436
  get native(): unknown;
437
+ /**
438
+ * Connects the signer to a provider.
439
+ *
440
+ * @param {Provider} provider - The provider to connect to.
441
+ * @returns {Signer} The connected signer.
442
+ */
119
443
  connect(provider: Provider): Signer;
444
+ /**
445
+ * Gets the address of the signer.
446
+ *
447
+ * @returns {Promise<string>} A promise that resolves to the address of the signer.
448
+ */
120
449
  getAddress(): Promise<string>;
450
+ /**
451
+ * Sends a signed transaction and waits for confirmation.
452
+ *
453
+ * @param {SignedTransaction} transaction - The signed transaction to send.
454
+ * @param {object} [sendOptions] - Optional parameters for sending and confirming the transaction.
455
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
456
+ */
121
457
  sendAndConfirm(transaction: SignedTransaction, _sendOptions?: object): Promise<TransactionReceipt>;
458
+ /**
459
+ * Signs a transaction.
460
+ *
461
+ * @param {TransactionRequest} transaction - The transaction request to sign.
462
+ * @returns {Promise<SignedTransaction>} A promise that resolves to the signed transaction.
463
+ * @throws {Error} If the transaction is invalid.
464
+ */
122
465
  signTransaction(transaction: TransactionRequest): Promise<SignedTransaction>;
466
+ /**
467
+ * Sends a signed transaction.
468
+ *
469
+ * @param {SignedTransaction} transaction - The signed transaction to send.
470
+ * @param {object} [sendOptions] - Optional parameters for sending the transaction.
471
+ * @returns {Promise<TransactionPending>} A promise that resolves to the pending transaction.
472
+ */
123
473
  sendTransaction(transaction: SignedTransaction, _sendOptions?: object): Promise<TransactionPending>;
124
474
  /**
125
475
  * signBuffer signs a buffer using the native signer
@@ -128,12 +478,20 @@ declare class TronWebSigner implements Signer {
128
478
  * the message length is 32 bytes, the signature will be the same as the ethereum signature.
129
479
  * you can find the signString function here:
130
480
  * https://github.com/tronprotocol/tronweb/blob/master/src/lib/trx.js
131
- * @param buffer
132
- * @returns
481
+ *
482
+ * @param {Uint8Array} buffer - The buffer to sign.
483
+ * @returns {Promise<Uint8Array>} A promise that resolves to the signed buffer as a Uint8Array.
484
+ * @throws {Error} If the private key is invalid.
133
485
  */
134
486
  signBuffer(buffer: Uint8Array): Promise<Uint8Array>;
487
+ /**
488
+ * Validates a transaction.
489
+ *
490
+ * @param {ethers.PopulatedTransaction} transaction - The transaction to validate.
491
+ * @returns {boolean} True if the transaction is valid, false otherwise.
492
+ * @throws {Error} If the transaction is invalid.
493
+ */
135
494
  static validateTransaction(transaction: ethers.PopulatedTransaction): boolean;
136
- buildTransaction(buildTxRequest: unknown): Promise<TransactionRequest>;
137
495
  }
138
496
 
139
497
  export { TronProvider, TronSigner, TronWebProvider, TronWebSigner };