@pushchain/core 6.0.20 → 6.0.21

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.
Files changed (111) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/package.json +1 -1
  3. package/src/lib/cache/cache.js +2 -0
  4. package/src/lib/constants/abi/index.d.ts +1 -0
  5. package/src/lib/constants/abi/index.js +8 -1
  6. package/src/lib/constants/abi/pc20.evm.d.ts +217 -0
  7. package/src/lib/constants/abi/pc20.evm.js +150 -0
  8. package/src/lib/constants/abi/prc20.evm.d.ts +172 -0
  9. package/src/lib/constants/abi/prc20.evm.js +97 -0
  10. package/src/lib/constants/abi/universalGatewayV0.json +1 -1
  11. package/src/lib/constants/chain.js +38 -8
  12. package/src/lib/constants/selectors.js +2 -2
  13. package/src/lib/constants/tokens.js +4 -3
  14. package/src/lib/formatters.js +16 -6
  15. package/src/lib/generated/uexecutor/v1/query.js +2 -4
  16. package/src/lib/generated/uexecutor/v1/types.d.ts +14 -0
  17. package/src/lib/generated/uexecutor/v1/types.js +90 -47
  18. package/src/lib/generated/uexecutor/v2/query.js +2 -4
  19. package/src/lib/generated/uexecutor/v2/types.d.ts +20 -0
  20. package/src/lib/generated/uexecutor/v2/types.js +49 -33
  21. package/src/lib/generated/v1/tx.js +30 -37
  22. package/src/lib/index.d.ts +3 -0
  23. package/src/lib/index.js +21 -3
  24. package/src/lib/internal/buffer.js +1 -2
  25. package/src/lib/orchestrator/cea-utils.js +73 -83
  26. package/src/lib/orchestrator/internals/account-manager.js +130 -139
  27. package/src/lib/orchestrator/internals/cascade.d.ts +0 -6
  28. package/src/lib/orchestrator/internals/cascade.js +1184 -1059
  29. package/src/lib/orchestrator/internals/confirmation.js +138 -148
  30. package/src/lib/orchestrator/internals/error-decoder.js +1 -1
  31. package/src/lib/orchestrator/internals/errors.js +12 -3
  32. package/src/lib/orchestrator/internals/execute-funds-only.d.ts +2 -2
  33. package/src/lib/orchestrator/internals/execute-funds-only.js +297 -259
  34. package/src/lib/orchestrator/internals/execute-funds-payload.d.ts +2 -2
  35. package/src/lib/orchestrator/internals/execute-funds-payload.js +220 -220
  36. package/src/lib/orchestrator/internals/execute-standard.d.ts +0 -8
  37. package/src/lib/orchestrator/internals/execute-standard.js +339 -342
  38. package/src/lib/orchestrator/internals/gas-calculator.js +497 -520
  39. package/src/lib/orchestrator/internals/gas-usd-sizer.js +101 -110
  40. package/src/lib/orchestrator/internals/gateway-client.js +102 -103
  41. package/src/lib/orchestrator/internals/helpers.js +30 -27
  42. package/src/lib/orchestrator/internals/inbound-tracker.js +234 -238
  43. package/src/lib/orchestrator/internals/outbound-sync.js +463 -452
  44. package/src/lib/orchestrator/internals/outbound-tracker.js +27 -34
  45. package/src/lib/orchestrator/internals/payload-builder.d.ts +2 -2
  46. package/src/lib/orchestrator/internals/payload-builder.js +119 -100
  47. package/src/lib/orchestrator/internals/pc-usd-oracle.js +121 -129
  48. package/src/lib/orchestrator/internals/pc20/address-codec.d.ts +31 -0
  49. package/src/lib/orchestrator/internals/pc20/address-codec.js +124 -0
  50. package/src/lib/orchestrator/internals/pc20/chain-namespace.d.ts +68 -0
  51. package/src/lib/orchestrator/internals/pc20/chain-namespace.js +136 -0
  52. package/src/lib/orchestrator/internals/pc20/errors.d.ts +160 -0
  53. package/src/lib/orchestrator/internals/pc20/errors.js +236 -0
  54. package/src/lib/orchestrator/internals/pc20/export.d.ts +172 -0
  55. package/src/lib/orchestrator/internals/pc20/export.js +412 -0
  56. package/src/lib/orchestrator/internals/pc20/gate.d.ts +67 -0
  57. package/src/lib/orchestrator/internals/pc20/gate.js +184 -0
  58. package/src/lib/orchestrator/internals/pc20/resolver.d.ts +187 -0
  59. package/src/lib/orchestrator/internals/pc20/resolver.js +658 -0
  60. package/src/lib/orchestrator/internals/pc20/svm.d.ts +189 -0
  61. package/src/lib/orchestrator/internals/pc20/svm.js +286 -0
  62. package/src/lib/orchestrator/internals/pc20/tracking.d.ts +46 -0
  63. package/src/lib/orchestrator/internals/pc20/tracking.js +109 -0
  64. package/src/lib/orchestrator/internals/preflight.js +1 -1
  65. package/src/lib/orchestrator/internals/progress-route-hooks.js +2 -2
  66. package/src/lib/orchestrator/internals/push-chain-tx.js +319 -329
  67. package/src/lib/orchestrator/internals/quote.js +90 -94
  68. package/src/lib/orchestrator/internals/rescue.js +76 -79
  69. package/src/lib/orchestrator/internals/response-builder.d.ts +28 -1
  70. package/src/lib/orchestrator/internals/response-builder.js +817 -701
  71. package/src/lib/orchestrator/internals/route-handlers.d.ts +7 -15
  72. package/src/lib/orchestrator/internals/route-handlers.js +1512 -1178
  73. package/src/lib/orchestrator/internals/signing.js +78 -83
  74. package/src/lib/orchestrator/internals/svm-bridge.d.ts +2 -2
  75. package/src/lib/orchestrator/internals/svm-bridge.js +161 -93
  76. package/src/lib/orchestrator/internals/svm-helpers.d.ts +15 -1
  77. package/src/lib/orchestrator/internals/svm-helpers.js +68 -24
  78. package/src/lib/orchestrator/internals/svm-rent.d.ts +19 -1
  79. package/src/lib/orchestrator/internals/svm-rent.js +163 -141
  80. package/src/lib/orchestrator/internals/tx-transformer.js +26 -23
  81. package/src/lib/orchestrator/internals/uea-manager.js +89 -86
  82. package/src/lib/orchestrator/max-pc-for-gas.js +5 -6
  83. package/src/lib/orchestrator/orchestrator.js +217 -200
  84. package/src/lib/orchestrator/orchestrator.types.d.ts +121 -1
  85. package/src/lib/orchestrator/orchestrator.types.js +19 -0
  86. package/src/lib/orchestrator/payload-builders.d.ts +2 -2
  87. package/src/lib/orchestrator/payload-builders.js +26 -24
  88. package/src/lib/orchestrator/route-detector.js +26 -9
  89. package/src/lib/orchestrator/svm-idl/ix-encoder.js +1 -2
  90. package/src/lib/orchestrator/svm-idl/normalize-address.js +2 -2
  91. package/src/lib/orchestrator/svm-idl/resolve.js +1 -2
  92. package/src/lib/price-fetch/price-fetch.js +67 -68
  93. package/src/lib/progress-hook/progress-hook.js +124 -72
  94. package/src/lib/push-chain/push-chain.js +171 -153
  95. package/src/lib/push-client/push-client.js +223 -237
  96. package/src/lib/universal/account/account.js +349 -365
  97. package/src/lib/universal/signer/signer.js +306 -294
  98. package/src/lib/universal-tx-detector/auto-detect.js +55 -60
  99. package/src/lib/universal-tx-detector/cascade.js +160 -172
  100. package/src/lib/universal-tx-detector/child-inbounds.js +67 -75
  101. package/src/lib/universal-tx-detector/classify.js +2 -3
  102. package/src/lib/universal-tx-detector/detector-svm.js +139 -147
  103. package/src/lib/universal-tx-detector/detector.js +145 -157
  104. package/src/lib/universal-tx-detector/normalize.js +7 -7
  105. package/src/lib/utils/external-tx-hash.js +1 -2
  106. package/src/lib/utils.d.ts +44 -0
  107. package/src/lib/utils.js +762 -683
  108. package/src/lib/vm-client/evm-client.js +186 -202
  109. package/src/lib/vm-client/svm-client.d.ts +1 -1
  110. package/src/lib/vm-client/svm-client.js +220 -224
  111. package/src/lib/vm-client/vm-client.types.d.ts +14 -2
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EvmClient = exports.EIP7702NotSupportedError = void 0;
4
- const tslib_1 = require("tslib");
5
4
  const viem_1 = require("viem");
