@latticexyz/entrykit 2.2.22-9f06079cb52cb39888097ea3a293ec71bd46ebbc → 2.2.22-a397ec2827f0b55f9f5b685a660295467d32c0c5

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.
@@ -188,21 +188,168 @@ function userOpExecutor({ executor }) {
188
188
  };
189
189
  }
190
190
 
191
+ // src/quarry/transports/methods/getUserOperationReceipt.ts
192
+ import {
193
+ decodeEventLog,
194
+ encodeEventTopics,
195
+ numberToHex as numberToHex2,
196
+ parseEventLogs as parseEventLogs2,
197
+ zeroAddress
198
+ } from "viem";
199
+ import { entryPoint07Abi as entryPoint07Abi2 } from "viem/account-abstraction";
200
+ var userOperationRevertReasonAbi = [
201
+ entryPoint07Abi2.find(
202
+ (item) => item.type === "event" && item.name === "UserOperationRevertReason"
203
+ )
204
+ ];
205
+ var userOperationEventTopic = encodeEventTopics({
206
+ abi: entryPoint07Abi2,
207
+ eventName: "UserOperationEvent"
208
+ });
209
+ function getUserOperationReceipt(userOpHash, receipt) {
210
+ const userOperationRevertReasonTopicEvent = encodeEventTopics({
211
+ abi: userOperationRevertReasonAbi
212
+ })[0];
213
+ let entryPoint = zeroAddress;
214
+ let revertReason = void 0;
215
+ let startIndex = -1;
216
+ let endIndex = -1;
217
+ receipt.logs.forEach((log, index) => {
218
+ if (log?.topics[0] === userOperationEventTopic[0]) {
219
+ if (log.topics[1] === userOpHash) {
220
+ endIndex = index;
221
+ entryPoint = log.address;
222
+ } else if (endIndex === -1) {
223
+ startIndex = index;
224
+ }
225
+ }
226
+ if (log?.topics[0] === userOperationRevertReasonTopicEvent) {
227
+ if (log.topics[1] === userOpHash) {
228
+ const decodedLog = decodeEventLog({
229
+ abi: userOperationRevertReasonAbi,
230
+ data: log.data,
231
+ topics: log.topics
232
+ });
233
+ revertReason = decodedLog.args.revertReason;
234
+ }
235
+ }
236
+ });
237
+ if (endIndex === -1) {
238
+ throw new Error("fatal: no UserOperationEvent in logs");
239
+ }
240
+ const logs = receipt.logs.slice(startIndex + 1, endIndex);
241
+ const userOperationEvent = parseEventLogs2({
242
+ abi: entryPoint07Abi2,
243
+ eventName: "UserOperationEvent",
244
+ args: {
245
+ userOpHash
246
+ },
247
+ logs: receipt.logs
248
+ })[0];
249
+ let paymaster = userOperationEvent.args.paymaster;
250
+ paymaster = paymaster === zeroAddress ? void 0 : paymaster;
251
+ return {
252
+ userOpHash,
253
+ entryPoint,
254
+ sender: userOperationEvent.args.sender,
255
+ nonce: numberToHex2(userOperationEvent.args.nonce),
256
+ paymaster,
257
+ actualGasUsed: numberToHex2(userOperationEvent.args.actualGasUsed),
258
+ actualGasCost: numberToHex2(userOperationEvent.args.actualGasCost),
259
+ success: userOperationEvent.args.success,
260
+ reason: revertReason,
261
+ logs,
262
+ receipt
263
+ };
264
+ }
265
+
266
+ // src/quarry/transports/wiresaw.ts
267
+ function wiresaw(transport) {
268
+ return (opts) => {
269
+ const { request: originalRequest, ...rest } = transport.wiresaw(opts);
270
+ let chainId = null;
271
+ const transactionHashes = {};
272
+ const transactionReceipts = {};
273
+ return {
274
+ ...rest,
275
+ async request(req) {
276
+ if (req.method === "eth_chainId") {
277
+ if (chainId != null) return chainId;
278
+ return chainId = await originalRequest(req);
279
+ }
280
+ if (req.method === "eth_estimateGas") {
281
+ return originalRequest({ ...req, method: "wiresaw_estimateGas" });
282
+ }
283
+ if (req.method === "eth_call") {
284
+ return originalRequest({ ...req, method: "wiresaw_call" });
285
+ }
286
+ if (req.method === "eth_getTransactionCount") {
287
+ return originalRequest({ ...req, method: "wiresaw_getTransactionCount" });
288
+ }
289
+ if (req.method === "eth_getTransactionReceipt") {
290
+ const transactionHash = req.params[0];
291
+ const receipt = transactionReceipts[transactionHash] ?? await originalRequest(req);
292
+ transactionReceipts[transactionHash] ??= receipt;
293
+ return receipt;
294
+ }
295
+ if (req.method === "eth_sendUserOperation") {
296
+ const { userOpHash, txHash } = await originalRequest({
297
+ ...req,
298
+ method: "wiresaw_sendUserOperation"
299
+ });
300
+ transactionHashes[userOpHash] = txHash;
301
+ return userOpHash;
302
+ }
303
+ if (req.method === "eth_getUserOperationReceipt") {
304
+ const userOpHash = req.params[0];
305
+ const knownTransactionHash = transactionHashes[userOpHash];
306
+ if (knownTransactionHash) {
307
+ const transactionReceipt = transactionReceipts[knownTransactionHash] ?? await originalRequest({
308
+ ...req,
309
+ params: [knownTransactionHash],
310
+ method: "eth_getTransactionReceipt"
311
+ });
312
+ transactionReceipts[knownTransactionHash] ??= transactionReceipt;
313
+ return transactionReceipt && getUserOperationReceipt(userOpHash, transactionReceipt);
314
+ }
315
+ const { request: fallbackRequest } = transport.fallbackBundler(opts);
316
+ return fallbackRequest(req);
317
+ }
318
+ if (req.method === "eth_estimateUserOperationGas") {
319
+ const { request: fallbackRequest } = transport.fallbackBundler(opts);
320
+ return fallbackRequest(req);
321
+ }
322
+ return originalRequest(req);
323
+ }
324
+ };
325
+ };
326
+ }
327
+
191
328
  // src/getBundlerTransport.ts
