diff --git a/packages/permissionless-test/ep-0.6/bundlerActions.test.ts b/packages/permissionless-test/ep-0.6/bundlerActions.test.ts index 2d83ccb0..622dad41 100644 --- a/packages/permissionless-test/ep-0.6/bundlerActions.test.ts +++ b/packages/permissionless-test/ep-0.6/bundlerActions.test.ts @@ -127,7 +127,6 @@ describe("BUNDLER ACTIONS", () => { to: zeroAddress, value: 0n }) - console.log(`Transaction hash: ${response}`) }, 100000) test("Sending user operation", async () => { diff --git a/packages/permissionless-test/ep-0.7/bundlerActions.test.ts b/packages/permissionless-test/ep-0.7/bundlerActions.test.ts index 91d9006c..8073face 100644 --- a/packages/permissionless-test/ep-0.7/bundlerActions.test.ts +++ b/packages/permissionless-test/ep-0.7/bundlerActions.test.ts @@ -102,7 +102,7 @@ describe("BUNDLER ACTIONS", () => { index: 3n }) - // const paymasterClient = getPimlicoPaymasterClient() + const paymasterClient = getPimlicoPaymasterClient() const pimlicoBundlerClient = getPimlicoBundlerClient() const smartAccountClient = createSmartAccountClient({ @@ -114,8 +114,8 @@ describe("BUNDLER ACTIONS", () => { const gasPrices = await pimlicoBundlerClient.getUserOperationGasPrice() return gasPrices.fast - } - // sponsorUserOperation: paymasterClient.sponsorUserOperation + }, + sponsorUserOperation: paymasterClient.sponsorUserOperation } }) @@ -128,7 +128,6 @@ describe("BUNDLER ACTIONS", () => { to: zeroAddress, value: 0n }) - console.log(`Transaction hash: ${response}`) }, 100000) test("Sending user operation", async () => { diff --git a/packages/permissionless-test/ep-0.7/safeSmartAccount.test.ts b/packages/permissionless-test/ep-0.7/safeSmartAccount.test.ts index 9e2407fc..cda0028f 100644 --- a/packages/permissionless-test/ep-0.7/safeSmartAccount.test.ts +++ b/packages/permissionless-test/ep-0.7/safeSmartAccount.test.ts @@ -203,18 +203,41 @@ describe("Safe Account", () => { }, 1000000) test("safe Smart account client send transaction", async () => { + const bundlerClient = getBundlerClient() + const erc20PaymasterAddress = + "0x000000000041F3aFe8892B48D88b6862efe0ec8d" + const smartAccountClient = await getSmartAccountClient({ - account: await getSignerToSafeSmartAccount() + account: await getSignerToSafeSmartAccount(), + middleware: { + sponsorUserOperation: async (args) => { + const gasEstimates = + await bundlerClient.estimateUserOperationGas({ + userOperation: { + ...args.userOperation, + paymaster: erc20PaymasterAddress + } + }) + + return { + ...gasEstimates, + paymaster: erc20PaymasterAddress + } + } + } }) - await refillSmartAccount( - walletClient, - smartAccountClient.account.address - ) + // await refillSmartAccount( + // walletClient, + // smartAccountClient.account.address + // ) const response = await smartAccountClient.sendTransaction({ to: zeroAddress, value: 0n, data: "0x" }) + + console.log(`Transaction hash: ${response}`) + expectTypeOf(response).toBeString() expect(response).toHaveLength(66) expect(response).toMatch(/^0x[0-9a-fA-F]{64}$/) diff --git a/packages/permissionless/actions/smartAccount/prepareUserOperationRequest.ts b/packages/permissionless/actions/smartAccount/prepareUserOperationRequest.ts index d681326a..60394773 100644 --- a/packages/permissionless/actions/smartAccount/prepareUserOperationRequest.ts +++ b/packages/permissionless/actions/smartAccount/prepareUserOperationRequest.ts @@ -149,13 +149,13 @@ async function prepareUserOperationRequestForEntryPointV06< } if (typeof middleware === "function") { - return (await middleware({ + return middleware({ userOperation, entryPoint: account.entryPoint } as { userOperation: UserOperation> entryPoint: entryPoint - })) as PrepareUserOperationRequestReturnType + }) as Promise> } if (middleware && typeof middleware !== "function" && middleware.gasPrice) { @@ -201,6 +201,7 @@ async function prepareUserOperationRequestForEntryPointV06< sponsorUserOperationData.preVerificationGas userOperation.paymasterAndData = sponsorUserOperationData.paymasterAndData + return userOperation as PrepareUserOperationRequestReturnType } if ( @@ -291,13 +292,13 @@ async function prepareUserOperationRequestEntryPointV07< } if (typeof middleware === "function") { - return (await middleware({ + return middleware({ userOperation, entryPoint: account.entryPoint } as { userOperation: UserOperation> entryPoint: entryPoint - })) as PrepareUserOperationRequestReturnType + }) as Promise> } if (middleware && typeof middleware !== "function" && middleware.gasPrice) { @@ -349,6 +350,8 @@ async function prepareUserOperationRequestEntryPointV07< userOperation.paymasterPostOpGasLimit = sponsorUserOperationData.paymasterPostOpGasLimit userOperation.paymasterData = sponsorUserOperationData.paymasterData + + return userOperation as PrepareUserOperationRequestReturnType } if ( @@ -356,13 +359,13 @@ async function prepareUserOperationRequestEntryPointV07< !userOperation.verificationGasLimit || !userOperation.preVerificationGas ) { - const gasParameters = await getAction(client, estimateUserOperationGas)( + const gasParameters = await getAction( + client, + estimateUserOperationGas + )( { userOperation, entryPoint: account.entryPoint - } as { - userOperation: UserOperation> - entryPoint: entryPoint }, stateOverrides ) @@ -373,6 +376,13 @@ async function prepareUserOperationRequestEntryPointV07< gasParameters.verificationGasLimit userOperation.preVerificationGas = userOperation.preVerificationGas || gasParameters.preVerificationGas + + userOperation.paymasterPostOpGasLimit = + userOperation.paymasterPostOpGasLimit || + gasParameters.paymasterPostOpGasLimit + userOperation.paymasterPostOpGasLimit = + userOperation.paymasterPostOpGasLimit || + gasParameters.paymasterPostOpGasLimit } return userOperation as PrepareUserOperationRequestReturnType