viem 0.0.1-alpha.23 → 0.0.1-alpha.25

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 (155) hide show
  1. package/contract/package.json +4 -0
  2. package/dist/call-ac509982.d.ts +23 -0
  3. package/dist/{chain-aa4898d0.d.ts → chain-c4ccb458.d.ts} +1 -1
  4. package/dist/{chain-4b39613a.d.ts → chain-f16512e8.d.ts} +20 -1
  5. package/dist/chains.d.ts +20 -8
  6. package/dist/chains.js +46 -46
  7. package/dist/chains.mjs +1 -1
  8. package/dist/{chunk-RJLUZTJS.mjs → chunk-2Y3UZMSP.mjs} +203 -84
  9. package/dist/chunk-2Y3UZMSP.mjs.map +1 -0
  10. package/dist/{chunk-ZKYGWITF.js → chunk-CD2XJOBJ.js} +261 -142
  11. package/dist/chunk-CD2XJOBJ.js.map +1 -0
  12. package/dist/{chunk-XBUH66KN.mjs → chunk-KSAO4Y4Q.mjs} +133 -54
  13. package/dist/chunk-KSAO4Y4Q.mjs.map +1 -0
  14. package/dist/{chunk-TXHOG6KU.mjs → chunk-LEPQJNVO.mjs} +18 -2
  15. package/dist/chunk-LEPQJNVO.mjs.map +1 -0
  16. package/dist/{chunk-7Y5QVLX7.js → chunk-NUXMGPMK.js} +30 -14
  17. package/dist/chunk-NUXMGPMK.js.map +1 -0
  18. package/dist/{chunk-SSPRUPGN.js → chunk-THMRUG4D.js} +148 -69
  19. package/dist/chunk-THMRUG4D.js.map +1 -0
  20. package/dist/{contract-4c3a37b3.d.ts → contract-9e76e561.d.ts} +44 -31
  21. package/dist/contract.d.ts +123 -0
  22. package/dist/contract.js +53 -0
  23. package/dist/{clients/index.js.map → contract.js.map} +0 -0
  24. package/dist/contract.mjs +53 -0
  25. package/dist/{clients/index.mjs.map → contract.mjs.map} +0 -0
  26. package/dist/{createClient-55a04188.d.ts → createClient-68ee4bb4.d.ts} +3 -3
  27. package/dist/{createPublicClient-3b27b282.d.ts → createPublicClient-b732194e.d.ts} +3 -3
  28. package/dist/{createTestClient-93f9eac6.d.ts → createTestClient-dedf321e.d.ts} +3 -3
  29. package/dist/{createWalletClient-c10df94d.d.ts → createWalletClient-75813d83.d.ts} +3 -3
  30. package/dist/decodeErrorResult-0b934d23.d.ts +16 -0
  31. package/dist/{eip1193-4c24765a.d.ts → eip1193-6f9ba163.d.ts} +1 -1
  32. package/dist/ens.d.ts +82 -1
  33. package/dist/ens.js +208 -3
  34. package/dist/ens.js.map +1 -1
  35. package/dist/ens.mjs +209 -4
  36. package/dist/ens.mjs.map +1 -1
  37. package/dist/getAbiItem-c8e6e7d4.d.ts +97 -0
  38. package/dist/index.d.ts +85 -133
  39. package/dist/index.js +237 -275
  40. package/dist/index.js.map +1 -1
  41. package/dist/index.mjs +245 -283
  42. package/dist/index.mjs.map +1 -1
  43. package/dist/public.d.ts +352 -10
  44. package/dist/public.js +3 -4
  45. package/dist/public.mjs +6 -7
  46. package/dist/readContract-4f6e2692.d.ts +10 -0
  47. package/dist/rpc-a5a7f376.d.ts +121 -0
  48. package/dist/{sendTransaction-f17a2389.d.ts → sendTransaction-e713f90c.d.ts} +3 -3
  49. package/dist/test.d.ts +160 -5
  50. package/dist/test.js +222 -18
  51. package/dist/test.js.map +1 -1
  52. package/dist/test.mjs +233 -29
  53. package/dist/test.mjs.map +1 -1
  54. package/dist/transactionReceipt-2a86c7c7.d.ts +26 -0
  55. package/dist/{transactionRequest-93e9f001.d.ts → transactionRequest-c7794f5e.d.ts} +1 -1
  56. package/dist/utils/index.d.ts +224 -20
  57. package/dist/utils/index.js +2 -6
  58. package/dist/utils/index.mjs +3 -7
  59. package/dist/wallet.d.ts +41 -7
  60. package/dist/wallet.js +3 -3
  61. package/dist/wallet.mjs +2 -2
  62. package/dist/watchEvent-c346c12d.d.ts +41 -0
  63. package/dist/window.d.ts +2 -2
  64. package/ens/package.json +4 -0
  65. package/package.json +13 -9
  66. package/src/_test/constants.ts +2 -0
  67. package/src/_test/utils.ts +10 -5
  68. package/src/actions/ens/getEnsAddress.bench.ts +26 -0
  69. package/src/actions/ens/getEnsAddress.test.ts +97 -0
  70. package/src/actions/ens/getEnsAddress.ts +122 -0
  71. package/src/actions/ens/getEnsName.bench.ts +30 -0
  72. package/src/actions/ens/getEnsName.test.ts +101 -0
  73. package/src/actions/ens/getEnsName.ts +106 -0
  74. package/src/actions/ens/index.test.ts +12 -0
  75. package/src/actions/ens/index.ts +3 -0
  76. package/src/actions/index.test.ts +2 -0
  77. package/src/actions/index.ts +9 -3
  78. package/src/actions/public/createEventFilter.test.ts +36 -4
  79. package/src/actions/public/createEventFilter.ts +27 -10
  80. package/src/actions/public/getFilterChanges.test.ts +198 -4
  81. package/src/actions/public/getFilterLogs.test.ts +195 -2
  82. package/src/actions/public/getLogs.test.ts +201 -2
  83. package/src/actions/public/index.test.ts +0 -1
  84. package/src/actions/public/index.ts +1 -7
  85. package/src/actions/public/multicall.ts +8 -3
  86. package/src/actions/public/simulateContract.ts +1 -4
  87. package/src/actions/public/watchContractEvent.test.ts +4 -4
  88. package/src/actions/{public → wallet}/deployContract.test.ts +1 -2
  89. package/src/actions/{public → wallet}/deployContract.ts +0 -0
  90. package/src/actions/wallet/index.test.ts +1 -0
  91. package/src/actions/wallet/index.ts +6 -0
  92. package/src/chains.test.ts +44 -1517
  93. package/src/clients/transports/webSocket.test.ts +1 -0
  94. package/src/clients/transports/webSocket.ts +1 -0
  95. package/src/contract.test.ts +31 -0
  96. package/src/contract.ts +68 -0
  97. package/src/ens.test.ts +15 -0
  98. package/src/ens.ts +4 -1
  99. package/src/errors/abi.ts +18 -2
  100. package/src/errors/chain.test.ts +46 -0
  101. package/src/errors/chain.ts +33 -0
  102. package/src/errors/contract.ts +2 -2
  103. package/src/errors/index.ts +3 -0
  104. package/src/index.test.ts +0 -145
  105. package/src/index.ts +0 -251
  106. package/src/public.test.ts +36 -0
  107. package/src/public.ts +2 -6
  108. package/src/test.test.ts +38 -0
  109. package/src/test.ts +1 -0
  110. package/src/types/contract.ts +144 -40
  111. package/src/types/index.ts +2 -1
  112. package/src/types/utils.ts +21 -0
  113. package/src/utils/abi/decodeErrorResult.test.ts +1 -1
  114. package/src/utils/abi/decodeEventLog.test.ts +542 -0
  115. package/src/utils/abi/decodeEventLog.ts +107 -0
  116. package/src/utils/abi/decodeFunctionData.test.ts +1 -2
  117. package/src/utils/abi/decodeFunctionData.ts +5 -2
  118. package/src/utils/abi/encodeFunctionData.ts +1 -4
  119. package/src/utils/abi/index.test.ts +1 -0
  120. package/src/utils/abi/index.ts +6 -0
  121. package/src/utils/ens/index.test.ts +1 -0
  122. package/src/utils/ens/index.ts +2 -0
  123. package/src/utils/ens/packetToBytes.test.ts +11 -0
  124. package/src/utils/ens/packetToBytes.ts +29 -0
  125. package/src/utils/index.test.ts +1 -3
  126. package/src/utils/index.ts +3 -2
  127. package/src/utils/rpc.test.ts +1 -0
  128. package/src/utils/rpc.ts +4 -2
  129. package/src/wallet.test.ts +19 -0
  130. package/wallet/package.json +4 -0
  131. package/clients/package.json +0 -4
  132. package/dist/chunk-7Y5QVLX7.js.map +0 -1
  133. package/dist/chunk-BV5NTHUX.js +0 -260
  134. package/dist/chunk-BV5NTHUX.js.map +0 -1
  135. package/dist/chunk-EGVXCZNJ.mjs +0 -260
  136. package/dist/chunk-EGVXCZNJ.mjs.map +0 -1
  137. package/dist/chunk-GX2KDAM3.mjs +0 -256
  138. package/dist/chunk-GX2KDAM3.mjs.map +0 -1
  139. package/dist/chunk-NW6724MI.js +0 -256
  140. package/dist/chunk-NW6724MI.js.map +0 -1
  141. package/dist/chunk-RJLUZTJS.mjs.map +0 -1
  142. package/dist/chunk-SSPRUPGN.js.map +0 -1
  143. package/dist/chunk-TXHOG6KU.mjs.map +0 -1
  144. package/dist/chunk-XBUH66KN.mjs.map +0 -1
  145. package/dist/chunk-ZKYGWITF.js.map +0 -1
  146. package/dist/clients/index.d.ts +0 -9
  147. package/dist/clients/index.js +0 -24
  148. package/dist/clients/index.mjs +0 -24
  149. package/dist/normalize-ef9240c0.d.ts +0 -33
  150. package/dist/parseGwei-3411cf2d.d.ts +0 -355
  151. package/dist/rpc-26932bae.d.ts +0 -61
  152. package/dist/stopImpersonatingAccount-afb26486.d.ts +0 -156
  153. package/dist/watchAsset-efd3dd05.d.ts +0 -38
  154. package/dist/watchPendingTransactions-57df1a13.d.ts +0 -373
  155. package/dist/webSocket-d2e7bd0e.d.ts +0 -83
