viem 0.0.1-alpha.27 → 0.0.1-alpha.29

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 (81) hide show
  1. package/dist/chain-4d46a747.d.ts +543 -0
  2. package/dist/{chain-b0cfb141.d.ts → chain-c7c44165.d.ts} +1 -1
  3. package/dist/chains.d.ts +5 -3
  4. package/dist/chains.js +46 -46
  5. package/dist/chains.mjs +1 -1
  6. package/dist/{chunk-JY7JGKSA.js → chunk-4VQKZYE2.js} +219 -157
  7. package/dist/chunk-4VQKZYE2.js.map +1 -0
  8. package/dist/{chunk-2DSFM32P.js → chunk-CKYH337I.js} +15 -15
  9. package/dist/{chunk-2DSFM32P.js.map → chunk-CKYH337I.js.map} +1 -1
  10. package/dist/{chunk-W7KWIGWO.js → chunk-EYORBAD4.js} +45 -44
  11. package/dist/chunk-EYORBAD4.js.map +1 -0
  12. package/dist/{chunk-LF6P33WQ.mjs → chunk-HPUQL3IM.mjs} +3 -3
  13. package/dist/chunk-HPUQL3IM.mjs.map +1 -0
  14. package/dist/chunk-OJ7H3CQF.js +265 -0
  15. package/dist/chunk-OJ7H3CQF.js.map +1 -0
  16. package/dist/chunk-Q67VUTW3.mjs +210 -0
  17. package/dist/chunk-Q67VUTW3.mjs.map +1 -0
  18. package/dist/{chunk-AKGXRZDN.mjs → chunk-RR4MGS6O.mjs} +27 -26
  19. package/dist/chunk-RR4MGS6O.mjs.map +1 -0
  20. package/dist/chunk-S252SZEL.mjs +265 -0
  21. package/dist/chunk-S252SZEL.mjs.map +1 -0
  22. package/dist/chunk-SEIPUKZE.js +210 -0
  23. package/dist/chunk-SEIPUKZE.js.map +1 -0
  24. package/dist/{chunk-BJJH7RYH.mjs → chunk-TQC7KZ24.mjs} +164 -102
  25. package/dist/chunk-TQC7KZ24.mjs.map +1 -0
  26. package/dist/contract.d.ts +12 -128
  27. package/dist/contract.js +6 -4
  28. package/dist/contract.mjs +5 -3
  29. package/dist/{createClient-6689596e.d.ts → createClient-5d5c14d6.d.ts} +5 -3
  30. package/dist/createPublicClient-2b4afeac.d.ts +629 -0
  31. package/dist/{eip1193-617a05ae.d.ts → eip1193-f09a55af.d.ts} +2 -2
  32. package/dist/ens.d.ts +10 -68
  33. package/dist/ens.js +5 -199
  34. package/dist/ens.js.map +1 -1
  35. package/dist/ens.mjs +7 -201
  36. package/dist/ens.mjs.map +1 -1
  37. package/dist/formatAbiItem-d231fef2.d.ts +14 -0
  38. package/dist/{getAbiItem-d2e8bd76.d.ts → getAbiItem-0e085959.d.ts} +15 -15
  39. package/dist/index.d.ts +22 -13
  40. package/dist/index.js +368 -26
  41. package/dist/index.js.map +1 -1
  42. package/dist/index.mjs +358 -16
  43. package/dist/index.mjs.map +1 -1
  44. package/dist/namehash-88f4639d.d.ts +22 -0
  45. package/dist/parseGwei-4d0b0d73.d.ts +344 -0
  46. package/dist/public.d.ts +11 -334
  47. package/dist/public.js +5 -3
  48. package/dist/public.mjs +4 -2
  49. package/dist/test-b9208949.d.ts +213 -0
  50. package/dist/test.d.ts +8 -149
  51. package/dist/test.js +20 -222
  52. package/dist/test.js.map +1 -1
  53. package/dist/test.mjs +30 -232
  54. package/dist/test.mjs.map +1 -1
  55. package/dist/{transactionReceipt-44dbf122.d.ts → transactionReceipt-84fc92e1.d.ts} +1 -1
  56. package/dist/{transactionRequest-f437b4ba.d.ts → transactionRequest-44c539b4.d.ts} +1 -1
  57. package/dist/utils/index.d.ts +12 -238
  58. package/dist/utils/index.js +2 -2
  59. package/dist/utils/index.mjs +1 -1
  60. package/dist/wallet-9b1c6905.d.ts +104 -0
  61. package/dist/wallet.d.ts +7 -41
  62. package/dist/wallet.js +3 -3
  63. package/dist/wallet.mjs +2 -2
  64. package/dist/window.d.ts +4 -2
  65. package/package.json +1 -1
  66. package/dist/call-3476b8ee.d.ts +0 -22
  67. package/dist/chain-42de87e5.d.ts +0 -359
  68. package/dist/chunk-AKGXRZDN.mjs.map +0 -1
  69. package/dist/chunk-BJJH7RYH.mjs.map +0 -1
  70. package/dist/chunk-JY7JGKSA.js.map +0 -1
  71. package/dist/chunk-LF6P33WQ.mjs.map +0 -1
  72. package/dist/chunk-W7KWIGWO.js.map +0 -1
  73. package/dist/contract-9dd2f98b.d.ts +0 -166
  74. package/dist/createPublicClient-fd558574.d.ts +0 -19
  75. package/dist/createTestClient-bc1d9028.d.ts +0 -34
  76. package/dist/createWalletClient-4df88244.d.ts +0 -30
  77. package/dist/decodeErrorResult-ac835649.d.ts +0 -16
  78. package/dist/readContract-c460f23a.d.ts +0 -10
  79. package/dist/rpc-8c10fc98.d.ts +0 -119
  80. package/dist/sendTransaction-7ce442c0.d.ts +0 -12
  81. package/dist/watchEvent-569c9976.d.ts +0 -41
