Skip to content

Commit

Permalink
fix: alchemy paymaster 0x override was not awaiting gas estimates (#660)
Browse files Browse the repository at this point in the history
  • Loading branch information
moldy530 committed May 10, 2024
1 parent c23cb54 commit 51d31ff
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
17 changes: 13 additions & 4 deletions packages/alchemy/e2e-tests/light-account.e2e.test.ts
@@ -1,6 +1,8 @@
import {
LocalAccountSigner,
sepolia,
type UserOperationCallData,
type UserOperationOverrides,
type UserOperationStruct,
} from "@alchemy/aa-core";
import { Alchemy, Network } from "alchemy-sdk";
Expand Down Expand Up @@ -98,17 +100,24 @@ describe("Light Account Client Tests", () => {
},
});

const uoStruct = (await provider.buildUserOperation({
const toSend = {
uo: {
target: provider.getAddress(),
data: "0x",
},
} as UserOperationCallData,
overrides: {
paymasterAndData: "0x", // bypass paymaster
},
})) as UserOperationStruct<"0.6.0">;
} as UserOperationOverrides<"0.6.0">,
};
const uoStruct = (await provider.buildUserOperation(
toSend
)) as UserOperationStruct<"0.6.0">;

expect(uoStruct.paymasterAndData).toBe("0x");

await expect(
provider.sendUserOperation(toSend)
).resolves.not.toThrowError();
}, 100000);

it("should successfully override fees and gas when using paymaster", async () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/alchemy/src/middleware/gasManager.ts
Expand Up @@ -200,12 +200,12 @@ export function alchemyGasManagerMiddleware<C extends ClientWithAlchemyMethods>(
if (bypassPaymasterAndData(overrides)) {
return {
...struct,
...fallbackGasEstimator(struct, {
...(await fallbackGasEstimator(struct, {
overrides,
account,
feeOptions,
client,
}),
})),
};
}

Expand Down

0 comments on commit 51d31ff

Please sign in to comment.