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 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" ,
Original file line number Diff line number Diff line change 1- import { BigNumberish , BytesLike , ethers } from "ethers" ;
1+ import { BigNumberish , ethers } from "ethers" ;
22import { OpToJSON } from "../../utils" ;
33import { 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-
2714export 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 ,
You can’t perform that action at this time.
0 commit comments