@layerzerolabs/lz-corekit-solana 3.0.15 → 3.0.16

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.ts CHANGED
@@ -1,59 +1,256 @@
1
1
  import { Connection, SendOptions, TransactionConfirmationStrategy, Keypair, PublicKey, ConfirmOptions, Commitment, GetLatestBlockhashConfig, Transaction, VersionedTransaction } from '@solana/web3.js';
2
2
  import { Provider, Block, Finality, TransactionResponse, TransactionReceipt, BlockTag, BlockWithTransactions, SignedTransaction, TransactionPending, Signer, TransactionRequest } from '@layerzerolabs/lz-core';
3
3
 
4
+ /**
5
+ * Represents a Solana blockchain provider.
6
+ * Implements the Provider interface for interacting with Solana-compatible blockchains.
7
+ */
4
8
  declare class SolanaProvider implements Provider {
5
9
  url: string;
6
10
  nativeProvider: Connection;
11
+ /**
12
+ * Creates an instance of SolanaProvider.
13
+ *
14
+ * @param {string} url - The URL of the Solana node.
15
+ */
7
16
  constructor(url: string);
17
+ /**
18
+ * Creates an instance of SolanaProvider from the given URL.
19
+ *
20
+ * @param {string} url - The URL of the Solana node.
21
+ * @returns {SolanaProvider} The created SolanaProvider instance.
22
+ * @throws {Error} If the URL parameter is invalid.
23
+ */
8
24
  static from(url: string): SolanaProvider;
25
+ /**
26
+ * Gets the native Solana provider instance.
27
+ *
28
+ * @returns {Connection} The native Solana provider instance.
29
+ */
9
30
  get native(): Connection;
31
+ /**
32
+ * Gets the balance of the specified address.
33
+ *
34
+ * @param {string} address - The address to get the balance of.
35
+ * @returns {Promise<string>} A promise that resolves to the balance of the address.
36
+ */
10
37
  getBalance(address: string): Promise<string>;
38
+ /**
39
+ * Gets the block specified by slot.
40
+ *
41
+ * @param {BlockTag} slot - The slot to specify the block.
42
+ * @returns {Promise<Block>} A promise that resolves to the block.
43
+ */
11
44
  getBlock(slot: string | number): Promise<Block>;
45
+ /**
46
+ * Gets the current block number.
47
+ *
48
+ * @returns {Promise<number>} A promise that resolves to the current block number.
49
+ */
12
50
  getBlockNumber(): Promise<number>;
51
+ /**
52
+ * Gets the current slot number for commitment.
53
+ *
54
+ * @param {Finality} [finality] - The commitment level (optional).
55
+ * @returns {Promise<number>} A promise that resolves to the current slot number.
56
+ */
13
57
  getSlot(finality?: Finality): Promise<number>;
58
+ /**
59
+ * Gets the UNIX timestamp for the block identified by slot.
60
+ *
61
+ * @param {BlockTag} slot - The slot to specify the block.
62
+ * @returns {Promise<number>} A promise that resolves to the UNIX timestamp of the block.
63
+ * @throws {Error} If the block timestamp is not available.
64
+ */
14
65
  getBlockTimestamp(slot: string | number): Promise<number>;
15
66
  /**
67
+ * Gets information about a transaction.
16
68
  *
17
- * @param txHash string The transaction hash is TransactionSignature in Solana
18
- * @returns TransactionResponse
69
+ * @param {string} txHash - The transaction hash is TransactionSignature in Solana
70
+ * @returns {Promise<TransactionResponse>} A promise that resolves to the transaction response
19
71
  */
20
72
  getTransaction(txHash: string): Promise<TransactionResponse>;
73
+ /**
74
+ * Gets the receipt of a transaction.
75
+ *
76
+ * @param {string} txHash - The transaction hash is TransactionSignature in Solana
77
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
78
+ * @throws {Error} If the transaction is not found.
79
+ */
21
80
  getTransactionReceipt(txHash: string): Promise<TransactionReceipt>;
81
+ /**
82
+ * Gets the number of transactions sent from the specified address.
83
+ *
84
+ * @param {string | Promise<string>} _addressOrName - The address to get the number of transactions from.
85
+ * @param {BlockTag | Promise<BlockTag>} [_blockTag] - The block tag to get the number of transactions from (optional).
86
+ * @returns {Promise<number>} A promise that resolves to the number of transactions sent from the address.
87
+ * @throws {Error} Method not implemented.
88
+ */
22
89
  getTransactionCount(_addressOrName: string | Promise<string>, _blockTag?: BlockTag | Promise<BlockTag>): Promise<number>;
90
+ /**
91
+ * Gets the block with transactions specified by blockTag.
92
+ *
93
+ * @param {BlockTag} blockTag - The block tag to specify the block.
94
+ * @returns {Promise<BlockWithTransactions>} A promise that resolves to the block with transactions.
95
+ * @throws {Error} If the block is not found.
96
+ */
23
97
  getBlockWithTransactions(blockTag: string | number): Promise<BlockWithTransactions>;
98
+ /**
99
+ * Sends a signed transaction to the blockchain.
100
+ *
101
+ * @param {SignedTransaction} transaction - The signed transaction to send.
102
+ * @param {SendOptions} [sendOptions] - Optional parameters for sending the transaction.
103
+ * @returns {Promise<TransactionPending>} A promise that resolves to the pending transaction.
104
+ */
24
105
  sendTransaction(transaction: SignedTransaction, sendOptions?: SendOptions): Promise<TransactionPending>;
106
+ /**
107
+ * Confirms a pending transaction.
108
+ *
109
+ * @param {TransactionPending} pending - The pending transaction to confirm.
110
+ * @param {TransactionConfirmationStrategy} [opts] - Optional parameters for the confirmation.
111
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
112
+ * @throws {Error} If the transaction fails.
113
+ */
25
114
  confirmTransaction(pending: TransactionPending, opts?: TransactionConfirmationStrategy): Promise<TransactionReceipt>;
115
+ /**
116
+ * Sends a signed transaction and waits for confirmation.
117
+ *
118
+ * @param {SignedTransaction} transaction - The signed transaction to send.
119
+ * @param {object} [opts] - Optional parameters for sending and confirming the transaction.
120
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
121
+ */
26
122
  sendAndConfirm(transaction: SignedTransaction, opts?: {
27
123
  confirm?: TransactionConfirmationStrategy;
28
124
  send?: SendOptions;
29
125
  }): Promise<TransactionReceipt>;
30
126
  }