192
329
  function getBundlerTransport(chain) {
193
330
  const bundlerHttpUrl = chain.rpcUrls.bundler?.http[0];
194
- const bundlerTransport = bundlerHttpUrl ? http(bundlerHttpUrl) : chain.id === 31337 ? userOpExecutor({
195
- executor: createClient({
196
- chain,
197
- transport: fallback([webSocket(), http()]),
198
- account: privateKeyToAccount(keccak256(stringToHex("local user op executor"))),
199
- pollingInterval: 10
200
- }).extend(transactionQueue())
201
- }) : null;
202
- if (!bundlerTransport) {
203
- throw new Error(`Chain ${chain.id} config did not include a bundler RPC URL.`);
331
+ const wiresawWebSocketUrl = chain.rpcUrls.wiresaw?.webSocket?.[0];
332
+ if (wiresawWebSocketUrl) {
333
+ return wiresaw({ wiresaw: webSocket(wiresawWebSocketUrl), fallbackBundler: http(bundlerHttpUrl) });
334
+ }
335
+ const wiresawHttpUrl = chain.rpcUrls.wiresaw?.http[0];
336
+ if (wiresawHttpUrl) {
337
+ return wiresaw({ wiresaw: http(wiresawHttpUrl), fallbackBundler: http(bundlerHttpUrl) });
338
+ }
339
+ if (bundlerHttpUrl) {
340
+ return http(bundlerHttpUrl);
341
+ }
342
+ if (chain.id === 31337) {
343
+ return userOpExecutor({
344
+ executor: createClient({
345
+ chain,
346
+ transport: fallback([webSocket(), http()]),
347
+ account: privateKeyToAccount(keccak256(stringToHex("local user op executor"))),
348
+ pollingInterval: 10
349
+ }).extend(transactionQueue())
350
+ });
204
351
  }
205
- return bundlerTransport;
352
+ throw new Error(`Chain ${chain.id} config did not include a bundler RPC URL.`);
206
353
  }
207
354
 
208
355
  // src/EntryKitConfigProvider.tsx
@@ -585,7 +732,7 @@ import { useClient } from "wagmi";
585
732
  import { queryOptions, skipToken, useQuery as useQuery2 } from "@tanstack/react-query";
586
733
 
587
734
  // src/quarry/getAllowance.ts
588
- import { numberToHex as numberToHex2 } from "viem";
735
+ import { numberToHex as numberToHex3 } from "viem";
589
736
 
590
737
  // src/quarry/common.ts
591
738
  import { defineStore } from "@latticexyz/store";
@@ -689,7 +836,7 @@ async function setAllowanceSlot({ client, userAddress, allowance }) {
689
836
  {
690
837
  address: paymaster.address,
691
838
  index: slot,
692
- value: numberToHex2(allowance, { size: 32 })
839
+ value: numberToHex3(allowance, { size: 32 })
693
840
  }
694
841
  );
695
842
  }