@@ -1,6 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); async function _asyncNullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return await rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunk7Y5QVLX7js = require('./chunk-7Y5QVLX7.js');
4
3
 
5
4
 
6
5
 
@@ -27,9 +26,7 @@ var _chunk7Y5QVLX7js = require('./chunk-7Y5QVLX7.js');
27
26
 
28
27
 
29
28
 
30
-
31
-
32
- var _chunkSSPRUPGNjs = require('./chunk-SSPRUPGN.js');
29
+ var _chunkTHMRUG4Djs = require('./chunk-THMRUG4D.js');
33
30
 
34
31
  // src/actions/public/call.ts
35
32
  async function call(client, {
@@ -49,10 +46,10 @@ async function call(client, {
49
46
  ...rest
50
47
  }) {
51
48
  if (maxFeePerGas !== void 0 && maxPriorityFeePerGas !== void 0 && maxFeePerGas < maxPriorityFeePerGas)
52
- throw new (0, _chunkSSPRUPGNjs.InvalidGasArgumentsError)();
53
- const blockNumberHex = blockNumber ? _chunkSSPRUPGNjs.numberToHex.call(void 0, blockNumber) : void 0;
49
+ throw new (0, _chunkTHMRUG4Djs.InvalidGasArgumentsError)();
50
+ const blockNumberHex = blockNumber ? _chunkTHMRUG4Djs.numberToHex.call(void 0, blockNumber) : void 0;
54
51
  const formatter = _optionalChain([chain, 'optionalAccess', _ => _.formatters, 'optionalAccess', _2 => _2.transactionRequest]);
55
- const request_ = _chunkSSPRUPGNjs.format.call(void 0,
52
+ const request_ = _chunkTHMRUG4Djs.format.call(void 0,
56
53
  {
57
54
  from,
58
55
  accessList,
@@ -64,10 +61,11 @@ async function call(client, {
64
61
  nonce,
65
62
  to,
66
63
  value,
67
- ..._chunkSSPRUPGNjs.extract.call(void 0, rest, { formatter })
64
+ // Pick out extra data that might exist on the chain's transaction request type.
65
+ ..._chunkTHMRUG4Djs.extract.call(void 0, rest, { formatter })
68
66
  },
69
67
  {
70
- formatter: formatter || _chunkSSPRUPGNjs.formatTransactionRequest
68
+ formatter: formatter || _chunkTHMRUG4Djs.formatTransactionRequest
71
69
  }
72
70
  );
73
71
  const response = await client.request({
@@ -87,7 +85,7 @@ async function simulateContract(client, {
87
85
  functionName,
88
86
  ...callRequest
89
87
  }) {
90
- const calldata = _chunkSSPRUPGNjs.encodeFunctionData.call(void 0, {
88
+ const calldata = _chunkTHMRUG4Djs.encodeFunctionData.call(void 0, {
91
89
  abi,
92
90
  args,
93
91
  functionName
@@ -98,7 +96,7 @@ async function simulateContract(client, {
98
96
  to: address,
99
97
  ...callRequest
100
98
  });
101
- const result = _chunkSSPRUPGNjs.decodeFunctionResult.call(void 0, {
99
+ const result = _chunkTHMRUG4Djs.decodeFunctionResult.call(void 0, {
102
100
  abi,
103
101
  args,
104
102
  functionName,
@@ -115,7 +113,7 @@ async function simulateContract(client, {
115
113
  }
116
114
  };
117
115
  } catch (err) {
118
- throw _chunkSSPRUPGNjs.getContractError.call(void 0, err, {
116
+ throw _chunkTHMRUG4Djs.getContractError.call(void 0, err, {
119
117
  abi,
120
118
  address,
121
119
  args,
@@ -142,80 +140,6 @@ async function createBlockFilter(client) {
142
140
  return { id, type: "block" };
143
141
  }
144
142
 
145
- // src/actions/public/createEventFilter.ts
146
- async function createEventFilter(client, {
147
- address,
148
- event,
149
- args,
150
- fromBlock,
151
- toBlock
152
- } = {}) {
153
- let topics = [];
154
- if (event) {
155
- topics = buildFilterTopics({ event, args });
156
- }
157
- const id = await client.request({
158
- method: "eth_newFilter",
159
- params: [
160
- {
161
- address,
162
- fromBlock: typeof fromBlock === "bigint" ? _chunkSSPRUPGNjs.numberToHex.call(void 0, fromBlock) : fromBlock,
163
- toBlock: typeof toBlock === "bigint" ? _chunkSSPRUPGNjs.numberToHex.call(void 0, toBlock) : toBlock,
164
- ...topics.length ? { topics } : {}
165
- }
166
- ]
167
- });
168
- return { id, type: "event" };
169
- }
170
- function buildFilterTopics({
171
- event,
172
- args: _args
173
- }) {
174
- const signature = _chunkSSPRUPGNjs.getEventSignature.call(void 0, event);
175
- return [signature];
176
- }
177
-
178
- // src/actions/public/createContractEventFilter.ts
179
- async function createContractEventFilter(client, {
180
- address,
181
- abi,
182
- args,
183
- eventName,
184
- fromBlock,
185
- toBlock
186
- }) {
187
- const topics = eventName ? _chunkSSPRUPGNjs.encodeEventTopics.call(void 0, {
188
- abi,
189
- args,
190
- eventName
191
- }) : void 0;
192
- const id = await client.request({
193
- method: "eth_newFilter",
194
- params: [
195
- {
196
- address,
197
- fromBlock: typeof fromBlock === "bigint" ? _chunkSSPRUPGNjs.numberToHex.call(void 0, fromBlock) : fromBlock,
198
- toBlock: typeof toBlock === "bigint" ? _chunkSSPRUPGNjs.numberToHex.call(void 0, toBlock) : toBlock,
199
- topics
200
- }
201
- ]
202
- });
203
- return { id, type: "event" };
204
- }
205
-
206
- // src/actions/public/deployContract.ts
207
- function deployContract(walletClient, { abi, args, bytecode, ...request }) {
208
- const calldata = _chunkSSPRUPGNjs.encodeDeployData.call(void 0, {
209
- abi,
210
- args,
211
- bytecode
212
- });
213
- return _chunk7Y5QVLX7js.sendTransaction.call(void 0, walletClient, {
214
- ...request,
215
- data: calldata
216
- });
217
- }
218
-
219
143
  // src/actions/public/estimateGas.ts
220
144
  async function estimateGas(client, {
221
145
  blockNumber,
@@ -229,16 +153,16 @@ async function estimateGas(client, {
229
153
  to,
230
154
  value
231
155
  }) {
232
- const blockNumberHex = blockNumber ? _chunkSSPRUPGNjs.numberToHex.call(void 0, blockNumber) : void 0;
156
+ const blockNumberHex = blockNumber ? _chunkTHMRUG4Djs.numberToHex.call(void 0, blockNumber) : void 0;
233
157
  const parameters = {
234
158
  data,
235
159
  from,
236
- gas: gas ? _chunkSSPRUPGNjs.numberToHex.call(void 0, gas) : void 0,
237
- gasPrice: gasPrice ? _chunkSSPRUPGNjs.numberToHex.call(void 0, gasPrice) : void 0,
238
- maxFeePerGas: maxFeePerGas ? _chunkSSPRUPGNjs.numberToHex.call(void 0, maxFeePerGas) : void 0,
239
- maxPriorityFeePerGas: maxPriorityFeePerGas ? _chunkSSPRUPGNjs.numberToHex.call(void 0, maxPriorityFeePerGas) : void 0,
160
+ gas: gas ? _chunkTHMRUG4Djs.numberToHex.call(void 0, gas) : void 0,
161
+ gasPrice: gasPrice ? _chunkTHMRUG4Djs.numberToHex.call(void 0, gasPrice) : void 0,
162
+ maxFeePerGas: maxFeePerGas ? _chunkTHMRUG4Djs.numberToHex.call(void 0, maxFeePerGas) : void 0,
163
+ maxPriorityFeePerGas: maxPriorityFeePerGas ? _chunkTHMRUG4Djs.numberToHex.call(void 0, maxPriorityFeePerGas) : void 0,
240
164
  to,
241
- value: value ? _chunkSSPRUPGNjs.numberToHex.call(void 0, value) : void 0
165
+ value: value ? _chunkTHMRUG4Djs.numberToHex.call(void 0, value) : void 0
242
166
  };
243
167
  const balance = await client.request({
244
168
  method: "eth_estimateGas",
@@ -249,7 +173,7 @@ async function estimateGas(client, {
249
173
 
250
174
  // src/actions/public/getBalance.ts
251
175
  async function getBalance(client, { address, blockNumber, blockTag = "latest" }) {
252
- const blockNumberHex = blockNumber ? _chunkSSPRUPGNjs.numberToHex.call(void 0, blockNumber) : void 0;
176
+ const blockNumberHex = blockNumber ? _chunkTHMRUG4Djs.numberToHex.call(void 0, blockNumber) : void 0;
253
177
  const balance = await client.request({
254
178
  method: "eth_getBalance",
255
179
  params: [address, blockNumberHex || blockTag]
@@ -264,7 +188,7 @@ async function getBlock(client, {
264
188
  blockTag = "latest",
265
189
  includeTransactions = false
266
190
  } = {}) {
267
- const blockNumberHex = blockNumber !== void 0 ? _chunkSSPRUPGNjs.numberToHex.call(void 0, blockNumber) : void 0;
191
+ const blockNumberHex = blockNumber !== void 0 ? _chunkTHMRUG4Djs.numberToHex.call(void 0, blockNumber) : void 0;
268
192
  let block = null;
269
193
  if (blockHash) {
270
194
  block = await client.request({
@@ -278,19 +202,19 @@ async function getBlock(client, {
278
202
  });
279
203
  }
280
204
  if (!block)
281
- throw new (0, _chunkSSPRUPGNjs.BlockNotFoundError)({ blockHash, blockNumber });
282
- return _chunkSSPRUPGNjs.format.call(void 0, block, {
283
- formatter: _optionalChain([client, 'access', _3 => _3.chain, 'optionalAccess', _4 => _4.formatters, 'optionalAccess', _5 => _5.block]) || _chunkSSPRUPGNjs.formatBlock
205
+ throw new (0, _chunkTHMRUG4Djs.BlockNotFoundError)({ blockHash, blockNumber });
206
+ return _chunkTHMRUG4Djs.format.call(void 0, block, {
207
+ formatter: _optionalChain([client, 'access', _3 => _3.chain, 'optionalAccess', _4 => _4.formatters, 'optionalAccess', _5 => _5.block]) || _chunkTHMRUG4Djs.formatBlock
284
208
  });
285
209
  }
286
210
 
287
211
  // src/actions/public/getBlockNumber.ts
288
212
  var cacheKey = (id) => `blockNumber.${id}`;
289
213
  function getBlockNumberCache(id) {
290
- return _chunkSSPRUPGNjs.getCache.call(void 0, cacheKey(id));
214
+ return _chunkTHMRUG4Djs.getCache.call(void 0, cacheKey(id));
291
215
  }
292
216
  async function getBlockNumber(client, { maxAge = client.pollingInterval } = {}) {
293
- const blockNumberHex = await _chunkSSPRUPGNjs.withCache.call(void 0,
217
+ const blockNumberHex = await _chunkTHMRUG4Djs.withCache.call(void 0,
294
218
  () => client.request({
295
219
  method: "eth_blockNumber"
296
220
  }),
@@ -305,7 +229,7 @@ async function getBlockTransactionCount(client, {
305
229
  blockNumber,
306
230
  blockTag = "latest"
307
231
  } = {}) {
308
- const blockNumberHex = blockNumber !== void 0 ? _chunkSSPRUPGNjs.numberToHex.call(void 0, blockNumber) : void 0;
232
+ const blockNumberHex = blockNumber !== void 0 ? _chunkTHMRUG4Djs.numberToHex.call(void 0, blockNumber) : void 0;
309
233
  let count = null;
310
234
  if (blockHash) {
311
235
  count = await client.request({
@@ -318,12 +242,12 @@ async function getBlockTransactionCount(client, {
318
242
  params: [blockNumberHex || blockTag]
319
243
  });
320
244
  }
321
- return _chunkSSPRUPGNjs.hexToNumber.call(void 0, count);
245
+ return _chunkTHMRUG4Djs.hexToNumber.call(void 0, count);
322
246
  }
323
247
 
324
248
  // src/actions/public/getBytecode.ts
325
249
  async function getBytecode(client, { address, blockNumber, blockTag = "latest" }) {
326
- const blockNumberHex = blockNumber !== void 0 ? _chunkSSPRUPGNjs.numberToHex.call(void 0, blockNumber) : void 0;
250
+ const blockNumberHex = blockNumber !== void 0 ? _chunkTHMRUG4Djs.numberToHex.call(void 0, blockNumber) : void 0;
327
251
  const hex = await client.request({
328
252
  method: "eth_getCode",
329
253
  params: [address, blockNumberHex || blockTag]
@@ -336,7 +260,7 @@ async function getBytecode(client, { address, blockNumber, blockTag = "latest" }
336
260
  // src/actions/public/getChainId.ts
337
261
  async function getChainId(client) {
338
262
  const chainIdHex = await client.request({ method: "eth_chainId" });
339
- return _chunkSSPRUPGNjs.hexToNumber.call(void 0, chainIdHex);
263
+ return _chunkTHMRUG4Djs.hexToNumber.call(void 0, chainIdHex);
340
264
  }
341
265
 
342
266
  // src/actions/public/getFeeHistory.ts
@@ -346,16 +270,16 @@ async function getFeeHistory(client, {
346
270
  blockTag = "latest",
347
271
  rewardPercentiles
348
272
  }) {
349
- const blockNumberHex = blockNumber ? _chunkSSPRUPGNjs.numberToHex.call(void 0, blockNumber) : void 0;
273
+ const blockNumberHex = blockNumber ? _chunkTHMRUG4Djs.numberToHex.call(void 0, blockNumber) : void 0;
350
274
  const feeHistory = await client.request({
351
275
  method: "eth_feeHistory",
352
276
  params: [
353
- _chunkSSPRUPGNjs.numberToHex.call(void 0, blockCount),
277
+ _chunkTHMRUG4Djs.numberToHex.call(void 0, blockCount),
354
278
  blockNumberHex || blockTag,
355
279
  rewardPercentiles
356
280
  ]
357
281
  });
358
- return _chunkSSPRUPGNjs.formatFeeHistory.call(void 0, feeHistory);
282
+ return _chunkTHMRUG4Djs.formatFeeHistory.call(void 0, feeHistory);
359
283
  }
360
284
 
361
285
  // src/actions/public/getFilterChanges.ts
@@ -365,7 +289,7 @@ async function getFilterChanges(client, { filter }) {
365
289
  params: [filter.id]
366
290
  });
367
291
  return logs.map(
368
- (log) => typeof log === "string" ? log : _chunkSSPRUPGNjs.formatLog.call(void 0, log)
292
+ (log) => typeof log === "string" ? log : _chunkTHMRUG4Djs.formatLog.call(void 0, log)
369
293
  );
370
294
  }
371
295
 
@@ -375,7 +299,7 @@ async function getFilterLogs(client, { filter }) {
375
299
  method: "eth_getFilterLogs",
376
300
  params: [filter.id]
377
301
  });
378
- return logs.map(_chunkSSPRUPGNjs.formatLog);
302
+ return logs.map(_chunkTHMRUG4Djs.formatLog);
379
303
  }
380
304
 
381
305
  // src/actions/public/getGasPrice.ts
@@ -386,6 +310,50 @@ async function getGasPrice(client) {
386
310
  return BigInt(gasPrice);
387
311
  }
388
312
 
313
+ // src/actions/public/createEventFilter.ts
314
+ async function createEventFilter(client, {
315
+ address,
316
+ event,
317
+ args,
318
+ fromBlock,
319
+ toBlock
320
+ } = {}) {
321
+ let topics = [];
322
+ if (event)
323
+ topics = buildFilterTopics({ event, args });
324
+ const id = await client.request({
325
+ method: "eth_newFilter",
326
+ params: [
327
+ {
328
+ address,
329
+ fromBlock: typeof fromBlock === "bigint" ? _chunkTHMRUG4Djs.numberToHex.call(void 0, fromBlock) : fromBlock,
330
+ toBlock: typeof toBlock === "bigint" ? _chunkTHMRUG4Djs.numberToHex.call(void 0, toBlock) : toBlock,
331
+ ...topics.length ? { topics } : {}
332
+ }
333
+ ]
334
+ });
335
+ return { id, type: "event" };
336
+ }
337
+ function buildFilterTopics({
338
+ event,
339
+ args
340
+ }) {
341
+ const eventName = _chunkTHMRUG4Djs.extractFunctionName.call(void 0, event);
342
+ const abi = unstable_parseAbi(event);
343
+ return _chunkTHMRUG4Djs.encodeEventTopics.call(void 0, { abi, eventName, args });
344
+ }
345
+ function unstable_parseAbi(definition) {
346
+ const name = _chunkTHMRUG4Djs.extractFunctionName.call(void 0, definition);
347
+ const params = _chunkTHMRUG4Djs.extractFunctionParams.call(void 0, definition);
348
+ return [
349
+ {
350
+ type: "event",
351
+ name,
352
+ inputs: params || []
353
+ }
354
+ ];
355
+ }
356
+
389
357
  // src/actions/public/getLogs.ts
390
358
  async function getLogs(client, {
391
359
  address,
@@ -412,18 +380,18 @@ async function getLogs(client, {
412
380
  {
413
381
  address,
414
382
  topics,
415
- fromBlock: typeof fromBlock === "bigint" ? _chunkSSPRUPGNjs.numberToHex.call(void 0, fromBlock) : fromBlock,
416
- toBlock: typeof toBlock === "bigint" ? _chunkSSPRUPGNjs.numberToHex.call(void 0, toBlock) : toBlock
383
+ fromBlock: typeof fromBlock === "bigint" ? _chunkTHMRUG4Djs.numberToHex.call(void 0, fromBlock) : fromBlock,
384
+ toBlock: typeof toBlock === "bigint" ? _chunkTHMRUG4Djs.numberToHex.call(void 0, toBlock) : toBlock
417
385
  }
418
386
  ]
419
387
  });
420
388
  }
421
- return logs.map(_chunkSSPRUPGNjs.formatLog);
389
+ return logs.map(_chunkTHMRUG4Djs.formatLog);
422
390
  }
423
391
 
424
392
  // src/actions/public/getStorageAt.ts
425
393
  async function getStorageAt(client, { address, blockNumber, blockTag = "latest", slot }) {
426
- const blockNumberHex = blockNumber !== void 0 ? _chunkSSPRUPGNjs.numberToHex.call(void 0, blockNumber) : void 0;
394
+ const blockNumberHex = blockNumber !== void 0 ? _chunkTHMRUG4Djs.numberToHex.call(void 0, blockNumber) : void 0;
427
395
  const data = await client.request({
428
396
  method: "eth_getStorageAt",
429
397
  params: [address, slot, blockNumberHex || blockTag]
@@ -439,7 +407,7 @@ async function getTransaction(client, {
439
407
  hash,
440
408
  index
441
409
  }) {
442
- const blockNumberHex = blockNumber !== void 0 ? _chunkSSPRUPGNjs.numberToHex.call(void 0, blockNumber) : void 0;
410
+ const blockNumberHex = blockNumber !== void 0 ? _chunkTHMRUG4Djs.numberToHex.call(void 0, blockNumber) : void 0;
443
411
  let transaction = null;
444
412
  if (hash) {
445
413
  transaction = await client.request({
@@ -449,24 +417,24 @@ async function getTransaction(client, {
449
417
  } else if (blockHash) {
450
418
  transaction = await client.request({
451
419
  method: "eth_getTransactionByBlockHashAndIndex",
452
- params: [blockHash, _chunkSSPRUPGNjs.numberToHex.call(void 0, index)]
420
+ params: [blockHash, _chunkTHMRUG4Djs.numberToHex.call(void 0, index)]
453
421
  });
454
422
  } else if (blockNumberHex || blockTag) {
455
423
  transaction = await client.request({
456
424
  method: "eth_getTransactionByBlockNumberAndIndex",
457
- params: [blockNumberHex || blockTag, _chunkSSPRUPGNjs.numberToHex.call(void 0, index)]
425
+ params: [blockNumberHex || blockTag, _chunkTHMRUG4Djs.numberToHex.call(void 0, index)]
458
426
  });
459
427
  }
460
428
  if (!transaction)
461
- throw new (0, _chunkSSPRUPGNjs.TransactionNotFoundError)({
429
+ throw new (0, _chunkTHMRUG4Djs.TransactionNotFoundError)({
462
430
  blockHash,
463
431
  blockNumber,
464
432
  blockTag,
465
433
  hash,
466
434
  index
467
435
  });
468
- return _chunkSSPRUPGNjs.format.call(void 0, transaction, {
469
- formatter: _optionalChain([client, 'access', _6 => _6.chain, 'optionalAccess', _7 => _7.formatters, 'optionalAccess', _8 => _8.transaction]) || _chunkSSPRUPGNjs.formatTransaction
436
+ return _chunkTHMRUG4Djs.format.call(void 0, transaction, {
437
+ formatter: _optionalChain([client, 'access', _6 => _6.chain, 'optionalAccess', _7 => _7.formatters, 'optionalAccess', _8 => _8.transaction]) || _chunkTHMRUG4Djs.formatTransaction
470
438
  });
471
439
  }
472
440
 
@@ -486,9 +454,9 @@ async function getTransactionConfirmations(client, { hash, transactionReceipt })
486
454
  async function getTransactionCount(client, { address, blockTag = "latest", blockNumber }) {
487
455
  const count = await client.request({
488
456
  method: "eth_getTransactionCount",
489
- params: [address, blockNumber ? _chunkSSPRUPGNjs.numberToHex.call(void 0, blockNumber) : blockTag]
457
+ params: [address, blockNumber ? _chunkTHMRUG4Djs.numberToHex.call(void 0, blockNumber) : blockTag]
490
458
  });
491
- return _chunkSSPRUPGNjs.hexToNumber.call(void 0, count);
459
+ return _chunkTHMRUG4Djs.hexToNumber.call(void 0, count);
492
460
  }
493
461
 
494
462
  // src/actions/public/getTransactionReceipt.ts
@@ -498,9 +466,9 @@ async function getTransactionReceipt(client, { hash }) {
498
466
  params: [hash]
499
467
  });
500
468
  if (!receipt)
501
- throw new (0, _chunkSSPRUPGNjs.TransactionReceiptNotFoundError)({ hash });
502
- return _chunkSSPRUPGNjs.format.call(void 0, receipt, {
503
- formatter: _optionalChain([client, 'access', _11 => _11.chain, 'optionalAccess', _12 => _12.formatters, 'optionalAccess', _13 => _13.transactionReceipt]) || _chunkSSPRUPGNjs.formatTransactionReceipt
469
+ throw new (0, _chunkTHMRUG4Djs.TransactionReceiptNotFoundError)({ hash });
470
+ return _chunkTHMRUG4Djs.format.call(void 0, receipt, {
471
+ formatter: _optionalChain([client, 'access', _11 => _11.chain, 'optionalAccess', _12 => _12.formatters, 'optionalAccess', _13 => _13.transactionReceipt]) || _chunkTHMRUG4Djs.formatTransactionReceipt
504
472
  });
505
473
  }
506
474
 
@@ -512,7 +480,7 @@ async function readContract(client, {
512
480
  functionName,
513
481
  ...callRequest
514
482
  }) {
515
- const calldata = _chunkSSPRUPGNjs.encodeFunctionData.call(void 0, {
483
+ const calldata = _chunkTHMRUG4Djs.encodeFunctionData.call(void 0, {
516
484
  abi,
517
485
  args,
518
486
  functionName
@@ -523,14 +491,14 @@ async function readContract(client, {
523
491
  to: address,
524
492
  ...callRequest
525
493
  });
526
- return _chunkSSPRUPGNjs.decodeFunctionResult.call(void 0, {
494
+ return _chunkTHMRUG4Djs.decodeFunctionResult.call(void 0, {
527
495
  abi,
528
496
  args,
529
497
  functionName,
530
498
  data: data || "0x"
531
499
  });
532
500
  } catch (err) {
533
- throw _chunkSSPRUPGNjs.getContractError.call(void 0, err, {
501
+ throw _chunkTHMRUG4Djs.getContractError.call(void 0, err, {
534
502
  abi,
535
503
  address,
536
504
  args,
@@ -551,7 +519,7 @@ async function multicall(client, args) {
551
519
  } = args;
552
520
  const calls = contracts.map(({ abi, address, args: args2, functionName }) => {
553
521
  try {
554
- const callData = _chunkSSPRUPGNjs.encodeFunctionData.call(void 0, {
522
+ const callData = _chunkTHMRUG4Djs.encodeFunctionData.call(void 0, {
555
523
  abi,
556
524
  args: args2,
557
525
  functionName
@@ -562,7 +530,7 @@ async function multicall(client, args) {
562
530
  target: address
563
531
  };
564
532
  } catch (err) {
565
- const error = _chunkSSPRUPGNjs.getContractError.call(void 0, err, {
533
+ const error = _chunkTHMRUG4Djs.getContractError.call(void 0, err, {
566
534
  abi,
567
535
  address,
568
536
  args: args2,
@@ -579,7 +547,7 @@ async function multicall(client, args) {
579
547
  }
580
548
  });
581
549
  const results = await readContract(client, {
582
- abi: _chunkSSPRUPGNjs.multicall3Abi,
550
+ abi: _chunkTHMRUG4Djs.multicall3Abi,
583
551
  address: multicallAddress,
584
552
  args: [calls],
585
553
  blockNumber,
@@ -591,17 +559,17 @@ async function multicall(client, args) {
591
559
  const { abi, address, functionName, args: args2 } = contracts[i];
592
560
  try {
593
561
  if (callData === "0x")
594
- throw new (0, _chunkSSPRUPGNjs.AbiDecodingZeroDataError)();
562
+ throw new (0, _chunkTHMRUG4Djs.AbiDecodingZeroDataError)();
595
563
  if (!success)
596
- throw new (0, _chunkSSPRUPGNjs.RawContractError)({ data: returnData });
597
- const result = _chunkSSPRUPGNjs.decodeFunctionResult.call(void 0, {
564
+ throw new (0, _chunkTHMRUG4Djs.RawContractError)({ data: returnData });
565
+ const result = _chunkTHMRUG4Djs.decodeFunctionResult.call(void 0, {
598
566
  abi,
599
567
  data: returnData,
600
568
  functionName
601
569
  });
602
570
  return { result, status: "success" };
603
571
  } catch (err) {
604
- const error = _chunkSSPRUPGNjs.getContractError.call(void 0, err, {
572
+ const error = _chunkTHMRUG4Djs.getContractError.call(void 0, err, {
605
573
  abi,
606
574
  address,
607
575
  args: args2,
@@ -665,6 +633,34 @@ function observe(observerId, callbacks, fn) {
665
633
  return unwatch;
666
634
  }
667
635
 
636
+ // src/actions/public/createContractEventFilter.ts
637
+ async function createContractEventFilter(client, {
638
+ address,
639
+ abi,
640
+ args,
641
+ eventName,
642
+ fromBlock,
643
+ toBlock
644
+ }) {
645
+ const topics = eventName ? _chunkTHMRUG4Djs.encodeEventTopics.call(void 0, {
646
+ abi,
647
+ args,
648
+ eventName
649
+ }) : void 0;
650
+ const id = await client.request({
651
+ method: "eth_newFilter",
652
+ params: [
653
+ {
654
+ address,
655
+ fromBlock: typeof fromBlock === "bigint" ? _chunkTHMRUG4Djs.numberToHex.call(void 0, fromBlock) : fromBlock,
656
+ toBlock: typeof toBlock === "bigint" ? _chunkTHMRUG4Djs.numberToHex.call(void 0, toBlock) : toBlock,
657
+ topics
658
+ }
659
+ ]
660
+ });
661
+ return { id, type: "event" };
662
+ }
663
+
668
664
  // src/utils/poll.ts
669
665
  function poll(fn, { emitOnBegin, initialWaitTime, interval }) {
670
666
  let active = true;
@@ -674,12 +670,12 @@ function poll(fn, { emitOnBegin, initialWaitTime, interval }) {
674
670
  if (emitOnBegin)
675
671
  data = await fn({ unpoll: unwatch });
676
672
  const initialWait = await _asyncNullishCoalesce(await _optionalChain([initialWaitTime, 'optionalCall', _17 => _17(data)]), async () => ( interval));
677
- await _chunkSSPRUPGNjs.wait.call(void 0, initialWait);
673
+ await _chunkTHMRUG4Djs.wait.call(void 0, initialWait);
678
674
  const poll2 = async () => {
679
675
  if (!active)
680
676
  return;
681
677
  await fn({ unpoll: unwatch });
682
- await _chunkSSPRUPGNjs.wait.call(void 0, interval);
678
+ await _chunkTHMRUG4Djs.wait.call(void 0, interval);
683
679
  poll2();
684
680
  };
685
681
  poll2();
@@ -792,6 +788,130 @@ function watchBlocks(client, {
792
788
  );
793
789
  }
794
790
 
791
+ // src/actions/public/watchContractEvent.ts
792
+ function watchContractEvent(client, {
793
+ abi,
794
+ address,
795
+ args,
796
+ batch = true,
797
+ eventName,
798
+ onError,
799
+ onLogs,
800
+ pollingInterval = client.pollingInterval
801
+ }) {
802
+ const observerId = JSON.stringify([
803
+ "watchContractEvent",
804
+ address,
805
+ args,
806
+ batch,
807
+ client.uid,
808
+ eventName,
809
+ pollingInterval
810
+ ]);
811
+ return observe(observerId, { onLogs, onError }, (emit) => {
812
+ let filter;
813
+ const unwatch = poll(
814
+ async () => {
815
+ try {
816
+ if (!filter) {
817
+ try {
818
+ filter = await createContractEventFilter(client, {
819
+ abi,
820
+ address,
821
+ args,
822
+ eventName
823
+ });
824
+ return;
825
+ } catch (err) {
826
+ unwatch();
827
+ throw err;
828
+ }
829
+ }
830
+ const logs = await getFilterChanges(client, { filter });
831
+ if (logs.length === 0)
832
+ return;
833
+ if (batch)
834
+ emit.onLogs(logs);
835
+ else
836
+ logs.forEach((log) => emit.onLogs([log]));
837
+ } catch (err) {
838
+ _optionalChain([emit, 'access', _24 => _24.onError, 'optionalCall', _25 => _25(err)]);
839
+ }
840
+ },
841
+ {
842
+ emitOnBegin: true,
843
+ interval: pollingInterval
844
+ }
845
+ );
846
+ return async () => {
847
+ if (filter)
848
+ await uninstallFilter(client, { filter });
849
+ unwatch();
850
+ };
851
+ });
852
+ }
853
+
854
+ // src/actions/public/watchEvent.ts
855
+ function watchEvent(client, {
856
+ address,
857
+ args,
858
+ batch = true,
859
+ event,
860
+ onError,
861
+ onLogs,
862
+ pollingInterval = client.pollingInterval
863
+ }) {
864
+ const observerId = JSON.stringify([
865
+ "watchEvent",
866
+ address,
867
+ args,
868
+ batch,
869
+ client.uid,
870
+ event,
871
+ pollingInterval
872
+ ]);
873
+ return observe(observerId, { onLogs, onError }, (emit) => {
874
+ let filter;
875
+ const unwatch = poll(
876
+ async () => {
877
+ try {
878
+ if (!filter) {
879
+ try {
880
+ filter = await createEventFilter(client, {
881
+ address,
882
+ args,
883
+ event
884
+ });
885
+ return;
886
+ } catch (err) {
887
+ unwatch();
888
+ throw err;
889
+ }
890
+ }
891
+ const logs = await getFilterChanges(client, { filter });
892
+ if (logs.length === 0)
893
+ return;
894
+ if (batch)
895
+ emit.onLogs(logs);
896
+ else
897
+ logs.forEach((log) => emit.onLogs([log]));
898
+ } catch (err) {
899
+ _optionalChain([emit, 'access', _26 => _26.onError, 'optionalCall', _27 => _27(err)]);
900
+ }
901
+ },
902
+ {
903
+ emitOnBegin: true,
904
+ interval: pollingInterval
905
+ }
906
+ );
907
+ return async () => {
908
+ if (filter)
909
+ await uninstallFilter(client, { filter });
910
+ unwatch();
911
+ };
912
+ });
913
+ }
914
+
795
915
  // src/actions/public/watchPendingTransactions.ts
796
916
  function watchPendingTransactions(client, {
797
917
  batch = true,
@@ -827,7 +947,7 @@ function watchPendingTransactions(client, {
827
947
  else
828
948
  hashes.forEach((hash) => emit.onTransactions([hash]));
829
949
  } catch (err) {
830
- _optionalChain([emit, 'access', _24 => _24.onError, 'optionalCall', _25 => _25(err)]);
950
+ _optionalChain([emit, 'access', _28 => _28.onError, 'optionalCall', _29 => _29(err)]);
831
951
  }
832
952
  },
833
953
  {
@@ -862,7 +982,7 @@ async function waitForTransactionReceipt(client, {
862
982
  return new Promise((resolve, reject) => {
863
983
  if (timeout)
864
984
  setTimeout(
865
- () => reject(new (0, _chunkSSPRUPGNjs.WaitForTransactionReceiptTimeoutError)({ hash })),
985
+ () => reject(new (0, _chunkTHMRUG4Djs.WaitForTransactionReceiptTimeoutError)({ hash })),
866
986
  timeout
867
987
  );
868
988
  const unobserve = observe(
@@ -892,7 +1012,7 @@ async function waitForTransactionReceipt(client, {
892
1012
  return;
893
1013
  done(() => emit.resolve(receipt));
894
1014
  } catch (err) {
895
- if (transaction && (err instanceof _chunkSSPRUPGNjs.TransactionNotFoundError || err instanceof _chunkSSPRUPGNjs.TransactionReceiptNotFoundError)) {
1015
+ if (transaction && (err instanceof _chunkTHMRUG4Djs.TransactionNotFoundError || err instanceof _chunkTHMRUG4Djs.TransactionReceiptNotFoundError)) {
896
1016
  replacedTransaction = transaction;
897
1017
  const block = await getBlock(client, {
898
1018
  blockNumber,
@@ -915,7 +1035,7 @@ async function waitForTransactionReceipt(client, {
915
1035
  reason = "cancelled";
916
1036
  }
917
1037
  done(() => {
918
- _optionalChain([emit, 'access', _26 => _26.onReplaced, 'optionalCall', _27 => _27({
1038
+ _optionalChain([emit, 'access', _30 => _30.onReplaced, 'optionalCall', _31 => _31({
919
1039
  reason,
920
1040
  replacedTransaction,
921
1041
  transaction: replacementTransaction,
@@ -967,6 +1087,5 @@ async function waitForTransactionReceipt(client, {
967
1087
 
968
1088
 
969
1089
 
970
-
971
- exports.call = call; exports.simulateContract = simulateContract; exports.createPendingTransactionFilter = createPendingTransactionFilter; exports.createBlockFilter = createBlockFilter; exports.createEventFilter = createEventFilter; exports.createContractEventFilter = createContractEventFilter; exports.deployContract = deployContract; exports.estimateGas = estimateGas; 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.watchPendingTransactions = watchPendingTransactions;
972
- //# sourceMappingURL=chunk-ZKYGWITF.js.map
1090
+ exports.call = call; exports.simulateContract = simulateContract; exports.createPendingTransactionFilter = createPendingTransactionFilter; exports.createBlockFilter = createBlockFilter; exports.estimateGas = estimateGas; 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;
1091
+ //# sourceMappingURL=chunk-CD2XJOBJ.js.map