31
127
 
128
+ /**
129
+ * Represents a Solana blockchain signer.
130
+ * Implements the Signer interface for interacting with Solana-compatible blockchains.
131
+ */
32
132
  declare class SolanaSigner implements Signer {
33
133
  private readonly keypair;
34
134
  private provider?;
135
+ /**
136
+ * Creates an instance of SolanaSigner.
137
+ *
138
+ * @param {Keypair} keypair - The Solana keypair to use as the signer.
139
+ */
35
140
  private constructor();
141
+ /**
142
+ * Creates an instance of SolanaSigner from a Keypair.
143
+ *
144
+ * @param {Keypair} source - The Solana keypair to create the signer from.
145
+ * @returns {SolanaSigner} The created SolanaSigner instance.
146
+ */
36
147
  static from(source: Keypair): SolanaSigner;
148
+ /**
149
+ * Creates an instance of SolanaSigner from a mnemonic and derivation path.
150
+ *
151
+ * @param {string} mnemonic - The mnemonic to create the signer from.
152
+ * @param {string} path - The derivation path (e.g., m/44'/501'/0'/0').
153
+ * @returns {SolanaSigner} The created SolanaSigner instance.
154
+ */
37
155
  static from(mnemonic: string, path: string): SolanaSigner;
156
+ /**
157
+ * Gets the native Solana keypair instance.
158
+ *
159
+ * @returns {Keypair} The native Solana keypair instance.
160
+ */
38
161
  get native(): unknown;
162
+ /**
163
+ * Connects the signer to a provider.
164
+ *
165
+ * @param {Provider} provider - The provider to connect to.
166
+ * @returns {this} The connected signer.
167
+ * @throws {Error} If the provider is not an instance of Connection.
168
+ */
39
169
  connect(provider: Provider): this;
170
+ /**
171
+ * Gets the address of the signer.
172
+ *
173
+ * @returns {Promise<string>} A promise that resolves to the address of the signer.
174
+ */
40
175
  getAddress(): Promise<string>;
176
+ /**
177
+ * Gets the address of the signer.
178
+ *
179
+ * @returns {string} The address of the signer.
180
+ */
41
181
  get address(): string;
182
+ /**
183
+ * Gets the public key of the signer.
184
+ *
185
+ * @returns {PublicKey} The public key of the signer.
186
+ */
42
187
  get publicKey(): PublicKey;
188
+ /**
189
+ * Gets the secret key of the signer.
190
+ *
191
+ * @returns {Uint8Array} The secret key of the signer.
192
+ */
43
193
  get secretKey(): Uint8Array;
194
+ /**
195
+ * Sends a signed transaction and waits for confirmation.
196
+ *
197
+ * @param {SignedTransaction} transaction - The signed transaction to send.
198
+ * @param {ConfirmOptions} [opts] - Optional parameters for sending and confirming the transaction.
199
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
200
+ */
44
201
  sendAndConfirm(transaction: SignedTransaction, opts?: ConfirmOptions): Promise<TransactionReceipt>;
202
+ /**
203
+ * Sends a signed transaction.
204
+ *
205
+ * @param {SignedTransaction} transaction - The signed transaction to send.
206
+ * @param {SendOptions} [sendOptions] - Optional parameters for sending the transaction.
207
+ * @returns {Promise<TransactionPending>} A promise that resolves to the pending transaction.
208
+ */
45
209
  sendTransaction(transaction: SignedTransaction, sendOptions?: SendOptions): Promise<TransactionPending>;
210
+ /**
211
+ * Signs a transaction.
212
+ *
213
+ * @param {TransactionRequest} transaction - The transaction request to sign.
214
+ * @param {Commitment | GetLatestBlockhashConfig} [opts] - Optional parameters for signing the transaction.
215
+ * @returns {Promise<SignedTransaction>} A promise that resolves to the signed transaction.
216
+ */
46
217
  signTransaction(transaction: TransactionRequest, opts?: Commitment | GetLatestBlockhashConfig): Promise<SignedTransaction>;
218
+ /**
219
+ * Signs a buffer (e.g., a message hash) using the native Solana signer.
220
+ *
221
+ * @param {Uint8Array} _buffer - The buffer to sign.
222
+ * @returns {Promise<Uint8Array>} A promise that resolves to the signed buffer as a Uint8Array.
223
+ * @throws {Error} Method not implemented.
224
+ */
47
225
  signBuffer(_buffer: Uint8Array): Promise<Uint8Array>;
226
+ /**
227
+ * Partially signs a transaction.
228
+ *
229
+ * @param {Transaction | VersionedTransaction} tx - The transaction to partially sign.
230
+ */
48
231
  partialSign(tx: Transaction | VersionedTransaction): void;
232
+ /**
233
+ * Asserts that the provider is connected and returns it.
234
+ *
235
+ * @returns {Connection} The connected provider.
236
+ * @throws {Error} If the provider is not connected.
237
+ */
49
238
  private assertAndGetProvider;
239
+ /**
240
+ * Builds a transaction.
241
+ *
242
+ * @param {unknown} buildTxRequest - The transaction request to build.
243
+ * @returns {Promise<TransactionRequest>} A promise that resolves to the built transaction request.
244
+ * @throws {Error} Method not implemented.
245
+ */
50
246
  buildTransaction(buildTxRequest: unknown): Promise<TransactionRequest>;
51
247
  }
52
248
  /**
53
249
  * Check if a transaction object is a VersionedTransaction or not
54
250
  * This function is not exported from @coral-xyz/anchor currently.
55
- * @param tx
56
- * @returns bool
251
+ *
252
+ * @param {Transaction | VersionedTransaction} tx - The transaction to check.
253
+ * @returns {boolean} True if the transaction is a VersionedTransaction, false otherwise.
57
254
  */
58
255
  declare const isVersionedTransaction: (tx: Transaction | VersionedTransaction) => tx is VersionedTransaction;
59
256