Skip to content

Commit

Permalink
remove observer for now, return partial user op receipts for speed
Browse files Browse the repository at this point in the history
  • Loading branch information
holic committed Nov 9, 2024
1 parent e48e9d8 commit a4f4f26
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
3 changes: 1 addition & 2 deletions packages/entrykit/src/getSessionClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Address, Chain, Client, Transport } from "viem";
import { smartAccountActions } from "permissionless";
import { callFrom } from "@latticexyz/world/internal";
import { createBundlerClient } from "./createBundlerClient";
import { observer } from "@latticexyz/explorer/observer";
import { SessionClient } from "./common";
import { SmartAccount } from "viem/account-abstraction";
import { getBundlerTransport } from "./getBundlerTransport";
Expand Down Expand Up @@ -30,7 +29,7 @@ export async function getSessionClient<chain extends Chain>({
})
.extend(smartAccountActions())
.extend(callFrom({ worldAddress, delegatorAddress: userAddress, publicClient: client }))
.extend(observer())
// TODO: add observer once we conditionally fetch receipts while bridge is open
.extend(() => ({ userAddress }));

return sessionClient;
Expand Down
6 changes: 2 additions & 4 deletions packages/entrykit/src/passkey/passkeyConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { reusePasskey } from "./reusePasskey";
import { createPasskey } from "./createPasskey";
import { defaultClientConfig } from "../common";
import { createBundlerClient } from "../createBundlerClient";
import { observer } from "@latticexyz/explorer/observer";
import { getPaymasterAddress } from "../getPaymasterAddress";
import { getBundlerTransport } from "../getBundlerTransport";
import { wiresaw } from "@latticexyz/wiresaw/internal";
Expand Down Expand Up @@ -199,9 +198,8 @@ export function passkeyConnector({ chainId }: PasskeyConnectorOptions): CreatePa
transport: bundlerTransport,
client,
account,
})
.extend(smartAccountActions())
.extend(observer());
}).extend(smartAccountActions());
// TODO: add observer once we conditionally fetch receipts while bridge is open
},

async getProvider(_params) {
Expand Down
34 changes: 26 additions & 8 deletions packages/wiresaw/src/transports/wiresaw.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { BundlerRpcSchema, Hash, Hex, PublicRpcSchema, RpcTransactionReceipt, Transport, http } from "viem";
import {
BundlerRpcSchema,
Hash,
Hex,
PublicRpcSchema,
RpcTransactionReceipt,
RpcUserOperationReceipt,
Transport,
http,
} from "viem";
import { getRpcMethod, getRpcSchema, TransportRequestFn, TransportRequestFnMapped } from "./common";
import { getUserOperationReceipt } from "../getUserOperationReceipt";

export type WiresawRpcSchema = [
{
Expand Down Expand Up @@ -52,7 +60,7 @@ export function wiresaw<const transport extends Transport>(getTransport: transpo
const getWiresawTransport =
args.chain?.rpcUrls && "wiresaw" in args.chain.rpcUrls
? // TODO: enable WS
http(args.chain.rpcUrls.wiresaw.http[0], { batch: true })
http(args.chain.rpcUrls.wiresaw.http[0])
: undefined;
if (!getWiresawTransport) return getTransport(args);

Expand Down Expand Up @@ -106,7 +114,7 @@ export function wiresaw<const transport extends Transport>(getTransport: transpo
}

if (method === "eth_getUserOperationReceipt") {
const { receipts, userOps } = getCache(await getChainId());
const { userOps } = getCache(await getChainId());
const [userOpHash] = params;
const transactionHash = userOps.get(userOpHash);

Expand All @@ -116,10 +124,20 @@ export function wiresaw<const transport extends Transport>(getTransport: transpo
throw new Error(`Could not find transaction hash for user op hash "${userOpHash}".`);
}

const receipt = await getReceipt(transactionHash, receipts);
if (!receipt) return null;

return getUserOperationReceipt(userOpHash, receipt);
// return instant/partial receipt for now until we can find a good way
// to opt-in to this when using things like permissionless actions, which
// call out to `waitForUserOperationReceipt`
return {
success: true,
userOpHash,
receipt: {
transactionHash,
},
} as RpcUserOperationReceipt;

// const receipt = await getReceipt(transactionHash, receipts);
// if (!receipt) return null;
// return getUserOperationReceipt(userOpHash, receipt);
}

return await transport.request({ method, params }, opts);
Expand Down

0 comments on commit a4f4f26

Please sign in to comment.