From d3305a0c19203124bbd38ab9176070c499b1fd80 Mon Sep 17 00:00:00 2001 From: joepegler Date: Wed, 15 Jan 2025 14:34:19 +0000 Subject: [PATCH] chore: prep user op fix (#169) --- CHANGELOG.md | 6 +++ bun.lockb | Bin 295644 -> 295596 bytes package.json | 2 +- src/sdk/clients/createBundlerClient.test.ts | 17 +++++++- .../smartAccount/debugUserOperation.ts | 4 +- .../clients/decorators/smartAccount/index.ts | 24 +++++++++- .../prepareTokenPaymasterUserOp.ts | 9 ++-- .../prepareUserOperationWithoutSignature.ts | 41 ++++++++++++++++++ 8 files changed, 90 insertions(+), 13 deletions(-) create mode 100644 src/sdk/clients/decorators/smartAccount/prepareUserOperationWithoutSignature.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 3070d4c70..4856252b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # @biconomy/sdk +## 0.0.26 + +### Patch Changes + +- Remove signature from prepareUserOperation flow + ## 0.0.25 ### Patch Changes diff --git a/bun.lockb b/bun.lockb index 518071456a334645c2dc8f3db6f4e2d77e8c82cc..09a08779552274e4618f01fa323efda00dbbc526 100755 GIT binary patch delta 7595 zcmXxod;D5;9mjEg{3dQwadR79HgTI1GYc;{Oie0H)Kqp!*)+q=3z`?YQ`ux)6fY&t z%b>NQGQ(?>>6lk^UdT(5xk61vXGx_+%Nc1Y_W8bF-_C>Yp5O25oWtdC`2DfxFWTXj zi*{I*9-H-z1?v`!)n|^4RfjXjmKf<-q7Ea-?5fy+P*kfdG$Fj3Vh&mmnXQ4MBk@afDXjouULdG#N&!3=s{v1#WM6Exvydc29VlMu?9m(@2^;g5oA7~ z*nrRhT4kXL;rWU=Xh9^Qn1?n*4^%8b2Vx&oEJ7FJ2Pu}I2Z@6f%g~49A&M0kK6zed8%+ZPs2z^|uEHoi}jA9O25II&c4{eAZr&xdv#L|jI z=t6vfVhMVXSg2TrJ|q_@R$u_B#fmi;Li!Vmbr?bBc*O>UPS7d~O$cWc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!R;nbtX&&CaZ>e^ z{{>f#Ju$Ih6r4F$UHnOK)pYkJ-J3eZ#-TPAubeYJb0c?$FSXTSHr!pjFt9Q?K6l#V zy1nfJZt}nx Promise + /** + * Prepares a user operation + * @param params - {@link PrepareUserOperationParameters} + * @returns The user operation. {@link PrepareUserOperationReturnType} + * @example + * const userOp = await prepareUserOperation({ + * calls: [{to: '0x...', value: 1n, data: '0x...'}] + * }) + */ + prepareUserOperation: ( + params: PrepareUserOperationParameters + ) => Promise> } export function smartAccountActions() { @@ -388,6 +406,8 @@ export function smartAccountActions() { writeContract: (args) => writeContract(client, args), waitForTransactionReceipt: (args) => waitForTransactionReceipt(client, args), - debugUserOperation: (args) => debugUserOperation(client, args) + debugUserOperation: (args) => debugUserOperation(client, args), + prepareUserOperation: (args) => + prepareUserOperationWithoutSignature(client, args) }) } diff --git a/src/sdk/clients/decorators/smartAccount/prepareTokenPaymasterUserOp.ts b/src/sdk/clients/decorators/smartAccount/prepareTokenPaymasterUserOp.ts index 7ca3853ed..d8121563e 100644 --- a/src/sdk/clients/decorators/smartAccount/prepareTokenPaymasterUserOp.ts +++ b/src/sdk/clients/decorators/smartAccount/prepareTokenPaymasterUserOp.ts @@ -7,13 +7,10 @@ import { maxUint256 } from "viem" import { encodeFunctionData } from "viem" -import { - type SmartAccount, - type UserOperation, - prepareUserOperation -} from "viem/account-abstraction" +import type { SmartAccount, UserOperation } from "viem/account-abstraction" import { getAction } from "viem/utils" import { BICONOMY_TOKEN_PAYMASTER } from "../../../account/utils/Constants" +import { prepareUserOperationWithoutSignature } from "./prepareUserOperationWithoutSignature" export type Transaction = { to: Address @@ -75,7 +72,7 @@ export async function prepareTokenPaymasterUserOp< const userOp = await getAction( client, - prepareUserOperation, + prepareUserOperationWithoutSignature, "prepareUserOperation" )({ calls: [ diff --git a/src/sdk/clients/decorators/smartAccount/prepareUserOperationWithoutSignature.ts b/src/sdk/clients/decorators/smartAccount/prepareUserOperationWithoutSignature.ts new file mode 100644 index 000000000..d0b97a14e --- /dev/null +++ b/src/sdk/clients/decorators/smartAccount/prepareUserOperationWithoutSignature.ts @@ -0,0 +1,41 @@ +import { prepareUserOperation } from "viem/account-abstraction" + +import type { Chain, Client, Transport } from "viem" +import type { + PrepareUserOperationParameters, + PrepareUserOperationRequest, + PrepareUserOperationReturnType, + SmartAccount +} from "viem/account-abstraction" +import { getAction } from "viem/utils" + +export async function prepareUserOperationWithoutSignature< + account extends SmartAccount | undefined, + const calls extends readonly unknown[], + const request extends PrepareUserOperationRequest< + account, + accountOverride, + calls + >, + accountOverride extends SmartAccount | undefined = undefined +>( + client: Client, + args: PrepareUserOperationParameters +): Promise< + Omit< + PrepareUserOperationReturnType, + "signature" + > +> { + const userOp = await getAction( + client, + prepareUserOperation, + "prepareUserOperation" + )(args) + + // Remove signature from userOp if it exists + // @ts-ignore + const { signature, ...userOpWithoutSignature } = userOp + + return userOpWithoutSignature +}