@layerzerolabs/lz-corekit-tron 2.3.8

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.
@@ -0,0 +1,134 @@
1
+ import { Finality } from '@solana/web3.js';
2
+ import { ethers } from 'ethers';
3
+ import TronWeb, { TransactionInfo } from 'tronweb';
4
+ import { Provider, Block, BlockWithTransactions, TransactionResponse, TransactionReceipt, BlockTag, SignedTransaction, TransactionPending, Signer, TransactionRequest } from '@layerzerolabs/lz-core';
5
+
6
+ /**
7
+ * TronProvider is a wrapper around TronWeb that implements the Provider interface
8
+ * It is implemented using ethers.js
9
+ */
10
+ declare class TronProvider implements Provider {
11
+ nativeProvider: ethers.providers.StaticJsonRpcProvider;
12
+ /**
13
+ *
14
+ * @param url RPC endpoint of the Tron full node, e.g. 'https://api.trongrid.io'
15
+ * @param apiKey
16
+ */
17
+ private constructor();
18
+ static from(url: string, apiKey?: string): TronProvider;
19
+ static from(client: TronWeb): TronProvider;
20
+ /**
21
+ * Returns the native provider
22
+ */
23
+ get native(): unknown;
24
+ private buildTronWebFrom;
25
+ getBalance(address: string): Promise<string>;
26
+ getBlock(blockTag: string | number): Promise<Block>;
27
+ getBlockWithTransactions(blockTag: string | number): Promise<BlockWithTransactions>;
28
+ getBlockNumber(): Promise<number>;
29
+ getBlockTimestamp(blockTag: string | number): Promise<number>;
30
+ getSlot(_finality?: Finality): Promise<number>;
31
+ getTransaction(txHash: string): Promise<TransactionResponse>;
32
+ getTransactionReceipt(txHash: string): Promise<TransactionReceipt>;
33
+ getTransactionCount(_addressOrName: string | Promise<string>, _blockTag?: BlockTag | Promise<BlockTag>): Promise<number>;
34
+ sendTransaction(transaction: SignedTransaction, _sendOptions?: object): Promise<TransactionPending>;
35
+ sendAndConfirm(transaction: SignedTransaction, opts?: object): Promise<TransactionReceipt>;
36
+ }
37
+
38
+ /**
39
+ * TronWebProvider is a wrapper around TronWeb that implements the Provider interface
40
+ *
41
+ * PITFALL:
42
+ * - This class is not compatible with ethers.js and is not fully tested.
43
+ * - The format of the response from sendTransaction and the receipt from getTransactionReceipt differs
44
+ * from that of the ethers provider.
45
+ */
46
+ declare class TronWebProvider implements Provider {
47
+ private url;
48
+ private apiKey?;
49
+ nativeProvider: TronWeb;
50
+ /**
51
+ * Create a new TronProvider
52
+ * @param url RPC endpoint of the Tron full node, e.g. 'https://api.trongrid.io'
53
+ * @param apiKey
54
+ */
55
+ constructor(url: string, apiKey?: string | undefined);
56
+ static from(url: string, apiKey?: string): TronWebProvider;
57
+ get native(): unknown;
58
+ getBalance(address: string): Promise<string>;
59
+ getBlock(blockTag: string | number): Promise<Block>;
60
+ getBlockWithTransactions(blockTag: string | number): Promise<BlockWithTransactions>;
61
+ getBlockNumber(): Promise<number>;
62
+ getBlockTimestamp(blockTag: string | number): Promise<number>;
63
+ getSlot(_finality?: Finality): Promise<number>;
64
+ getTransaction(txHash: string): Promise<TransactionResponse>;
65
+ getTransactionReceipt(txHash: string): Promise<TransactionReceipt>;
66
+ getTransactionCount(_addressOrName: string | Promise<string>, _blockTag?: BlockTag | Promise<BlockTag>): Promise<number>;
67
+ sendTransaction(transaction: SignedTransaction, sendOptions?: {
68
+ confirmations?: number;
69
+ }): Promise<TransactionPending>;
70
+ waitTransaction(txHash: string, confirmations?: number): Promise<TransactionInfo | undefined>;
71
+ sendAndConfirm(transaction: SignedTransaction, opts?: {
72
+ confirmations?: number;
73
+ }): Promise<TransactionReceipt>;
74
+ }
75
+
76
+ /**
77
+ * TronSigner is a wrapper around TronWeb that implements the Signer interface
78
+ * It is implemented using ethers.js
79
+ */
80
+ declare class TronSigner implements Signer {
81
+ private readonly nativeSigner;
82
+ private constructor();
83
+ static from(source: ethers.Signer): Signer;
84
+ static from(client: TronWeb): Signer;
85
+ static from(privKey: string): Signer;
86
+ static from(mnemonic: string, path: string): Signer;
87
+ get native(): unknown;
88
+ connect(provider: Provider): Signer;
89
+ static buildTronWebFrom(signer: ethers.Signer): TronWeb;
90
+ static createTronWeb: (url: string, privateKey: string, apiKey?: string) => TronWeb;
91
+ getAddress(): Promise<string>;
92
+ sendAndConfirm(transaction: SignedTransaction, _opts?: object): Promise<TransactionReceipt>;
93
+ signTransaction(transaction: TransactionRequest): Promise<SignedTransaction>;
94
+ sendTransaction(transaction: SignedTransaction, _sendOptions?: object): Promise<TransactionPending>;
95
+ signBuffer(buffer: Uint8Array): Promise<Uint8Array>;
96
+ static validateTransaction(transaction: ethers.PopulatedTransaction): boolean;
97
+ }
98
+
99
+ /**
100
+ * TronWebSigner is a wrapper around TronWeb that implements the Signer interface
101
+ *
102
+ * PITFALL:
103
+ * - This class is not compatible with ethers.js and is not fully tested.
104
+ * - The signature produced by signBuffer is different from the ethers signer
105
+ * when the message length is not 32 bytes
106
+ * - The format of the response from sendTransaction differs from that of the ethers signer.
107
+ */
108
+ declare class TronWebSigner implements Signer {
109
+ private readonly nativeSigner;
110
+ private constructor();
111
+ static from(signer: TronWeb): Signer;
112
+ static from(privKey: string): Signer;
113
+ static from(mnemonic: string, path?: string): Signer;
114
+ get native(): unknown;
115
+ connect(provider: Provider): Signer;
116
+ getAddress(): Promise<string>;
117
+ sendAndConfirm(transaction: SignedTransaction, _sendOptions?: object): Promise<TransactionReceipt>;
118
+ signTransaction(transaction: TransactionRequest): Promise<SignedTransaction>;
119
+ sendTransaction(transaction: SignedTransaction, _sendOptions?: object): Promise<TransactionPending>;
120
+ /**
121
+ * signBuffer signs a buffer using the native signer
122
+ * but the signString function of native signer is different from the ethers signer,
123
+ * TronWeb uses a message header with a fixed 32 bytes length, which means that only if
124
+ * the message length is 32 bytes, the signature will be the same as the ethereum signature.
125
+ * you can find the signString function here:
126
+ * https://github.com/tronprotocol/tronweb/blob/master/src/lib/trx.js
127
+ * @param buffer
128
+ * @returns
129
+ */
130
+ signBuffer(buffer: Uint8Array): Promise<Uint8Array>;
131
+ static validateTransaction(transaction: ethers.PopulatedTransaction): boolean;
132
+ }
133
+
134
+ export { TronProvider, TronSigner, TronWebProvider, TronWebSigner };
@@ -0,0 +1,134 @@
1
+ import { Finality } from '@solana/web3.js';
2
+ import { ethers } from 'ethers';
3
+ import TronWeb, { TransactionInfo } from 'tronweb';
4
+ import { Provider, Block, BlockWithTransactions, TransactionResponse, TransactionReceipt, BlockTag, SignedTransaction, TransactionPending, Signer, TransactionRequest } from '@layerzerolabs/lz-core';
5
+
6
+ /**
7
+ * TronProvider is a wrapper around TronWeb that implements the Provider interface
8
+ * It is implemented using ethers.js
9
+ */
10
+ declare class TronProvider implements Provider {
11
+ nativeProvider: ethers.providers.StaticJsonRpcProvider;
12
+ /**
13
+ *
14
+ * @param url RPC endpoint of the Tron full node, e.g. 'https://api.trongrid.io'
15
+ * @param apiKey
16
+ */
17
+ private constructor();
18
+ static from(url: string, apiKey?: string): TronProvider;
19
+ static from(client: TronWeb): TronProvider;
20
+ /**
21
+ * Returns the native provider
22
+ */
23
+ get native(): unknown;
24
+ private buildTronWebFrom;
25
+ getBalance(address: string): Promise<string>;
26
+ getBlock(blockTag: string | number): Promise<Block>;
27
+ getBlockWithTransactions(blockTag: string | number): Promise<BlockWithTransactions>;
28
+ getBlockNumber(): Promise<number>;
29
+ getBlockTimestamp(blockTag: string | number): Promise<number>;
30
+ getSlot(_finality?: Finality): Promise<number>;
31
+ getTransaction(txHash: string): Promise<TransactionResponse>;
32
+ getTransactionReceipt(txHash: string): Promise<TransactionReceipt>;
33
+ getTransactionCount(_addressOrName: string | Promise<string>, _blockTag?: BlockTag | Promise<BlockTag>): Promise<number>;
34
+ sendTransaction(transaction: SignedTransaction, _sendOptions?: object): Promise<TransactionPending>;
35
+ sendAndConfirm(transaction: SignedTransaction, opts?: object): Promise<TransactionReceipt>;
36
+ }
37
+
38
+ /**
39
+ * TronWebProvider is a wrapper around TronWeb that implements the Provider interface
40
+ *
41
+ * PITFALL:
42
+ * - This class is not compatible with ethers.js and is not fully tested.
43
+ * - The format of the response from sendTransaction and the receipt from getTransactionReceipt differs
44
+ * from that of the ethers provider.
45
+ */
46
+ declare class TronWebProvider implements Provider {
47
+ private url;
48
+ private apiKey?;
49
+ nativeProvider: TronWeb;
50
+ /**
51
+ * Create a new TronProvider
52
+ * @param url RPC endpoint of the Tron full node, e.g. 'https://api.trongrid.io'
53
+ * @param apiKey
54
+ */
55
+ constructor(url: string, apiKey?: string | undefined);
56
+ static from(url: string, apiKey?: string): TronWebProvider;
57
+ get native(): unknown;
58
+ getBalance(address: string): Promise<string>;
59
+ getBlock(blockTag: string | number): Promise<Block>;
60
+ getBlockWithTransactions(blockTag: string | number): Promise<BlockWithTransactions>;
61
+ getBlockNumber(): Promise<number>;
62
+ getBlockTimestamp(blockTag: string | number): Promise<number>;
63
+ getSlot(_finality?: Finality): Promise<number>;
64
+ getTransaction(txHash: string): Promise<TransactionResponse>;
65
+ getTransactionReceipt(txHash: string): Promise<TransactionReceipt>;
66
+ getTransactionCount(_addressOrName: string | Promise<string>, _blockTag?: BlockTag | Promise<BlockTag>): Promise<number>;
67
+ sendTransaction(transaction: SignedTransaction, sendOptions?: {
68
+ confirmations?: number;
69
+ }): Promise<TransactionPending>;
70
+ waitTransaction(txHash: string, confirmations?: number): Promise<TransactionInfo | undefined>;
71
+ sendAndConfirm(transaction: SignedTransaction, opts?: {
72
+ confirmations?: number;
73
+ }): Promise<TransactionReceipt>;
74
+ }
75
+
76
+ /**
77
+ * TronSigner is a wrapper around TronWeb that implements the Signer interface
78
+ * It is implemented using ethers.js
79
+ */
80
+ declare class TronSigner implements Signer {
81
+ private readonly nativeSigner;
82
+ private constructor();
83
+ static from(source: ethers.Signer): Signer;
84
+ static from(client: TronWeb): Signer;
85
+ static from(privKey: string): Signer;
86
+ static from(mnemonic: string, path: string): Signer;
87
+ get native(): unknown;
88
+ connect(provider: Provider): Signer;
89
+ static buildTronWebFrom(signer: ethers.Signer): TronWeb;
90
+ static createTronWeb: (url: string, privateKey: string, apiKey?: string) => TronWeb;
91
+ getAddress(): Promise<string>;
92
+ sendAndConfirm(transaction: SignedTransaction, _opts?: object): Promise<TransactionReceipt>;
93
+ signTransaction(transaction: TransactionRequest): Promise<SignedTransaction>;
94
+ sendTransaction(transaction: SignedTransaction, _sendOptions?: object): Promise<TransactionPending>;
95
+ signBuffer(buffer: Uint8Array): Promise<Uint8Array>;
96
+ static validateTransaction(transaction: ethers.PopulatedTransaction): boolean;
97
+ }
98
+
99
+ /**
100
+ * TronWebSigner is a wrapper around TronWeb that implements the Signer interface
101
+ *
102
+ * PITFALL:
103
+ * - This class is not compatible with ethers.js and is not fully tested.
104
+ * - The signature produced by signBuffer is different from the ethers signer
105
+ * when the message length is not 32 bytes
106
+ * - The format of the response from sendTransaction differs from that of the ethers signer.
107
+ */
108
+ declare class TronWebSigner implements Signer {
109
+ private readonly nativeSigner;
110
+ private constructor();
111
+ static from(signer: TronWeb): Signer;
112
+ static from(privKey: string): Signer;
113
+ static from(mnemonic: string, path?: string): Signer;
114
+ get native(): unknown;
115
+ connect(provider: Provider): Signer;
116
+ getAddress(): Promise<string>;
117
+ sendAndConfirm(transaction: SignedTransaction, _sendOptions?: object): Promise<TransactionReceipt>;
118
+ signTransaction(transaction: TransactionRequest): Promise<SignedTransaction>;
119
+ sendTransaction(transaction: SignedTransaction, _sendOptions?: object): Promise<TransactionPending>;
120
+ /**
121
+ * signBuffer signs a buffer using the native signer
122
+ * but the signString function of native signer is different from the ethers signer,
123
+ * TronWeb uses a message header with a fixed 32 bytes length, which means that only if
124
+ * the message length is 32 bytes, the signature will be the same as the ethereum signature.
125
+ * you can find the signString function here:
126
+ * https://github.com/tronprotocol/tronweb/blob/master/src/lib/trx.js
127
+ * @param buffer
128
+ * @returns
129
+ */
130
+ signBuffer(buffer: Uint8Array): Promise<Uint8Array>;
131
+ static validateTransaction(transaction: ethers.PopulatedTransaction): boolean;
132
+ }
133
+
134
+ export { TronProvider, TronSigner, TronWebProvider, TronWebSigner };