@@ -10,6 +10,7 @@ use cairo_vm::hint_processor::builtin_hint_processor::hint_utils::{
10
10
} ;
11
11
use cairo_vm:: hint_processor:: hint_processor_utils:: felt_to_usize;
12
12
use cairo_vm:: types:: relocatable:: MaybeRelocatable ;
13
+ use starknet_types_core:: felt:: Felt ;
13
14
14
15
use crate :: hints:: error:: { OsHintError , OsHintResult } ;
15
16
use crate :: hints:: types:: HintArgs ;
@@ -27,8 +28,28 @@ pub(crate) fn selected_builtins<S: StateReader>(
27
28
Ok ( ( ) )
28
29
}
29
30
30
- pub ( crate ) fn select_builtin < S : StateReader > ( HintArgs { .. } : HintArgs < ' _ , ' _ , S > ) -> OsHintResult {
31
- todo ! ( )
31
+ pub ( crate ) fn select_builtin < S : StateReader > (
32
+ HintArgs { exec_scopes, vm, ids_data, ap_tracking, .. } : HintArgs < ' _ , ' _ , S > ,
33
+ ) -> OsHintResult {
34
+ let n_selected_builtins: Felt = exec_scopes. get ( Scope :: NSelectedBuiltins . into ( ) ) ?;
35
+ let selected_encodings_ptr =
36
+ get_ptr_from_var_name ( Ids :: SelectedEncodings . into ( ) , vm, ids_data, ap_tracking) ?;
37
+ let all_encodings_ptr =
38
+ get_ptr_from_var_name ( Ids :: AllEncodings . into ( ) , vm, ids_data, ap_tracking) ?;
39
+ let select_builtin = n_selected_builtins != Felt :: ZERO // Equivalent to n_selected_builtins > 0.
40
+ && vm. get_integer ( selected_encodings_ptr) ? == vm. get_integer ( all_encodings_ptr) ?;
41
+ if select_builtin {
42
+ exec_scopes. insert_value ( Scope :: NSelectedBuiltins . into ( ) , n_selected_builtins - Felt :: ONE ) ;
43
+ }
44
+ insert_value_from_var_name (
45
+ Ids :: NSelectedBuiltins . into ( ) ,
46
+ Felt :: from ( select_builtin) ,
47
+ vm,
48
+ ids_data,
49
+ ap_tracking,
50
+ ) ?;
51
+
52
+ Ok ( ( ) )
32
53
}
33
54
34
55
/// Update subsets of the pointer at 'builtin_ptrs' with the pointers at 'selected_ptrs' according
0 commit comments