Skip to content

Commit

Permalink
assume user op receipt success
Browse files Browse the repository at this point in the history
  • Loading branch information
holic committed Oct 23, 2024
1 parent 1ae4a02 commit 5d62534
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions packages/entrykit/src/onboarding/useSetupAppAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ export function useSetupAppAccount() {
await queryClient.invalidateQueries({ queryKey: ["readContract"] });

// TODO: throw if revert?
// TODO: add success boolean to wiresaw return value
// if (!receipt.success) return;
if (!receipt.success) return;

if (registerSpender) {
const queryKey = getSpenderQueryKey({
Expand Down
10 changes: 5 additions & 5 deletions packages/entrykit/src/wiresaw.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Hash, Hex, RpcTransactionReceipt, Transport } from "viem";
import { UserOperationReceipt } from "viem/account-abstraction";
import { Hash, Hex, RpcTransactionReceipt, RpcUserOperationReceipt, Transport } from "viem";

export const wiresawChainIds = new Set([17420, 31337]);

Expand All @@ -8,7 +7,7 @@ export function wiresaw<const transport extends Transport>(originalTransport: tr
const { request: originalRequest, ...rest } = originalTransport(opts);

let chainId: Hex | null = null;
const receipts = new Map<Hash, RpcTransactionReceipt | UserOperationReceipt>();
const receipts = new Map<Hash, RpcTransactionReceipt | RpcUserOperationReceipt>();

return {
...rest,
Expand Down Expand Up @@ -54,16 +53,17 @@ export function wiresaw<const transport extends Transport>(originalTransport: tr
})) as { txHash: Hex; userOpHash: Hex };
// :haroldsmile:
receipts.set(result.userOpHash, {
success: true,
userOpHash: result.userOpHash,
receipt: { transactionHash: result.txHash },
} as UserOperationReceipt);
} as RpcUserOperationReceipt);
return result.userOpHash;
}

if (req.method === "eth_getUserOperationReceipt") {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const hash = (req.params as any)[0] as Hash;
const receipt = receipts.get(hash) ?? ((await originalRequest(req)) as UserOperationReceipt);
const receipt = receipts.get(hash) ?? ((await originalRequest(req)) as RpcUserOperationReceipt);
if (!receipts.has(hash)) receipts.set(hash, receipt);
return receipt;
}
Expand Down

0 comments on commit 5d62534

Please sign in to comment.