@@ -69,34 +69,38 @@ const handlePmSponsor = async ({
6969} ) => {
7070 const is06 = entryPoint === entryPoint06Address ;
7171
72- let op = {
72+ let sponsoredUserOp = {
7373 ...userOperation ,
7474 ...getDummyPaymasterData ( { is06, paymaster, paymasterMode } ) ,
7575 } as UserOperation ;
7676
77+ // User provided gasLimits
7778 const callGasLimit = userOperation . callGasLimit ;
7879 const verificationGasLimit = userOperation . verificationGasLimit ;
7980 const preVerificationGas = userOperation . preVerificationGas ;
8081
8182 if ( estimateGas ) {
8283 try {
8384 const gasEstimates = await bundler . estimateUserOperationGas ( {
84- ...op ,
85+ ...sponsoredUserOp ,
8586 entryPointAddress : entryPoint ,
8687 } ) ;
8788
88- op = {
89- ...op ,
89+ sponsoredUserOp = {
90+ ...sponsoredUserOp ,
9091 ...gasEstimates ,
9192 } as UserOperation ;
9293
93- op . callGasLimit = maxBigInt ( op . callGasLimit , callGasLimit ) ;
94- op . preVerificationGas = maxBigInt (
95- op . preVerificationGas ,
94+ sponsoredUserOp . callGasLimit = maxBigInt (
95+ gasEstimates . callGasLimit ,
96+ callGasLimit ,
97+ ) ;
98+ sponsoredUserOp . preVerificationGas = maxBigInt (
99+ gasEstimates . preVerificationGas ,
96100 preVerificationGas ,
97101 ) ;
98- op . verificationGasLimit = maxBigInt (
99- op . verificationGasLimit ,
102+ sponsoredUserOp . verificationGasLimit = maxBigInt (
103+ gasEstimates . verificationGasLimit ,
100104 verificationGasLimit ,
101105 ) ;
102106 } catch ( e : unknown ) {
@@ -116,15 +120,19 @@ const handlePmSponsor = async ({
116120 }
117121
118122 const result = {
119- preVerificationGas : toHex ( op . preVerificationGas ) ,
120- callGasLimit : toHex ( op . callGasLimit ) ,
121- paymasterVerificationGasLimit : toHex ( op . paymasterVerificationGasLimit || 0 ) ,
122- paymasterPostOpGasLimit : toHex ( op . paymasterPostOpGasLimit || 0 ) ,
123- verificationGasLimit : toHex ( op . verificationGasLimit || 0 ) ,
123+ preVerificationGas : toHex ( sponsoredUserOp . preVerificationGas ) ,
124+ callGasLimit : toHex ( sponsoredUserOp . callGasLimit ) ,
125+ paymasterVerificationGasLimit : toHex (
126+ sponsoredUserOp . paymasterVerificationGasLimit || 0 ,
127+ ) ,
128+ paymasterPostOpGasLimit : toHex (
129+ sponsoredUserOp . paymasterPostOpGasLimit || 0 ,
130+ ) ,
131+ verificationGasLimit : toHex ( sponsoredUserOp . verificationGasLimit || 0 ) ,
124132 ...( await getSignedPaymasterData ( {
125133 publicClient,
126134 signer : paymasterSigner ,
127- userOp : userOperation ,
135+ userOp : sponsoredUserOp ,
128136 paymaster,
129137 paymasterMode,
130138 } ) ) ,
0 commit comments