Skip to content

Commit 65e4592

Browse files
authored
fix(entrykit): create session account (#3798)
1 parent 8150fcd commit 65e4592

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

packages/entrykit/src/onboarding/useSetupSession.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Hex, encodeFunctionData, parseEventLogs } from "viem";
1+
import { Hex, encodeFunctionData, parseEventLogs, zeroAddress } from "viem";
22
import { useMutation, useQueryClient } from "@tanstack/react-query";
33
import { getAction } from "viem/utils";
44
import { entryPoint07Abi, sendUserOperation, waitForUserOperationReceipt } from "viem/account-abstraction";
@@ -84,6 +84,8 @@ export function useSetupSession({ connector, userClient }: { connector: Connecto
8484
});
8585
console.log("got send calls ID", id);
8686

87+
// TODO: switch to `waitForCallsStatus`, but needs to be able to run "headless" (no popup)
88+
8789
const bundlerClient = createBundlerClient({
8890
transport: getBundlerTransport(client.chain),
8991
client,
@@ -112,6 +114,29 @@ export function useSetupSession({ connector, userClient }: { connector: Connecto
112114
],
113115
}),
114116
);
117+
118+
// create session account instead of doing lazily
119+
await (async () => {
120+
console.log("creating session account by sending empty user op");
121+
const hash = await getAction(
122+
sessionClient,
123+
sendUserOperation,
124+
"sendUserOperation",
125+
)({
126+
calls: [{ to: zeroAddress }],
127+
});
128+
129+
const receipt = await getAction(
130+
bundlerClient,
131+
waitForUserOperationReceipt,
132+
"waitForUserOperationReceipt",
133+
)({ hash });
134+
console.log("got user op receipt", receipt);
135+
136+
if (!receipt.success) {
137+
console.error("not successful?", receipt);
138+
}
139+
})();
115140
} else if (userClient.account.type === "smart") {
116141
// Set up session for smart account wallet
117142
const calls = [];

0 commit comments

Comments
 (0)