This repository was archived by the owner on Oct 20, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +2
-21
lines changed Expand file tree Collapse file tree 2 files changed +2
-21
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " userop" ,
3
- "version" : " 0.3.2 " ,
3
+ "version" : " 0.3.3 " ,
4
4
"description" : " A simple JS library for building ERC-4337 UserOperations." ,
5
5
"types" : " ./dist/index.d.ts" ,
6
6
"main" : " ./dist/index.js" ,
Original file line number Diff line number Diff line change 1
- import { BigNumberish , BytesLike , ethers } from "ethers" ;
1
+ import { BigNumberish , ethers } from "ethers" ;
2
2
import { OpToJSON } from "../../utils" ;
3
3
import { UserOperationMiddlewareFn } from "../../types" ;
4
4
@@ -11,28 +11,9 @@ interface GasEstimate {
11
11
verificationGas : BigNumberish ;
12
12
}
13
13
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
-
27
14
export const estimateUserOperationGas =
28
15
( provider : ethers . providers . JsonRpcProvider ) : UserOperationMiddlewareFn =>
29
16
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
-
36
17
const est = ( await provider . send ( "eth_estimateUserOperationGas" , [
37
18
OpToJSON ( ctx . op ) ,
38
19
ctx . entryPoint ,
You can’t perform that action at this time.
0 commit comments