@layerzerolabs/lz-corekit-iotal1 3.0.143

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,224 @@
1
+ import { IotaClient } from '@iota/iota-sdk/client';
2
+ import { Provider, Block, BlockWithTransactions, Finality, TransactionResponse, TransactionReceipt, BlockTag, SignedTransaction, TransactionPending, Signer, TransactionRequest } from '@layerzerolabs/lz-core';
3
+ import { Ed25519Keypair } from '@iota/iota-sdk/keypairs/ed25519';
4
+
5
+ /**
6
+ * Represents an Iota Move blockchain provider.
7
+ * Implements the Provider interface for interacting with the Iota Move blockchain.
8
+ */
9
+ declare class IotaL1Provider implements Provider {
10
+ readonly url: string;
11
+ readonly authHeader?: {
12
+ authField: string;
13
+ authValue: string;
14
+ } | undefined;
15
+ readonly nativeProvider: IotaClient;
16
+ /**
17
+ * Creates an instance of IotaL1Provider.
18
+ *
19
+ * @param {string} url - The URL of the Iota Move node.
20
+ * @param {string} [faucet] - The URL of the faucet (optional).
21
+ * @param {string} [indexer] - The URL of the indexer (optional).
22
+ * @param authHeader
23
+ */
24
+ private constructor();
25
+ /**
26
+ * Creates an instance of IotaL1Provider from the given parameters.
27
+ *
28
+ * @param {string} source - The URL of the Iota Move node.
29
+ * @param authHeader
30
+ * @returns {IotaL1Provider} The created IotaL1Provider instance.
31
+ * @throws {Error} If the source parameter is not a string.
32
+ */
33
+ static from(source: string, authHeader?: {
34
+ authField: string;
35
+ authValue: string;
36
+ }): IotaL1Provider;
37
+ /**
38
+ * Gets the native Iota Move client instance.
39
+ *
40
+ * @returns {IotaClient} The native Iota Move client instance.
41
+ */
42
+ get native(): IotaClient;
43
+ /**
44
+ * Gets the balance of the specified address.
45
+ *
46
+ * @param {string} address - The address to get the balance of.
47
+ * @returns {Promise<string>} A promise that resolves to the balance of the address.
48
+ * @throws {Error} If the address is not a valid Iota Move address.
49
+ */
50
+ getBalance(address: string): Promise<string>;
51
+ /**
52
+ * Gets the block specified by blockTag.
53
+ *
54
+ * @param {BlockTag} blockTag - The block tag to specify the block.
55
+ * @returns {Promise<Block>} A promise that resolves to the block.
56
+ * @throws {Error} If the blockTag is invalid.
57
+ */
58
+ getBlock(blockTag: string | number): Promise<Block>;
59
+ /**
60
+ * Gets the block with transactions specified by blockTag.
61
+ *
62
+ * @param {BlockTag} blockTag - The block tag to specify the block.
63
+ * @returns {Promise<BlockWithTransactions>} A promise that resolves to the block with transactions.
64
+ * @throws {Error} If the blockTag is invalid.
65
+ */
66
+ getBlockWithTransactions(blockTag: string | number): Promise<BlockWithTransactions>;
67
+ /**
68
+ * Gets the current block number.
69
+ *
70
+ * @returns {Promise<number>} A promise that resolves to the current check point.
71
+ */
72
+ getBlockNumber(): Promise<number>;
73
+ /**
74
+ * Gets the current slot number for commitment, not suitable for Iota Move.
75
+ *
76
+ * @param {Finality} [commitment] - The commitment level (optional).
77
+ * @returns {Promise<number>} A promise that resolves to the current slot number.
78
+ * @throws {Error} Method not implemented.
79
+ */
80
+ getSlot(_finality?: Finality): Promise<number>;
81
+ /**
82
+ * Gets the timestamp (A string containing a 64-bit unsigned integer) for the block identified by blockTag.
83
+ *
84
+ * @param {BlockTag} blockTag - The block tag to specify the block.
85
+ * @returns {Promise<number>} A promise that resolves to the timestamp of the block.
86
+ * @throws {Error} If the blockTag is invalid.
87
+ */
88
+ getBlockTimestamp(blockTag: string | number): Promise<number>;
89
+ /**
90
+ * Gets information about a transaction.
91
+ *
92
+ * @param {string} txHash - The hash of the transaction.
93
+ * @returns {Promise<TransactionResponse>} A promise that resolves to the transaction response.
94
+ * @throws {Error} If the transaction hash is invalid.
95
+ */
96
+ getTransaction(txHash: string): Promise<TransactionResponse>;
97
+ /**
98
+ * Gets the receipt of a transaction.
99
+ *
100
+ * @param {string} txHash - The hash of the transaction.
101
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
102
+ * @throws {Error} If the transaction hash is invalid.
103
+ */
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} If the address is invalid.
112
+ */
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
+ */
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
+ * @throws {Error} If the transaction fails.
129
+ */
130
+ confirmTransaction(pending: TransactionPending, opts?: object): Promise<TransactionReceipt>;
131
+ /**
132
+ * Sends a signed transaction and waits for confirmation.
133
+ *
134
+ * @param {SignedTransaction} transaction - The signed transaction to send.
135
+ * @param {object} [opts] - Optional parameters for sending and confirming the transaction.
136
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
137
+ */
138
+ sendAndConfirm(transaction: SignedTransaction, opts?: object): Promise<TransactionReceipt>;
139
+ }
140
+
141
+ /**
142
+ * Represents an Iota Move blockchain signer.
143
+ * Implements the Signer interface for interacting with the Iota Move blockchain.
144
+ */
145
+ declare class IotaL1Signer implements Signer {
146
+ nativeSigner: Ed25519Keypair;
147
+ provider: IotaL1Provider | undefined;
148
+ /**
149
+ * Creates an instance of IotaL1Signer.
150
+ *
151
+ * @param {Ed25519Keypair} signer - The Iota Move account to use as the signer.
152
+ */
153
+ private constructor();
154
+ /**
155
+ * Creates an instance of IotaL1Signer from the given parameters.
156
+ *
157
+ * @param {string | Ed25519Keypair} source - The source to create the signer from, could be a private key, a mnemonics or an Iota Move account.
158
+ * @param {string} [path] - The derivation path (optional). e.g. m/44'/4218'/0'/0'/0' If provided, the source is treated as a mnemonics.
159
+ * @returns {IotaL1Signer} The created IotaL1Signer instance.
160
+ * @throws {Error} If the parameters are invalid.
161
+ */
162
+ static from(source: string | Ed25519Keypair, path?: string): IotaL1Signer;
163
+ /**
164
+ * Gets the native Iota Move signer instance.
165
+ *
166
+ * @returns {Ed25519Keypair} The native Iota Move signer instance.
167
+ */
168
+ get native(): Ed25519Keypair;
169
+ /**
170
+ * Connects the signer to a provider.
171
+ *
172
+ * @param {Provider} provider - The provider to connect to.
173
+ * @returns {this} The connected signer.
174
+ * @throws {Error} If the provider is not an instance of IotaL1Provider.
175
+ */
176
+ connect(provider: Provider): this;
177
+ /**
178
+ * Gets the address of the signer.
179
+ *
180
+ * @returns {Promise<string>} A promise that resolves to the address of the signer.
181
+ */
182
+ getAddress(): Promise<string>;
183
+ /**
184
+ * Gets the address of the signer.
185
+ *
186
+ * @returns {string} The address of the signer.
187
+ */
188
+ get address(): string;
189
+ /**
190
+ * Sends a signed transaction and waits for confirmation.
191
+ *
192
+ * @param {SignedTransaction} transaction - The signed transaction to send.
193
+ * @param {object} [opts] - Optional parameters for sending and confirming the transaction.
194
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
195
+ * @throws {Error} If the provider is not connected.
196
+ */
197
+ sendAndConfirm(transaction: SignedTransaction, opts?: object): Promise<TransactionReceipt>;
198
+ /**
199
+ * Sends a signed transaction.
200
+ *
201
+ * @param {SignedTransaction} transaction - The signed transaction to send.
202
+ * @param {object} [sendOptions] - Optional parameters for sending the transaction.
203
+ * @returns {Promise<TransactionPending>} A promise that resolves to the pending transaction.
204
+ * @throws {Error} If the provider is not connected.
205
+ */
206
+ sendTransaction(transaction: SignedTransaction, sendOptions?: object): Promise<TransactionPending>;
207
+ /**
208
+ * Signs a transaction.
209
+ *
210
+ * @param {TransactionRequest} transaction - The transaction request to sign.
211
+ * @returns {Promise<SignedTransaction>} A promise that resolves to the signed transaction.
212
+ * @throws {Error} If the native provider is not connected.
213
+ */
214
+ signTransaction(transaction: TransactionRequest): Promise<SignedTransaction>;
215
+ /**
216
+ * Signs a buffer (e.g., a message hash) using the native Iota Move signer.
217
+ *
218
+ * @param {Uint8Array} buffer - The buffer to sign.
219
+ * @returns {Promise<Uint8Array>} A promise that resolves to the signed buffer as a Uint8Array.
220
+ */
221
+ signBuffer(buffer: Uint8Array): Promise<Uint8Array>;
222
+ }
223
+
224
+ export { IotaL1Provider, IotaL1Signer };
@@ -0,0 +1,224 @@
1
+ import { IotaClient } from '@iota/iota-sdk/client';
2
+ import { Provider, Block, BlockWithTransactions, Finality, TransactionResponse, TransactionReceipt, BlockTag, SignedTransaction, TransactionPending, Signer, TransactionRequest } from '@layerzerolabs/lz-core';
3
+ import { Ed25519Keypair } from '@iota/iota-sdk/keypairs/ed25519';
4
+
5
+ /**
6
+ * Represents an Iota Move blockchain provider.
7
+ * Implements the Provider interface for interacting with the Iota Move blockchain.
8
+ */
9
+ declare class IotaL1Provider implements Provider {
10
+ readonly url: string;
11
+ readonly authHeader?: {
12
+ authField: string;
13
+ authValue: string;
14
+ } | undefined;
15
+ readonly nativeProvider: IotaClient;
16
+ /**
17
+ * Creates an instance of IotaL1Provider.
18
+ *
19
+ * @param {string} url - The URL of the Iota Move node.
20
+ * @param {string} [faucet] - The URL of the faucet (optional).
21
+ * @param {string} [indexer] - The URL of the indexer (optional).
22
+ * @param authHeader
23
+ */
24
+ private constructor();
25
+ /**
26
+ * Creates an instance of IotaL1Provider from the given parameters.
27
+ *
28
+ * @param {string} source - The URL of the Iota Move node.
29
+ * @param authHeader
30
+ * @returns {IotaL1Provider} The created IotaL1Provider instance.
31
+ * @throws {Error} If the source parameter is not a string.
32
+ */
33
+ static from(source: string, authHeader?: {
34
+ authField: string;
35
+ authValue: string;
36
+ }): IotaL1Provider;
37
+ /**
38
+ * Gets the native Iota Move client instance.
39
+ *
40
+ * @returns {IotaClient} The native Iota Move client instance.
41
+ */
42
+ get native(): IotaClient;
43
+ /**
44
+ * Gets the balance of the specified address.
45
+ *
46
+ * @param {string} address - The address to get the balance of.
47
+ * @returns {Promise<string>} A promise that resolves to the balance of the address.
48
+ * @throws {Error} If the address is not a valid Iota Move address.
49
+ */
50
+ getBalance(address: string): Promise<string>;
51
+ /**
52
+ * Gets the block specified by blockTag.
53
+ *
54
+ * @param {BlockTag} blockTag - The block tag to specify the block.
55
+ * @returns {Promise<Block>} A promise that resolves to the block.
56
+ * @throws {Error} If the blockTag is invalid.
57
+ */
58
+ getBlock(blockTag: string | number): Promise<Block>;
59
+ /**
60
+ * Gets the block with transactions specified by blockTag.
61
+ *
62
+ * @param {BlockTag} blockTag - The block tag to specify the block.
63
+ * @returns {Promise<BlockWithTransactions>} A promise that resolves to the block with transactions.
64
+ * @throws {Error} If the blockTag is invalid.
65
+ */
66
+ getBlockWithTransactions(blockTag: string | number): Promise<BlockWithTransactions>;
67
+ /**
68
+ * Gets the current block number.
69
+ *
70
+ * @returns {Promise<number>} A promise that resolves to the current check point.
71
+ */
72
+ getBlockNumber(): Promise<number>;
73
+ /**
74
+ * Gets the current slot number for commitment, not suitable for Iota Move.
75
+ *
76
+ * @param {Finality} [commitment] - The commitment level (optional).
77
+ * @returns {Promise<number>} A promise that resolves to the current slot number.
78
+ * @throws {Error} Method not implemented.
79
+ */
80
+ getSlot(_finality?: Finality): Promise<number>;
81
+ /**
82
+ * Gets the timestamp (A string containing a 64-bit unsigned integer) for the block identified by blockTag.
83
+ *
84
+ * @param {BlockTag} blockTag - The block tag to specify the block.
85
+ * @returns {Promise<number>} A promise that resolves to the timestamp of the block.
86
+ * @throws {Error} If the blockTag is invalid.
87
+ */
88
+ getBlockTimestamp(blockTag: string | number): Promise<number>;
89
+ /**
90
+ * Gets information about a transaction.
91
+ *
92
+ * @param {string} txHash - The hash of the transaction.
93
+ * @returns {Promise<TransactionResponse>} A promise that resolves to the transaction response.
94
+ * @throws {Error} If the transaction hash is invalid.
95
+ */
96
+ getTransaction(txHash: string): Promise<TransactionResponse>;
97
+ /**
98
+ * Gets the receipt of a transaction.
99
+ *
100
+ * @param {string} txHash - The hash of the transaction.
101
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
102
+ * @throws {Error} If the transaction hash is invalid.
103
+ */
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} If the address is invalid.
112
+ */
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
+ */
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
+ * @throws {Error} If the transaction fails.
129
+ */
130
+ confirmTransaction(pending: TransactionPending, opts?: object): Promise<TransactionReceipt>;
131
+ /**
132
+ * Sends a signed transaction and waits for confirmation.
133
+ *
134
+ * @param {SignedTransaction} transaction - The signed transaction to send.
135
+ * @param {object} [opts] - Optional parameters for sending and confirming the transaction.
136
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
137
+ */
138
+ sendAndConfirm(transaction: SignedTransaction, opts?: object): Promise<TransactionReceipt>;
139
+ }
140
+
141
+ /**
142
+ * Represents an Iota Move blockchain signer.
143
+ * Implements the Signer interface for interacting with the Iota Move blockchain.
144
+ */
145
+ declare class IotaL1Signer implements Signer {
146
+ nativeSigner: Ed25519Keypair;
147
+ provider: IotaL1Provider | undefined;
148
+ /**
149
+ * Creates an instance of IotaL1Signer.
150
+ *
151
+ * @param {Ed25519Keypair} signer - The Iota Move account to use as the signer.
152
+ */
153
+ private constructor();
154
+ /**
155
+ * Creates an instance of IotaL1Signer from the given parameters.
156
+ *
157
+ * @param {string | Ed25519Keypair} source - The source to create the signer from, could be a private key, a mnemonics or an Iota Move account.
158
+ * @param {string} [path] - The derivation path (optional). e.g. m/44'/4218'/0'/0'/0' If provided, the source is treated as a mnemonics.
159
+ * @returns {IotaL1Signer} The created IotaL1Signer instance.
160
+ * @throws {Error} If the parameters are invalid.
161
+ */
162
+ static from(source: string | Ed25519Keypair, path?: string): IotaL1Signer;
163
+ /**
164
+ * Gets the native Iota Move signer instance.
165
+ *
166
+ * @returns {Ed25519Keypair} The native Iota Move signer instance.
167
+ */
168
+ get native(): Ed25519Keypair;
169
+ /**
170
+ * Connects the signer to a provider.
171
+ *
172
+ * @param {Provider} provider - The provider to connect to.
173
+ * @returns {this} The connected signer.
174
+ * @throws {Error} If the provider is not an instance of IotaL1Provider.
175
+ */
176
+ connect(provider: Provider): this;
177
+ /**
178
+ * Gets the address of the signer.
179
+ *
180
+ * @returns {Promise<string>} A promise that resolves to the address of the signer.
181
+ */
182
+ getAddress(): Promise<string>;
183
+ /**
184
+ * Gets the address of the signer.
185
+ *
186
+ * @returns {string} The address of the signer.
187
+ */
188
+ get address(): string;
189
+ /**
190
+ * Sends a signed transaction and waits for confirmation.
191
+ *
192
+ * @param {SignedTransaction} transaction - The signed transaction to send.
193
+ * @param {object} [opts] - Optional parameters for sending and confirming the transaction.
194
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
195
+ * @throws {Error} If the provider is not connected.
196
+ */
197
+ sendAndConfirm(transaction: SignedTransaction, opts?: object): Promise<TransactionReceipt>;
198
+ /**
199
+ * Sends a signed transaction.
200
+ *
201
+ * @param {SignedTransaction} transaction - The signed transaction to send.
202
+ * @param {object} [sendOptions] - Optional parameters for sending the transaction.
203
+ * @returns {Promise<TransactionPending>} A promise that resolves to the pending transaction.
204
+ * @throws {Error} If the provider is not connected.
205
+ */
206
+ sendTransaction(transaction: SignedTransaction, sendOptions?: object): Promise<TransactionPending>;
207
+ /**
208
+ * Signs a transaction.
209
+ *
210
+ * @param {TransactionRequest} transaction - The transaction request to sign.
211
+ * @returns {Promise<SignedTransaction>} A promise that resolves to the signed transaction.
212
+ * @throws {Error} If the native provider is not connected.
213
+ */
214
+ signTransaction(transaction: TransactionRequest): Promise<SignedTransaction>;
215
+ /**
216
+ * Signs a buffer (e.g., a message hash) using the native Iota Move signer.
217
+ *
218
+ * @param {Uint8Array} buffer - The buffer to sign.
219
+ * @returns {Promise<Uint8Array>} A promise that resolves to the signed buffer as a Uint8Array.
220
+ */
221
+ signBuffer(buffer: Uint8Array): Promise<Uint8Array>;
222
+ }
223
+
224
+ export { IotaL1Provider, IotaL1Signer };