From 8319ee6c42575c3ac8f122c8dac7c8127362d5ed Mon Sep 17 00:00:00 2001 From: mouseless <97399882+mouseless-eth@users.noreply.github.com> Date: Fri, 25 Oct 2024 16:18:03 +0100 Subject: [PATCH 1/2] make undefined check on allowance and balance slots --- .../utils/prepareUserOperationForErc20Paymaster.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/permissionless/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.ts b/packages/permissionless/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.ts index 2d153ff9..51597912 100644 --- a/packages/permissionless/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.ts +++ b/packages/permissionless/experimental/pimlico/utils/prepareUserOperationForErc20Paymaster.ts @@ -138,15 +138,16 @@ export const prepareUserOperationForErc20Paymaster = } //////////////////////////////////////////////////////////////////////////////// - // Call prepareUserOperation //////////////////////////////////////////////////////////////////////////////// const allowanceSlot = _allowanceSlot ?? quotes[0].allowanceSlot const balanceSlot = _balanceSlot ?? quotes[0].balanceSlot - const hasSlot = - allowanceSlot !== undefined && balanceSlot !== undefined + const hasAllowanceSlot = allowanceSlot !== undefined + const hasBalanceSlot = balanceSlot !== undefined + + const hasSlot = hasAllowanceSlot && hasBalanceSlot if (!hasSlot && balanceOverride) { throw new Error( @@ -155,7 +156,7 @@ export const prepareUserOperationForErc20Paymaster = } const balanceStateOverride = - balanceOverride && balanceSlot + balanceOverride && hasBalanceSlot ? erc20BalanceOverride({ token, owner: account.address, @@ -164,7 +165,7 @@ export const prepareUserOperationForErc20Paymaster = : undefined const allowanceStateOverride = - balanceOverride && allowanceSlot + balanceOverride && hasAllowanceSlot ? erc20AllowanceOverride({ token, owner: account.address, From 25ee9a9c56a99bd3aa5bc0b079e478e3617be542 Mon Sep 17 00:00:00 2001 From: mouseless <97399882+mouseless-eth@users.noreply.github.com> Date: Fri, 25 Oct 2024 16:20:17 +0100 Subject: [PATCH 2/2] add changeset --- .changeset/small-horses-sniff.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/small-horses-sniff.md diff --git a/.changeset/small-horses-sniff.md b/.changeset/small-horses-sniff.md new file mode 100644 index 00000000..a2ee9a49 --- /dev/null +++ b/.changeset/small-horses-sniff.md @@ -0,0 +1,5 @@ +--- +"permissionless": patch +--- + +Fixed when slot overrides returned from pimlico_getTokenQuotes are zero