From 8f5f49933b5ecf985e50bd73ed4157cf39fcf1a1 Mon Sep 17 00:00:00 2001 From: Garvit Khatri Date: Thu, 11 Apr 2024 20:30:14 +0530 Subject: [PATCH 1/2] use BigInt instead of 1n --- .../ep-0.6/biconomySmartaccount.test.ts | 24 ++++++++-------- .../ep-0.6/bundlerActions.test.ts | 4 +-- .../permissionless-test/ep-0.6/index.test.ts | 4 +-- .../ep-0.6/simpleAccount.test.ts | 22 +++++++-------- .../ep-0.7/bundlerActions.test.ts | 6 ++-- packages/permissionless-test/ep-0.7/utils.ts | 8 +++--- .../ep-0.7/walletClientToCustomSigner.test.ts | 16 +++++------ packages/permissionless-test/src/constants.ts | 2 +- packages/permissionless-test/src/opStack.ts | 2 +- .../biconomy/signerToBiconomySmartAccount.ts | 4 +-- .../kernel/signerToEcdsaKernelSmartAccount.ts | 2 +- .../accounts/safe/signerToSafeSmartAccount.ts | 28 +++++++++++-------- .../simple/signerToSimpleSmartAccount.ts | 9 ++++-- .../actions/smartAccount/deployContract.ts | 4 +-- .../prepareUserOperationRequest.ts | 24 +++++++++------- .../actions/smartAccount/sendTransaction.ts | 6 ++-- .../actions/smartAccount/sendTransactions.ts | 6 ++-- .../actions/smartAccount/signTypedData.ts | 2 +- packages/permissionless/errors/account.ts | 2 +- .../utils/getPackedUserOperation.ts | 14 +++++++--- .../utils/getRequiredPrefund.ts | 10 ++++--- .../utils/getUserOperationHash.ts | 14 +++++++--- 22 files changed, 120 insertions(+), 93 deletions(-) diff --git a/packages/permissionless-test/ep-0.6/biconomySmartaccount.test.ts b/packages/permissionless-test/ep-0.6/biconomySmartaccount.test.ts index 9d9a8c85..f38abf20 100644 --- a/packages/permissionless-test/ep-0.6/biconomySmartaccount.test.ts +++ b/packages/permissionless-test/ep-0.6/biconomySmartaccount.test.ts @@ -78,7 +78,7 @@ describe("Biconomy Modular Smart Account (ECDSA module)", () => { await expect(async () => ecdsaSmartAccount.signTransaction({ to: zeroAddress, - value: 0n, + value: BigInt(0), data: "0x" }) ).rejects.toThrow(SignTransactionNotSupportedBySmartAccount) @@ -111,12 +111,12 @@ describe("Biconomy Modular Smart Account (ECDSA module)", () => { transactions: [ { to: zeroAddress, - value: 0n, + value: BigInt(0), data: "0x" }, { to: zeroAddress, - value: 0n, + value: BigInt(0), data: "0x" } ] @@ -152,7 +152,7 @@ describe("Biconomy Modular Smart Account (ECDSA module)", () => { const txHash = await entryPointContract.write.depositTo( [smartAccountClient.account.address], { - value: 10n + value: BigInt(10) } ) @@ -183,7 +183,7 @@ describe("Biconomy Modular Smart Account (ECDSA module)", () => { const response = await smartAccountClient.sendTransaction({ to: zeroAddress, - value: 0n, + value: BigInt(0), data: "0x" }) @@ -242,12 +242,12 @@ describe("Biconomy Modular Smart Account (ECDSA module)", () => { transactions: [ { to: zeroAddress, - value: 0n, + value: BigInt(0), data: "0x" }, { to: zeroAddress, - value: 0n, + value: BigInt(0), data: "0x" } ] @@ -303,7 +303,7 @@ describe("Biconomy Modular Smart Account (ECDSA module)", () => { // Send an initial tx to deploy the account const hash = await smartAccountClient.sendTransaction({ to: zeroAddress, - value: 0n, + value: BigInt(0), data: "0x" }) @@ -326,7 +326,7 @@ describe("Biconomy Modular Smart Account (ECDSA module)", () => { test("verifySignature of deployed", async () => { const initialEcdsaSmartAccount = await getSignerToBiconomyAccount({ - index: 0n + index: BigInt(0) }) const smartAccountClient = await getSmartAccountClient({ @@ -351,7 +351,7 @@ describe("Biconomy Modular Smart Account (ECDSA module)", () => { test("verifySignature of not deployed", async () => { const initialEcdsaSmartAccount = await getSignerToBiconomyAccount({ - index: 10000n + index: BigInt(10000) }) const smartAccountClient = await getSmartAccountClient({ @@ -376,7 +376,7 @@ describe("Biconomy Modular Smart Account (ECDSA module)", () => { test("verifySignature with signTypedData", async () => { const initialEcdsaSmartAccount = await getSignerToBiconomyAccount({ - index: 0n + index: BigInt(0) }) const smartAccountClient = await getSmartAccountClient({ @@ -456,7 +456,7 @@ describe("Biconomy Modular Smart Account (ECDSA module)", () => { test("verifySignature with signTypedData for not deployed", async () => { const initialEcdsaSmartAccount = await getSignerToBiconomyAccount({ - index: 1000000n + index: BigInt(1000000) }) const smartAccountClient = await getSmartAccountClient({ diff --git a/packages/permissionless-test/ep-0.6/bundlerActions.test.ts b/packages/permissionless-test/ep-0.6/bundlerActions.test.ts index 622dad41..128093a2 100644 --- a/packages/permissionless-test/ep-0.6/bundlerActions.test.ts +++ b/packages/permissionless-test/ep-0.6/bundlerActions.test.ts @@ -98,7 +98,7 @@ describe("BUNDLER ACTIONS", () => { ), entryPoint: getEntryPoint(), factoryAddress: process.env.FACTORY_ADDRESS_V06 as Address, - index: 3n + index: BigInt(3) }) const paymasterClient = getPimlicoPaymasterClient() @@ -125,7 +125,7 @@ describe("BUNDLER ACTIONS", () => { const response = await smartAccountClient.sendTransaction({ to: zeroAddress, - value: 0n + value: BigInt(0) }) }, 100000) diff --git a/packages/permissionless-test/ep-0.6/index.test.ts b/packages/permissionless-test/ep-0.6/index.test.ts index d81973f5..9ea61302 100644 --- a/packages/permissionless-test/ep-0.6/index.test.ts +++ b/packages/permissionless-test/ep-0.6/index.test.ts @@ -40,11 +40,11 @@ describe("test public actions and utils", () => { expect(deepHexlify(null)).toBe(null) expect(deepHexlify(true)).toBe(true) expect(deepHexlify(false)).toBe(false) - expect(deepHexlify(1n)).toBe("0x1") + expect(deepHexlify(BigInt(1))).toBe("0x1") expect( deepHexlify({ name: "Garvit", - balance: 1n + balance: BigInt(1) }) ).toEqual({ name: "Garvit", diff --git a/packages/permissionless-test/ep-0.6/simpleAccount.test.ts b/packages/permissionless-test/ep-0.6/simpleAccount.test.ts index bbbb9d18..f6a0024e 100644 --- a/packages/permissionless-test/ep-0.6/simpleAccount.test.ts +++ b/packages/permissionless-test/ep-0.6/simpleAccount.test.ts @@ -71,7 +71,7 @@ describe("Simple Account", () => { await expect(async () => simpleSmartAccount.signTransaction({ to: zeroAddress, - value: 0n, + value: BigInt(0), data: "0x" }) ).rejects.toThrow(SignTransactionNotSupportedBySmartAccount) @@ -136,12 +136,12 @@ describe("Simple Account", () => { transactions: [ { to: zeroAddress, - value: 0n, + value: BigInt(0), data: "0x" }, { to: zeroAddress, - value: 0n, + value: BigInt(0), data: "0x" } ] @@ -174,7 +174,7 @@ describe("Simple Account", () => { const txHash = await entryPointContract.write.depositTo( [smartAccountClient.account.address], { - value: 10n + value: BigInt(10) } ) @@ -196,7 +196,7 @@ describe("Simple Account", () => { ) const response = await smartAccountClient.sendTransaction({ to: zeroAddress, - value: 0n, + value: BigInt(0), data: "0x" }) expectTypeOf(response).toBeString() @@ -221,7 +221,7 @@ describe("Simple Account", () => { const response = await smartAccountClient.sendTransaction({ to: smartAccountClient.account.address, data: "0x", - value: 0n + value: BigInt(0) }) expectTypeOf(response).toBeString() @@ -242,7 +242,7 @@ describe("Simple Account", () => { userOperation: { callData: await smartAccountClient.account.encodeCallData({ to: zeroAddress, - value: 0n, + value: BigInt(0), data: "0x" }) } @@ -265,7 +265,7 @@ describe("Simple Account", () => { const response = await smartAccountClient.sendTransaction({ to: zeroAddress, - value: 0n, + value: BigInt(0), data: "0x" }) @@ -318,12 +318,12 @@ describe("Simple Account", () => { transactions: [ { to: zeroAddress, - value: 0n, + value: BigInt(0), data: "0x" }, { to: zeroAddress, - value: 0n, + value: BigInt(0), data: "0x" } ] @@ -364,7 +364,7 @@ describe("Simple Account", () => { test("verifySignature", async () => { const initialEcdsaSmartAccount = await getSignerToSimpleSmartAccount({ - index: 0n + index: BigInt(0) }) const pimlicoPaymaster = getPimlicoPaymasterClient() diff --git a/packages/permissionless-test/ep-0.7/bundlerActions.test.ts b/packages/permissionless-test/ep-0.7/bundlerActions.test.ts index 8073face..da7e430e 100644 --- a/packages/permissionless-test/ep-0.7/bundlerActions.test.ts +++ b/packages/permissionless-test/ep-0.7/bundlerActions.test.ts @@ -99,7 +99,7 @@ describe("BUNDLER ACTIONS", () => { ), entryPoint: getEntryPoint(), factoryAddress: process.env.FACTORY_ADDRESS_V07 as Address, - index: 3n + index: BigInt(3) }) const paymasterClient = getPimlicoPaymasterClient() @@ -126,7 +126,7 @@ describe("BUNDLER ACTIONS", () => { const response = await smartAccountClient.sendTransaction({ to: zeroAddress, - value: 0n + value: BigInt(0) }) }, 100000) @@ -230,7 +230,7 @@ describe("BUNDLER ACTIONS", () => { userOperation: { callData: await simpleAccountClient.account.encodeCallData({ to: zeroAddress, - value: 0n, + value: BigInt(0), data: "0x" }) } diff --git a/packages/permissionless-test/ep-0.7/utils.ts b/packages/permissionless-test/ep-0.7/utils.ts index e28c5518..38787407 100644 --- a/packages/permissionless-test/ep-0.7/utils.ts +++ b/packages/permissionless-test/ep-0.7/utils.ts @@ -87,7 +87,7 @@ export const getTestingChain = () => { export const getSignerToSimpleSmartAccount = async ({ signer = privateKeyToAccount(process.env.TEST_PRIVATE_KEY as Hex), address, - index = 0n + index = BigInt(0) }: { signer?: SmartAccountSigner address?: Address @@ -141,7 +141,7 @@ export const getSignerToSafeSmartAccount = async (args?: { entryPoint: getEntryPoint(), signer: signer, safeVersion: "1.4.1", - saltNonce: args?.saltNonce ?? 100n, + saltNonce: args?.saltNonce ?? BigInt(100), setupTransactions: args?.setupTransactions }) } @@ -150,7 +150,7 @@ export const getSmartAccountClient = async ({ account, middleware, preFund = false, - index = 0n + index = BigInt(0) }: Middleware & { account?: SmartAccount preFund?: boolean @@ -308,7 +308,7 @@ export const refillSmartAccount = async ( ) => { const publicClient = getPublicClient() const balance = await publicClient.getBalance({ address }) - if (balance === 0n) { + if (balance === BigInt(0)) { await walletClient.sendTransaction({ to: address, value: parseEther("1") diff --git a/packages/permissionless-test/ep-0.7/walletClientToCustomSigner.test.ts b/packages/permissionless-test/ep-0.7/walletClientToCustomSigner.test.ts index 5ebe93b0..902d41e6 100644 --- a/packages/permissionless-test/ep-0.7/walletClientToCustomSigner.test.ts +++ b/packages/permissionless-test/ep-0.7/walletClientToCustomSigner.test.ts @@ -74,7 +74,7 @@ describe("Simple Account from walletClient", () => { await expect(async () => simpleSmartAccount.signTransaction({ to: zeroAddress, - value: 0n, + value: BigInt(0), data: "0x" }) ).rejects.toThrow(new SignTransactionNotSupportedBySmartAccount()) @@ -161,12 +161,12 @@ describe("Simple Account from walletClient", () => { transactions: [ { to: zeroAddress, - value: 0n, + value: BigInt(0), data: "0x" }, { to: zeroAddress, - value: 0n, + value: BigInt(0), data: "0x" } ] @@ -205,7 +205,7 @@ describe("Simple Account from walletClient", () => { const txHash = await entryPointContract.write.depositTo( [smartAccountClient.account.address], { - value: 10n + value: BigInt(10) } ) @@ -231,7 +231,7 @@ describe("Simple Account from walletClient", () => { ) const response = await smartAccountClient.sendTransaction({ to: zeroAddress, - value: 0n, + value: BigInt(0), data: "0x" }) expectTypeOf(response).toBeString() @@ -257,7 +257,7 @@ describe("Simple Account from walletClient", () => { const response = await smartAccountClient.sendTransaction({ to: zeroAddress, - value: 0n, + value: BigInt(0), data: "0x" }) @@ -313,12 +313,12 @@ describe("Simple Account from walletClient", () => { transactions: [ { to: zeroAddress, - value: 0n, + value: BigInt(0), data: "0x" }, { to: zeroAddress, - value: 0n, + value: BigInt(0), data: "0x" } ] diff --git a/packages/permissionless-test/src/constants.ts b/packages/permissionless-test/src/constants.ts index efcaae29..3fe2fa31 100644 --- a/packages/permissionless-test/src/constants.ts +++ b/packages/permissionless-test/src/constants.ts @@ -19,7 +19,7 @@ export let forkBlockNumber: bigint if (process.env.VITE_ANVIL_BLOCK_NUMBER) { forkBlockNumber = BigInt(Number(process.env.VITE_ANVIL_BLOCK_NUMBER)) } else { - forkBlockNumber = 10419392n + forkBlockNumber = BigInt(10419392) warn( `\`VITE_ANVIL_BLOCK_NUMBER\` not found. Falling back to \`${forkBlockNumber}\`.` ) diff --git a/packages/permissionless-test/src/opStack.ts b/packages/permissionless-test/src/opStack.ts index 1a282d27..44b7ea82 100644 --- a/packages/permissionless-test/src/opStack.ts +++ b/packages/permissionless-test/src/opStack.ts @@ -16,7 +16,7 @@ if (process.env.VITE_ANVIL_BLOCK_NUMBER_OPTIMISM) { Number(process.env.VITE_ANVIL_BLOCK_NUMBER_OPTIMISM) ) } else { - forkBlockNumberOptimism = 115197387n + forkBlockNumberOptimism = BigInt(115197387) warn( `\`VITE_ANVIL_BLOCK_NUMBER_OPTIMISM\` not found. Falling back to \`${forkBlockNumberOptimism}\`.` ) diff --git a/packages/permissionless/accounts/biconomy/signerToBiconomySmartAccount.ts b/packages/permissionless/accounts/biconomy/signerToBiconomySmartAccount.ts index 48c7db83..86c748ca 100644 --- a/packages/permissionless/accounts/biconomy/signerToBiconomySmartAccount.ts +++ b/packages/permissionless/accounts/biconomy/signerToBiconomySmartAccount.ts @@ -135,7 +135,7 @@ const getAccountAddress = async ({ fallbackHandlerAddress, ecdsaModuleAddress, owner, - index = 0n + index = BigInt(0) }: { factoryAddress: Address accountLogicAddress: Address @@ -219,7 +219,7 @@ export async function signerToBiconomySmartAccount< signer, address, entryPoint: entryPointAddress, - index = 0n, + index = BigInt(0), factoryAddress = BICONOMY_ADDRESSES.FACTORY_ADDRESS, accountLogicAddress = BICONOMY_ADDRESSES.ACCOUNT_V2_0_LOGIC, fallbackHandlerAddress = BICONOMY_ADDRESSES.DEFAULT_FALLBACK_HANDLER_ADDRESS, diff --git a/packages/permissionless/accounts/kernel/signerToEcdsaKernelSmartAccount.ts b/packages/permissionless/accounts/kernel/signerToEcdsaKernelSmartAccount.ts index 6b4f9a3f..f2c37ac7 100644 --- a/packages/permissionless/accounts/kernel/signerToEcdsaKernelSmartAccount.ts +++ b/packages/permissionless/accounts/kernel/signerToEcdsaKernelSmartAccount.ts @@ -237,7 +237,7 @@ export async function signerToEcdsaKernelSmartAccount< signer, address, entryPoint: entryPointAddress, - index = 0n, + index = BigInt(0), factoryAddress = KERNEL_ADDRESSES.FACTORY_ADDRESS, accountLogicAddress = KERNEL_ADDRESSES.ACCOUNT_V2_2_LOGIC, ecdsaValidatorAddress = KERNEL_ADDRESSES.ECDSA_VALIDATOR, diff --git a/packages/permissionless/accounts/safe/signerToSafeSmartAccount.ts b/packages/permissionless/accounts/safe/signerToSafeSmartAccount.ts index 6025720d..7dc228fc 100644 --- a/packages/permissionless/accounts/safe/signerToSafeSmartAccount.ts +++ b/packages/permissionless/accounts/safe/signerToSafeSmartAccount.ts @@ -268,7 +268,7 @@ const getInitializerCode = async ({ functionName: "enableModules", args: [[safe4337ModuleAddress, ...safeModules]] }), - value: 0n, + value: BigInt(0), operation: 1 }, ...setupTransactions.map((tx) => ({ ...tx, operation: 0 as 0 | 1 })) @@ -328,12 +328,12 @@ const getInitializerCode = async ({ functionName: "setup", args: [ [owner], - 1n, + BigInt(1), multiSendAddress, multiSendCallData, safe4337ModuleAddress, zeroAddress, - 0n, + BigInt(0), zeroAddress ] }) @@ -345,15 +345,21 @@ function getPaymasterAndData(unpackedUserOperation: UserOperation<"v0.7">) { unpackedUserOperation.paymaster, pad( toHex( - unpackedUserOperation.paymasterVerificationGasLimit || 0n + unpackedUserOperation.paymasterVerificationGasLimit || + BigInt(0) + ), + { + size: 16 + } + ), + pad( + toHex( + unpackedUserOperation.paymasterPostOpGasLimit || BigInt(0) ), { size: 16 } ), - pad(toHex(unpackedUserOperation.paymasterPostOpGasLimit || 0n), { - size: 16 - }), unpackedUserOperation.paymasterData || ("0x" as Hex) ]) : "0x" @@ -365,7 +371,7 @@ const getAccountInitCode = async ({ safe4337ModuleAddress, safeSingletonAddress, multiSendAddress, - saltNonce = 0n, + saltNonce = BigInt(0), setupTransactions = [], safeModules = [] }: { @@ -444,7 +450,7 @@ const getAccountAddress = async < multiSendAddress, setupTransactions = [], safeModules = [], - saltNonce = 0n + saltNonce = BigInt(0) }: { client: Client owner: Address @@ -621,7 +627,7 @@ export async function signerToSafeSmartAccount< safeSingletonAddress: _safeSingletonAddress, multiSendAddress: _multiSendAddress, multiSendCallOnlyAddress: _multiSendCallOnlyAddress, - saltNonce = 0n, + saltNonce = BigInt(0), validUntil = 0, validAfter = 0, safeModules = [], @@ -869,7 +875,7 @@ export async function signerToSafeSmartAccount< }[] to = multiSendCallOnlyAddress - value = 0n + value = BigInt(0) data = encodeMultiSend( argsArray.map((tx) => ({ ...tx, operation: 0 })) diff --git a/packages/permissionless/accounts/simple/signerToSimpleSmartAccount.ts b/packages/permissionless/accounts/simple/signerToSimpleSmartAccount.ts index e1c62cc2..2018abb2 100644 --- a/packages/permissionless/accounts/simple/signerToSimpleSmartAccount.ts +++ b/packages/permissionless/accounts/simple/signerToSimpleSmartAccount.ts @@ -33,7 +33,10 @@ export type SimpleSmartAccount< chain extends Chain | undefined = Chain | undefined > = SmartAccount -const getAccountInitCode = async (owner: Address, index = 0n): Promise => { +const getAccountInitCode = async ( + owner: Address, + index = BigInt(0) +): Promise => { if (!owner) throw new Error("Owner account not found") return encodeFunctionData({ @@ -77,7 +80,7 @@ const getAccountAddress = async < factoryAddress, entryPoint: entryPointAddress, owner, - index = 0n + index = BigInt(0) }: { client: Client factoryAddress: Address @@ -133,7 +136,7 @@ export async function signerToSimpleSmartAccount< signer, factoryAddress, entryPoint: entryPointAddress, - index = 0n, + index = BigInt(0), address }: SignerToSimpleSmartAccountParameters ): Promise> { diff --git a/packages/permissionless/actions/smartAccount/deployContract.ts b/packages/permissionless/actions/smartAccount/deployContract.ts index 840cb307..315654c1 100644 --- a/packages/permissionless/actions/smartAccount/deployContract.ts +++ b/packages/permissionless/actions/smartAccount/deployContract.ts @@ -88,8 +88,8 @@ export async function deployContract< )({ userOperation: { sender: account.address, - maxFeePerGas: request.maxFeePerGas || 0n, - maxPriorityFeePerGas: request.maxPriorityFeePerGas || 0n, + maxFeePerGas: request.maxFeePerGas || BigInt(0), + maxPriorityFeePerGas: request.maxPriorityFeePerGas || BigInt(0), callData: await account.encodeDeployCallData({ abi, bytecode, diff --git a/packages/permissionless/actions/smartAccount/prepareUserOperationRequest.ts b/packages/permissionless/actions/smartAccount/prepareUserOperationRequest.ts index 60394773..a370ec1c 100644 --- a/packages/permissionless/actions/smartAccount/prepareUserOperationRequest.ts +++ b/packages/permissionless/actions/smartAccount/prepareUserOperationRequest.ts @@ -137,11 +137,13 @@ async function prepareUserOperationRequestForEntryPointV06< callData, paymasterAndData: "0x", signature: partialUserOperation.signature || "0x", - maxFeePerGas: partialUserOperation.maxFeePerGas || 0n, - maxPriorityFeePerGas: partialUserOperation.maxPriorityFeePerGas || 0n, - callGasLimit: partialUserOperation.callGasLimit || 0n, - verificationGasLimit: partialUserOperation.verificationGasLimit || 0n, - preVerificationGas: partialUserOperation.preVerificationGas || 0n + maxFeePerGas: partialUserOperation.maxFeePerGas || BigInt(0), + maxPriorityFeePerGas: + partialUserOperation.maxPriorityFeePerGas || BigInt(0), + callGasLimit: partialUserOperation.callGasLimit || BigInt(0), + verificationGasLimit: + partialUserOperation.verificationGasLimit || BigInt(0), + preVerificationGas: partialUserOperation.preVerificationGas || BigInt(0) } if (userOperation.signature === "0x") { @@ -273,17 +275,19 @@ async function prepareUserOperationRequestEntryPointV07< factory: factory, factoryData: factoryData, callData, - callGasLimit: partialUserOperation.callGasLimit || 0n, - verificationGasLimit: partialUserOperation.verificationGasLimit || 0n, - preVerificationGas: partialUserOperation.preVerificationGas || 0n, + callGasLimit: partialUserOperation.callGasLimit || BigInt(0), + verificationGasLimit: + partialUserOperation.verificationGasLimit || BigInt(0), + preVerificationGas: + partialUserOperation.preVerificationGas || BigInt(0), maxFeePerGas: partialUserOperation.maxFeePerGas || gasEstimation?.maxFeePerGas || - 0n, + BigInt(0), maxPriorityFeePerGas: partialUserOperation.maxPriorityFeePerGas || gasEstimation?.maxPriorityFeePerGas || - 0n, + BigInt(0), signature: partialUserOperation.signature || "0x" } diff --git a/packages/permissionless/actions/smartAccount/sendTransaction.ts b/packages/permissionless/actions/smartAccount/sendTransaction.ts index 9972672c..dd15f0dc 100644 --- a/packages/permissionless/actions/smartAccount/sendTransaction.ts +++ b/packages/permissionless/actions/smartAccount/sendTransaction.ts @@ -113,7 +113,7 @@ export async function sendTransaction< const callData = await account.encodeCallData({ to, - value: value || 0n, + value: value || BigInt(0), data: data || "0x" }) @@ -123,8 +123,8 @@ export async function sendTransaction< )({ userOperation: { sender: account.address, - maxFeePerGas: maxFeePerGas || 0n, - maxPriorityFeePerGas: maxPriorityFeePerGas || 0n, + maxFeePerGas: maxFeePerGas || BigInt(0), + maxPriorityFeePerGas: maxPriorityFeePerGas || BigInt(0), callData: callData, nonce: nonce ? BigInt(nonce) : undefined }, diff --git a/packages/permissionless/actions/smartAccount/sendTransactions.ts b/packages/permissionless/actions/smartAccount/sendTransactions.ts index f9318e8f..1955f404 100644 --- a/packages/permissionless/actions/smartAccount/sendTransactions.ts +++ b/packages/permissionless/actions/smartAccount/sendTransactions.ts @@ -112,7 +112,7 @@ export async function sendTransactions< if (!to) throw new Error("Missing to address") return { to, - value: value || 0n, + value: value || BigInt(0), data: data || "0x" } }) @@ -124,8 +124,8 @@ export async function sendTransactions< )({ userOperation: { sender: account.address, - maxFeePerGas: maxFeePerGas || 0n, - maxPriorityFeePerGas: maxPriorityFeePerGas || 0n, + maxFeePerGas: maxFeePerGas || BigInt(0), + maxPriorityFeePerGas: maxPriorityFeePerGas || BigInt(0), callData: callData, nonce: nonce }, diff --git a/packages/permissionless/actions/smartAccount/signTypedData.ts b/packages/permissionless/actions/smartAccount/signTypedData.ts index 76bf6f0b..bc7e07fa 100644 --- a/packages/permissionless/actions/smartAccount/signTypedData.ts +++ b/packages/permissionless/actions/smartAccount/signTypedData.ts @@ -9,7 +9,7 @@ import { getTypesForEIP712Domain, validateTypedData } from "viem" -import { type SmartAccount } from "../../accounts/types" +import type { SmartAccount } from "../../accounts/types" import type { EntryPoint } from "../../types/entrypoint" import { AccountOrClientNotFoundError, parseAccount } from "../../utils/" diff --git a/packages/permissionless/errors/account.ts b/packages/permissionless/errors/account.ts index 1aee91a6..629f7d45 100644 --- a/packages/permissionless/errors/account.ts +++ b/packages/permissionless/errors/account.ts @@ -323,7 +323,7 @@ export class InvalidSmartAccountNonceError extends BaseError { docsPath?: string nonce: bigint }) { - const nonceKey = nonce >> 64n // first 192 bits of nonce + const nonceKey = nonce >> BigInt(64) // first 192 bits of nonce const nonceSequence = nonce & 0xffffffffffffffffn // last 64 bits of nonce super( diff --git a/packages/permissionless/utils/getPackedUserOperation.ts b/packages/permissionless/utils/getPackedUserOperation.ts index 9b94d03b..241cebde 100644 --- a/packages/permissionless/utils/getPackedUserOperation.ts +++ b/packages/permissionless/utils/getPackedUserOperation.ts @@ -66,15 +66,21 @@ export function getPaymasterAndData( unpackedUserOperation.paymaster, pad( toHex( - unpackedUserOperation.paymasterVerificationGasLimit || 0n + unpackedUserOperation.paymasterVerificationGasLimit || + BigInt(0) + ), + { + size: 16 + } + ), + pad( + toHex( + unpackedUserOperation.paymasterPostOpGasLimit || BigInt(0) ), { size: 16 } ), - pad(toHex(unpackedUserOperation.paymasterPostOpGasLimit || 0n), { - size: 16 - }), unpackedUserOperation.paymasterData || ("0x" as Hex) ]) : "0x" diff --git a/packages/permissionless/utils/getRequiredPrefund.ts b/packages/permissionless/utils/getRequiredPrefund.ts index 7357f934..e60ed0f1 100644 --- a/packages/permissionless/utils/getRequiredPrefund.ts +++ b/packages/permissionless/utils/getRequiredPrefund.ts @@ -27,7 +27,9 @@ export const getRequiredPrefund = ({ if (entryPointAddress === ENTRYPOINT_ADDRESS_V06) { const userOperationVersion0_6 = userOperation as UserOperation<"v0.6"> const multiplier = - userOperationVersion0_6.paymasterAndData.length > 2 ? 3n : 1n + userOperationVersion0_6.paymasterAndData.length > 2 + ? BigInt(3) + : BigInt(1) const requiredGas = userOperationVersion0_6.callGasLimit + userOperationVersion0_6.verificationGasLimit * multiplier + @@ -39,12 +41,12 @@ export const getRequiredPrefund = ({ } const userOperationV07 = userOperation as UserOperation<"v0.7"> - const multiplier = userOperationV07.paymaster ? 3n : 1n + const multiplier = userOperationV07.paymaster ? BigInt(3) : BigInt(1) const verificationGasLimit = userOperationV07.verificationGasLimit + - (userOperationV07.paymasterPostOpGasLimit || 0n) + - (userOperationV07.paymasterVerificationGasLimit || 0n) + (userOperationV07.paymasterPostOpGasLimit || BigInt(0)) + + (userOperationV07.paymasterVerificationGasLimit || BigInt(0)) const requiredGas = userOperationV07.callGasLimit + diff --git a/packages/permissionless/utils/getUserOperationHash.ts b/packages/permissionless/utils/getUserOperationHash.ts index 68d88ef2..de3ea6e2 100644 --- a/packages/permissionless/utils/getUserOperationHash.ts +++ b/packages/permissionless/utils/getUserOperationHash.ts @@ -55,14 +55,20 @@ function packUserOp({ ? concat([ userOperation.paymaster, pad( - toHex(userOperation.paymasterVerificationGasLimit || 0n), + toHex( + userOperation.paymasterVerificationGasLimit || + BigInt(0) + ), + { + size: 16 + } + ), + pad( + toHex(userOperation.paymasterPostOpGasLimit || BigInt(0)), { size: 16 } ), - pad(toHex(userOperation.paymasterPostOpGasLimit || 0n), { - size: 16 - }), userOperation.paymasterData || "0x" ]) : "0x" From 8652af7665f15e77e65cb62682dd36d8acecc204 Mon Sep 17 00:00:00 2001 From: Garvit Khatri Date: Thu, 11 Apr 2024 20:31:35 +0530 Subject: [PATCH 2/2] add changeset --- .changeset/chilly-insects-sneeze.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/chilly-insects-sneeze.md diff --git a/.changeset/chilly-insects-sneeze.md b/.changeset/chilly-insects-sneeze.md new file mode 100644 index 00000000..b9024afa --- /dev/null +++ b/.changeset/chilly-insects-sneeze.md @@ -0,0 +1,5 @@ +--- +"permissionless": patch +--- + +Fixed use of BigInt literals for targeting lower than ES2020