From 3d2e7ab63b086f8c123f80eaaaf38d41bc0c2387 Mon Sep 17 00:00:00 2001 From: mouseless <97399882+mouseless-eth@users.noreply.github.com> Date: Thu, 24 Oct 2024 16:36:51 +0100 Subject: [PATCH 1/7] make undefined check --- .../pimlico/utils/prepareUserOperationForErc20Paymaster.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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( From 5775efaad35a4816571878eef7bf76196f96c95a Mon Sep 17 00:00:00 2001 From: mouseless <97399882+mouseless-eth@users.noreply.github.com> Date: Thu, 24 Oct 2024 16:39:25 +0100 Subject: [PATCH 2/7] add changeset --- .changeset/wild-files-whisper.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/wild-files-whisper.md diff --git a/.changeset/wild-files-whisper.md b/.changeset/wild-files-whisper.md new file mode 100644 index 00000000..7448a226 --- /dev/null +++ b/.changeset/wild-files-whisper.md @@ -0,0 +1,5 @@ +--- +"permissionless": patch +--- + +Handle case when slot overrides returned from pimlico_getTokenQuotes are zero From 5605f545e7fed90a60ec427e6dd65662f20d8542 Mon Sep 17 00:00:00 2001 From: Garvit Khatri Date: Thu, 24 Oct 2024 21:10:57 +0530 Subject: [PATCH 3/7] Update wild-files-whisper.md --- .changeset/wild-files-whisper.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/wild-files-whisper.md b/.changeset/wild-files-whisper.md index 7448a226..a2ee9a49 100644 --- a/.changeset/wild-files-whisper.md +++ b/.changeset/wild-files-whisper.md @@ -2,4 +2,4 @@ "permissionless": patch --- -Handle case when slot overrides returned from pimlico_getTokenQuotes are zero +Fixed when slot overrides returned from pimlico_getTokenQuotes are zero From 34ddc589df00a32078bbc3cea071e471ad2c170d Mon Sep 17 00:00:00 2001 From: mouseless <97399882+mouseless-eth@users.noreply.github.com> Date: Thu, 24 Oct 2024 17:14:23 +0100 Subject: [PATCH 4/7] fix failing tests --- .../permissionless-test/mock-aa-infra/mock-paymaster/relay.ts | 4 ++++ .../utils/prepareUserOperationForErc20Paymaster.test.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) 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 From fe4e2e430ff362eb2df2c02569057f02054ba30d Mon Sep 17 00:00:00 2001 From: mouseless <97399882+mouseless-eth@users.noreply.github.com> Date: Thu, 24 Oct 2024 18:31:00 +0100 Subject: [PATCH 5/7] fix failing test --- .../permissionless/utils/erc20BalanceOverride.test.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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) } From f79e133d83523bc1ed397a00090a123f8f6e7e00 Mon Sep 17 00:00:00 2001 From: mouseless <97399882+mouseless-eth@users.noreply.github.com> Date: Thu, 24 Oct 2024 18:38:19 +0100 Subject: [PATCH 6/7] fix failing tests --- .../permissionless/utils/erc20AllowanceOverride.test.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/permissionless/utils/erc20AllowanceOverride.test.ts b/packages/permissionless/utils/erc20AllowanceOverride.test.ts index a1bdc7eb..f68ffa91 100644 --- a/packages/permissionless/utils/erc20AllowanceOverride.test.ts +++ b/packages/permissionless/utils/erc20AllowanceOverride.test.ts @@ -8,8 +8,8 @@ import { describe("erc20AllowanceOverride", () => { test("should return the correct structure for valid inputs", () => { const params = { - token: "0xTokenAddress", - owner: "0xOwnerAddress", + token: "0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF", + owner: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", spender: "0xSpenderAddress", slot: BigInt(1), amount: BigInt(100) @@ -32,8 +32,8 @@ describe("erc20AllowanceOverride", () => { test("should use the default amount when none is provided", () => { const params: Erc20AllowanceOverrideParameters = { - token: "0xTokenAddress", - owner: "0xOwnerAddress", + token: "0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF", + owner: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", spender: "0xSpenderAddress", slot: BigInt(1) } From 7287f4e8fb2314d6025cda7c3e7a9dc068b339fc Mon Sep 17 00:00:00 2001 From: mouseless <97399882+mouseless-eth@users.noreply.github.com> Date: Thu, 24 Oct 2024 19:54:08 +0100 Subject: [PATCH 7/7] fix failing tests --- packages/permissionless/utils/erc20AllowanceOverride.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/permissionless/utils/erc20AllowanceOverride.test.ts b/packages/permissionless/utils/erc20AllowanceOverride.test.ts index f68ffa91..d5343bf9 100644 --- a/packages/permissionless/utils/erc20AllowanceOverride.test.ts +++ b/packages/permissionless/utils/erc20AllowanceOverride.test.ts @@ -10,7 +10,7 @@ describe("erc20AllowanceOverride", () => { const params = { token: "0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF", owner: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", - spender: "0xSpenderAddress", + spender: "0xDDdDddDdDdddDDddDDddDDDDdDdDDdDDdDDDDDDd", slot: BigInt(1), amount: BigInt(100) } as const @@ -34,7 +34,7 @@ describe("erc20AllowanceOverride", () => { const params: Erc20AllowanceOverrideParameters = { token: "0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF", owner: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", - spender: "0xSpenderAddress", + spender: "0xDDdDddDdDdddDDddDDddDDDDdDdDDdDDdDDDDDDd", slot: BigInt(1) }