Skip to content
This repository was archived by the owner on Oct 20, 2024. It is now read-only.

Commit ef1a5fc

Browse files
authored
Remove redundant estimateCreationGas from gasLimit middleware (#102)
1 parent 2018000 commit ef1a5fc

File tree

2 files changed

+2
-21
lines changed

2 files changed

+2
-21
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "userop",
3-
"version": "0.3.2",
3+
"version": "0.3.3",
44
"description": "A simple JS library for building ERC-4337 UserOperations.",
55
"types": "./dist/index.d.ts",
66
"main": "./dist/index.js",

src/preset/middleware/gasLimit.ts

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BigNumberish, BytesLike, ethers } from "ethers";
1+
import { BigNumberish, ethers } from "ethers";
22
import { OpToJSON } from "../../utils";
33
import { UserOperationMiddlewareFn } from "../../types";
44

@@ -11,28 +11,9 @@ interface GasEstimate {
1111
verificationGas: BigNumberish;
1212
}
1313

14-
const estimateCreationGas = async (
15-
provider: ethers.providers.JsonRpcProvider,
16-
initCode: BytesLike
17-
): Promise<ethers.BigNumber> => {
18-
const initCodeHex = ethers.utils.hexlify(initCode);
19-
const factory = initCodeHex.substring(0, 42);
20-
const callData = "0x" + initCodeHex.substring(42);
21-
return await provider.estimateGas({
22-
to: factory,
23-
data: callData,
24-
});
25-
};
26-
2714
export const estimateUserOperationGas =
2815
(provider: ethers.providers.JsonRpcProvider): UserOperationMiddlewareFn =>
2916
async (ctx) => {
30-
if (ethers.BigNumber.from(ctx.op.nonce).isZero()) {
31-
ctx.op.verificationGasLimit = ethers.BigNumber.from(
32-
ctx.op.verificationGasLimit
33-
).add(await estimateCreationGas(provider, ctx.op.initCode));
34-
}
35-
3617
const est = (await provider.send("eth_estimateUserOperationGas", [
3718
OpToJSON(ctx.op),
3819
ctx.entryPoint,

0 commit comments

Comments
 (0)