Skip to content

Commit

Permalink
parse receipt for success
Browse files Browse the repository at this point in the history
  • Loading branch information
holic committed Nov 9, 2024
1 parent 051e0dd commit 3b489ec
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
3 changes: 3 additions & 0 deletions packages/entrykit/playground/wagmiConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const chains = [
...anvil,
rpcUrls: {
...anvil.rpcUrls,
bundler: {
http: ["http://127.0.0.1:4337"],
},
// TODO: automatically grant allowance in anvil instead of requiring the service
quarryPassIssuer: {
http: ["http://127.0.0.1:3003/rpc"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export async function estimateUserOperationGas(
_params: rpcMethod["Parameters"],
): Promise<rpcMethod["ReturnType"]> {
return formatUserOperationRequest({
callGasLimit: 50_000_000n,
callGasLimit: 20_000_000n,
preVerificationGas: 200_000n,
verificationGasLimit: 2_000_000n,
paymasterVerificationGasLimit: 200_000n,
Expand Down
30 changes: 26 additions & 4 deletions packages/paymaster/src/transports/methods/sendUserOperation.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import { Client, Transport, Chain, Account, RpcUserOperation, RpcUserOperationReceipt, parseEther } from "viem";
import {
Client,
Transport,
Chain,
Account,
RpcUserOperation,
RpcUserOperationReceipt,
parseEther,
parseEventLogs,
} from "viem";
import {
formatUserOperation,
toPackedUserOperation,
getUserOperationHash,
entryPoint07Address,
entryPoint07Abi,
} from "viem/account-abstraction";
import { setBalance, writeContract } from "viem/actions";
import { setBalance, waitForTransactionReceipt, writeContract } from "viem/actions";
import { getAction } from "viem/utils";

// TODO: move to common package?
Expand Down Expand Up @@ -67,9 +76,22 @@ export async function sendUserOperation({
gas,
});

const receipt = await getAction(
executor,
waitForTransactionReceipt,
"waitForTransactionReceipt",
)({ hash: transactionHash });

// TODO: replace with `getUserOperationReceipt`?
const parsedLogs = parseEventLogs({
logs: receipt.logs,
abi: entryPoint07Abi,
eventName: "UserOperationEvent" as const,
});

return {
success: true,
success: parsedLogs[0]!.args.success,
userOpHash,
receipt: { transactionHash },
receipt,
};
}

0 comments on commit 3b489ec

Please sign in to comment.