@@ -26,7 +26,7 @@
26
26
 
27
27
 
28
28
 
29
- var _chunkW7KWIGWOjs = require('./chunk-W7KWIGWO.js');
29
+ var _chunkEYORBAD4js = require('./chunk-EYORBAD4.js');
30
30
 
31
31
  // src/actions/public/call.ts
32
32
  async function call(client, {
@@ -45,10 +45,10 @@ async function call(client, {
45
45
  ...rest
46
46
  }) {
47
47
  if (maxFeePerGas !== void 0 && maxPriorityFeePerGas !== void 0 && maxFeePerGas < maxPriorityFeePerGas)
48
- throw new (0, _chunkW7KWIGWOjs.InvalidGasArgumentsError)();
49
- const blockNumberHex = blockNumber ? _chunkW7KWIGWOjs.numberToHex.call(void 0, blockNumber) : void 0;
48
+ throw new (0, _chunkEYORBAD4js.InvalidGasArgumentsError)();
49
+ const blockNumberHex = blockNumber ? _chunkEYORBAD4js.numberToHex.call(void 0, blockNumber) : void 0;
50
50
  const formatter = _optionalChain([client, 'access', _ => _.chain, 'optionalAccess', _2 => _2.formatters, 'optionalAccess', _3 => _3.transactionRequest]);
51
- const request_ = _chunkW7KWIGWOjs.format.call(void 0,
51
+ const request_ = _chunkEYORBAD4js.format.call(void 0,
52
52
  {
53
53
  from,
54
54
  accessList,
@@ -61,10 +61,10 @@ async function call(client, {
61
61
  to,
62
62
  value,
63
63
  // Pick out extra data that might exist on the chain's transaction request type.
64
- ..._chunkW7KWIGWOjs.extract.call(void 0, rest, { formatter })
64
+ ..._chunkEYORBAD4js.extract.call(void 0, rest, { formatter })
65
65
  },
66
66
  {
67
- formatter: formatter || _chunkW7KWIGWOjs.formatTransactionRequest
67
+ formatter: formatter || _chunkEYORBAD4js.formatTransactionRequest
68
68
  }
69
69
  );
70
70
  const response = await client.request({
@@ -84,7 +84,7 @@ async function simulateContract(client, {
84
84
  functionName,
85
85
  ...callRequest
86
86
  }) {
87
- const calldata = _chunkW7KWIGWOjs.encodeFunctionData.call(void 0, {
87
+ const calldata = _chunkEYORBAD4js.encodeFunctionData.call(void 0, {
88
88
  abi,
89
89
  args,
90
90
  functionName
@@ -95,7 +95,7 @@ async function simulateContract(client, {
95
95
  to: address,
96
96
  ...callRequest
97
97
  });
98
- const result = _chunkW7KWIGWOjs.decodeFunctionResult.call(void 0, {
98
+ const result = _chunkEYORBAD4js.decodeFunctionResult.call(void 0, {
99
99
  abi,
100
100
  args,
101
101
  functionName,
@@ -112,7 +112,7 @@ async function simulateContract(client, {
112
112
  }
113
113
  };
114
114
  } catch (err) {
115
- throw _chunkW7KWIGWOjs.getContractError.call(void 0, err, {
115
+ throw _chunkEYORBAD4js.getContractError.call(void 0, err, {
116
116
  abi,
117
117
  address,
118
118
  args,
@@ -139,6 +139,75 @@ async function createBlockFilter(client) {
139
139
  return { id, type: "block" };
140
140
  }
141
141
 
142
+ // src/actions/public/createEventFilter.ts
143
+ async function createEventFilter(client, {
144
+ address,
145
+ args,
146
+ event,
147
+ fromBlock,
148
+ toBlock
149
+ } = {}) {
150
+ let topics = [];
151
+ if (event)
152
+ topics = _chunkEYORBAD4js.encodeEventTopics.call(void 0, {
153
+ abi: [event],
154
+ eventName: event.name,
155
+ args
156
+ });
157
+ const id = await client.request({
158
+ method: "eth_newFilter",
159
+ params: [
160
+ {
161
+ address,
162
+ fromBlock: typeof fromBlock === "bigint" ? _chunkEYORBAD4js.numberToHex.call(void 0, fromBlock) : fromBlock,
163
+ toBlock: typeof toBlock === "bigint" ? _chunkEYORBAD4js.numberToHex.call(void 0, toBlock) : toBlock,
164
+ ...topics.length ? { topics } : {}
165
+ }
166
+ ]
167
+ });
168
+ return {
169
+ abi: event ? [event] : void 0,
170
+ args,
171
+ eventName: event ? event.name : void 0,
172
+ id,
173
+ type: "event"
174
+ };
175
+ }
176
+
177
+ // src/actions/public/createContractEventFilter.ts
178
+ async function createContractEventFilter(client, {
179
+ address,
180
+ abi,
181
+ args,
182
+ eventName,
183
+ fromBlock,
184
+ toBlock
185
+ }) {
186
+ const topics = eventName ? _chunkEYORBAD4js.encodeEventTopics.call(void 0, {
187
+ abi,
188
+ args,
189
+ eventName
190
+ }) : void 0;
191
+ const id = await client.request({
192
+ method: "eth_newFilter",
193
+ params: [
194
+ {
195
+ address,
196
+ fromBlock: typeof fromBlock === "bigint" ? _chunkEYORBAD4js.numberToHex.call(void 0, fromBlock) : fromBlock,
197
+ toBlock: typeof toBlock === "bigint" ? _chunkEYORBAD4js.numberToHex.call(void 0, toBlock) : toBlock,
198
+ topics
199
+ }
200
+ ]
201
+ });
202
+ return {
203
+ abi,
204
+ args,
205
+ eventName,
206
+ id,
207
+ type: "event"
208
+ };
209
+ }
210
+
142
211
  // src/actions/public/estimateGas.ts
143
212
  async function estimateGas(client, {
144
213
  accessList,
@@ -155,9 +224,9 @@ async function estimateGas(client, {
155
224
  value,
156
225
  ...rest
157
226
  }) {
158
- const blockNumberHex = blockNumber ? _chunkW7KWIGWOjs.numberToHex.call(void 0, blockNumber) : void 0;
227
+ const blockNumberHex = blockNumber ? _chunkEYORBAD4js.numberToHex.call(void 0, blockNumber) : void 0;
159
228
  const formatter = _optionalChain([client, 'access', _4 => _4.chain, 'optionalAccess', _5 => _5.formatters, 'optionalAccess', _6 => _6.transactionRequest]);
160
- const request_ = _chunkW7KWIGWOjs.format.call(void 0,
229
+ const request_ = _chunkEYORBAD4js.format.call(void 0,
161
230
  {
162
231
  from,
163
232
  accessList,
@@ -170,10 +239,10 @@ async function estimateGas(client, {
170
239
  to,
171
240
  value,
172
241
  // Pick out extra data that might exist on the chain's transaction request type.
173
- ..._chunkW7KWIGWOjs.extract.call(void 0, rest, { formatter })
242
+ ..._chunkEYORBAD4js.extract.call(void 0, rest, { formatter })
174
243
  },
175
244
  {
176
- formatter: formatter || _chunkW7KWIGWOjs.formatTransactionRequest
245
+ formatter: formatter || _chunkEYORBAD4js.formatTransactionRequest
177
246
  }
178
247
  );
179
248
  const balance = await client.request({
@@ -191,7 +260,7 @@ async function estimateContractGas(client, {
191
260
  functionName,
192
261
  ...request
193
262
  }) {
194
- const data = _chunkW7KWIGWOjs.encodeFunctionData.call(void 0, {
263
+ const data = _chunkEYORBAD4js.encodeFunctionData.call(void 0, {
195
264
  abi,
196
265
  args,
197
266
  functionName
@@ -204,7 +273,7 @@ async function estimateContractGas(client, {
204
273
  });
205
274
  return gas;
206
275
  } catch (err) {
207
- throw _chunkW7KWIGWOjs.getContractError.call(void 0, err, {
276
+ throw _chunkEYORBAD4js.getContractError.call(void 0, err, {
208
277
  abi,
209
278
  address,
210
279
  args,
@@ -217,7 +286,7 @@ async function estimateContractGas(client, {
217
286
 
218
287
  // src/actions/public/getBalance.ts
219
288
  async function getBalance(client, { address, blockNumber, blockTag = "latest" }) {
220
- const blockNumberHex = blockNumber ? _chunkW7KWIGWOjs.numberToHex.call(void 0, blockNumber) : void 0;
289
+ const blockNumberHex = blockNumber ? _chunkEYORBAD4js.numberToHex.call(void 0, blockNumber) : void 0;
221
290
  const balance = await client.request({
222
291
  method: "eth_getBalance",
223
292
  params: [address, blockNumberHex || blockTag]
@@ -232,7 +301,7 @@ async function getBlock(client, {
232
301
  blockTag = "latest",
233
302
  includeTransactions = false
234
303
  } = {}) {
235
- const blockNumberHex = blockNumber !== void 0 ? _chunkW7KWIGWOjs.numberToHex.call(void 0, blockNumber) : void 0;
304
+ const blockNumberHex = blockNumber !== void 0 ? _chunkEYORBAD4js.numberToHex.call(void 0, blockNumber) : void 0;
236
305
  let block = null;
237
306
  if (blockHash) {
238
307
  block = await client.request({
@@ -246,19 +315,19 @@ async function getBlock(client, {
246
315
  });
247
316
  }
248
317
  if (!block)
249
- throw new (0, _chunkW7KWIGWOjs.BlockNotFoundError)({ blockHash, blockNumber });
250
- return _chunkW7KWIGWOjs.format.call(void 0, block, {
251
- formatter: _optionalChain([client, 'access', _7 => _7.chain, 'optionalAccess', _8 => _8.formatters, 'optionalAccess', _9 => _9.block]) || _chunkW7KWIGWOjs.formatBlock
318
+ throw new (0, _chunkEYORBAD4js.BlockNotFoundError)({ blockHash, blockNumber });
319
+ return _chunkEYORBAD4js.format.call(void 0, block, {
320
+ formatter: _optionalChain([client, 'access', _7 => _7.chain, 'optionalAccess', _8 => _8.formatters, 'optionalAccess', _9 => _9.block]) || _chunkEYORBAD4js.formatBlock
252
321
  });
253
322
  }
254
323
 
255
324
  // src/actions/public/getBlockNumber.ts
256
325
  var cacheKey = (id) => `blockNumber.${id}`;
257
326
  function getBlockNumberCache(id) {
258
- return _chunkW7KWIGWOjs.getCache.call(void 0, cacheKey(id));
327
+ return _chunkEYORBAD4js.getCache.call(void 0, cacheKey(id));
259
328
  }
260
329
  async function getBlockNumber(client, { maxAge = client.pollingInterval } = {}) {
261
- const blockNumberHex = await _chunkW7KWIGWOjs.withCache.call(void 0,
330
+ const blockNumberHex = await _chunkEYORBAD4js.withCache.call(void 0,
262
331
  () => client.request({
263
332
  method: "eth_blockNumber"
264
333
  }),
@@ -273,7 +342,7 @@ async function getBlockTransactionCount(client, {
273
342
  blockNumber,
274
343
  blockTag = "latest"
275
344
  } = {}) {
276
- const blockNumberHex = blockNumber !== void 0 ? _chunkW7KWIGWOjs.numberToHex.call(void 0, blockNumber) : void 0;
345
+ const blockNumberHex = blockNumber !== void 0 ? _chunkEYORBAD4js.numberToHex.call(void 0, blockNumber) : void 0;
277
346
  let count = null;
278
347
  if (blockHash) {
279
348
  count = await client.request({
@@ -286,12 +355,12 @@ async function getBlockTransactionCount(client, {
286
355
  params: [blockNumberHex || blockTag]
287
356
  });
288
357
  }
289
- return _chunkW7KWIGWOjs.hexToNumber.call(void 0, count);
358
+ return _chunkEYORBAD4js.hexToNumber.call(void 0, count);
290
359
  }
291
360
 
292
361
  // src/actions/public/getBytecode.ts
293
362
  async function getBytecode(client, { address, blockNumber, blockTag = "latest" }) {
294
- const blockNumberHex = blockNumber !== void 0 ? _chunkW7KWIGWOjs.numberToHex.call(void 0, blockNumber) : void 0;
363
+ const blockNumberHex = blockNumber !== void 0 ? _chunkEYORBAD4js.numberToHex.call(void 0, blockNumber) : void 0;
295
364
  const hex = await client.request({
296
365
  method: "eth_getCode",
297
366
  params: [address, blockNumberHex || blockTag]
@@ -304,7 +373,7 @@ async function getBytecode(client, { address, blockNumber, blockTag = "latest" }
304
373
  // src/actions/public/getChainId.ts
305
374
  async function getChainId(client) {
306
375
  const chainIdHex = await client.request({ method: "eth_chainId" });
307
- return _chunkW7KWIGWOjs.hexToNumber.call(void 0, chainIdHex);
376
+ return _chunkEYORBAD4js.hexToNumber.call(void 0, chainIdHex);
308
377
  }
309
378
 
310
379
  // src/actions/public/getFeeHistory.ts
@@ -314,16 +383,16 @@ async function getFeeHistory(client, {
314
383
  blockTag = "latest",
315
384
  rewardPercentiles
316
385
  }) {
317
- const blockNumberHex = blockNumber ? _chunkW7KWIGWOjs.numberToHex.call(void 0, blockNumber) : void 0;
386
+ const blockNumberHex = blockNumber ? _chunkEYORBAD4js.numberToHex.call(void 0, blockNumber) : void 0;
318
387
  const feeHistory = await client.request({
319
388
  method: "eth_feeHistory",
320
389
  params: [
321
- _chunkW7KWIGWOjs.numberToHex.call(void 0, blockCount),
390
+ _chunkEYORBAD4js.numberToHex.call(void 0, blockCount),
322
391
  blockNumberHex || blockTag,
323
392
  rewardPercentiles
324
393
  ]
325
394
  });
326
- return _chunkW7KWIGWOjs.formatFeeHistory.call(void 0, feeHistory);
395
+ return _chunkEYORBAD4js.formatFeeHistory.call(void 0, feeHistory);
327
396
  }
328
397
 
329
398
  // src/actions/public/getFilterChanges.ts
@@ -332,9 +401,16 @@ async function getFilterChanges(client, { filter }) {
332
401
  method: "eth_getFilterChanges",
333
402
  params: [filter.id]
334
403
  });
335
- return logs.map(
336
- (log) => typeof log === "string" ? log : _chunkW7KWIGWOjs.formatLog.call(void 0, log)
337
- );
404
+ return logs.map((log) => {
405
+ if (typeof log === "string")
406
+ return log;
407
+ const { eventName, args } = "abi" in filter && filter.abi ? _chunkEYORBAD4js.decodeEventLog.call(void 0, {
408
+ abi: filter.abi,
409
+ data: log.data,
410
+ topics: log.topics
411
+ }) : { eventName: void 0, args: void 0 };
412
+ return _chunkEYORBAD4js.formatLog.call(void 0, log, { args, eventName });
413
+ });
338
414
  }
339
415
 
340
416
  // src/actions/public/getFilterLogs.ts
@@ -343,7 +419,14 @@ async function getFilterLogs(client, { filter }) {
343
419
  method: "eth_getFilterLogs",
344
420
  params: [filter.id]
345
421
  });
346
- return logs.map(_chunkW7KWIGWOjs.formatLog);
422
+ return logs.map((log) => {
423
+ const { eventName, args } = "abi" in filter && filter.abi ? _chunkEYORBAD4js.decodeEventLog.call(void 0, {
424
+ abi: filter.abi,
425
+ data: log.data,
426
+ topics: log.topics
427
+ }) : { eventName: void 0, args: void 0 };
428
+ return _chunkEYORBAD4js.formatLog.call(void 0, log, { args, eventName });
429
+ });
347
430
  }
348
431
 
349
432
  // src/actions/public/getGasPrice.ts
@@ -354,50 +437,6 @@ async function getGasPrice(client) {
354
437
  return BigInt(gasPrice);
355
438
  }
356
439
 
357
- // src/actions/public/createEventFilter.ts
358
- async function createEventFilter(client, {
359
- address,
360
- event,
361
- args,
362
- fromBlock,
363
- toBlock
364
- } = {}) {
365
- let topics = [];
366
- if (event)
367
- topics = buildFilterTopics({ event, args });
368
- const id = await client.request({
369
- method: "eth_newFilter",
370
- params: [
371
- {
372
- address,
373
- fromBlock: typeof fromBlock === "bigint" ? _chunkW7KWIGWOjs.numberToHex.call(void 0, fromBlock) : fromBlock,
374
- toBlock: typeof toBlock === "bigint" ? _chunkW7KWIGWOjs.numberToHex.call(void 0, toBlock) : toBlock,
375
- ...topics.length ? { topics } : {}
376
- }
377
- ]
378
- });
379
- return { id, type: "event" };
380
- }
381
- function buildFilterTopics({
382
- event,
383
- args
384
- }) {
385
- const eventName = _chunkW7KWIGWOjs.extractFunctionName.call(void 0, event);
386
- const abi = unstable_parseAbi(event);
387
- return _chunkW7KWIGWOjs.encodeEventTopics.call(void 0, { abi, eventName, args });
388
- }
389
- function unstable_parseAbi(definition) {
390
- const name = _chunkW7KWIGWOjs.extractFunctionName.call(void 0, definition);
391
- const params = _chunkW7KWIGWOjs.extractFunctionParams.call(void 0, definition);
392
- return [
393
- {
394
- type: "event",
395
- name,
396
- inputs: params || []
397
- }
398
- ];
399
- }
400
-
401
440
  // src/actions/public/getLogs.ts
402
441
  async function getLogs(client, {
403
442
  address,
@@ -408,9 +447,12 @@ async function getLogs(client, {
408
447
  args
409
448
  } = {}) {
410
449
  let topics = [];
411
- if (event) {
412
- topics = buildFilterTopics({ event, args });
413
- }
450
+ if (event)
451
+ topics = _chunkEYORBAD4js.encodeEventTopics.call(void 0, {
452
+ abi: [event],
453
+ eventName: event.name,
454
+ args
455
+ });
414
456
  let logs;
415
457
  if (blockHash) {
416
458
  logs = await client.request({
@@ -424,18 +466,25 @@ async function getLogs(client, {
424
466
  {
425
467
  address,
426
468
  topics,
427
- fromBlock: typeof fromBlock === "bigint" ? _chunkW7KWIGWOjs.numberToHex.call(void 0, fromBlock) : fromBlock,
428
- toBlock: typeof toBlock === "bigint" ? _chunkW7KWIGWOjs.numberToHex.call(void 0, toBlock) : toBlock
469
+ fromBlock: typeof fromBlock === "bigint" ? _chunkEYORBAD4js.numberToHex.call(void 0, fromBlock) : fromBlock,
470
+ toBlock: typeof toBlock === "bigint" ? _chunkEYORBAD4js.numberToHex.call(void 0, toBlock) : toBlock
429
471
  }
430
472
  ]
431
473
  });
432
474
  }
433
- return logs.map(_chunkW7KWIGWOjs.formatLog);
475
+ return logs.map((log) => {
476
+ const { eventName, args: args2 } = event ? _chunkEYORBAD4js.decodeEventLog.call(void 0, {
477
+ abi: [event],
478
+ data: log.data,
479
+ topics: log.topics
480
+ }) : { eventName: void 0, args: void 0 };
481
+ return _chunkEYORBAD4js.formatLog.call(void 0, log, { args: args2, eventName });
482
+ });
434
483
  }
435
484
 
436
485
  // src/actions/public/getStorageAt.ts
437
486
  async function getStorageAt(client, { address, blockNumber, blockTag = "latest", slot }) {
438
- const blockNumberHex = blockNumber !== void 0 ? _chunkW7KWIGWOjs.numberToHex.call(void 0, blockNumber) : void 0;
487
+ const blockNumberHex = blockNumber !== void 0 ? _chunkEYORBAD4js.numberToHex.call(void 0, blockNumber) : void 0;
439
488
  const data = await client.request({
440
489
  method: "eth_getStorageAt",
441
490
  params: [address, slot, blockNumberHex || blockTag]
@@ -451,7 +500,7 @@ async function getTransaction(client, {
451
500
  hash,
452
501
  index
453
502
  }) {
454
- const blockNumberHex = blockNumber !== void 0 ? _chunkW7KWIGWOjs.numberToHex.call(void 0, blockNumber) : void 0;
503
+ const blockNumberHex = blockNumber !== void 0 ? _chunkEYORBAD4js.numberToHex.call(void 0, blockNumber) : void 0;
455
504
  let transaction = null;
456
505
  if (hash) {
457
506
  transaction = await client.request({
@@ -461,24 +510,24 @@ async function getTransaction(client, {
461
510
  } else if (blockHash) {
462
511
  transaction = await client.request({
463
512
  method: "eth_getTransactionByBlockHashAndIndex",
464
- params: [blockHash, _chunkW7KWIGWOjs.numberToHex.call(void 0, index)]
513
+ params: [blockHash, _chunkEYORBAD4js.numberToHex.call(void 0, index)]
465
514
  });
466
515
  } else if (blockNumberHex || blockTag) {
467
516
  transaction = await client.request({
468
517
  method: "eth_getTransactionByBlockNumberAndIndex",
469
- params: [blockNumberHex || blockTag, _chunkW7KWIGWOjs.numberToHex.call(void 0, index)]
518
+ params: [blockNumberHex || blockTag, _chunkEYORBAD4js.numberToHex.call(void 0, index)]
470
519
  });
471
520
  }
472
521
  if (!transaction)
473
- throw new (0, _chunkW7KWIGWOjs.TransactionNotFoundError)({
522
+ throw new (0, _chunkEYORBAD4js.TransactionNotFoundError)({
474
523
  blockHash,
475
524
  blockNumber,
476
525
  blockTag,
477
526
  hash,
478
527
  index
479
528
  });
480
- return _chunkW7KWIGWOjs.format.call(void 0, transaction, {
481
- formatter: _optionalChain([client, 'access', _10 => _10.chain, 'optionalAccess', _11 => _11.formatters, 'optionalAccess', _12 => _12.transaction]) || _chunkW7KWIGWOjs.formatTransaction
529
+ return _chunkEYORBAD4js.format.call(void 0, transaction, {
530
+ formatter: _optionalChain([client, 'access', _10 => _10.chain, 'optionalAccess', _11 => _11.formatters, 'optionalAccess', _12 => _12.transaction]) || _chunkEYORBAD4js.formatTransaction
482
531
  });
483
532
  }
484
533
 
@@ -498,9 +547,9 @@ async function getTransactionConfirmations(client, { hash, transactionReceipt })
498
547
  async function getTransactionCount(client, { address, blockTag = "latest", blockNumber }) {
499
548
  const count = await client.request({
500
549
  method: "eth_getTransactionCount",
501
- params: [address, blockNumber ? _chunkW7KWIGWOjs.numberToHex.call(void 0, blockNumber) : blockTag]
550
+ params: [address, blockNumber ? _chunkEYORBAD4js.numberToHex.call(void 0, blockNumber) : blockTag]
502
551
  });
503
- return _chunkW7KWIGWOjs.hexToNumber.call(void 0, count);
552
+ return _chunkEYORBAD4js.hexToNumber.call(void 0, count);
504
553
  }
505
554
 
506
555
  // src/actions/public/getTransactionReceipt.ts
@@ -510,9 +559,9 @@ async function getTransactionReceipt(client, { hash }) {
510
559
  params: [hash]
511
560
  });
512
561
  if (!receipt)
513
- throw new (0, _chunkW7KWIGWOjs.TransactionReceiptNotFoundError)({ hash });
514
- return _chunkW7KWIGWOjs.format.call(void 0, receipt, {
515
- formatter: _optionalChain([client, 'access', _15 => _15.chain, 'optionalAccess', _16 => _16.formatters, 'optionalAccess', _17 => _17.transactionReceipt]) || _chunkW7KWIGWOjs.formatTransactionReceipt
562
+ throw new (0, _chunkEYORBAD4js.TransactionReceiptNotFoundError)({ hash });
563
+ return _chunkEYORBAD4js.format.call(void 0, receipt, {
564
+ formatter: _optionalChain([client, 'access', _15 => _15.chain, 'optionalAccess', _16 => _16.formatters, 'optionalAccess', _17 => _17.transactionReceipt]) || _chunkEYORBAD4js.formatTransactionReceipt
516
565
  });
517
566
  }
518
567
 
@@ -524,7 +573,7 @@ async function readContract(client, {
524
573
  functionName,
525
574
  ...callRequest
526
575
  }) {
527
- const calldata = _chunkW7KWIGWOjs.encodeFunctionData.call(void 0, {
576
+ const calldata = _chunkEYORBAD4js.encodeFunctionData.call(void 0, {
528
577
  abi,
529
578
  args,
530
579
  functionName
@@ -535,14 +584,14 @@ async function readContract(client, {
535
584
  to: address,
536
585
  ...callRequest
537
586
  });
538
- return _chunkW7KWIGWOjs.decodeFunctionResult.call(void 0, {
587
+ return _chunkEYORBAD4js.decodeFunctionResult.call(void 0, {
539
588
  abi,
540
589
  args,
541
590
  functionName,
542
591
  data: data || "0x"
543
592
  });
544
593
  } catch (err) {
545
- throw _chunkW7KWIGWOjs.getContractError.call(void 0, err, {
594
+ throw _chunkEYORBAD4js.getContractError.call(void 0, err, {
546
595
  abi,
547
596
  address,
548
597
  args,
@@ -563,7 +612,7 @@ async function multicall(client, args) {
563
612
  } = args;
564
613
  const calls = contracts.map(({ abi, address, args: args2, functionName }) => {
565
614
  try {
566
- const callData = _chunkW7KWIGWOjs.encodeFunctionData.call(void 0, {
615
+ const callData = _chunkEYORBAD4js.encodeFunctionData.call(void 0, {
567
616
  abi,
568
617
  args: args2,
569
618
  functionName
@@ -574,7 +623,7 @@ async function multicall(client, args) {
574
623
  target: address
575
624
  };
576
625
  } catch (err) {
577
- const error = _chunkW7KWIGWOjs.getContractError.call(void 0, err, {
626
+ const error = _chunkEYORBAD4js.getContractError.call(void 0, err, {
578
627
  abi,
579
628
  address,
580
629
  args: args2,
@@ -591,7 +640,7 @@ async function multicall(client, args) {
591
640
  }
592
641
  });
593
642
  const results = await readContract(client, {
594
- abi: _chunkW7KWIGWOjs.multicall3Abi,
643
+ abi: _chunkEYORBAD4js.multicall3Abi,
595
644
  address: multicallAddress,
596
645
  args: [calls],
597
646
  blockNumber,
@@ -603,17 +652,17 @@ async function multicall(client, args) {
603
652
  const { abi, address, functionName, args: args2 } = contracts[i];
604
653
  try {
605
654
  if (callData === "0x")
606
- throw new (0, _chunkW7KWIGWOjs.AbiDecodingZeroDataError)();
655
+ throw new (0, _chunkEYORBAD4js.AbiDecodingZeroDataError)();
607
656
  if (!success)
608
- throw new (0, _chunkW7KWIGWOjs.RawContractError)({ data: returnData });
609
- const result = _chunkW7KWIGWOjs.decodeFunctionResult.call(void 0, {
657
+ throw new (0, _chunkEYORBAD4js.RawContractError)({ data: returnData });
658
+ const result = _chunkEYORBAD4js.decodeFunctionResult.call(void 0, {
610
659
  abi,
611
660
  data: returnData,
612
661
  functionName
613
662
  });
614
663
  return { result, status: "success" };
615
664
  } catch (err) {
616
- const error = _chunkW7KWIGWOjs.getContractError.call(void 0, err, {
665
+ const error = _chunkEYORBAD4js.getContractError.call(void 0, err, {
617
666
  abi,
618
667
  address,
619
668
  args: args2,
@@ -677,34 +726,6 @@ function observe(observerId, callbacks, fn) {
677
726
  return unwatch;
678
727
  }
679
728
 
680
- // src/actions/public/createContractEventFilter.ts
681
- async function createContractEventFilter(client, {
682
- address,
683
- abi,
684
- args,
685
- eventName,
686
- fromBlock,
687
- toBlock
688
- }) {
689
- const topics = eventName ? _chunkW7KWIGWOjs.encodeEventTopics.call(void 0, {
690
- abi,
691
- args,
692
- eventName
693
- }) : void 0;
694
- const id = await client.request({
695
- method: "eth_newFilter",
696
- params: [
697
- {
698
- address,
699
- fromBlock: typeof fromBlock === "bigint" ? _chunkW7KWIGWOjs.numberToHex.call(void 0, fromBlock) : fromBlock,
700
- toBlock: typeof toBlock === "bigint" ? _chunkW7KWIGWOjs.numberToHex.call(void 0, toBlock) : toBlock,
701
- topics
702
- }
703
- ]
704
- });
705
- return { id, type: "event" };
706
- }
707
-
708
729
  // src/utils/poll.ts
709
730
  function poll(fn, { emitOnBegin, initialWaitTime, interval }) {
710
731
  let active = true;
@@ -714,12 +735,12 @@ function poll(fn, { emitOnBegin, initialWaitTime, interval }) {
714
735
  if (emitOnBegin)
715
736
  data = await fn({ unpoll: unwatch });
716
737
  const initialWait = await _asyncNullishCoalesce(await _optionalChain([initialWaitTime, 'optionalCall', _21 => _21(data)]), async () => ( interval));
717
- await _chunkW7KWIGWOjs.wait.call(void 0, initialWait);
738
+ await _chunkEYORBAD4js.wait.call(void 0, initialWait);
718
739
  const poll2 = async () => {
719
740
  if (!active)
720
741
  return;
721
742
  await fn({ unpoll: unwatch });
722
- await _chunkW7KWIGWOjs.wait.call(void 0, interval);
743
+ await _chunkEYORBAD4js.wait.call(void 0, interval);
723
744
  poll2();
724
745
  };
725
746
  poll2();
@@ -853,25 +874,46 @@ function watchContractEvent(client, {
853
874
  pollingInterval
854
875
  ]);
855
876
  return observe(observerId, { onLogs, onError }, (emit) => {
877
+ let currentBlockNumber;
856
878
  let filter;
879
+ let initialized = false;
857
880
  const unwatch = poll(
858
881
  async () => {
882
+ if (!initialized) {
883
+ try {
884
+ filter = await createContractEventFilter(client, {
885
+ abi,
886
+ address,
887
+ args,
888
+ eventName
889
+ });
890
+ } catch (e) {
891
+ }
892
+ initialized = true;
893
+ return;
894
+ }
859
895
  try {
860
- if (!filter) {
861
- try {
862
- filter = await createContractEventFilter(client, {
863
- abi,
896
+ let logs;
897
+ if (filter) {
898
+ logs = await getFilterChanges(client, { filter });
899
+ } else {
900
+ const blockNumber = await getBlockNumber(client);
901
+ if (currentBlockNumber && currentBlockNumber !== blockNumber) {
902
+ logs = await getLogs(client, {
864
903
  address,
865
904
  args,
866
- eventName
905
+ fromBlock: blockNumber,
906
+ toBlock: blockNumber,
907
+ event: _chunkEYORBAD4js.getAbiItem.call(void 0, {
908
+ abi,
909
+ name: eventName
910
+ })
867
911
  });
868
- return;
869
- } catch (err) {
870
- unwatch();
871
- throw err;
912
+ } else {
913
+ logs = [];
872
914
  }
915
+ currentBlockNumber = blockNumber;
873
916
  }
874
- const logs = await getFilterChanges(client, { filter });
875
917
  if (logs.length === 0)
876
918
  return;
877
919
  if (batch)
@@ -915,24 +957,42 @@ function watchEvent(client, {
915
957
  pollingInterval
916
958
  ]);
917
959
  return observe(observerId, { onLogs, onError }, (emit) => {
960
+ let currentBlockNumber;
918
961
  let filter;
962
+ let initialized = false;
919
963
  const unwatch = poll(
920
964
  async () => {
965
+ if (!initialized) {
966
+ try {
967
+ filter = await createEventFilter(client, {
968
+ address,
969
+ args,
970
+ event
971
+ });
972
+ } catch (e2) {
973
+ }
974
+ initialized = true;
975
+ return;
976
+ }
921
977
  try {
922
- if (!filter) {
923
- try {
924
- filter = await createEventFilter(client, {
978
+ let logs;
979
+ if (filter) {
980
+ logs = await getFilterChanges(client, { filter });
981
+ } else {
982
+ const blockNumber = await getBlockNumber(client);
983
+ if (currentBlockNumber && currentBlockNumber !== blockNumber) {
984
+ logs = await getLogs(client, {
925
985
  address,
926
986
  args,
987
+ fromBlock: blockNumber,
988
+ toBlock: blockNumber,
927
989
  event
928
990
  });
929
- return;
930
- } catch (err) {
931
- unwatch();
932
- throw err;
991
+ } else {
992
+ logs = [];
933
993
  }
994
+ currentBlockNumber = blockNumber;
934
995
  }
935
- const logs = await getFilterChanges(client, { filter });
936
996
  if (logs.length === 0)
937
997
  return;
938
998
  if (batch)
@@ -1026,7 +1086,7 @@ async function waitForTransactionReceipt(client, {
1026
1086
  return new Promise((resolve, reject) => {
1027
1087
  if (timeout)
1028
1088
  setTimeout(
1029
- () => reject(new (0, _chunkW7KWIGWOjs.WaitForTransactionReceiptTimeoutError)({ hash })),
1089
+ () => reject(new (0, _chunkEYORBAD4js.WaitForTransactionReceiptTimeoutError)({ hash })),
1030
1090
  timeout
1031
1091
  );
1032
1092
  const unobserve = observe(
@@ -1056,7 +1116,7 @@ async function waitForTransactionReceipt(client, {
1056
1116
  return;
1057
1117
  done(() => emit.resolve(receipt));
1058
1118
  } catch (err) {
1059
- if (transaction && (err instanceof _chunkW7KWIGWOjs.TransactionNotFoundError || err instanceof _chunkW7KWIGWOjs.TransactionReceiptNotFoundError)) {
1119
+ if (transaction && (err instanceof _chunkEYORBAD4js.TransactionNotFoundError || err instanceof _chunkEYORBAD4js.TransactionReceiptNotFoundError)) {
1060
1120
  replacedTransaction = transaction;
1061
1121
  const block = await getBlock(client, {
1062
1122
  blockNumber,
@@ -1132,5 +1192,7 @@ async function waitForTransactionReceipt(client, {
1132
1192
 
1133
1193
 
1134
1194
 
1135
- exports.call = call; exports.simulateContract = simulateContract; exports.createPendingTransactionFilter = createPendingTransactionFilter; exports.createBlockFilter = createBlockFilter; exports.estimateGas = estimateGas; exports.estimateContractGas = estimateContractGas; exports.getBalance = getBalance; exports.getBlock = getBlock; exports.getBlockNumberCache = getBlockNumberCache; exports.getBlockNumber = getBlockNumber; exports.getBlockTransactionCount = getBlockTransactionCount; exports.getBytecode = getBytecode; exports.getChainId = getChainId; exports.getFeeHistory = getFeeHistory; exports.getFilterChanges = getFilterChanges; exports.getFilterLogs = getFilterLogs; exports.getGasPrice = getGasPrice; exports.getLogs = getLogs; exports.getStorageAt = getStorageAt; exports.getTransaction = getTransaction; exports.getTransactionConfirmations = getTransactionConfirmations; exports.getTransactionCount = getTransactionCount; exports.getTransactionReceipt = getTransactionReceipt; exports.readContract = readContract; exports.multicall = multicall; exports.uninstallFilter = uninstallFilter; exports.waitForTransactionReceipt = waitForTransactionReceipt; exports.watchBlockNumber = watchBlockNumber; exports.watchBlocks = watchBlocks; exports.watchContractEvent = watchContractEvent; exports.watchEvent = watchEvent; exports.watchPendingTransactions = watchPendingTransactions;
1136
- //# sourceMappingURL=chunk-JY7JGKSA.js.map
1195
+
1196
+
1197
+ exports.call = call; exports.simulateContract = simulateContract; exports.createPendingTransactionFilter = createPendingTransactionFilter; exports.createBlockFilter = createBlockFilter; exports.createEventFilter = createEventFilter; exports.createContractEventFilter = createContractEventFilter; exports.estimateGas = estimateGas; exports.estimateContractGas = estimateContractGas; exports.getBalance = getBalance; exports.getBlock = getBlock; exports.getBlockNumberCache = getBlockNumberCache; exports.getBlockNumber = getBlockNumber; exports.getBlockTransactionCount = getBlockTransactionCount; exports.getBytecode = getBytecode; exports.getChainId = getChainId; exports.getFeeHistory = getFeeHistory; exports.getFilterChanges = getFilterChanges; exports.getFilterLogs = getFilterLogs; exports.getGasPrice = getGasPrice; exports.getLogs = getLogs; exports.getStorageAt = getStorageAt; exports.getTransaction = getTransaction; exports.getTransactionConfirmations = getTransactionConfirmations; exports.getTransactionCount = getTransactionCount; exports.getTransactionReceipt = getTransactionReceipt; exports.readContract = readContract; exports.multicall = multicall; exports.uninstallFilter = uninstallFilter; exports.waitForTransactionReceipt = waitForTransactionReceipt; exports.watchBlockNumber = watchBlockNumber; exports.watchBlocks = watchBlocks; exports.watchContractEvent = watchContractEvent; exports.watchEvent = watchEvent; exports.watchPendingTransactions = watchPendingTransactions;
1198
+ //# sourceMappingURL=chunk-4VQKZYE2.js.map