@layerzerolabs/lz-corekit-evm 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/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @layerzerolabs/lz-corekit-evm
2
2
 
3
+ ## 3.0.17
4
+
5
+ ### Patch Changes
6
+
7
+ - 40f2269: islander mainnet
8
+ - 40f2269: testnets
9
+ - Updated dependencies [40f2269]
10
+ - Updated dependencies [40f2269]
11
+ - @layerzerolabs/lz-core@3.0.17
12
+ - @layerzerolabs/lz-utilities@3.0.17
13
+
14
+ ## 3.0.16
15
+
16
+ ### Patch Changes
17
+
18
+ - 87a4bc9: islander mainnet
19
+ - Updated dependencies [87a4bc9]
20
+ - @layerzerolabs/lz-core@3.0.16
21
+ - @layerzerolabs/lz-utilities@3.0.16
22
+
3
23
  ## 3.0.15
4
24
 
5
25
  ### Patch Changes
package/README.md CHANGED
@@ -1 +1,98 @@
1
- # @layerzerolabs/lz-corekit
1
+ # @layerzerolabs/lz-corekit-evm
2
+
3
+ The EVM CoreKit is a comprehensive SDK designed to interact with the EVM-compatible blockchain. It provides a set of utilities and modules to facilitate the development and integration of applications with the EVM-compatible blockchain.
4
+
5
+ ## Features
6
+
7
+ - **Retrieve Account Information**: Gets the balance of the specified address.
8
+ - **Retrieve Block Information**: Gets the block height, timestamp and related transactions of the specified block.
9
+ - **Transaction Management**: Get, build, sign, send and confirm transactions.
10
+
11
+ ## Installation
12
+
13
+ To install the EVM CoreKit, you can use npm or yarn:
14
+
15
+ ```sh
16
+ npm install @layerzerolabs/lz-corekit-evm
17
+ ```
18
+
19
+ or
20
+
21
+ ```sh
22
+ yarn add @layerzerolabs/lz-corekit-evm
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ ### Initialization
28
+
29
+ ```typescript
30
+ import { EvmProvider } from "@layerzerolabs/lz-corekit-evm";
31
+
32
+ // url is the EVM-compatible chain full node url
33
+ const url = "http://127.0.0.1:8502";
34
+ const provider = EvmProvider.from(url);
35
+ ```
36
+
37
+ ### Retrieve Account Information
38
+
39
+ #### Get Account Balance
40
+
41
+ ```typescript
42
+ import { EvmProvider } from "@layerzerolabs/lz-corekit-evm";
43
+
44
+ // url is the EVM-compatible chain full node url
45
+ const url = "http://127.0.0.1:8502";
46
+ const provider = EvmProvider.from(url);
47
+
48
+ const address = "0x1";
49
+ const balance = await provider.getBalance(address);
50
+ ```
51
+
52
+ ### Retrieve Block Information
53
+
54
+ #### Get Latest Block Height
55
+
56
+ ```typescript
57
+ import { EvmProvider } from "@layerzerolabs/lz-corekit-evm";
58
+
59
+ // url is the EVM-compatible chain full node url
60
+ const url = "http://127.0.0.1:8502";
61
+ const provider = EvmProvider.from(url);
62
+
63
+ const number = await provider.getBlockNumber();
64
+ ```
65
+
66
+ ### Transaction Management
67
+
68
+ #### Get Transaction by hash
69
+
70
+ ```typescript
71
+ import { EvmProvider } from "@layerzerolabs/lz-corekit-evm";
72
+
73
+ // url is the EVM-compatible chain full node url
74
+ const url = "http://127.0.0.1:8502";
75
+ const provider = EvmProvider.from(url);
76
+
77
+ const hash = "0x1";
78
+ const tx = await provider.getTransaction(hash);
79
+ ```
80
+
81
+ #### Sign, Send and Confirm Transaction
82
+
83
+ ```typescript
84
+ import { EvmProvider, EvmSigner } from '@layerzerolabs/lz-corekit-evm'
85
+ import { SignedTransaction, TransactionReceipt, TransactionRequest } from '@layerzerolabs/lz-core'
86
+
87
+ // url is the EVM-compatible chain full node url
88
+ const url = "http://127.0.0.1:8502"
89
+ const provider = EvmProvider.from(url)
90
+
91
+ const privateKey = '0x1234'
92
+ const signer = EvmSigner.from(privateKey)
93
+ signer.connect(provider)
94
+
95
+ const tx: TransactionRequest = ...
96
+ const stx: SignedTransaction = await signer.signTransaction(tx)
97
+ const receipt: TransactionReceipt = await signer.sendAndConfirm(stx)
98
+ ```
package/dist/index.cjs CHANGED
@@ -5,10 +5,22 @@ var lzCore = require('@layerzerolabs/lz-core');
5
5
 
6
6
  // src/providers/evm.ts
7
7
  var EvmProvider = class _EvmProvider {
8
+ /**
9
+ * Creates an instance of EvmProvider.
10
+ *
11
+ * @param {string} url - The URL of the EVM node.
12
+ */
8
13
  constructor(url) {
9
14
  this.url = url;
10
15
  this.nativeProvider = new ethers.ethers.providers.JsonRpcProvider(url);
11
16
  }
17
+ /**
18
+ * Creates an instance of EvmProvider from the given source.
19
+ *
20
+ * @param {string} source - The source to create the provider from.
21
+ * @returns {EvmProvider} The created EvmProvider instance.
22
+ * @throws {Error} If the source parameter is not a string.
23
+ */
12
24
  static from(source) {
13
25
  if (typeof source === "string") {
14
26
  return new _EvmProvider(source);
@@ -16,61 +28,155 @@ var EvmProvider = class _EvmProvider {
16
28
  throw new Error("Invalid parameters");
17
29
  }
18
30
  }
31
+ /**
32
+ * Gets the native EVM provider instance.
33
+ *
34
+ * @returns {ethers.providers.JsonRpcProvider} The native EVM provider instance.
35
+ */
19
36
  get native() {
20
37
  return this.nativeProvider;
21
38
  }
39
+ /**
40
+ * Gets the balance of the specified address.
41
+ *
42
+ * @param {string} address - The address to get the balance of.
43
+ * @returns {Promise<string>} A promise that resolves to the balance of the address.
44
+ */
22
45
  async getBalance(address) {
23
46
  return (await this.nativeProvider.getBalance(address)).toString();
24
47
  }
48
+ /**
49
+ * Gets the block specified by blockTag.
50
+ *
51
+ * @param {BlockTag} blockTag - The block tag to specify the block.
52
+ * @returns {Promise<Block>} A promise that resolves to the block.
53
+ */
25
54
  async getBlock(blockTag) {
26
55
  const response = await this.nativeProvider.getBlock(blockTag);
27
56
  return lzCore.Block.from(response);
28
57
  }
58
+ /**
59
+ * Gets the block with transactions specified by blockTag.
60
+ *
61
+ * @param {BlockTag} blockTag - The block tag to specify the block.
62
+ * @returns {Promise<BlockWithTransactions>} A promise that resolves to the block with transactions.
63
+ */
29
64
  async getBlockWithTransactions(blockTag) {
30
65
  const response = await this.nativeProvider.getBlockWithTransactions(blockTag);
31
66
  return lzCore.BlockWithTransactions.from(response);
32
67
  }
68
+ /**
69
+ * Gets the current block number.
70
+ *
71
+ * @returns {Promise<number>} A promise that resolves to the current block number.
72
+ */
33
73
  async getBlockNumber() {
34
74
  return this.nativeProvider.getBlockNumber();
35
75
  }
76
+ /**
77
+ * Gets the current slot number for commitment, not suitable for EVM.
78
+ *
79
+ * @param {Finality} [finality] - The commitment level (optional).
80
+ * @returns {Promise<number>} A promise that resolves to the current slot number.
81
+ * @throws {Error} Method not implemented.
82
+ */
36
83
  // eslint-disable-next-line @typescript-eslint/require-await
37
84
  async getSlot(_finality) {
38
85
  await Promise.resolve();
39
86
  throw new Error("Method not implemented.");
40
87
  }
88
+ /**
89
+ * Gets the UNIX timestamp for the block identified by blockTag.
90
+ *
91
+ * @param {BlockTag} blockTag - The block tag to specify the block.
92
+ * @returns {Promise<number>} A promise that resolves to the UNIX timestamp of the block.
93
+ */
41
94
  async getBlockTimestamp(blockTag) {
42
95
  return this.nativeProvider.getBlock(blockTag).then((block) => block.timestamp);
43
96
  }
97
+ /**
98
+ * Gets information about a transaction.
99
+ *
100
+ * @param {string} txHash - The hash of the transaction.
101
+ * @returns {Promise<TransactionResponse>} A promise that resolves to the transaction response.
102
+ */
44
103
  async getTransaction(txHash) {
45
104
  const response = await this.nativeProvider.getTransaction(txHash);
46
105
  return lzCore.TransactionResponse.from(response);
47
106
  }
107
+ /**
108
+ * Gets the receipt of a transaction.
109
+ *
110
+ * @param {string} txHash - The hash of the transaction.
111
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
112
+ */
48
113
  async getTransactionReceipt(txHash) {
49
114
  const response = await this.nativeProvider.getTransactionReceipt(txHash);
50
115
  return lzCore.TransactionReceipt.from(response);
51
116
  }
117
+ /**
118
+ * Gets the number of transactions sent from the specified address.
119
+ *
120
+ * @param {string | Promise<string>} addressOrName - The address to get the number of transactions from.
121
+ * @param {BlockTag | Promise<BlockTag>} [blockTag] - The block tag to get the number of transactions from (optional).
122
+ * @returns {Promise<number>} A promise that resolves to the number of transactions sent from the address.
123
+ */
52
124
  async getTransactionCount(addressOrName, blockTag) {
53
125
  return this.nativeProvider.getTransactionCount(addressOrName, blockTag);
54
126
  }
127
+ /**
128
+ * Sends a signed transaction to the blockchain.
129
+ *
130
+ * @param {SignedTransaction} transaction - The signed transaction to send.
131
+ * @param {object} [sendOptions] - Optional parameters for sending the transaction.
132
+ * @returns {Promise<TransactionPending>} A promise that resolves to the pending transaction.
133
+ */
55
134
  async sendTransaction(transaction, _sendOptions) {
56
135
  const stx = transaction.signed;
57
136
  const response = await this.nativeProvider.sendTransaction(stx);
58
137
  return lzCore.TransactionPending.from(response);
59
138
  }
139
+ /**
140
+ * Confirms a pending transaction.
141
+ *
142
+ * @param {TransactionPending} pending - The pending transaction to confirm.
143
+ * @param {object} [opts] - Optional parameters for the confirmation.
144
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
145
+ */
60
146
  async confirmTransaction(pending, _opts) {
61
147
  const nativePending = pending.pending;
62
148
  const response = await nativePending.wait();
63
149
  return lzCore.TransactionReceipt.from(response);
64
150
  }
151
+ /**
152
+ * Sends a signed transaction and waits for confirmation.
153
+ *
154
+ * @param {SignedTransaction} transaction - The signed transaction to send.
155
+ * @param {object} [opts] - Optional parameters for sending and confirming the transaction.
156
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
157
+ */
65
158
  async sendAndConfirm(transaction, opts) {
66
159
  const pending = await this.sendTransaction(transaction, opts);
67
160
  return this.confirmTransaction(pending, opts);
68
161
  }
69
162
  };
70
163
  var EvmSigner = class {
164
+ /**
165
+ * Creates an instance of EvmSigner.
166
+ *
167
+ * @param {ethers.Signer} signer - The EVM signer to use.
168
+ */
71
169
  constructor(signer) {
72
170
  this.nativeSigner = signer;
73
171
  }
172
+ /**
173
+ * Creates an instance of EvmSigner from the given source.
174
+ *
175
+ * @param {ethers.Signer | string} source - The source to create the signer from.
176
+ * @param {string} [path] - The derivation path (optional).
177
+ * @returns {EvmSigner} The created EvmSigner instance.
178
+ * @throws {Error} If the source parameter is invalid.
179
+ */
74
180
  static from(source, path) {
75
181
  if (source instanceof ethers.ethers.Signer) {
76
182
  return new this(source);
@@ -81,9 +187,21 @@ var EvmSigner = class {
81
187
  return new this(ethers.ethers.Wallet.fromMnemonic(source, path));
82
188
  }
83
189
  }
190
+ /**
191
+ * Gets the native EVM signer instance.
192
+ *
193
+ * @returns {ethers.Signer} The native EVM signer instance.
194
+ */
84
195
  get native() {
85
196
  return this.nativeSigner;
86
197
  }
198
+ /**
199
+ * Connects the signer to a provider.
200
+ *
201
+ * @param {Provider} provider - The provider to connect to.
202
+ * @returns {this} The connected signer.
203
+ * @throws {Error} If the provider is not an instance of ethers.providers.Provider.
204
+ */
87
205
  connect(provider) {
88
206
  if (!(provider.native instanceof ethers.ethers.providers.Provider)) {
89
207
  throw new Error("Only ethers.providers.Provider is supported.");
@@ -91,18 +209,42 @@ var EvmSigner = class {
91
209
  this.nativeSigner = this.nativeSigner.connect(provider.native);
92
210
  return this;
93
211
  }
212
+ /**
213
+ * Gets the address of the signer.
214
+ *
215
+ * @returns {Promise<string>} A promise that resolves to the address of the signer.
216
+ */
94
217
  async getAddress() {
95
218
  return this.nativeSigner.getAddress();
96
219
  }
220
+ /**
221
+ * Gets the address of the signer.
222
+ *
223
+ * @returns {string} The address of the signer.
224
+ */
97
225
  get address() {
98
226
  return this.nativeSigner.address;
99
227
  }
228
+ /**
229
+ * Sends a signed transaction and waits for confirmation.
230
+ *
231
+ * @param {SignedTransaction} transaction - The signed transaction to send.
232
+ * @param {object} [opts] - Optional parameters for sending and confirming the transaction.
233
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
234
+ */
100
235
  async sendAndConfirm(transaction, opts) {
101
236
  const pending = await this.sendTransaction(transaction);
102
237
  const response = pending.pending;
103
238
  const receipt = await response.wait(opts?.confirmations);
104
239
  return lzCore.TransactionReceipt.from(receipt);
105
240
  }
241
+ /**
242
+ * Sends a signed transaction.
243
+ *
244
+ * @param {SignedTransaction} transaction - The signed transaction to send.
245
+ * @returns {Promise<TransactionPending>} A promise that resolves to the pending transaction.
246
+ * @throws {Error} If no provider is attached to the signer.
247
+ */
106
248
  async sendTransaction(transaction) {
107
249
  const stx = transaction.signed;
108
250
  if (this.nativeSigner.provider === void 0) {
@@ -111,22 +253,31 @@ var EvmSigner = class {
111
253
  const response = await this.nativeSigner.provider.sendTransaction(stx);
112
254
  return lzCore.TransactionPending.from(response);
113
255
  }
256
+ /**
257
+ * Signs a transaction.
258
+ *
259
+ * @param {TransactionRequest} transaction - The transaction request to sign.
260
+ * @returns {Promise<SignedTransaction>} A promise that resolves to the signed transaction.
261
+ */
114
262
  async signTransaction(transaction) {
115
263
  const tx = transaction.request;
116
264
  const populatedTransaction = await this.nativeSigner.populateTransaction(tx);
117
265
  const response = await this.nativeSigner.signTransaction(populatedTransaction);
118
266
  return lzCore.SignedTransaction.from(response);
119
267
  }
268
+ /**
269
+ * Signs a buffer (e.g., a message hash) using the native EVM signer.
270
+ *
271
+ * @param {Uint8Array} buffer - The buffer to sign.
272
+ * @returns {Promise<Uint8Array>} A promise that resolves to the signed buffer as a Uint8Array.
273
+ */
120
274
  async signBuffer(buffer) {
121
275
  const signedMessage = await this.nativeSigner.signMessage(buffer);
122
276
  return ethers.ethers.utils.arrayify(signedMessage);
123
277
  }
124
- async buildTransaction(buildTxRequest) {
125
- return Promise.reject(new Error("Method not implemented."));
126
- }
127
278
  };
128
279
 
129
280
  exports.EvmProvider = EvmProvider;
130
281
  exports.EvmSigner = EvmSigner;
131
- //# sourceMappingURL=out.js.map
282
+ //# sourceMappingURL=index.cjs.map
132
283
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/providers/evm.ts","../src/signers/evm.ts"],"names":["ethers","SignedTransaction","TransactionPending","TransactionReceipt"],"mappings":";AAAA,SAAS,cAAc;AAEvB;AAAA,EACI;AAAA,EAEA;AAAA,EAIA;AA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\n Finality,\n Provider,\n SignedTransaction,\n TransactionPending,\n TransactionReceipt,\n TransactionResponse,\n} from '@layerzerolabs/lz-core'\n\nexport class EvmProvider implements Provider {\n nativeProvider: ethers.providers.JsonRpcProvider\n\n constructor(public url: string) {\n this.nativeProvider = new ethers.providers.JsonRpcProvider(url)\n }\n\n static from(url: string): EvmProvider\n\n static from(source: string): EvmProvider {\n if (typeof source === 'string') {\n return new EvmProvider(source)\n } else {\n throw new Error('Invalid parameters')\n }\n }\n\n get native(): ethers.providers.JsonRpcProvider {\n return this.nativeProvider\n }\n\n async getBalance(address: string): Promise<string> {\n return (await this.nativeProvider.getBalance(address)).toString()\n }\n\n async getBlock(blockTag: string | number): Promise<Block> {\n const response = await this.nativeProvider.getBlock(blockTag)\n return Block.from(response)\n }\n\n async getBlockWithTransactions(blockTag: string | number): Promise<BlockWithTransactions> {\n const response = await this.nativeProvider.getBlockWithTransactions(blockTag)\n return BlockWithTransactions.from(response)\n }\n\n async getBlockNumber(): Promise<number> {\n return this.nativeProvider.getBlockNumber()\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n async getSlot(_finality?: Finality): Promise<number> {\n await Promise.resolve()\n throw new Error('Method not implemented.')\n }\n\n async getBlockTimestamp(blockTag: string | number): Promise<number> {\n return this.nativeProvider.getBlock(blockTag).then((block) => block.timestamp)\n }\n\n async getTransaction(txHash: string): Promise<TransactionResponse> {\n const response = await this.nativeProvider.getTransaction(txHash)\n return TransactionResponse.from(response)\n }\n\n async getTransactionReceipt(txHash: string): Promise<TransactionReceipt> {\n const response = await this.nativeProvider.getTransactionReceipt(txHash)\n return TransactionReceipt.from(response)\n }\n\n async getTransactionCount(\n addressOrName: string | Promise<string>,\n blockTag?: BlockTag | Promise<BlockTag>\n ): Promise<number> {\n return this.nativeProvider.getTransactionCount(addressOrName, blockTag)\n }\n\n async sendTransaction(transaction: SignedTransaction, _sendOptions?: object): Promise<TransactionPending> {\n type NativeSignedTransaction = Parameters<typeof this.nativeProvider.sendTransaction>[0]\n const stx = transaction.signed as NativeSignedTransaction\n\n const response = await this.nativeProvider.sendTransaction(stx)\n return TransactionPending.from(response)\n }\n\n async confirmTransaction(pending: TransactionPending, _opts?: object): Promise<TransactionReceipt> {\n const nativePending = pending.pending as ethers.providers.TransactionResponse\n const response = await nativePending.wait()\n return TransactionReceipt.from(response)\n }\n\n async sendAndConfirm(transaction: SignedTransaction, opts?: object): Promise<TransactionReceipt> {\n const pending = await this.sendTransaction(transaction, opts)\n return this.confirmTransaction(pending, opts)\n }\n}\n","import { ethers } from 'ethers'\n\nimport {\n Provider,\n SignedTransaction,\n Signer,\n TransactionPending,\n TransactionReceipt,\n TransactionRequest,\n} from '@layerzerolabs/lz-core'\n\nexport class EvmSigner implements Signer {\n private nativeSigner: ethers.Signer\n\n private constructor(signer: ethers.Signer) {\n this.nativeSigner = signer\n }\n\n static from(source: ethers.Signer | string, path?: string): EvmSigner {\n if (source instanceof ethers.Signer) {\n return new this(source)\n }\n if (path === undefined) {\n return new this(new ethers.Wallet(source))\n } else {\n return new this(ethers.Wallet.fromMnemonic(source, path))\n }\n }\n\n get native(): ethers.Signer {\n return this.nativeSigner\n }\n\n connect(provider: Provider): this {\n if (!(provider.native instanceof ethers.providers.Provider)) {\n throw new Error('Only ethers.providers.Provider is supported.')\n }\n\n this.nativeSigner = this.nativeSigner.connect(provider.native)\n return this\n }\n\n async getAddress(): Promise<string> {\n return this.nativeSigner.getAddress()\n }\n\n get address(): string {\n return (this.nativeSigner as ethers.Signer & { address: string }).address\n }\n\n async sendAndConfirm(\n transaction: SignedTransaction,\n opts?: { confirmations?: number }\n ): Promise<TransactionReceipt> {\n const pending = await this.sendTransaction(transaction)\n const response = pending.pending as ethers.providers.TransactionResponse\n const receipt = await response.wait(opts?.confirmations)\n return TransactionReceipt.from(receipt)\n }\n\n async sendTransaction(transaction: SignedTransaction): Promise<TransactionPending> {\n type NativeSignedTransaction = Parameters<ethers.providers.Provider['sendTransaction']>[0]\n const stx = transaction.signed as NativeSignedTransaction\n if (this.nativeSigner.provider === undefined) {\n throw new Error('No provider attached to the signer')\n }\n\n const response = await this.nativeSigner.provider.sendTransaction(stx)\n return TransactionPending.from(response)\n }\n\n async signTransaction(transaction: TransactionRequest): Promise<SignedTransaction> {\n type NativeTransactionRequest = Parameters<ethers.Signer['populateTransaction']>[0]\n const tx = transaction.request as NativeTransactionRequest\n\n const populatedTransaction = await this.nativeSigner.populateTransaction(tx)\n const response = await this.nativeSigner.signTransaction(populatedTransaction)\n return SignedTransaction.from(response)\n }\n\n async signBuffer(buffer: Uint8Array): Promise<Uint8Array> {\n const signedMessage = await this.nativeSigner.signMessage(buffer)\n return ethers.utils.arrayify(signedMessage)\n }\n\n async buildTransaction(buildTxRequest: unknown): Promise<TransactionRequest> {\n return Promise.reject(new Error('Method not implemented.'))\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/providers/evm.ts","../src/signers/evm.ts"],"names":["ethers","Block","BlockWithTransactions","TransactionResponse","TransactionReceipt","TransactionPending","SignedTransaction"],"mappings":";;;;;;AAkBa,IAAA,WAAA,GAAN,MAAM,YAAgC,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQzC,YAAmB,GAAa,EAAA;AAAb,IAAA,IAAA,CAAA,GAAA,GAAA,GAAA;AACf,IAAA,IAAA,CAAK,cAAiB,GAAA,IAAIA,aAAO,CAAA,SAAA,CAAU,gBAAgB,GAAG,CAAA;AAAA;AAClE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBA,OAAO,KAAK,MAA6B,EAAA;AACrC,IAAI,IAAA,OAAO,WAAW,QAAU,EAAA;AAC5B,MAAO,OAAA,IAAI,aAAY,MAAM,CAAA;AAAA,KAC1B,MAAA;AACH,MAAM,MAAA,IAAI,MAAM,oBAAoB,CAAA;AAAA;AACxC;AACJ;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,IAAI,MAA2C,GAAA;AAC3C,IAAA,OAAO,IAAK,CAAA,cAAA;AAA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;AAAA,EAQA,MAAM,WAAW,MAAyC,EAAA;AACtD,IAAA,MAAM,aAAgB,GAAA,MAAM,IAAK,CAAA,YAAA,CAAa,YAAY,MAAM,CAAA;AAChE,IAAON,OAAAA,aAAAA,CAAO,KAAM,CAAA,QAAA,CAAS,aAAa,CAAA;AAAA;AAElD","file":"index.cjs","sourcesContent":["import { ethers } from 'ethers'\n\nimport {\n Block,\n BlockTag,\n BlockWithTransactions,\n Finality,\n Provider,\n SignedTransaction,\n TransactionPending,\n TransactionReceipt,\n TransactionResponse,\n} from '@layerzerolabs/lz-core'\n\n/**\n * Represents an EVM (Ethereum Virtual Machine) blockchain provider.\n * Implements the Provider interface for interacting with EVM-compatible blockchains.\n */\nexport class EvmProvider implements Provider {\n nativeProvider: ethers.providers.JsonRpcProvider\n\n /**\n * Creates an instance of EvmProvider.\n *\n * @param {string} url - The URL of the EVM node.\n */\n constructor(public url: string) {\n this.nativeProvider = new ethers.providers.JsonRpcProvider(url)\n }\n\n /**\n * Creates an instance of EvmProvider from the given URL.\n *\n * @param {string} url - The URL of the EVM node.\n * @returns {EvmProvider} The created EvmProvider instance.\n */\n static from(url: string): EvmProvider\n\n /**\n * Creates an instance of EvmProvider from the given source.\n *\n * @param {string} source - The source to create the provider from.\n * @returns {EvmProvider} The created EvmProvider instance.\n * @throws {Error} If the source parameter is not a string.\n */\n static from(source: string): EvmProvider {\n if (typeof source === 'string') {\n return new EvmProvider(source)\n } else {\n throw new Error('Invalid parameters')\n }\n }\n\n /**\n * Gets the native EVM provider instance.\n *\n * @returns {ethers.providers.JsonRpcProvider} The native EVM provider instance.\n */\n get native(): ethers.providers.JsonRpcProvider {\n return this.nativeProvider\n }\n\n /**\n * Gets the balance of the specified address.\n *\n * @param {string} address - The address to get the balance of.\n * @returns {Promise<string>} A promise that resolves to the balance of the address.\n */\n async getBalance(address: string): Promise<string> {\n return (await this.nativeProvider.getBalance(address)).toString()\n }\n\n /**\n * Gets the block specified by blockTag.\n *\n * @param {BlockTag} blockTag - The block tag to specify the block.\n * @returns {Promise<Block>} A promise that resolves to the block.\n */\n async getBlock(blockTag: string | number): Promise<Block> {\n const response = await this.nativeProvider.getBlock(blockTag)\n return Block.from(response)\n }\n\n /**\n * Gets the block with transactions specified by blockTag.\n *\n * @param {BlockTag} blockTag - The block tag to specify the block.\n * @returns {Promise<BlockWithTransactions>} A promise that resolves to the block with transactions.\n */\n async getBlockWithTransactions(blockTag: string | number): Promise<BlockWithTransactions> {\n const response = await this.nativeProvider.getBlockWithTransactions(blockTag)\n return BlockWithTransactions.from(response)\n }\n\n /**\n * Gets the current block number.\n *\n * @returns {Promise<number>} A promise that resolves to the current block number.\n */\n async getBlockNumber(): Promise<number> {\n return this.nativeProvider.getBlockNumber()\n }\n\n /**\n * Gets the current slot number for commitment, not suitable for EVM.\n *\n * @param {Finality} [finality] - The commitment level (optional).\n * @returns {Promise<number>} A promise that resolves to the current slot number.\n * @throws {Error} Method not implemented.\n */\n // eslint-disable-next-line @typescript-eslint/require-await\n async getSlot(_finality?: Finality): Promise<number> {\n await Promise.resolve()\n throw new Error('Method not implemented.')\n }\n\n /**\n * Gets the UNIX timestamp for the block identified by blockTag.\n *\n * @param {BlockTag} blockTag - The block tag to specify the block.\n * @returns {Promise<number>} A promise that resolves to the UNIX timestamp of the block.\n */\n async getBlockTimestamp(blockTag: string | number): Promise<number> {\n return this.nativeProvider.getBlock(blockTag).then((block) => block.timestamp)\n }\n\n /**\n * Gets information about a transaction.\n *\n * @param {string} txHash - The hash of the transaction.\n * @returns {Promise<TransactionResponse>} A promise that resolves to the transaction response.\n */\n async getTransaction(txHash: string): Promise<TransactionResponse> {\n const response = await this.nativeProvider.getTransaction(txHash)\n return TransactionResponse.from(response)\n }\n\n /**\n * Gets the receipt of a transaction.\n *\n * @param {string} txHash - The hash of the transaction.\n * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.\n */\n async getTransactionReceipt(txHash: string): Promise<TransactionReceipt> {\n const response = await this.nativeProvider.getTransactionReceipt(txHash)\n return TransactionReceipt.from(response)\n }\n\n /**\n * Gets the number of transactions sent from the specified address.\n *\n * @param {string | Promise<string>} addressOrName - The address to get the number of transactions from.\n * @param {BlockTag | Promise<BlockTag>} [blockTag] - The block tag to get the number of transactions from (optional).\n * @returns {Promise<number>} A promise that resolves to the number of transactions sent from the address.\n */\n async getTransactionCount(\n addressOrName: string | Promise<string>,\n blockTag?: BlockTag | Promise<BlockTag>\n ): Promise<number> {\n return this.nativeProvider.getTransactionCount(addressOrName, blockTag)\n }\n\n /**\n * Sends a signed transaction to the blockchain.\n *\n * @param {SignedTransaction} transaction - The signed transaction to send.\n * @param {object} [sendOptions] - Optional parameters for sending the transaction.\n * @returns {Promise<TransactionPending>} A promise that resolves to the pending transaction.\n */\n async sendTransaction(transaction: SignedTransaction, _sendOptions?: object): Promise<TransactionPending> {\n type NativeSignedTransaction = Parameters<typeof this.nativeProvider.sendTransaction>[0]\n const stx = transaction.signed as NativeSignedTransaction\n\n const response = await this.nativeProvider.sendTransaction(stx)\n return TransactionPending.from(response)\n }\n\n /**\n * Confirms a pending transaction.\n *\n * @param {TransactionPending} pending - The pending transaction to confirm.\n * @param {object} [opts] - Optional parameters for the confirmation.\n * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.\n */\n async confirmTransaction(pending: TransactionPending, _opts?: object): Promise<TransactionReceipt> {\n const nativePending = pending.pending as ethers.providers.TransactionResponse\n const response = await nativePending.wait()\n return TransactionReceipt.from(response)\n }\n\n /**\n * Sends a signed transaction and waits for confirmation.\n *\n * @param {SignedTransaction} transaction - The signed transaction to send.\n * @param {object} [opts] - Optional parameters for sending and confirming the transaction.\n * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.\n */\n async sendAndConfirm(transaction: SignedTransaction, opts?: object): Promise<TransactionReceipt> {\n const pending = await this.sendTransaction(transaction, opts)\n return this.confirmTransaction(pending, opts)\n }\n}\n","import { ethers } from 'ethers'\n\nimport {\n Provider,\n SignedTransaction,\n Signer,\n TransactionPending,\n TransactionReceipt,\n TransactionRequest,\n} from '@layerzerolabs/lz-core'\n\n/**\n * Represents an EVM (Ethereum Virtual Machine) blockchain signer.\n * Implements the Signer interface for interacting with EVM-compatible blockchains.\n */\nexport class EvmSigner implements Signer {\n private nativeSigner: ethers.Signer\n\n /**\n * Creates an instance of EvmSigner.\n *\n * @param {ethers.Signer} signer - The EVM signer to use.\n */\n private constructor(signer: ethers.Signer) {\n this.nativeSigner = signer\n }\n\n /**\n * Creates an instance of EvmSigner from the given source.\n *\n * @param {ethers.Signer | string} source - The source to create the signer from.\n * @param {string} [path] - The derivation path (optional).\n * @returns {EvmSigner} The created EvmSigner instance.\n * @throws {Error} If the source parameter is invalid.\n */\n static from(source: ethers.Signer | string, path?: string): EvmSigner {\n if (source instanceof ethers.Signer) {\n return new this(source)\n }\n if (path === undefined) {\n return new this(new ethers.Wallet(source))\n } else {\n return new this(ethers.Wallet.fromMnemonic(source, path))\n }\n }\n\n /**\n * Gets the native EVM signer instance.\n *\n * @returns {ethers.Signer} The native EVM signer instance.\n */\n get native(): ethers.Signer {\n return this.nativeSigner\n }\n\n /**\n * Connects the signer to a provider.\n *\n * @param {Provider} provider - The provider to connect to.\n * @returns {this} The connected signer.\n * @throws {Error} If the provider is not an instance of ethers.providers.Provider.\n */\n connect(provider: Provider): this {\n if (!(provider.native instanceof ethers.providers.Provider)) {\n throw new Error('Only ethers.providers.Provider is supported.')\n }\n\n this.nativeSigner = this.nativeSigner.connect(provider.native)\n return this\n }\n\n /**\n * Gets the address of the signer.\n *\n * @returns {Promise<string>} A promise that resolves to the address of the signer.\n */\n async getAddress(): Promise<string> {\n return this.nativeSigner.getAddress()\n }\n\n /**\n * Gets the address of the signer.\n *\n * @returns {string} The address of the signer.\n */\n get address(): string {\n return (this.nativeSigner as ethers.Signer & { address: string }).address\n }\n\n /**\n * Sends a signed transaction and waits for confirmation.\n *\n * @param {SignedTransaction} transaction - The signed transaction to send.\n * @param {object} [opts] - Optional parameters for sending and confirming the transaction.\n * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.\n */\n async sendAndConfirm(\n transaction: SignedTransaction,\n opts?: { confirmations?: number }\n ): Promise<TransactionReceipt> {\n const pending = await this.sendTransaction(transaction)\n const response = pending.pending as ethers.providers.TransactionResponse\n const receipt = await response.wait(opts?.confirmations)\n return TransactionReceipt.from(receipt)\n }\n\n /**\n * Sends a signed transaction.\n *\n * @param {SignedTransaction} transaction - The signed transaction to send.\n * @returns {Promise<TransactionPending>} A promise that resolves to the pending transaction.\n * @throws {Error} If no provider is attached to the signer.\n */\n async sendTransaction(transaction: SignedTransaction): Promise<TransactionPending> {\n type NativeSignedTransaction = Parameters<ethers.providers.Provider['sendTransaction']>[0]\n const stx = transaction.signed as NativeSignedTransaction\n if (this.nativeSigner.provider === undefined) {\n throw new Error('No provider attached to the signer')\n }\n\n const response = await this.nativeSigner.provider.sendTransaction(stx)\n return TransactionPending.from(response)\n }\n\n /**\n * Signs a transaction.\n *\n * @param {TransactionRequest} transaction - The transaction request to sign.\n * @returns {Promise<SignedTransaction>} A promise that resolves to the signed transaction.\n */\n async signTransaction(transaction: TransactionRequest): Promise<SignedTransaction> {\n type NativeTransactionRequest = Parameters<ethers.Signer['populateTransaction']>[0]\n const tx = transaction.request as NativeTransactionRequest\n\n const populatedTransaction = await this.nativeSigner.populateTransaction(tx)\n const response = await this.nativeSigner.signTransaction(populatedTransaction)\n return SignedTransaction.from(response)\n }\n\n /**\n * Signs a buffer (e.g., a message hash) using the native EVM signer.\n *\n * @param {Uint8Array} buffer - The buffer to sign.\n * @returns {Promise<Uint8Array>} A promise that resolves to the signed buffer as a Uint8Array.\n */\n async signBuffer(buffer: Uint8Array): Promise<Uint8Array> {\n const signedMessage = await this.nativeSigner.signMessage(buffer)\n return ethers.utils.arrayify(signedMessage)\n }\n}\n"]}
package/dist/index.d.mts CHANGED
@@ -1,41 +1,201 @@
1
1
  import { ethers } from 'ethers';
2
2
  import { Provider, Block, BlockWithTransactions, Finality, TransactionResponse, TransactionReceipt, BlockTag, SignedTransaction, TransactionPending, Signer, TransactionRequest } from '@layerzerolabs/lz-core';
3
3
 
4
+ /**
5
+ * Represents an EVM (Ethereum Virtual Machine) blockchain provider.
6
+ * Implements the Provider interface for interacting with EVM-compatible blockchains.
7
+ */
4
8
  declare class EvmProvider implements Provider {
5
9
  url: string;
6
10
  nativeProvider: ethers.providers.JsonRpcProvider;
11
+ /**
12
+ * Creates an instance of EvmProvider.
13
+ *
14
+ * @param {string} url - The URL of the EVM node.
15
+ */
7
16
  constructor(url: string);
17
+ /**
18
+ * Creates an instance of EvmProvider from the given URL.
19
+ *
20
+ * @param {string} url - The URL of the EVM node.
21
+ * @returns {EvmProvider} The created EvmProvider instance.
22
+ */
8
23
  static from(url: string): EvmProvider;
24
+ /**
25
+ * Gets the native EVM provider instance.
26
+ *
27
+ * @returns {ethers.providers.JsonRpcProvider} The native EVM provider instance.
28
+ */
9
29
  get native(): ethers.providers.JsonRpcProvider;
30
+ /**
31
+ * Gets the balance of the specified address.
32
+ *
33
+ * @param {string} address - The address to get the balance of.
34
+ * @returns {Promise<string>} A promise that resolves to the balance of the address.
35
+ */
10
36
  getBalance(address: string): Promise<string>;
37
+ /**
38
+ * Gets the block specified by blockTag.
39
+ *
40
+ * @param {BlockTag} blockTag - The block tag to specify the block.
41
+ * @returns {Promise<Block>} A promise that resolves to the block.
42
+ */
11
43
  getBlock(blockTag: string | number): Promise<Block>;
44
+ /**
45
+ * Gets the block with transactions specified by blockTag.
46
+ *
47
+ * @param {BlockTag} blockTag - The block tag to specify the block.
48
+ * @returns {Promise<BlockWithTransactions>} A promise that resolves to the block with transactions.
49
+ */
12
50
  getBlockWithTransactions(blockTag: string | number): Promise<BlockWithTransactions>;
51
+ /**
52
+ * Gets the current block number.
53
+ *
54
+ * @returns {Promise<number>} A promise that resolves to the current block number.
55
+ */
13
56
  getBlockNumber(): Promise<number>;
57
+ /**
58
+ * Gets the current slot number for commitment, not suitable for EVM.
59
+ *
60
+ * @param {Finality} [finality] - The commitment level (optional).
61
+ * @returns {Promise<number>} A promise that resolves to the current slot number.
62
+ * @throws {Error} Method not implemented.
63
+ */
14
64
  getSlot(_finality?: Finality): Promise<number>;
65
+ /**
66
+ * Gets the UNIX timestamp for the block identified by blockTag.
67
+ *
68
+ * @param {BlockTag} blockTag - The block tag to specify the block.
69
+ * @returns {Promise<number>} A promise that resolves to the UNIX timestamp of the block.
70
+ */
15
71
  getBlockTimestamp(blockTag: string | number): Promise<number>;
72
+ /**
73
+ * Gets information about a transaction.
74
+ *
75
+ * @param {string} txHash - The hash of the transaction.
76
+ * @returns {Promise<TransactionResponse>} A promise that resolves to the transaction response.
77
+ */
16
78
  getTransaction(txHash: string): Promise<TransactionResponse>;
79
+ /**
80
+ * Gets the receipt of a transaction.
81
+ *
82
+ * @param {string} txHash - The hash of the transaction.
83
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
84
+ */
17
85
  getTransactionReceipt(txHash: string): Promise<TransactionReceipt>;
86
+ /**
87
+ * Gets the number of transactions sent from the specified address.
88
+ *
89
+ * @param {string | Promise<string>} addressOrName - The address to get the number of transactions from.
90
+ * @param {BlockTag | Promise<BlockTag>} [blockTag] - The block tag to get the number of transactions from (optional).
91
+ * @returns {Promise<number>} A promise that resolves to the number of transactions sent from the address.
92
+ */
18
93
  getTransactionCount(addressOrName: string | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>): Promise<number>;
94
+ /**
95
+ * Sends a signed transaction to the blockchain.
96
+ *
97
+ * @param {SignedTransaction} transaction - The signed transaction to send.
98
+ * @param {object} [sendOptions] - Optional parameters for sending the transaction.
99
+ * @returns {Promise<TransactionPending>} A promise that resolves to the pending transaction.
100
+ */
19
101
  sendTransaction(transaction: SignedTransaction, _sendOptions?: object): Promise<TransactionPending>;
102
+ /**
103
+ * Confirms a pending transaction.
104
+ *
105
+ * @param {TransactionPending} pending - The pending transaction to confirm.
106
+ * @param {object} [opts] - Optional parameters for the confirmation.
107
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
108
+ */
20
109
  confirmTransaction(pending: TransactionPending, _opts?: object): Promise<TransactionReceipt>;
110
+ /**
111
+ * Sends a signed transaction and waits for confirmation.
112
+ *
113
+ * @param {SignedTransaction} transaction - The signed transaction to send.
114
+ * @param {object} [opts] - Optional parameters for sending and confirming the transaction.
115
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
116
+ */
21
117
  sendAndConfirm(transaction: SignedTransaction, opts?: object): Promise<TransactionReceipt>;
22
118
  }
23
119
 
120
+ /**
121
+ * Represents an EVM (Ethereum Virtual Machine) blockchain signer.
122
+ * Implements the Signer interface for interacting with EVM-compatible blockchains.
123
+ */
24
124
  declare class EvmSigner implements Signer {
25
125
  private nativeSigner;
126
+ /**
127
+ * Creates an instance of EvmSigner.
128
+ *
129
+ * @param {ethers.Signer} signer - The EVM signer to use.
130
+ */
26
131
  private constructor();
132
+ /**
133
+ * Creates an instance of EvmSigner from the given source.
134
+ *
135
+ * @param {ethers.Signer | string} source - The source to create the signer from.
136
+ * @param {string} [path] - The derivation path (optional).
137
+ * @returns {EvmSigner} The created EvmSigner instance.
138
+ * @throws {Error} If the source parameter is invalid.
139
+ */
27
140
  static from(source: ethers.Signer | string, path?: string): EvmSigner;
141
+ /**
142
+ * Gets the native EVM signer instance.
143
+ *
144
+ * @returns {ethers.Signer} The native EVM signer instance.
145
+ */
28
146
  get native(): ethers.Signer;
147
+ /**
148
+ * Connects the signer to a provider.
149
+ *
150
+ * @param {Provider} provider - The provider to connect to.
151
+ * @returns {this} The connected signer.
152
+ * @throws {Error} If the provider is not an instance of ethers.providers.Provider.
153
+ */
29
154
  connect(provider: Provider): this;
155
+ /**
156
+ * Gets the address of the signer.
157
+ *
158
+ * @returns {Promise<string>} A promise that resolves to the address of the signer.
159
+ */
30
160
  getAddress(): Promise<string>;
161
+ /**
162
+ * Gets the address of the signer.
163
+ *
164
+ * @returns {string} The address of the signer.
165
+ */
31
166
  get address(): string;
167
+ /**
168
+ * Sends a signed transaction and waits for confirmation.
169
+ *
170
+ * @param {SignedTransaction} transaction - The signed transaction to send.
171
+ * @param {object} [opts] - Optional parameters for sending and confirming the transaction.
172
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
173
+ */
32
174
  sendAndConfirm(transaction: SignedTransaction, opts?: {
33
175
  confirmations?: number;
34
176
  }): Promise<TransactionReceipt>;
177
+ /**
178
+ * Sends a signed transaction.
179
+ *
180
+ * @param {SignedTransaction} transaction - The signed transaction to send.
181
+ * @returns {Promise<TransactionPending>} A promise that resolves to the pending transaction.
182
+ * @throws {Error} If no provider is attached to the signer.
183
+ */
35
184
  sendTransaction(transaction: SignedTransaction): Promise<TransactionPending>;
185
+ /**
186
+ * Signs a transaction.
187
+ *
188
+ * @param {TransactionRequest} transaction - The transaction request to sign.
189
+ * @returns {Promise<SignedTransaction>} A promise that resolves to the signed transaction.
190
+ */
36
191
  signTransaction(transaction: TransactionRequest): Promise<SignedTransaction>;
192
+ /**
193
+ * Signs a buffer (e.g., a message hash) using the native EVM signer.
194
+ *
195
+ * @param {Uint8Array} buffer - The buffer to sign.
196
+ * @returns {Promise<Uint8Array>} A promise that resolves to the signed buffer as a Uint8Array.
197
+ */
37
198
  signBuffer(buffer: Uint8Array): Promise<Uint8Array>;
38
- buildTransaction(buildTxRequest: unknown): Promise<TransactionRequest>;
39
199
  }
40
200
 
41
201
  export { EvmProvider, EvmSigner };
package/dist/index.d.ts CHANGED
@@ -1,41 +1,201 @@
1
1
  import { ethers } from 'ethers';
2
2
  import { Provider, Block, BlockWithTransactions, Finality, TransactionResponse, TransactionReceipt, BlockTag, SignedTransaction, TransactionPending, Signer, TransactionRequest } from '@layerzerolabs/lz-core';
3
3
 
4
+ /**
5
+ * Represents an EVM (Ethereum Virtual Machine) blockchain provider.
6
+ * Implements the Provider interface for interacting with EVM-compatible blockchains.
7
+ */
4
8
  declare class EvmProvider implements Provider {
5
9
  url: string;
6
10
  nativeProvider: ethers.providers.JsonRpcProvider;
11
+ /**
12
+ * Creates an instance of EvmProvider.
13
+ *
14
+ * @param {string} url - The URL of the EVM node.
15
+ */
7
16
  constructor(url: string);
17
+ /**
18
+ * Creates an instance of EvmProvider from the given URL.
19
+ *
20
+ * @param {string} url - The URL of the EVM node.
21
+ * @returns {EvmProvider} The created EvmProvider instance.
22
+ */
8
23
  static from(url: string): EvmProvider;
24
+ /**
25
+ * Gets the native EVM provider instance.
26
+ *
27
+ * @returns {ethers.providers.JsonRpcProvider} The native EVM provider instance.
28
+ */
9
29
  get native(): ethers.providers.JsonRpcProvider;
30
+ /**
31
+ * Gets the balance of the specified address.
32
+ *
33
+ * @param {string} address - The address to get the balance of.
34
+ * @returns {Promise<string>} A promise that resolves to the balance of the address.
35
+ */
10
36
  getBalance(address: string): Promise<string>;
37
+ /**
38
+ * Gets the block specified by blockTag.
39
+ *
40
+ * @param {BlockTag} blockTag - The block tag to specify the block.
41
+ * @returns {Promise<Block>} A promise that resolves to the block.
42
+ */
11
43
  getBlock(blockTag: string | number): Promise<Block>;
44
+ /**
45
+ * Gets the block with transactions specified by blockTag.
46
+ *
47
+ * @param {BlockTag} blockTag - The block tag to specify the block.
48
+ * @returns {Promise<BlockWithTransactions>} A promise that resolves to the block with transactions.
49
+ */
12
50
  getBlockWithTransactions(blockTag: string | number): Promise<BlockWithTransactions>;
51
+ /**
52
+ * Gets the current block number.
53
+ *
54
+ * @returns {Promise<number>} A promise that resolves to the current block number.
55
+ */
13
56
  getBlockNumber(): Promise<number>;
57
+ /**
58
+ * Gets the current slot number for commitment, not suitable for EVM.
59
+ *
60
+ * @param {Finality} [finality] - The commitment level (optional).
61
+ * @returns {Promise<number>} A promise that resolves to the current slot number.
62
+ * @throws {Error} Method not implemented.
63
+ */
14
64
  getSlot(_finality?: Finality): Promise<number>;
65
+ /**
66
+ * Gets the UNIX timestamp for the block identified by blockTag.
67
+ *
68
+ * @param {BlockTag} blockTag - The block tag to specify the block.
69
+ * @returns {Promise<number>} A promise that resolves to the UNIX timestamp of the block.
70
+ */
15
71
  getBlockTimestamp(blockTag: string | number): Promise<number>;
72
+ /**
73
+ * Gets information about a transaction.
74
+ *
75
+ * @param {string} txHash - The hash of the transaction.
76
+ * @returns {Promise<TransactionResponse>} A promise that resolves to the transaction response.
77
+ */
16
78
  getTransaction(txHash: string): Promise<TransactionResponse>;
79
+ /**
80
+ * Gets the receipt of a transaction.
81
+ *
82
+ * @param {string} txHash - The hash of the transaction.
83
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
84
+ */
17
85
  getTransactionReceipt(txHash: string): Promise<TransactionReceipt>;
86
+ /**
87
+ * Gets the number of transactions sent from the specified address.
88
+ *
89
+ * @param {string | Promise<string>} addressOrName - The address to get the number of transactions from.
90
+ * @param {BlockTag | Promise<BlockTag>} [blockTag] - The block tag to get the number of transactions from (optional).
91
+ * @returns {Promise<number>} A promise that resolves to the number of transactions sent from the address.
92
+ */
18
93
  getTransactionCount(addressOrName: string | Promise<string>, blockTag?: BlockTag | Promise<BlockTag>): Promise<number>;
94
+ /**
95
+ * Sends a signed transaction to the blockchain.
96
+ *
97
+ * @param {SignedTransaction} transaction - The signed transaction to send.
98
+ * @param {object} [sendOptions] - Optional parameters for sending the transaction.
99
+ * @returns {Promise<TransactionPending>} A promise that resolves to the pending transaction.
100
+ */
19
101
  sendTransaction(transaction: SignedTransaction, _sendOptions?: object): Promise<TransactionPending>;
102
+ /**
103
+ * Confirms a pending transaction.
104
+ *
105
+ * @param {TransactionPending} pending - The pending transaction to confirm.
106
+ * @param {object} [opts] - Optional parameters for the confirmation.
107
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
108
+ */
20
109
  confirmTransaction(pending: TransactionPending, _opts?: object): Promise<TransactionReceipt>;
110
+ /**
111
+ * Sends a signed transaction and waits for confirmation.
112
+ *
113
+ * @param {SignedTransaction} transaction - The signed transaction to send.
114
+ * @param {object} [opts] - Optional parameters for sending and confirming the transaction.
115
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
116
+ */
21
117
  sendAndConfirm(transaction: SignedTransaction, opts?: object): Promise<TransactionReceipt>;
22
118
  }
23
119
 
120
+ /**
121
+ * Represents an EVM (Ethereum Virtual Machine) blockchain signer.
122
+ * Implements the Signer interface for interacting with EVM-compatible blockchains.
123
+ */
24
124
  declare class EvmSigner implements Signer {
25
125
  private nativeSigner;
126
+ /**
127
+ * Creates an instance of EvmSigner.
128
+ *
129
+ * @param {ethers.Signer} signer - The EVM signer to use.
130
+ */
26
131
  private constructor();
132
+ /**
133
+ * Creates an instance of EvmSigner from the given source.
134
+ *
135
+ * @param {ethers.Signer | string} source - The source to create the signer from.
136
+ * @param {string} [path] - The derivation path (optional).
137
+ * @returns {EvmSigner} The created EvmSigner instance.
138
+ * @throws {Error} If the source parameter is invalid.
139
+ */
27
140
  static from(source: ethers.Signer | string, path?: string): EvmSigner;
141
+ /**
142
+ * Gets the native EVM signer instance.
143
+ *
144
+ * @returns {ethers.Signer} The native EVM signer instance.
145
+ */
28
146
  get native(): ethers.Signer;
147
+ /**
148
+ * Connects the signer to a provider.
149
+ *
150
+ * @param {Provider} provider - The provider to connect to.
151
+ * @returns {this} The connected signer.
152
+ * @throws {Error} If the provider is not an instance of ethers.providers.Provider.
153
+ */
29
154
  connect(provider: Provider): this;
155
+ /**
156
+ * Gets the address of the signer.
157
+ *
158
+ * @returns {Promise<string>} A promise that resolves to the address of the signer.
159
+ */
30
160
  getAddress(): Promise<string>;
161
+ /**
162
+ * Gets the address of the signer.
163
+ *
164
+ * @returns {string} The address of the signer.
165
+ */
31
166
  get address(): string;
167
+ /**
168
+ * Sends a signed transaction and waits for confirmation.
169
+ *
170
+ * @param {SignedTransaction} transaction - The signed transaction to send.
171
+ * @param {object} [opts] - Optional parameters for sending and confirming the transaction.
172
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
173
+ */
32
174
  sendAndConfirm(transaction: SignedTransaction, opts?: {
33
175
  confirmations?: number;
34
176
  }): Promise<TransactionReceipt>;
177
+ /**
178
+ * Sends a signed transaction.
179
+ *
180
+ * @param {SignedTransaction} transaction - The signed transaction to send.
181
+ * @returns {Promise<TransactionPending>} A promise that resolves to the pending transaction.
182
+ * @throws {Error} If no provider is attached to the signer.
183
+ */
35
184
  sendTransaction(transaction: SignedTransaction): Promise<TransactionPending>;
185
+ /**
186
+ * Signs a transaction.
187
+ *
188
+ * @param {TransactionRequest} transaction - The transaction request to sign.
189
+ * @returns {Promise<SignedTransaction>} A promise that resolves to the signed transaction.
190
+ */
36
191
  signTransaction(transaction: TransactionRequest): Promise<SignedTransaction>;
192
+ /**
193
+ * Signs a buffer (e.g., a message hash) using the native EVM signer.
194
+ *
195
+ * @param {Uint8Array} buffer - The buffer to sign.
196
+ * @returns {Promise<Uint8Array>} A promise that resolves to the signed buffer as a Uint8Array.
197
+ */
37
198
  signBuffer(buffer: Uint8Array): Promise<Uint8Array>;
38
- buildTransaction(buildTxRequest: unknown): Promise<TransactionRequest>;
39
199
  }
40
200
 
41
201
  export { EvmProvider, EvmSigner };
package/dist/index.mjs CHANGED
@@ -3,10 +3,22 @@ import { Block, BlockWithTransactions, TransactionResponse, TransactionReceipt,
3
3
 
4
4
  // src/providers/evm.ts
5
5
  var EvmProvider = class _EvmProvider {
6
+ /**
7
+ * Creates an instance of EvmProvider.
8
+ *
9
+ * @param {string} url - The URL of the EVM node.
10
+ */
6
11
  constructor(url) {
7
12
  this.url = url;
8
13
  this.nativeProvider = new ethers.providers.JsonRpcProvider(url);
9
14
  }
15
+ /**
16
+ * Creates an instance of EvmProvider from the given source.
17
+ *
18
+ * @param {string} source - The source to create the provider from.
19
+ * @returns {EvmProvider} The created EvmProvider instance.
20
+ * @throws {Error} If the source parameter is not a string.
21
+ */
10
22
  static from(source) {
11
23
  if (typeof source === "string") {
12
24
  return new _EvmProvider(source);
@@ -14,61 +26,155 @@ var EvmProvider = class _EvmProvider {
14
26
  throw new Error("Invalid parameters");
15
27
  }
16
28
  }
29
+ /**
30
+ * Gets the native EVM provider instance.
31
+ *
32
+ * @returns {ethers.providers.JsonRpcProvider} The native EVM provider instance.
33
+ */
17
34
  get native() {
18
35
  return this.nativeProvider;
19
36
  }
37
+ /**
38
+ * Gets the balance of the specified address.
39
+ *
40
+ * @param {string} address - The address to get the balance of.
41
+ * @returns {Promise<string>} A promise that resolves to the balance of the address.
42
+ */
20
43
  async getBalance(address) {
21
44
  return (await this.nativeProvider.getBalance(address)).toString();
22
45
  }
46
+ /**
47
+ * Gets the block specified by blockTag.
48
+ *
49
+ * @param {BlockTag} blockTag - The block tag to specify the block.
50
+ * @returns {Promise<Block>} A promise that resolves to the block.
51
+ */
23
52
  async getBlock(blockTag) {
24
53
  const response = await this.nativeProvider.getBlock(blockTag);
25
54
  return Block.from(response);
26
55
  }
56
+ /**
57
+ * Gets the block with transactions specified by blockTag.
58
+ *
59
+ * @param {BlockTag} blockTag - The block tag to specify the block.
60
+ * @returns {Promise<BlockWithTransactions>} A promise that resolves to the block with transactions.
61
+ */
27
62
  async getBlockWithTransactions(blockTag) {
28
63
  const response = await this.nativeProvider.getBlockWithTransactions(blockTag);
29
64
  return BlockWithTransactions.from(response);
30
65
  }
66
+ /**
67
+ * Gets the current block number.
68
+ *
69
+ * @returns {Promise<number>} A promise that resolves to the current block number.
70
+ */
31
71
  async getBlockNumber() {
32
72
  return this.nativeProvider.getBlockNumber();
33
73
  }
74
+ /**
75
+ * Gets the current slot number for commitment, not suitable for EVM.
76
+ *
77
+ * @param {Finality} [finality] - The commitment level (optional).
78
+ * @returns {Promise<number>} A promise that resolves to the current slot number.
79
+ * @throws {Error} Method not implemented.
80
+ */
34
81
  // eslint-disable-next-line @typescript-eslint/require-await
35
82
  async getSlot(_finality) {
36
83
  await Promise.resolve();
37
84
  throw new Error("Method not implemented.");
38
85
  }
86
+ /**
87
+ * Gets the UNIX timestamp for the block identified by blockTag.
88
+ *
89
+ * @param {BlockTag} blockTag - The block tag to specify the block.
90
+ * @returns {Promise<number>} A promise that resolves to the UNIX timestamp of the block.
91
+ */
39
92
  async getBlockTimestamp(blockTag) {
40
93
  return this.nativeProvider.getBlock(blockTag).then((block) => block.timestamp);
41
94
  }
95
+ /**
96
+ * Gets information about a transaction.
97
+ *
98
+ * @param {string} txHash - The hash of the transaction.
99
+ * @returns {Promise<TransactionResponse>} A promise that resolves to the transaction response.
100
+ */
42
101
  async getTransaction(txHash) {
43
102
  const response = await this.nativeProvider.getTransaction(txHash);
44
103
  return TransactionResponse.from(response);
45
104
  }
105
+ /**
106
+ * Gets the receipt of a transaction.
107
+ *
108
+ * @param {string} txHash - The hash of the transaction.
109
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
110
+ */
46
111
  async getTransactionReceipt(txHash) {
47
112
  const response = await this.nativeProvider.getTransactionReceipt(txHash);
48
113
  return TransactionReceipt.from(response);
49
114
  }
115
+ /**
116
+ * Gets the number of transactions sent from the specified address.
117
+ *
118
+ * @param {string | Promise<string>} addressOrName - The address to get the number of transactions from.
119
+ * @param {BlockTag | Promise<BlockTag>} [blockTag] - The block tag to get the number of transactions from (optional).
120
+ * @returns {Promise<number>} A promise that resolves to the number of transactions sent from the address.
121
+ */
50
122
  async getTransactionCount(addressOrName, blockTag) {
51
123
  return this.nativeProvider.getTransactionCount(addressOrName, blockTag);
52
124
  }
125
+ /**
126
+ * Sends a signed transaction to the blockchain.
127
+ *
128
+ * @param {SignedTransaction} transaction - The signed transaction to send.
129
+ * @param {object} [sendOptions] - Optional parameters for sending the transaction.
130
+ * @returns {Promise<TransactionPending>} A promise that resolves to the pending transaction.
131
+ */
53
132
  async sendTransaction(transaction, _sendOptions) {
54
133
  const stx = transaction.signed;
55
134
  const response = await this.nativeProvider.sendTransaction(stx);
56
135
  return TransactionPending.from(response);
57
136
  }
137
+ /**
138
+ * Confirms a pending transaction.
139
+ *
140
+ * @param {TransactionPending} pending - The pending transaction to confirm.
141
+ * @param {object} [opts] - Optional parameters for the confirmation.
142
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
143
+ */
58
144
  async confirmTransaction(pending, _opts) {
59
145
  const nativePending = pending.pending;
60
146
  const response = await nativePending.wait();
61
147
  return TransactionReceipt.from(response);
62
148
  }
149
+ /**
150
+ * Sends a signed transaction and waits for confirmation.
151
+ *
152
+ * @param {SignedTransaction} transaction - The signed transaction to send.
153
+ * @param {object} [opts] - Optional parameters for sending and confirming the transaction.
154
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
155
+ */
63
156
  async sendAndConfirm(transaction, opts) {
64
157
  const pending = await this.sendTransaction(transaction, opts);
65
158
  return this.confirmTransaction(pending, opts);
66
159
  }
67
160
  };
68
161
  var EvmSigner = class {
162
+ /**
163
+ * Creates an instance of EvmSigner.
164
+ *
165
+ * @param {ethers.Signer} signer - The EVM signer to use.
166
+ */
69
167
  constructor(signer) {
70
168
  this.nativeSigner = signer;
71
169
  }
170
+ /**
171
+ * Creates an instance of EvmSigner from the given source.
172
+ *
173
+ * @param {ethers.Signer | string} source - The source to create the signer from.
174
+ * @param {string} [path] - The derivation path (optional).
175
+ * @returns {EvmSigner} The created EvmSigner instance.
176
+ * @throws {Error} If the source parameter is invalid.
177
+ */
72
178
  static from(source, path) {
73
179
  if (source instanceof ethers.Signer) {
74
180
  return new this(source);
@@ -79,9 +185,21 @@ var EvmSigner = class {
79
185
  return new this(ethers.Wallet.fromMnemonic(source, path));
80
186
  }
81
187
  }
188
+ /**
189
+ * Gets the native EVM signer instance.
190
+ *
191
+ * @returns {ethers.Signer} The native EVM signer instance.
192
+ */
82
193
  get native() {
83
194
  return this.nativeSigner;
84
195
  }
196
+ /**
197
+ * Connects the signer to a provider.
198
+ *
199
+ * @param {Provider} provider - The provider to connect to.
200
+ * @returns {this} The connected signer.
201
+ * @throws {Error} If the provider is not an instance of ethers.providers.Provider.
202
+ */
85
203
  connect(provider) {
86
204
  if (!(provider.native instanceof ethers.providers.Provider)) {
87
205
  throw new Error("Only ethers.providers.Provider is supported.");
@@ -89,18 +207,42 @@ var EvmSigner = class {
89
207
  this.nativeSigner = this.nativeSigner.connect(provider.native);
90
208
  return this;
91
209
  }
210
+ /**
211
+ * Gets the address of the signer.
212
+ *
213
+ * @returns {Promise<string>} A promise that resolves to the address of the signer.
214
+ */
92
215
  async getAddress() {
93
216
  return this.nativeSigner.getAddress();
94
217
  }
218
+ /**
219
+ * Gets the address of the signer.
220
+ *
221
+ * @returns {string} The address of the signer.
222
+ */
95
223
  get address() {
96
224
  return this.nativeSigner.address;
97
225
  }
226
+ /**
227
+ * Sends a signed transaction and waits for confirmation.
228
+ *
229
+ * @param {SignedTransaction} transaction - The signed transaction to send.
230
+ * @param {object} [opts] - Optional parameters for sending and confirming the transaction.
231
+ * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.
232
+ */
98
233
  async sendAndConfirm(transaction, opts) {
99
234
  const pending = await this.sendTransaction(transaction);
100
235
  const response = pending.pending;
101
236
  const receipt = await response.wait(opts?.confirmations);
102
237
  return TransactionReceipt.from(receipt);
103
238
  }
239
+ /**
240
+ * Sends a signed transaction.
241
+ *
242
+ * @param {SignedTransaction} transaction - The signed transaction to send.
243
+ * @returns {Promise<TransactionPending>} A promise that resolves to the pending transaction.
244
+ * @throws {Error} If no provider is attached to the signer.
245
+ */
104
246
  async sendTransaction(transaction) {
105
247
  const stx = transaction.signed;
106
248
  if (this.nativeSigner.provider === void 0) {
@@ -109,21 +251,30 @@ var EvmSigner = class {
109
251
  const response = await this.nativeSigner.provider.sendTransaction(stx);
110
252
  return TransactionPending.from(response);
111
253
  }
254
+ /**
255
+ * Signs a transaction.
256
+ *
257
+ * @param {TransactionRequest} transaction - The transaction request to sign.
258
+ * @returns {Promise<SignedTransaction>} A promise that resolves to the signed transaction.
259
+ */
112
260
  async signTransaction(transaction) {
113
261
  const tx = transaction.request;
114
262
  const populatedTransaction = await this.nativeSigner.populateTransaction(tx);
115
263
  const response = await this.nativeSigner.signTransaction(populatedTransaction);
116
264
  return SignedTransaction.from(response);
117
265
  }
266
+ /**
267
+ * Signs a buffer (e.g., a message hash) using the native EVM signer.
268
+ *
269
+ * @param {Uint8Array} buffer - The buffer to sign.
270
+ * @returns {Promise<Uint8Array>} A promise that resolves to the signed buffer as a Uint8Array.
271
+ */
118
272
  async signBuffer(buffer) {
119
273
  const signedMessage = await this.nativeSigner.signMessage(buffer);
120
274
  return ethers.utils.arrayify(signedMessage);
121
275
  }
122
- async buildTransaction(buildTxRequest) {
123
- return Promise.reject(new Error("Method not implemented."));
124
- }
125
276
  };
126
277
 
127
278
  export { EvmProvider, EvmSigner };
128
- //# sourceMappingURL=out.js.map
279
+ //# sourceMappingURL=index.mjs.map
129
280
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/providers/evm.ts","../src/signers/evm.ts"],"names":["ethers","SignedTransaction","TransactionPending","TransactionReceipt"],"mappings":";AAAA,SAAS,cAAc;AAEvB;AAAA,EACI;AAAA,EAEA;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAEA,IAAM,cAAN,MAAM,aAAgC;AAAA,EAGzC,YAAmB,KAAa;AAAb;AACf,SAAK,iBAAiB,IAAI,OAAO,UAAU,gBAAgB,GAAG;AAAA,EAClE;AAAA,EAIA,OAAO,KAAK,QAA6B;AACrC,QAAI,OAAO,WAAW,UAAU;AAC5B,aAAO,IAAI,aAAY,MAAM;AAAA,IACjC,OAAO;AACH,YAAM,IAAI,MAAM,oBAAoB;AAAA,IACxC;AAAA,EACJ;AAAA,EAEA,IAAI,SAA2C;AAC3C,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,MAAM,WAAW,SAAkC;AAC/C,YAAQ,MAAM,KAAK,eAAe,WAAW,OAAO,GAAG,SAAS;AAAA,EACpE;AAAA,EAEA,MAAM,SAAS,UAA2C;AACtD,UAAM,WAAW,MAAM,KAAK,eAAe,SAAS,QAAQ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AAW;AAC1C,YAAM,IAAI,MAAM,oCAAoC;AAAA,IACxD;AAEA,UAAM,WAAW,MAAM,KAAK,aAAa,SAAS,gBAAgB,GAAG;AACrE,WAAOD,oBAAmB,KAAK,QAAQ;AAAA,EAC3C;AAAA,EAEA,MAAM,gBAAgB,aAA6D;AAE/E,UAAM,KAAK,YAAY;AAEvB,UAAM,uBAAuB,MAAM,KAAK,aAAa,oBAAoB,EAAE;AAC3E,UAAM,WAAW,MAAM,KAAK,aAAa,gBAAgB,oBAAoB;AAC7E,WAAOD,mBAAkB,KAAK,QAAQ;AAAA,EAC1C;AAAA,EAEA,MAAM,WAAW,QAAyC;AACtD,UAAM,gBAAgB,MAAM,KAAK,aAAa,YAAY,MAAM;AAChE,WAAOD,QAAO,MAAM,SAAS,aAAa;AAAA,EAC9C;AAAA,EAEA,MAAM,iBAAiB,gBAAsD;AACzE,WAAO,QAAQ,OAAO,IAAI,MAAM,yBAAyB,CAAC;AAAA,EAC9D;AACJ","sourcesContent":["import { ethers } from 'ethers'\n\nimport {\n Block,\n BlockTag,\n BlockWithTransactions,\n Finality,\n Provider,\n SignedTransaction,\n TransactionPending,\n TransactionReceipt,\n TransactionResponse,\n} from '@layerzerolabs/lz-core'\n\nexport class EvmProvider implements Provider {\n nativeProvider: ethers.providers.JsonRpcProvider\n\n constructor(public url: string) {\n this.nativeProvider = new ethers.providers.JsonRpcProvider(url)\n }\n\n static from(url: string): EvmProvider\n\n static from(source: string): EvmProvider {\n if (typeof source === 'string') {\n return new EvmProvider(source)\n } else {\n throw new Error('Invalid parameters')\n }\n }\n\n get native(): ethers.providers.JsonRpcProvider {\n return this.nativeProvider\n }\n\n async getBalance(address: string): Promise<string> {\n return (await this.nativeProvider.getBalance(address)).toString()\n }\n\n async getBlock(blockTag: string | number): Promise<Block> {\n const response = await this.nativeProvider.getBlock(blockTag)\n return Block.from(response)\n }\n\n async getBlockWithTransactions(blockTag: string | number): Promise<BlockWithTransactions> {\n const response = await this.nativeProvider.getBlockWithTransactions(blockTag)\n return BlockWithTransactions.from(response)\n }\n\n async getBlockNumber(): Promise<number> {\n return this.nativeProvider.getBlockNumber()\n }\n\n // eslint-disable-next-line @typescript-eslint/require-await\n async getSlot(_finality?: Finality): Promise<number> {\n await Promise.resolve()\n throw new Error('Method not implemented.')\n }\n\n async getBlockTimestamp(blockTag: string | number): Promise<number> {\n return this.nativeProvider.getBlock(blockTag).then((block) => block.timestamp)\n }\n\n async getTransaction(txHash: string): Promise<TransactionResponse> {\n const response = await this.nativeProvider.getTransaction(txHash)\n return TransactionResponse.from(response)\n }\n\n async getTransactionReceipt(txHash: string): Promise<TransactionReceipt> {\n const response = await this.nativeProvider.getTransactionReceipt(txHash)\n return TransactionReceipt.from(response)\n }\n\n async getTransactionCount(\n addressOrName: string | Promise<string>,\n blockTag?: BlockTag | Promise<BlockTag>\n ): Promise<number> {\n return this.nativeProvider.getTransactionCount(addressOrName, blockTag)\n }\n\n async sendTransaction(transaction: SignedTransaction, _sendOptions?: object): Promise<TransactionPending> {\n type NativeSignedTransaction = Parameters<typeof this.nativeProvider.sendTransaction>[0]\n const stx = transaction.signed as NativeSignedTransaction\n\n const response = await this.nativeProvider.sendTransaction(stx)\n return TransactionPending.from(response)\n }\n\n async confirmTransaction(pending: TransactionPending, _opts?: object): Promise<TransactionReceipt> {\n const nativePending = pending.pending as ethers.providers.TransactionResponse\n const response = await nativePending.wait()\n return TransactionReceipt.from(response)\n }\n\n async sendAndConfirm(transaction: SignedTransaction, opts?: object): Promise<TransactionReceipt> {\n const pending = await this.sendTransaction(transaction, opts)\n return this.confirmTransaction(pending, opts)\n }\n}\n","import { ethers } from 'ethers'\n\nimport {\n Provider,\n SignedTransaction,\n Signer,\n TransactionPending,\n TransactionReceipt,\n TransactionRequest,\n} from '@layerzerolabs/lz-core'\n\nexport class EvmSigner implements Signer {\n private nativeSigner: ethers.Signer\n\n private constructor(signer: ethers.Signer) {\n this.nativeSigner = signer\n }\n\n static from(source: ethers.Signer | string, path?: string): EvmSigner {\n if (source instanceof ethers.Signer) {\n return new this(source)\n }\n if (path === undefined) {\n return new this(new ethers.Wallet(source))\n } else {\n return new this(ethers.Wallet.fromMnemonic(source, path))\n }\n }\n\n get native(): ethers.Signer {\n return this.nativeSigner\n }\n\n connect(provider: Provider): this {\n if (!(provider.native instanceof ethers.providers.Provider)) {\n throw new Error('Only ethers.providers.Provider is supported.')\n }\n\n this.nativeSigner = this.nativeSigner.connect(provider.native)\n return this\n }\n\n async getAddress(): Promise<string> {\n return this.nativeSigner.getAddress()\n }\n\n get address(): string {\n return (this.nativeSigner as ethers.Signer & { address: string }).address\n }\n\n async sendAndConfirm(\n transaction: SignedTransaction,\n opts?: { confirmations?: number }\n ): Promise<TransactionReceipt> {\n const pending = await this.sendTransaction(transaction)\n const response = pending.pending as ethers.providers.TransactionResponse\n const receipt = await response.wait(opts?.confirmations)\n return TransactionReceipt.from(receipt)\n }\n\n async sendTransaction(transaction: SignedTransaction): Promise<TransactionPending> {\n type NativeSignedTransaction = Parameters<ethers.providers.Provider['sendTransaction']>[0]\n const stx = transaction.signed as NativeSignedTransaction\n if (this.nativeSigner.provider === undefined) {\n throw new Error('No provider attached to the signer')\n }\n\n const response = await this.nativeSigner.provider.sendTransaction(stx)\n return TransactionPending.from(response)\n }\n\n async signTransaction(transaction: TransactionRequest): Promise<SignedTransaction> {\n type NativeTransactionRequest = Parameters<ethers.Signer['populateTransaction']>[0]\n const tx = transaction.request as NativeTransactionRequest\n\n const populatedTransaction = await this.nativeSigner.populateTransaction(tx)\n const response = await this.nativeSigner.signTransaction(populatedTransaction)\n return SignedTransaction.from(response)\n }\n\n async signBuffer(buffer: Uint8Array): Promise<Uint8Array> {\n const signedMessage = await this.nativeSigner.signMessage(buffer)\n return ethers.utils.arrayify(signedMessage)\n }\n\n async buildTransaction(buildTxRequest: unknown): Promise<TransactionRequest> {\n return Promise.reject(new Error('Method not implemented.'))\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/providers/evm.ts","../src/signers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CAAK,YAAa,CAAA,QAAA,KAAa,KAAW,CAAA,EAAA;AAC1C,MAAM,MAAA,IAAI,MAAM,oCAAoC,CAAA;AAAA;AAGxD,IAAA,MAAM,WAAW,MAAM,IAAA,CAAK,YAAa,CAAA,QAAA,CAAS,gBAAgB,GAAG,CAAA;AACrE,IAAOC,OAAAA,kBAAAA,CAAmB,KAAK,QAAQ,CAAA;AAAA;AAC3C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,gBAAgB,WAA6D,EAAA;AAE/E,IAAA,MAAM,KAAK,WAAY,CAAA,OAAA;AAEvB,IAAA,MAAM,oBAAuB,GAAA,MAAM,IAAK,CAAA,YAAA,CAAa,oBAAoB,EAAE,CAAA;AAC3E,IAAA,MAAM,QAAW,GAAA,MAAM,IAAK,CAAA,YAAA,CAAa,gBAAgB,oBAAoB,CAAA;AAC7E,IAAOC,OAAAA,iBAAAA,CAAkB,KAAK,QAAQ,CAAA;AAAA;AAC1C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,WAAW,MAAyC,EAAA;AACtD,IAAA,MAAM,aAAgB,GAAA,MAAM,IAAK,CAAA,YAAA,CAAa,YAAY,MAAM,CAAA;AAChE,IAAOH,OAAAA,MAAAA,CAAO,KAAM,CAAA,QAAA,CAAS,aAAa,CAAA;AAAA;AAElD","file":"index.mjs","sourcesContent":["import { ethers } from 'ethers'\n\nimport {\n Block,\n BlockTag,\n BlockWithTransactions,\n Finality,\n Provider,\n SignedTransaction,\n TransactionPending,\n TransactionReceipt,\n TransactionResponse,\n} from '@layerzerolabs/lz-core'\n\n/**\n * Represents an EVM (Ethereum Virtual Machine) blockchain provider.\n * Implements the Provider interface for interacting with EVM-compatible blockchains.\n */\nexport class EvmProvider implements Provider {\n nativeProvider: ethers.providers.JsonRpcProvider\n\n /**\n * Creates an instance of EvmProvider.\n *\n * @param {string} url - The URL of the EVM node.\n */\n constructor(public url: string) {\n this.nativeProvider = new ethers.providers.JsonRpcProvider(url)\n }\n\n /**\n * Creates an instance of EvmProvider from the given URL.\n *\n * @param {string} url - The URL of the EVM node.\n * @returns {EvmProvider} The created EvmProvider instance.\n */\n static from(url: string): EvmProvider\n\n /**\n * Creates an instance of EvmProvider from the given source.\n *\n * @param {string} source - The source to create the provider from.\n * @returns {EvmProvider} The created EvmProvider instance.\n * @throws {Error} If the source parameter is not a string.\n */\n static from(source: string): EvmProvider {\n if (typeof source === 'string') {\n return new EvmProvider(source)\n } else {\n throw new Error('Invalid parameters')\n }\n }\n\n /**\n * Gets the native EVM provider instance.\n *\n * @returns {ethers.providers.JsonRpcProvider} The native EVM provider instance.\n */\n get native(): ethers.providers.JsonRpcProvider {\n return this.nativeProvider\n }\n\n /**\n * Gets the balance of the specified address.\n *\n * @param {string} address - The address to get the balance of.\n * @returns {Promise<string>} A promise that resolves to the balance of the address.\n */\n async getBalance(address: string): Promise<string> {\n return (await this.nativeProvider.getBalance(address)).toString()\n }\n\n /**\n * Gets the block specified by blockTag.\n *\n * @param {BlockTag} blockTag - The block tag to specify the block.\n * @returns {Promise<Block>} A promise that resolves to the block.\n */\n async getBlock(blockTag: string | number): Promise<Block> {\n const response = await this.nativeProvider.getBlock(blockTag)\n return Block.from(response)\n }\n\n /**\n * Gets the block with transactions specified by blockTag.\n *\n * @param {BlockTag} blockTag - The block tag to specify the block.\n * @returns {Promise<BlockWithTransactions>} A promise that resolves to the block with transactions.\n */\n async getBlockWithTransactions(blockTag: string | number): Promise<BlockWithTransactions> {\n const response = await this.nativeProvider.getBlockWithTransactions(blockTag)\n return BlockWithTransactions.from(response)\n }\n\n /**\n * Gets the current block number.\n *\n * @returns {Promise<number>} A promise that resolves to the current block number.\n */\n async getBlockNumber(): Promise<number> {\n return this.nativeProvider.getBlockNumber()\n }\n\n /**\n * Gets the current slot number for commitment, not suitable for EVM.\n *\n * @param {Finality} [finality] - The commitment level (optional).\n * @returns {Promise<number>} A promise that resolves to the current slot number.\n * @throws {Error} Method not implemented.\n */\n // eslint-disable-next-line @typescript-eslint/require-await\n async getSlot(_finality?: Finality): Promise<number> {\n await Promise.resolve()\n throw new Error('Method not implemented.')\n }\n\n /**\n * Gets the UNIX timestamp for the block identified by blockTag.\n *\n * @param {BlockTag} blockTag - The block tag to specify the block.\n * @returns {Promise<number>} A promise that resolves to the UNIX timestamp of the block.\n */\n async getBlockTimestamp(blockTag: string | number): Promise<number> {\n return this.nativeProvider.getBlock(blockTag).then((block) => block.timestamp)\n }\n\n /**\n * Gets information about a transaction.\n *\n * @param {string} txHash - The hash of the transaction.\n * @returns {Promise<TransactionResponse>} A promise that resolves to the transaction response.\n */\n async getTransaction(txHash: string): Promise<TransactionResponse> {\n const response = await this.nativeProvider.getTransaction(txHash)\n return TransactionResponse.from(response)\n }\n\n /**\n * Gets the receipt of a transaction.\n *\n * @param {string} txHash - The hash of the transaction.\n * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.\n */\n async getTransactionReceipt(txHash: string): Promise<TransactionReceipt> {\n const response = await this.nativeProvider.getTransactionReceipt(txHash)\n return TransactionReceipt.from(response)\n }\n\n /**\n * Gets the number of transactions sent from the specified address.\n *\n * @param {string | Promise<string>} addressOrName - The address to get the number of transactions from.\n * @param {BlockTag | Promise<BlockTag>} [blockTag] - The block tag to get the number of transactions from (optional).\n * @returns {Promise<number>} A promise that resolves to the number of transactions sent from the address.\n */\n async getTransactionCount(\n addressOrName: string | Promise<string>,\n blockTag?: BlockTag | Promise<BlockTag>\n ): Promise<number> {\n return this.nativeProvider.getTransactionCount(addressOrName, blockTag)\n }\n\n /**\n * Sends a signed transaction to the blockchain.\n *\n * @param {SignedTransaction} transaction - The signed transaction to send.\n * @param {object} [sendOptions] - Optional parameters for sending the transaction.\n * @returns {Promise<TransactionPending>} A promise that resolves to the pending transaction.\n */\n async sendTransaction(transaction: SignedTransaction, _sendOptions?: object): Promise<TransactionPending> {\n type NativeSignedTransaction = Parameters<typeof this.nativeProvider.sendTransaction>[0]\n const stx = transaction.signed as NativeSignedTransaction\n\n const response = await this.nativeProvider.sendTransaction(stx)\n return TransactionPending.from(response)\n }\n\n /**\n * Confirms a pending transaction.\n *\n * @param {TransactionPending} pending - The pending transaction to confirm.\n * @param {object} [opts] - Optional parameters for the confirmation.\n * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.\n */\n async confirmTransaction(pending: TransactionPending, _opts?: object): Promise<TransactionReceipt> {\n const nativePending = pending.pending as ethers.providers.TransactionResponse\n const response = await nativePending.wait()\n return TransactionReceipt.from(response)\n }\n\n /**\n * Sends a signed transaction and waits for confirmation.\n *\n * @param {SignedTransaction} transaction - The signed transaction to send.\n * @param {object} [opts] - Optional parameters for sending and confirming the transaction.\n * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.\n */\n async sendAndConfirm(transaction: SignedTransaction, opts?: object): Promise<TransactionReceipt> {\n const pending = await this.sendTransaction(transaction, opts)\n return this.confirmTransaction(pending, opts)\n }\n}\n","import { ethers } from 'ethers'\n\nimport {\n Provider,\n SignedTransaction,\n Signer,\n TransactionPending,\n TransactionReceipt,\n TransactionRequest,\n} from '@layerzerolabs/lz-core'\n\n/**\n * Represents an EVM (Ethereum Virtual Machine) blockchain signer.\n * Implements the Signer interface for interacting with EVM-compatible blockchains.\n */\nexport class EvmSigner implements Signer {\n private nativeSigner: ethers.Signer\n\n /**\n * Creates an instance of EvmSigner.\n *\n * @param {ethers.Signer} signer - The EVM signer to use.\n */\n private constructor(signer: ethers.Signer) {\n this.nativeSigner = signer\n }\n\n /**\n * Creates an instance of EvmSigner from the given source.\n *\n * @param {ethers.Signer | string} source - The source to create the signer from.\n * @param {string} [path] - The derivation path (optional).\n * @returns {EvmSigner} The created EvmSigner instance.\n * @throws {Error} If the source parameter is invalid.\n */\n static from(source: ethers.Signer | string, path?: string): EvmSigner {\n if (source instanceof ethers.Signer) {\n return new this(source)\n }\n if (path === undefined) {\n return new this(new ethers.Wallet(source))\n } else {\n return new this(ethers.Wallet.fromMnemonic(source, path))\n }\n }\n\n /**\n * Gets the native EVM signer instance.\n *\n * @returns {ethers.Signer} The native EVM signer instance.\n */\n get native(): ethers.Signer {\n return this.nativeSigner\n }\n\n /**\n * Connects the signer to a provider.\n *\n * @param {Provider} provider - The provider to connect to.\n * @returns {this} The connected signer.\n * @throws {Error} If the provider is not an instance of ethers.providers.Provider.\n */\n connect(provider: Provider): this {\n if (!(provider.native instanceof ethers.providers.Provider)) {\n throw new Error('Only ethers.providers.Provider is supported.')\n }\n\n this.nativeSigner = this.nativeSigner.connect(provider.native)\n return this\n }\n\n /**\n * Gets the address of the signer.\n *\n * @returns {Promise<string>} A promise that resolves to the address of the signer.\n */\n async getAddress(): Promise<string> {\n return this.nativeSigner.getAddress()\n }\n\n /**\n * Gets the address of the signer.\n *\n * @returns {string} The address of the signer.\n */\n get address(): string {\n return (this.nativeSigner as ethers.Signer & { address: string }).address\n }\n\n /**\n * Sends a signed transaction and waits for confirmation.\n *\n * @param {SignedTransaction} transaction - The signed transaction to send.\n * @param {object} [opts] - Optional parameters for sending and confirming the transaction.\n * @returns {Promise<TransactionReceipt>} A promise that resolves to the transaction receipt.\n */\n async sendAndConfirm(\n transaction: SignedTransaction,\n opts?: { confirmations?: number }\n ): Promise<TransactionReceipt> {\n const pending = await this.sendTransaction(transaction)\n const response = pending.pending as ethers.providers.TransactionResponse\n const receipt = await response.wait(opts?.confirmations)\n return TransactionReceipt.from(receipt)\n }\n\n /**\n * Sends a signed transaction.\n *\n * @param {SignedTransaction} transaction - The signed transaction to send.\n * @returns {Promise<TransactionPending>} A promise that resolves to the pending transaction.\n * @throws {Error} If no provider is attached to the signer.\n */\n async sendTransaction(transaction: SignedTransaction): Promise<TransactionPending> {\n type NativeSignedTransaction = Parameters<ethers.providers.Provider['sendTransaction']>[0]\n const stx = transaction.signed as NativeSignedTransaction\n if (this.nativeSigner.provider === undefined) {\n throw new Error('No provider attached to the signer')\n }\n\n const response = await this.nativeSigner.provider.sendTransaction(stx)\n return TransactionPending.from(response)\n }\n\n /**\n * Signs a transaction.\n *\n * @param {TransactionRequest} transaction - The transaction request to sign.\n * @returns {Promise<SignedTransaction>} A promise that resolves to the signed transaction.\n */\n async signTransaction(transaction: TransactionRequest): Promise<SignedTransaction> {\n type NativeTransactionRequest = Parameters<ethers.Signer['populateTransaction']>[0]\n const tx = transaction.request as NativeTransactionRequest\n\n const populatedTransaction = await this.nativeSigner.populateTransaction(tx)\n const response = await this.nativeSigner.signTransaction(populatedTransaction)\n return SignedTransaction.from(response)\n }\n\n /**\n * Signs a buffer (e.g., a message hash) using the native EVM signer.\n *\n * @param {Uint8Array} buffer - The buffer to sign.\n * @returns {Promise<Uint8Array>} A promise that resolves to the signed buffer as a Uint8Array.\n */\n async signBuffer(buffer: Uint8Array): Promise<Uint8Array> {\n const signedMessage = await this.nativeSigner.signMessage(buffer)\n return ethers.utils.arrayify(signedMessage)\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@layerzerolabs/lz-corekit-evm",
3
- "version": "3.0.15",
3
+ "version": "3.0.17",
4
4
  "description": "LayerZero Core Library",
5
5
  "license": "BUSL-1.1",
6
6
  "exports": {
@@ -23,22 +23,20 @@
23
23
  "clean-prebuild": "rimraf dist"
24
24
  },
25
25
  "dependencies": {
26
- "@layerzerolabs/lz-core": "^3.0.15",
27
- "@layerzerolabs/lz-utilities": "^3.0.15",
26
+ "@layerzerolabs/lz-core": "^3.0.17",
27
+ "@layerzerolabs/lz-utilities": "^3.0.17",
28
28
  "ethers": "^5.7.2"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@jest/globals": "^29.7.0",
32
- "@layerzerolabs/tronweb-typescript": "^0.0.0",
33
- "@layerzerolabs/tsup-config-next": "^3.0.15",
34
- "@layerzerolabs/typescript-config-next": "^3.0.15",
32
+ "@layerzerolabs/tsup-config-next": "^3.0.17",
33
+ "@layerzerolabs/typescript-config-next": "^3.0.17",
35
34
  "@types/jest": "^29.5.10",
36
- "@types/tronweb": "npm:@layerzerolabs/tronweb-typescript@workspace:^",
37
35
  "jest": "^29.7.0",
38
36
  "jest-extended": "^4.0.2",
39
37
  "rimraf": "^5.0.5",
40
38
  "ts-jest": "^29.1.1",
41
- "tsup": "^8.0.1",
39
+ "tsup": "^8.3.5",
42
40
  "typescript": "~5.2.2"
43
41
  },
44
42
  "publishConfig": {