@@ -151,58 +151,56 @@ func (op UserOperation) MarshalJSON() ([]byte, error) {
151
151
}
152
152
153
153
// UnmarshalJSON decodes a JSON encoding into a UserOperation.
154
- func UnmarshalJSON (data []byte ) ( * UserOperation , error ) {
154
+ func ( op * UserOperation ) UnmarshalJSON (data []byte ) error {
155
155
var uoDTO UserOperationDTO
156
156
if err := json .Unmarshal (data , & uoDTO ); err != nil {
157
- return nil , err
157
+ return err
158
158
}
159
159
160
- var op UserOperation
161
160
var err error
162
161
op .Sender = common .HexToAddress (uoDTO .Sender )
163
- fmt .Printf ("raw.Nonce: %s\n " , uoDTO .Nonce )
164
162
if nonceBI , ok := big .NewInt (0 ).SetString (uoDTO .Nonce , 0 ); ! ok {
165
- return nil , fmt .Errorf ("invalid nonce: %w" , err )
163
+ return fmt .Errorf ("invalid nonce: %w" , err )
166
164
} else {
167
165
op .Nonce = decimal .NewFromBigInt (nonceBI , 0 )
168
166
}
169
167
if op .InitCode , err = hexutil .Decode (uoDTO .InitCode ); err != nil {
170
- return nil , fmt .Errorf ("invalid initCode: %w" , err )
168
+ return fmt .Errorf ("invalid initCode: %w" , err )
171
169
}
172
170
if op .CallData , err = hexutil .Decode (uoDTO .CallData ); err != nil {
173
- return nil , fmt .Errorf ("invalid callData: %w" , err )
171
+ return fmt .Errorf ("invalid callData: %w" , err )
174
172
}
175
173
if callGasLimitBI , ok := new (big.Int ).SetString (uoDTO .CallGasLimit , 0 ); ! ok {
176
- return nil , fmt .Errorf ("invalid callGasLimit: %w" , err )
174
+ return fmt .Errorf ("invalid callGasLimit: %w" , err )
177
175
} else {
178
176
op .CallGasLimit = decimal .NewFromBigInt (callGasLimitBI , 0 )
179
177
}
180
178
if verificationGasLimitBI , ok := new (big.Int ).SetString (uoDTO .VerificationGasLimit , 0 ); ! ok {
181
- return nil , fmt .Errorf ("invalid verificationGasLimit: %w" , err )
179
+ return fmt .Errorf ("invalid verificationGasLimit: %w" , err )
182
180
} else {
183
181
op .VerificationGasLimit = decimal .NewFromBigInt (verificationGasLimitBI , 0 )
184
182
}
185
183
if preVerificationGasBI , ok := new (big.Int ).SetString (uoDTO .PreVerificationGas , 0 ); ! ok {
186
- return nil , fmt .Errorf ("invalid preVerificationGas: %w" , err )
184
+ return fmt .Errorf ("invalid preVerificationGas: %w" , err )
187
185
} else {
188
186
op .PreVerificationGas = decimal .NewFromBigInt (preVerificationGasBI , 0 )
189
187
}
190
188
if maxFeePerGasBI , ok := new (big.Int ).SetString (uoDTO .MaxFeePerGas , 0 ); ! ok {
191
- return nil , fmt .Errorf ("invalid maxFeePerGas: %w" , err )
189
+ return fmt .Errorf ("invalid maxFeePerGas: %w" , err )
192
190
} else {
193
191
op .MaxFeePerGas = decimal .NewFromBigInt (maxFeePerGasBI , 0 )
194
192
}
195
193
if maxPriorityFeePerGasBI , ok := new (big.Int ).SetString (uoDTO .MaxPriorityFeePerGas , 0 ); ! ok {
196
- return nil , fmt .Errorf ("invalid maxPriorityFeePerGas: %w" , err )
194
+ return fmt .Errorf ("invalid maxPriorityFeePerGas: %w" , err )
197
195
} else {
198
196
op .MaxPriorityFeePerGas = decimal .NewFromBigInt (maxPriorityFeePerGasBI , 0 )
199
197
}
200
198
if op .PaymasterAndData , err = hexutil .Decode (uoDTO .PaymasterAndData ); err != nil {
201
- return nil , fmt .Errorf ("invalid paymasterAndData: %w" , err )
199
+ return fmt .Errorf ("invalid paymasterAndData: %w" , err )
202
200
}
203
201
if op .Signature , err = hexutil .Decode (uoDTO .Signature ); err != nil {
204
- return nil , fmt .Errorf ("invalid signature: %w" , err )
202
+ return fmt .Errorf ("invalid signature: %w" , err )
205
203
}
206
204
207
- return & op , nil
205
+ return nil
208
206
}
0 commit comments