diff --git a/.changeset/orange-llamas-train.md b/.changeset/orange-llamas-train.md new file mode 100644 index 00000000..ea04549a --- /dev/null +++ b/.changeset/orange-llamas-train.md @@ -0,0 +1,5 @@ +--- +"permissionless": patch +--- + +Enable setting custom nonce for user operations diff --git a/src/actions/smartAccount/sendTransaction.ts b/src/actions/smartAccount/sendTransaction.ts index abfc22d1..78506b54 100644 --- a/src/actions/smartAccount/sendTransaction.ts +++ b/src/actions/smartAccount/sendTransaction.ts @@ -87,6 +87,7 @@ export async function sendTransaction< maxPriorityFeePerGas, to, value, + nonce, sponsorUserOperation } = args @@ -119,7 +120,8 @@ export async function sendTransaction< paymasterAndData: "0x", maxFeePerGas: maxFeePerGas || 0n, maxPriorityFeePerGas: maxPriorityFeePerGas || 0n, - callData: callData + callData: callData, + nonce: nonce ? BigInt(nonce) : undefined }, account: account, sponsorUserOperation diff --git a/src/actions/smartAccount/sendTransactions.ts b/src/actions/smartAccount/sendTransactions.ts index 7a9b5596..93de8b88 100644 --- a/src/actions/smartAccount/sendTransactions.ts +++ b/src/actions/smartAccount/sendTransactions.ts @@ -26,6 +26,7 @@ export type SendTransactionsWithPaymasterParameters< SponsorUserOperationMiddleware & { maxFeePerGas?: bigint maxPriorityFeePerGas?: bigint + nonce?: bigint } /** @@ -86,7 +87,8 @@ export async function sendTransactions< transactions, sponsorUserOperation, maxFeePerGas, - maxPriorityFeePerGas + maxPriorityFeePerGas, + nonce } = args if (!account_) { @@ -121,7 +123,8 @@ export async function sendTransactions< paymasterAndData: "0x", maxFeePerGas: maxFeePerGas || 0n, maxPriorityFeePerGas: maxPriorityFeePerGas || 0n, - callData: callData + callData: callData, + nonce: nonce }, account: account, sponsorUserOperation diff --git a/test/safeSmartAccount.test.ts b/test/safeSmartAccount.test.ts index 6eb3db6d..dd67afe0 100644 --- a/test/safeSmartAccount.test.ts +++ b/test/safeSmartAccount.test.ts @@ -27,9 +27,6 @@ import { dotenv.config() -let testPrivateKey: Hex -let factoryAddress: Address - beforeAll(() => { if (!process.env.PIMLICO_API_KEY) { throw new Error("PIMLICO_API_KEY environment variable not set") @@ -53,8 +50,6 @@ beforeAll(() => { if (!process.env.GREETER_ADDRESS) { throw new Error("ENTRYPOINT_ADDRESS environment variable not set") } - testPrivateKey = process.env.TEST_PRIVATE_KEY as Hex - factoryAddress = process.env.FACTORY_ADDRESS as Address }) describe("Safe Account", () => {