@@ -40,6 +40,7 @@ use cairo_vm::{
40
40
relocatable:: { MaybeRelocatable , Relocatable } ,
41
41
} ,
42
42
vm:: {
43
+ errors:: runner_errors:: RunnerError ,
43
44
runners:: cairo_runner:: { CairoArg , CairoRunner , ExecutionResources , RunResources } ,
44
45
vm_core:: VirtualMachine ,
45
46
} ,
@@ -469,24 +470,24 @@ impl ExecutionEntryPoint {
469
470
470
471
/// Returns the hash of the executed contract class.
471
472
fn get_code_class_hash < S : State > ( & self , state : & mut S ) -> Result < [ u8 ; 32 ] , TransactionError > {
472
- if self . class_hash . is_some ( ) {
473
+ if let Some ( class_hash ) = self . class_hash {
473
474
match self . call_type {
474
- CallType :: Delegate => return Ok ( self . class_hash . unwrap ( ) ) ,
475
+ CallType :: Delegate => return Ok ( class_hash) ,
475
476
_ => return Err ( TransactionError :: CallTypeIsNotDelegate ) ,
476
477
}
477
478
}
478
479
let code_address = match self . call_type {
479
- CallType :: Call => Some ( self . contract_address . clone ( ) ) ,
480
+ CallType :: Call => & self . contract_address ,
480
481
CallType :: Delegate => {
481
- if self . code_address . is_some ( ) {
482
- self . code_address . clone ( )
482
+ if let Some ( ref code_address ) = self . code_address {
483
+ code_address
483
484
} else {
484
485
return Err ( TransactionError :: AttempToUseNoneCodeAddress ) ;
485
486
}
486
487
}
487
488
} ;
488
489
489
- get_deployed_address_class_hash_at_address ( state, & code_address. unwrap ( ) )
490
+ get_deployed_address_class_hash_at_address ( state, code_address)
490
491
}
491
492
492
493
fn _execute_version0_class < S : StateReader > (
@@ -653,7 +654,6 @@ impl ExecutionEntryPoint {
653
654
) ;
654
655
let mut runner = StarknetRunner :: new ( cairo_runner, vm, hint_processor) ;
655
656
656
- // TODO: handle error cases
657
657
// Load builtin costs
658
658
let builtin_costs: Vec < MaybeRelocatable > =
659
659
vec ! [ 0 . into( ) , 0 . into( ) , 0 . into( ) , 0 . into( ) , 0 . into( ) ] ;
@@ -664,14 +664,16 @@ impl ExecutionEntryPoint {
664
664
. into ( ) ;
665
665
666
666
// Load extra data
667
- let core_program_end_ptr =
668
- ( runner. cairo_runner . program_base . unwrap ( ) + program. data_len ( ) ) . unwrap ( ) ;
667
+ let core_program_end_ptr = ( runner
668
+ . cairo_runner
669
+ . program_base
670
+ . ok_or ( RunnerError :: NoProgBase ) ?
671
+ + program. data_len ( ) ) ?;
669
672
let program_extra_data: Vec < MaybeRelocatable > =
670
673
vec ! [ 0x208B7FFF7FFF7FFE . into( ) , builtin_costs_ptr] ;
671
674
runner
672
675
. vm
673
- . load_data ( core_program_end_ptr, & program_extra_data)
674
- . unwrap ( ) ;
676
+ . load_data ( core_program_end_ptr, & program_extra_data) ?;
675
677
676
678
// Positional arguments are passed to *args in the 'run_from_entrypoint' function.
677
679
let data = self . calldata . iter ( ) . map ( |d| d. into ( ) ) . collect ( ) ;
@@ -687,7 +689,7 @@ impl ExecutionEntryPoint {
687
689
. collect ( ) ;
688
690
entrypoint_args. push ( CairoArg :: Single ( alloc_pointer. clone ( ) ) ) ;
689
691
entrypoint_args. push ( CairoArg :: Single (
690
- alloc_pointer. add_usize ( self . calldata . len ( ) ) . unwrap ( ) ,
692
+ alloc_pointer. add_usize ( self . calldata . len ( ) ) ? ,
691
693
) ) ;
692
694
693
695
let ref_vec: Vec < & CairoArg > = entrypoint_args. iter ( ) . collect ( ) ;
@@ -711,11 +713,11 @@ impl ExecutionEntryPoint {
711
713
. get_initial_fp ( )
712
714
. ok_or ( TransactionError :: MissingInitialFp ) ?;
713
715
714
- let args_ptr = initial_fp - ( entrypoint_args. len ( ) + 2 ) ;
716
+ let args_ptr = ( initial_fp - ( entrypoint_args. len ( ) + 2 ) ) ? ;
715
717
716
718
runner
717
719
. vm
718
- . mark_address_range_as_accessed ( args_ptr. unwrap ( ) , entrypoint_args. len ( ) ) ?;
720
+ . mark_address_range_as_accessed ( args_ptr, entrypoint_args. len ( ) ) ?;
719
721
720
722
* resources_manager = runner
721
723
. hint_processor
0 commit comments