diff --git a/.changeset/wild-files-whisper.md b/.changeset/wild-files-whisper.md new file mode 100644 index 00000000..a2ee9a49 --- /dev/null +++ b/.changeset/wild-files-whisper.md @@ -0,0 +1,5 @@ +--- +"permissionless": patch +--- + +Fixed when slot overrides returned from pimlico_getTokenQuotes are zero diff --git a/packages/permissionless-test/mock-aa-infra/mock-paymaster/relay.ts b/packages/permissionless-test/mock-aa-infra/mock-paymaster/relay.ts index 2d7c55ce..cfbd64b6 100644 --- a/packages/permissionless-test/mock-aa-infra/mock-paymaster/relay.ts +++ b/packages/permissionless-test/mock-aa-infra/mock-paymaster/relay.ts @@ -333,11 +333,15 @@ const handleMethod = async ( [getAddress("0xffffffffffffffffffffffffffffffffffffffff")]: { exchangeRateNativeToUsd: "0x1a2b3c4d5e6f7890abcdef", exchangeRate: "0x3a7b9c8d6e5f4321", + balanceSlot: "0x0", + allowanceSlot: "0x1", postOpGas: "0x1a2b3c" }, [ERC20_ADDRESS]: { exchangeRateNativeToUsd: "0x5cc717fbb3450c0000000", exchangeRate: "0x5cc717fbb3450c0000", + balanceSlot: "0x5", + allowanceSlot: "0x0", postOpGas: "0xc350" } } diff --git a/packages/permissionless/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.test.ts b/packages/permissionless/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.test.ts index 54bfc051..6583b108 100644 --- a/packages/permissionless/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.test.ts +++ b/packages/permissionless/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.test.ts @@ -193,7 +193,7 @@ describe.each(getCoreSmartAccounts())( ) testWithRpc.skipIf(!supportsEntryPointV07)( - "prepareUserOperationForErc20Paymaster_v07", + "prepareUserOperationForErc20Paymaster_v07 (balanceOverride enabled)", async ({ rpc }) => { const { anvilRpc } = rpc diff --git a/packages/permissionless/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.ts b/packages/permissionless/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.ts index 60c304c0..2d153ff9 100644 --- a/packages/permissionless/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.ts +++ b/packages/permissionless/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.ts @@ -145,7 +145,8 @@ export const prepareUserOperationForErc20Paymaster = const allowanceSlot = _allowanceSlot ?? quotes[0].allowanceSlot const balanceSlot = _balanceSlot ?? quotes[0].balanceSlot - const hasSlot = allowanceSlot && balanceSlot + const hasSlot = + allowanceSlot !== undefined && balanceSlot !== undefined if (!hasSlot && balanceOverride) { throw new Error( diff --git a/packages/permissionless/utils/erc20AllowanceOverride.test.ts b/packages/permissionless/utils/erc20AllowanceOverride.test.ts index a1bdc7eb..d5343bf9 100644 --- a/packages/permissionless/utils/erc20AllowanceOverride.test.ts +++ b/packages/permissionless/utils/erc20AllowanceOverride.test.ts @@ -8,9 +8,9 @@ import { describe("erc20AllowanceOverride", () => { test("should return the correct structure for valid inputs", () => { const params = { - token: "0xTokenAddress", - owner: "0xOwnerAddress", - spender: "0xSpenderAddress", + token: "0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF", + owner: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", + spender: "0xDDdDddDdDdddDDddDDddDDDDdDdDDdDDdDDDDDDd", slot: BigInt(1), amount: BigInt(100) } as const @@ -32,9 +32,9 @@ describe("erc20AllowanceOverride", () => { test("should use the default amount when none is provided", () => { const params: Erc20AllowanceOverrideParameters = { - token: "0xTokenAddress", - owner: "0xOwnerAddress", - spender: "0xSpenderAddress", + token: "0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF", + owner: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", + spender: "0xDDdDddDdDdddDDddDDddDDDDdDdDDdDDdDDDDDDd", slot: BigInt(1) } diff --git a/packages/permissionless/utils/erc20BalanceOverride.test.ts b/packages/permissionless/utils/erc20BalanceOverride.test.ts index 2262b5c4..c486de91 100644 --- a/packages/permissionless/utils/erc20BalanceOverride.test.ts +++ b/packages/permissionless/utils/erc20BalanceOverride.test.ts @@ -8,8 +8,8 @@ import { describe("erc20BalanceOverride", () => { test("should return the correct structure for valid inputs", () => { const params = { - token: "0xTokenAddress", - owner: "0xOwnerAddress", + token: "0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF", + owner: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", slot: BigInt(1), balance: BigInt(1000) } as const @@ -31,8 +31,8 @@ describe("erc20BalanceOverride", () => { test("should use the default balance when none is provided", () => { const params: Erc20BalanceOverrideParameters = { - token: "0xTokenAddress", - owner: "0xOwnerAddress", + token: "0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF", + owner: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", slot: BigInt(1) }