Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make undefined check #310

Merged
merged 7 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/wild-files-whisper.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 @@ -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"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ describe.each(getCoreSmartAccounts())(
)

testWithRpc.skipIf(!supportsEntryPointV07)(
"prepareUserOperationForErc20Paymaster_v07",
"prepareUserOperationForErc20Paymaster_v07 (balanceOverride enabled)",
async ({ rpc }) => {
const { anvilRpc } = rpc

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
12 changes: 6 additions & 6 deletions packages/permissionless/utils/erc20AllowanceOverride.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}

Expand Down
8 changes: 4 additions & 4 deletions packages/permissionless/utils/erc20BalanceOverride.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}

Expand Down
Loading