@@ -399,12 +399,51 @@ impl StarknetSyscallHandler for &mut CheatableNativeSyscallHandler<'_> {
399
399
calldata : & [ Felt ] ,
400
400
remaining_gas : & mut u64 ,
401
401
) -> SyscallResult < Vec < Felt > > {
402
- self . native_syscall_handler . library_call (
403
- class_hash,
404
- function_selector,
405
- calldata,
402
+ self . pre_execute_syscall (
406
403
remaining_gas,
407
- )
404
+ self . native_syscall_handler
405
+ . gas_costs ( )
406
+ . syscalls
407
+ . library_call
408
+ . base_syscall_cost ( ) ,
409
+ SyscallSelector :: LibraryCall ,
410
+ ) ?;
411
+
412
+ let class_hash = ClassHash ( class_hash) ;
413
+
414
+ let wrapper_calldata = Calldata ( Arc :: new ( calldata. to_vec ( ) ) ) ;
415
+
416
+ let selector = EntryPointSelector ( function_selector) ;
417
+
418
+ let mut entry_point = CallEntryPoint {
419
+ class_hash : Some ( class_hash) ,
420
+ code_address : None ,
421
+ entry_point_type : EntryPointType :: External ,
422
+ entry_point_selector : selector,
423
+ calldata : wrapper_calldata,
424
+ // The call context remains the same in a library call.
425
+ storage_address : self . native_syscall_handler . base . call . storage_address ,
426
+ caller_address : self . native_syscall_handler . base . call . caller_address ,
427
+ call_type : CallType :: Delegate ,
428
+ initial_gas : * remaining_gas,
429
+ } ;
430
+
431
+ let error_wrapper_function =
432
+ |e : SyscallExecutionError ,
433
+ class_hash : ClassHash ,
434
+ storage_address : ContractAddress ,
435
+ selector : EntryPointSelector | {
436
+ e. as_lib_call_execution_error ( class_hash, storage_address, selector)
437
+ } ;
438
+
439
+ Ok ( self
440
+ . execute_inner_call (
441
+ & mut entry_point,
442
+ remaining_gas,
443
+ class_hash,
444
+ error_wrapper_function,
445
+ ) ?
446
+ . 0 )
408
447
}
409
448
410
449
fn call_contract (
0 commit comments