@@ -262,30 +262,36 @@ impl Declare {
262
262
Ok ( ( ) )
263
263
}
264
264
265
- /// Calculates actual fee used by the transaction using the execution
266
- /// info returned by apply(), then updates the transaction execution info with the data of the fee.
267
- pub fn execute < S : State + StateReader > (
265
+ fn set_contract_class < S : State + StateReader > (
268
266
& self ,
269
267
state : & mut S ,
270
- block_context : & BlockContext ,
271
- ) -> Result < TransactionExecutionInfo , TransactionError > {
272
- let mut tx_exec_info = self . apply ( state, block_context) ?;
273
- self . handle_nonce ( state) ?;
274
- // Set contract class
268
+ ) -> Result < ( ) , TransactionError > {
275
269
match state. get_contract_class ( & self . class_hash ) {
276
270
Err ( StateError :: NoneCompiledHash ( _) ) => {
277
271
// Class is undeclared; declare it.
278
272
state. set_contract_class ( & self . class_hash , & self . contract_class ) ?;
273
+ Ok ( ( ) )
279
274
}
280
- Err ( error) => return Err ( error. into ( ) ) ,
275
+ Err ( error) => Err ( error. into ( ) ) ,
281
276
Ok ( _) => {
282
277
// Class is already declared; cannot redeclare.
283
- return Err ( TransactionError :: ClassAlreadyDeclared ( self . class_hash ) ) ;
278
+ Err ( TransactionError :: ClassAlreadyDeclared ( self . class_hash ) )
284
279
}
285
280
}
281
+ }
282
+ /// Calculates actual fee used by the transaction using the execution
283
+ /// info returned by apply(), then updates the transaction execution info with the data of the fee.
284
+ pub fn execute < S : State + StateReader > (
285
+ & self ,
286
+ state : & mut S ,
287
+ block_context : & BlockContext ,
288
+ ) -> Result < TransactionExecutionInfo , TransactionError > {
289
+ let mut tx_exec_info = self . apply ( state, block_context) ?;
290
+ self . handle_nonce ( state) ?;
286
291
287
292
let ( fee_transfer_info, actual_fee) =
288
293
self . charge_fee ( state, & tx_exec_info. actual_resources , block_context) ?;
294
+ self . set_contract_class ( state) ?;
289
295
tx_exec_info. set_fee_info ( actual_fee, fee_transfer_info) ;
290
296
291
297
Ok ( tx_exec_info)
0 commit comments