Skip to content

Commit

Permalink
Merge pull request #312 from pimlicolabs/fix/erc20-overrides
Browse files Browse the repository at this point in the history
Fix/erc20 overrides
  • Loading branch information
mouseless0x authored Oct 25, 2024
2 parents 5dce3a9 + 25ee9a9 commit ef3b889
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/small-horses-sniff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"permissionless": patch
---

Fixed when slot overrides returned from pimlico_getTokenQuotes are zero
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -155,7 +156,7 @@ export const prepareUserOperationForErc20Paymaster =
}

const balanceStateOverride =
balanceOverride && balanceSlot
balanceOverride && hasBalanceSlot
? erc20BalanceOverride({
token,
owner: account.address,
Expand All @@ -164,7 +165,7 @@ export const prepareUserOperationForErc20Paymaster =
: undefined

const allowanceStateOverride =
balanceOverride && allowanceSlot
balanceOverride && hasAllowanceSlot
? erc20AllowanceOverride({
token,
owner: account.address,
Expand Down

0 comments on commit ef3b889

Please sign in to comment.