From 133d2550f1b8dfd52f82873bd81113017132b82b Mon Sep 17 00:00:00 2001 From: Sergey Potekhin Date: Sun, 7 Jul 2024 18:38:20 +0200 Subject: [PATCH] Update smart account init --- src/components/safe/useSafeProvider.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/components/safe/useSafeProvider.tsx b/src/components/safe/useSafeProvider.tsx index 209ad4c..ff1e64a 100644 --- a/src/components/safe/useSafeProvider.tsx +++ b/src/components/safe/useSafeProvider.tsx @@ -7,7 +7,7 @@ import { createSmartAccountClient, } from "permissionless"; import { signerToSafeSmartAccount } from "permissionless/accounts"; -import { createPimlicoBundlerClient } from "permissionless/clients/pimlico"; +import { createPimlicoBundlerClient, createPimlicoPaymasterClient } from "permissionless/clients/pimlico"; import { http } from "viem"; import { sepolia } from "viem/chains"; import { ENTRYPOINT_ADDRESS_V07_TYPE } from "permissionless/_types/types"; @@ -30,16 +30,24 @@ export const useSafeProvider = () => { }); const pimlicoBundlerClient = createPimlicoBundlerClient({ - transport: http(`https://api.pimlico.io/v1/sepolia/rpc?apikey=${process.env.NEXT_PUBLIC_PIMLICO_API_KEY}`), + transport: http(`https://api.pimlico.io/v2/sepolia/rpc?apikey=${process.env.NEXT_PUBLIC_PIMLICO_API_KEY}`), entryPoint: ENTRYPOINT_ADDRESS_V07, }); + const paymasterClient = createPimlicoPaymasterClient({ + entryPoint: ENTRYPOINT_ADDRESS_V07, + transport: http(`https://api.pimlico.io/v2/sepolia/rpc?apikey=${process.env.NEXT_PUBLIC_PIMLICO_API_KEY}`), + }) + const smartAccountClient = createSmartAccountClient({ account: smartAccount, entryPoint: ENTRYPOINT_ADDRESS_V07, chain: sepolia, - bundlerTransport: http(`https://api.pimlico.io/v1/sepolia/rpc?apikey=${process.env.NEXT_PUBLIC_PIMLICO_API_KEY}`), + bundlerTransport: http(`https://api.pimlico.io/v2/sepolia/rpc?apikey=${process.env.NEXT_PUBLIC_PIMLICO_API_KEY}`, { + timeout: 30_000, + }), middleware: { + sponsorUserOperation: paymasterClient.sponsorUserOperation, // optional gasPrice: async () => (await pimlicoBundlerClient.getUserOperationGasPrice()).standard, // if using pimlico bundler },