Skip to content

Commit 3dbcdaa

Browse files
committed
feat(wip): add bundler client example and why it's worse
1 parent 4054dff commit 3dbcdaa

File tree

1 file changed

+33
-0
lines changed
  • account-kit/infra/src/client

1 file changed

+33
-0
lines changed

account-kit/infra/src/client/viem.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { createBundlerClient } from "viem/account-abstraction";
2+
import type { AlchemySmartAccountClientConfig } from "./smartAccountClient";
3+
4+
// Yea this isn't great or going to work well, we should just keep using our smart account client, but change the account type to match the viem one
5+
export const foo = (params: AlchemySmartAccountClientConfig) => {
6+
const cl = createBundlerClient({
7+
transport: params.transport,
8+
chain: params.chain,
9+
paymasterContext: { policyId: params.policyId },
10+
paymaster: {
11+
async getPaymasterStubData(parameters) {
12+
if (!("policyId" in parameters.context)) {
13+
throw new Error("policyId is required");
14+
}
15+
16+
throw new Error(
17+
"this is the biggest issue with viem's approach. we can't skip gas estimation during paymaster flows..."
18+
);
19+
},
20+
async getPaymasterData(parameters) {
21+
throw new Error("port over the paymaster data middleware");
22+
},
23+
},
24+
userOperation: {
25+
// This doesn't have the ability to skip gas estimation AFAICT
26+
estimateFeesPerGas(parameters) {
27+
throw new Error("port over the fee estimator middleware");
28+
},
29+
},
30+
});
31+
32+
return cl;
33+
};

0 commit comments

Comments
 (0)