6
5
  /**
7
6
  * ABI of the ERC-7821 `execute(bytes32 mode, bytes executionData)` entrypoint —
@@ -40,6 +39,7 @@ const ERC7821_EXECUTION_TUPLE = {
40
39
  * safely fall back to a non-7702 path without risk of double execution.
41
40
  */
42
41
  class EIP7702NotSupportedError extends Error {
42
+ reason;
43
43
  constructor(reason) {
44
44
  super('Signer cannot produce an EIP-7702 authorization');
45
45
  this.name = 'EIP7702NotSupportedError';
@@ -57,6 +57,7 @@ exports.EIP7702NotSupportedError = EIP7702NotSupportedError;
57
57
  * });
58
58
  */
59
59
  class EvmClient {
60
+ publicClient;
60
61
  constructor({ rpcUrls, chain }) {
61
62
  // retryCount/retryDelay make reads (incl. contract reads + Push status
62
63
  // queries via PushClient) resilient to transient RPC 5xx (e.g. 502s under
@@ -86,10 +87,8 @@ class EvmClient {
86
87
  * console.log('Address has no funds');
87
88
  * }
88
89
  */
89
- getBalance(address) {
90
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
91
- return this.publicClient.getBalance({ address });
92
- });
90
+ async getBalance(address) {
91
+ return this.publicClient.getBalance({ address });
93
92
  }
94
93
  /**
95
94
  * Performs a read-only call to a smart contract.
@@ -115,14 +114,12 @@ class EvmClient {
115
114
  * args: ['0xUserAddress'],
116
115
  * });
117
116
  */
118
- readContract(_a) {
119
- return tslib_1.__awaiter(this, arguments, void 0, function* ({ abi, address, functionName, args = [], }) {
120
- return this.publicClient.readContract({
121
- abi: abi,
122
- address: address,
123
- functionName,
124
- args,
125
- });
117
+ async readContract({ abi, address, functionName, args = [], }) {
118
+ return this.publicClient.readContract({
119
+ abi: abi,
120
+ address: address,
121
+ functionName,
122
+ args,
126
123
  });
127
124
  }
128
125
  /**
@@ -131,17 +128,15 @@ class EvmClient {
131
128
  * This is a convenience wrapper around readContract using the minimal
132
129
  * ERC-20 ABI: balanceOf(address) -> uint256.
133
130
  */
134
- getErc20Balance(_a) {
135
- return tslib_1.__awaiter(this, arguments, void 0, function* ({ tokenAddress, ownerAddress, }) {
136
- const erc20Abi = (0, viem_1.parseAbi)([
137
- 'function balanceOf(address) view returns (uint256)',
138
- ]);
139
- return this.readContract({
140
- abi: erc20Abi,
141
- address: tokenAddress,
142
- functionName: 'balanceOf',
143
- args: [ownerAddress],
144
- });
131
+ async getErc20Balance({ tokenAddress, ownerAddress, }) {
132
+ const erc20Abi = (0, viem_1.parseAbi)([
133
+ 'function balanceOf(address) view returns (uint256)',
134
+ ]);
135
+ return this.readContract({
136
+ abi: erc20Abi,
137
+ address: tokenAddress,
138
+ functionName: 'balanceOf',
139
+ args: [ownerAddress],
145
140
  });
146
141
  }
147
142
  /**
@@ -173,19 +168,17 @@ class EvmClient {
173
168
  * signer: universalSigner,
174
169
  * });
175
170
  */
176
- writeContract(_a) {
177
- return tslib_1.__awaiter(this, arguments, void 0, function* ({ abi, address, functionName, args = [], value = BigInt(0), signer, }) {
178
- const data = (0, viem_1.encodeFunctionData)({
179
- abi: abi,
180
- functionName,
181
- args,
182
- });
183
- return this.sendTransaction({
184
- to: address,
185
- data,
186
- value,
187
- signer,
188
- });
171
+ async writeContract({ abi, address, functionName, args = [], value = BigInt(0), signer, }) {
172
+ const data = (0, viem_1.encodeFunctionData)({
173
+ abi: abi,
174
+ functionName,
175
+ args,
176
+ });
177
+ return this.sendTransaction({
178
+ to: address,
179
+ data,
180
+ value,
181
+ signer,
189
182
  });
190
183
  }
191
184
  /**
@@ -208,44 +201,42 @@ class EvmClient {
208
201
  * });
209
202
  * console.log(`ETH transfer sent: ${txHash}`);
210
203
  */
211
- sendTransaction(_a) {
212
- return tslib_1.__awaiter(this, arguments, void 0, function* ({ to, data, value = BigInt(0), signer, nonce: explicitNonce, gas: explicitGas, }) {
213
- // Estimate gas and fees first (can run in parallel)
214
- const [gas, feePerGas, chainId] = yield Promise.all([
215
- explicitGas
216
- ? Promise.resolve(explicitGas)
217
- : data === '0x'
218
- ? Promise.resolve(BigInt(21000))
219
- : this.publicClient.estimateGas({
220
- account: signer.account.address,
221
- to,
222
- data,
223
- value,
224
- }),
225
- this.publicClient.estimateFeesPerGas(),
226
- this.publicClient.getChainId(),
227
- ]);
228
- const nonce = explicitNonce !== null && explicitNonce !== void 0 ? explicitNonce : yield this.publicClient.getTransactionCount({
229
- address: signer.account.address,
230
- blockTag: 'pending',
231
- });
232
- const unsignedTx = (0, viem_1.serializeTransaction)({
233
- chainId,
234
- type: 'eip1559',
235
- to,
236
- data,
237
- gas,
238
- nonce,
239
- maxFeePerGas: feePerGas.maxFeePerGas,
240
- maxPriorityFeePerGas: feePerGas.maxPriorityFeePerGas,
241
- value,
242
- });
243
- if (!signer.signAndSendTransaction) {
244
- throw new Error('signer.signAndSendTransaction is undefined');
245
- }
246
- const txHashBytes = yield signer.signAndSendTransaction((0, viem_1.hexToBytes)(unsignedTx));
247
- return (0, viem_1.bytesToHex)(txHashBytes);
204
+ async sendTransaction({ to, data, value = BigInt(0), signer, nonce: explicitNonce, gas: explicitGas, }) {
205
+ // Estimate gas and fees first (can run in parallel)
206
+ const [gas, feePerGas, chainId] = await Promise.all([
207
+ explicitGas
208
+ ? Promise.resolve(explicitGas)
209
+ : data === '0x'
210
+ ? Promise.resolve(BigInt(21000))
211
+ : this.publicClient.estimateGas({
212
+ account: signer.account.address,
213
+ to,
214
+ data,
215
+ value,
216
+ }),
217
+ this.publicClient.estimateFeesPerGas(),
218
+ this.publicClient.getChainId(),
219
+ ]);
220
+ const nonce = explicitNonce ?? await this.publicClient.getTransactionCount({
221
+ address: signer.account.address,
222
+ blockTag: 'pending',
223
+ });
224
+ const unsignedTx = (0, viem_1.serializeTransaction)({
225
+ chainId,
226
+ type: 'eip1559',
227
+ to,
228
+ data,
229
+ gas,
230
+ nonce,
231
+ maxFeePerGas: feePerGas.maxFeePerGas,
232
+ maxPriorityFeePerGas: feePerGas.maxPriorityFeePerGas,
233
+ value,
248
234
  });
235
+ if (!signer.signAndSendTransaction) {
236
+ throw new Error('signer.signAndSendTransaction is undefined');
237
+ }
238
+ const txHashBytes = await signer.signAndSendTransaction((0, viem_1.hexToBytes)(unsignedTx));
239
+ return (0, viem_1.bytesToHex)(txHashBytes);
249
240
  }
250
241
  /**
251
242
  * Executes a batch of calls atomically from a native EOA using EIP-7702.
@@ -266,95 +257,93 @@ class EvmClient {
266
257
  *
267
258
  * @returns The transaction hash.
268
259
  */
269
- sendBatch7702(_a) {
270
- return tslib_1.__awaiter(this, arguments, void 0, function* ({ executor, calls, signer, }) {
271
- if (!signer.signAuthorization) {
272
- // No capability at all → safe pre-broadcast signal to fall back.
273
- throw new EIP7702NotSupportedError();
274
- }
275
- if (!signer.signAndSendTransaction) {
276
- throw new Error('signer.signAndSendTransaction is undefined');
277
- }
278
- const account = signer.account.address;
279
- // ERC-7821 maps target == address(0) to address(this); reject it so a batch
280
- // can't silently behave differently here vs. the sequential fallback.
281
- if (calls.some((c) => /^0x0{40}$/i.test(c.to) || c.to.toLowerCase() === '0x0')) {
282
- throw new Error('sendBatch7702: a call has a zero `to` address, which ERC-7821 reinterprets ' +
283
- 'as the account itself. Use an explicit target.');
284
- }
285
- // ERC-7821: execute(mode, executionData) where executionData = abi.encode(Execution[]).
286
- const executionData = (0, viem_1.encodeAbiParameters)([ERC7821_EXECUTION_TUPLE], [
287
- calls.map((c) => ({ target: c.to, value: c.value, callData: c.data })),
288
- ]);
289
- const data = (0, viem_1.encodeFunctionData)({
290
- abi: PUSH_BATCH_EXECUTOR_ABI,
291
- functionName: 'execute',
292
- args: [ERC7821_BATCH_MODE, executionData],
293
- });
294
- const [feePerGas, chainId, nonce] = yield Promise.all([
295
- this.publicClient.estimateFeesPerGas(),
296
- this.publicClient.getChainId(),
297
- this.publicClient.getTransactionCount({
298
- address: account,
299
- blockTag: 'pending',
300
- }),
301
- ]);
302
- // EIP-7702 self-execution: the transaction consumes `nonce`, so the
303
- // authorization (validated after the sender's nonce is bumped) must carry
304
- // `nonce + 1`. This is the only step that can reveal the wallet truly can't
305
- // sign a 7702 authorization (presence of the method is not a guarantee), so
306
- // a failure here is surfaced as EIP7702NotSupportedError — pre-broadcast,
307
- // hence safe for the caller to fall back on.
308
- let authorization;
309
- try {
310
- authorization = yield signer.signAuthorization({
311
- contractAddress: executor,
312
- chainId,
313
- nonce: nonce + 1,
314
- });
315
- }
316
- catch (err) {
317
- throw new EIP7702NotSupportedError(err);
318
- }
319
- // Estimate gas against the delegated account: override the EOA's code with
320
- // the 7702 delegation designator (0xef0100 || executor) so estimation runs
321
- // the executor. Fall back to a safe ceiling if the node rejects overrides.
322
- let gas;
323
- try {
324
- gas = yield this.publicClient.estimateGas({
325
- account,
326
- to: account,
327
- data,
328
- stateOverride: [
329
- {
330
- address: account,
331
- code: ('0xef0100' + executor.slice(2)),
332
- },
333
- ],
334
- });
335
- gas = (gas * BigInt(120)) / BigInt(100); // headroom for delegation + auth
336
- }
337
- catch (_b) {
338
- // Estimation unavailable (e.g. node rejects state overrides). Scale the
339
- // ceiling with the batch size so large batches don't OOG — the legacy
340
- // per-call loop budgeted ~500k gas per call; mirror that plus overhead.
341
- gas = BigInt(500000) * BigInt(calls.length) + BigInt(100000);
342
- }
343
- const unsignedTx = (0, viem_1.serializeTransaction)({
260
+ async sendBatch7702({ executor, calls, signer, }) {
261
+ if (!signer.signAuthorization) {
262
+ // No capability at all → safe pre-broadcast signal to fall back.
263
+ throw new EIP7702NotSupportedError();
264
+ }
265
+ if (!signer.signAndSendTransaction) {
266
+ throw new Error('signer.signAndSendTransaction is undefined');
267
+ }
268
+ const account = signer.account.address;
269
+ // ERC-7821 maps target == address(0) to address(this); reject it so a batch
270
+ // can't silently behave differently here vs. the sequential fallback.
271
+ if (calls.some((c) => /^0x0{40}$/i.test(c.to) || c.to.toLowerCase() === '0x0')) {
272
+ throw new Error('sendBatch7702: a call has a zero `to` address, which ERC-7821 reinterprets ' +
273
+ 'as the account itself. Use an explicit target.');
274
+ }
275
+ // ERC-7821: execute(mode, executionData) where executionData = abi.encode(Execution[]).
276
+ const executionData = (0, viem_1.encodeAbiParameters)([ERC7821_EXECUTION_TUPLE], [
277
+ calls.map((c) => ({ target: c.to, value: c.value, callData: c.data })),
278
+ ]);
279
+ const data = (0, viem_1.encodeFunctionData)({
280
+ abi: PUSH_BATCH_EXECUTOR_ABI,
281
+ functionName: 'execute',
282
+ args: [ERC7821_BATCH_MODE, executionData],
283
+ });
284
+ const [feePerGas, chainId, nonce] = await Promise.all([
285
+ this.publicClient.estimateFeesPerGas(),
286
+ this.publicClient.getChainId(),
287
+ this.publicClient.getTransactionCount({
288
+ address: account,
289
+ blockTag: 'pending',
290
+ }),
291
+ ]);
292
+ // EIP-7702 self-execution: the transaction consumes `nonce`, so the
293
+ // authorization (validated after the sender's nonce is bumped) must carry
294
+ // `nonce + 1`. This is the only step that can reveal the wallet truly can't
295
+ // sign a 7702 authorization (presence of the method is not a guarantee), so
296
+ // a failure here is surfaced as EIP7702NotSupportedError — pre-broadcast,
297
+ // hence safe for the caller to fall back on.
298
+ let authorization;
299
+ try {
300
+ authorization = await signer.signAuthorization({
301
+ contractAddress: executor,
344
302
  chainId,
345
- type: 'eip7702',
303
+ nonce: nonce + 1,
304
+ });
305
+ }
306
+ catch (err) {
307
+ throw new EIP7702NotSupportedError(err);
308
+ }
309
+ // Estimate gas against the delegated account: override the EOA's code with
310
+ // the 7702 delegation designator (0xef0100 || executor) so estimation runs
311
+ // the executor. Fall back to a safe ceiling if the node rejects overrides.
312
+ let gas;
313
+ try {
314
+ gas = await this.publicClient.estimateGas({
315
+ account,
346
316
  to: account,
347
317
  data,
348
- gas,
349
- nonce,
350
- maxFeePerGas: feePerGas.maxFeePerGas,
351
- maxPriorityFeePerGas: feePerGas.maxPriorityFeePerGas,
352
- value: BigInt(0),
353
- authorizationList: [authorization],
318
+ stateOverride: [
319
+ {
320
+ address: account,
321
+ code: ('0xef0100' + executor.slice(2)),
322
+ },
323
+ ],
354
324
  });
355
- const txHashBytes = yield signer.signAndSendTransaction((0, viem_1.hexToBytes)(unsignedTx));
356
- return (0, viem_1.bytesToHex)(txHashBytes);
325
+ gas = (gas * BigInt(120)) / BigInt(100); // headroom for delegation + auth
326
+ }
327
+ catch {
328
+ // Estimation unavailable (e.g. node rejects state overrides). Scale the
329
+ // ceiling with the batch size so large batches don't OOG — the legacy
330
+ // per-call loop budgeted ~500k gas per call; mirror that plus overhead.
331
+ gas = BigInt(500_000) * BigInt(calls.length) + BigInt(100_000);
332
+ }
333
+ const unsignedTx = (0, viem_1.serializeTransaction)({
334
+ chainId,
335
+ type: 'eip7702',
336
+ to: account,
337
+ data,
338
+ gas,
339
+ nonce,
340
+ maxFeePerGas: feePerGas.maxFeePerGas,
341
+ maxPriorityFeePerGas: feePerGas.maxPriorityFeePerGas,
342
+ value: BigInt(0),
343
+ authorizationList: [authorization],
357
344
  });
345
+ const txHashBytes = await signer.signAndSendTransaction((0, viem_1.hexToBytes)(unsignedTx));
346
+ return (0, viem_1.bytesToHex)(txHashBytes);
358
347
  }
359
348
  /**
360
349
  * Estimates the gas required for a transaction.
@@ -386,14 +375,12 @@ class EvmClient {
386
375
  * value: BigInt(0),
387
376
  * });
388
377
  */
389
- estimateGas(_a) {
390
- return tslib_1.__awaiter(this, arguments, void 0, function* ({ from, to, value, data, }) {
391
- return this.publicClient.estimateGas({
392
- account: from || undefined,
393
- to,
394
- value,
395
- data,
396
- });
378
+ async estimateGas({ from, to, value, data, }) {
379
+ return this.publicClient.estimateGas({
380
+ account: from || undefined,
381
+ to,
382
+ value,
383
+ data,
397
384
  });
398
385
  }
399
386
  /**
@@ -415,10 +402,8 @@ class EvmClient {
415
402
  * const totalCost = gasPrice * gasEstimate;
416
403
  * console.log(`Estimated transaction cost: ${totalCost} wei`);
417
404
  */
418
- getGasPrice() {
419
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
420
- return this.publicClient.getGasPrice();
421
- });
405
+ async getGasPrice() {
406
+ return this.publicClient.getGasPrice();
422
407
  }
423
408
  /**
424
409
  * Fetches the full transaction response by hash.
@@ -430,20 +415,21 @@ class EvmClient {
430
415
  * const tx = await evmClient.getTransaction('0xabc...');
431
416
  * console.log(tx?.from, tx?.to, tx?.value);
432
417
  */
433
- getTransaction(txHash) {
434
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
435
- const tx = yield this.publicClient.getTransaction({ hash: txHash });
436
- if (!tx)
437
- throw new Error('No transaction found!');
438
- const wait = (...args_1) => tslib_1.__awaiter(this, [...args_1], void 0, function* (confirmations = 1) {
439
- const receipt = yield this.publicClient.waitForTransactionReceipt({
440
- hash: txHash,
441
- confirmations,
442
- });
443
- return receipt;
418
+ async getTransaction(txHash) {
419
+ const tx = await this.publicClient.getTransaction({ hash: txHash });
420
+ if (!tx)
421
+ throw new Error('No transaction found!');
422
+ const wait = async (confirmations = 1) => {
423
+ const receipt = await this.publicClient.waitForTransactionReceipt({
424
+ hash: txHash,
425
+ confirmations,
444
426
  });
445
- return Object.assign(Object.assign({}, tx), { wait });
446
- });
427
+ return receipt;
428
+ };
429
+ return {
430
+ ...tx,
431
+ wait,
432
+ };
447
433
  }
448
434
  /**
449
435
  * Waits for a transaction to achieve the desired number of confirmations.
@@ -453,26 +439,24 @@ class EvmClient {
453
439
  * @param pollIntervalMs - How often to check (default: 1000 ms)
454
440
  * @param timeoutMs - Maximum time to wait before error (default: 60000 ms)
455
441
  */
456
- waitForConfirmations(_a) {
457
- return tslib_1.__awaiter(this, arguments, void 0, function* ({ txHash, confirmations = 3, pollIntervalMs = 1000, timeoutMs = 30000, }) {
458
- const receipt = yield this.publicClient.waitForTransactionReceipt({
459
- hash: txHash,
460
- });
461
- const targetBlock = receipt.blockNumber + BigInt(confirmations);
462
- const startTime = Date.now();
463
- // eslint-disable-next-line no-constant-condition
464
- while (true) {
465
- const currentBlock = yield this.publicClient.getBlockNumber();
466
- if (currentBlock >= targetBlock) {
467
- return;
468
- }
469
- if (Date.now() - startTime > timeoutMs) {
470
- throw new Error(`Timeout: transaction ${txHash} not confirmed with ${confirmations} confirmations ` +
471
- `within ${timeoutMs} ms`);
472
- }
473
- yield new Promise((r) => setTimeout(r, pollIntervalMs));
474
- }
442
+ async waitForConfirmations({ txHash, confirmations = 3, pollIntervalMs = 1000, timeoutMs = 30000, }) {
443
+ const receipt = await this.publicClient.waitForTransactionReceipt({
444
+ hash: txHash,
475
445
  });
446
+ const targetBlock = receipt.blockNumber + BigInt(confirmations);
447
+ const startTime = Date.now();
448
+ // eslint-disable-next-line no-constant-condition
449
+ while (true) {
450
+ const currentBlock = await this.publicClient.getBlockNumber();
451
+ if (currentBlock >= targetBlock) {
452
+ return;
453
+ }
454
+ if (Date.now() - startTime > timeoutMs) {
455
+ throw new Error(`Timeout: transaction ${txHash} not confirmed with ${confirmations} confirmations ` +
456
+ `within ${timeoutMs} ms`);
457
+ }
458
+ await new Promise((r) => setTimeout(r, pollIntervalMs));
459
+ }
476
460
  }
477
461
  }
478
462
  exports.EvmClient = EvmClient;
@@ -26,7 +26,7 @@ export declare class SvmClient {
26
26
  /**
27
27
  * Sends a Solana transaction using a smart contract instruction.
28
28
  */
29
- writeContract({ abi, signer, functionName, args, accounts, extraSigners, }: WriteContractParams): Promise<string>;
29
+ writeContract({ abi, signer, functionName, args, accounts, extraSigners, remainingAccounts, }: WriteContractParams): Promise<string>;
30
30
  /**
31
31
  * Sends a set of instructions as a manually-signed Solana transaction.
32
32
  */