@@ -681,13 +681,16 @@ impl TupleNextStore<
681681 }
682682}
683683
684+ const RESULT_OK_INDICATOR : felt252 = 0 ;
685+ const RESULT_ERR_INDICATOR : felt252 = 1 ;
686+
684687impl ResultStore <T , E , + Store <T >, + Store <E >, + Drop <T >, + Drop <E >> of Store <Result <T , E >> {
685688 #[inline]
686689 fn read (address_domain : u32 , base : StorageBaseAddress ) -> SyscallResult <Result <T , E >> {
687690 let idx = Store :: <felt252 >:: read (address_domain , base )? ;
688- if idx == 0 {
691+ if idx == RESULT_OK_INDICATOR {
689692 starknet :: SyscallResult :: Ok (Ok (Store :: read_at_offset (address_domain , base , 1_u8 )? ))
690- } else if idx == 1 {
693+ } else if idx == RESULT_ERR_INDICATOR {
691694 starknet :: SyscallResult :: Ok (Err (Store :: read_at_offset (address_domain , base , 1_u8 )? ))
692695 } else {
693696 starknet :: SyscallResult :: Err (array! [' Incorrect index:' ])
@@ -700,11 +703,11 @@ impl ResultStore<T, E, +Store<T>, +Store<E>, +Drop<T>, +Drop<E>> of Store<Result
700703 ) -> SyscallResult <()> {
701704 match value {
702705 Ok (x ) => {
703- Store :: write (address_domain , base , 0 )? ;
706+ Store :: write (address_domain , base , RESULT_OK_INDICATOR )? ;
704707 Store :: write_at_offset (address_domain , base , 1_u8 , x )? ;
705708 },
706709 Err (x ) => {
707- Store :: write (address_domain , base , 1 )? ;
710+ Store :: write (address_domain , base , RESULT_ERR_INDICATOR )? ;
708711 Store :: write_at_offset (address_domain , base , 1_u8 , x )? ;
709712 },
710713 }
@@ -716,11 +719,11 @@ impl ResultStore<T, E, +Store<T>, +Store<E>, +Drop<T>, +Drop<E>> of Store<Result
716719 address_domain : u32 , base : StorageBaseAddress , offset : u8 ,
717720 ) -> SyscallResult <Result <T , E >> {
718721 let idx = Store :: <felt252 >:: read_at_offset (address_domain , base , offset )? ;
719- if idx == 0 {
722+ if idx == RESULT_OK_INDICATOR {
720723 starknet :: SyscallResult :: Ok (
721724 Ok (Store :: read_at_offset (address_domain , base , offset + 1_u8 )? ),
722725 )
723- } else if idx == 1 {
726+ } else if idx == RESULT_ERR_INDICATOR {
724727 starknet :: SyscallResult :: Ok (
725728 Err (Store :: read_at_offset (address_domain , base , offset + 1_u8 )? ),
726729 )
@@ -735,11 +738,11 @@ impl ResultStore<T, E, +Store<T>, +Store<E>, +Drop<T>, +Drop<E>> of Store<Result
735738 ) -> SyscallResult <()> {
736739 match value {
737740 Ok (x ) => {
738- Store :: write_at_offset (address_domain , base , offset , 0 )? ;
741+ Store :: write_at_offset (address_domain , base , offset , RESULT_OK_INDICATOR )? ;
739742 Store :: write_at_offset (address_domain , base , offset + 1_u8 , x )? ;
740743 },
741744 Err (x ) => {
742- Store :: write_at_offset (address_domain , base , offset , 0 )? ;
745+ Store :: write_at_offset (address_domain , base , offset , RESULT_ERR_INDICATOR )? ;
743746 Store :: write_at_offset (address_domain , base , offset + 1_u8 , x )? ;
744747 },
745748 }
@@ -752,13 +755,16 @@ impl ResultStore<T, E, +Store<T>, +Store<E>, +Drop<T>, +Drop<E>> of Store<Result
752755 }
753756}
754757
758+ const OPTION_NONE_INDICATOR : felt252 = 0 ;
759+ const OPTION_SOME_INDICATOR : felt252 = 1 ;
760+
755761impl OptionStore <T , + Store <T >, + Drop <T >> of Store <Option <T >> {
756762 #[inline]
757763 fn read (address_domain : u32 , base : StorageBaseAddress ) -> SyscallResult <Option <T >> {
758764 let idx = Store :: <felt252 >:: read (address_domain , base )? ;
759- if idx == 1 {
765+ if idx == OPTION_SOME_INDICATOR {
760766 starknet :: SyscallResult :: Ok (Some (Store :: read_at_offset (address_domain , base , 1_u8 )? ))
761- } else if idx == 0 {
767+ } else if idx == OPTION_NONE_INDICATOR {
762768 starknet :: SyscallResult :: Ok (None )
763769 } else {
764770 starknet :: SyscallResult :: Err (array! [' Incorrect index:' ])
@@ -769,10 +775,10 @@ impl OptionStore<T, +Store<T>, +Drop<T>> of Store<Option<T>> {
769775 fn write (address_domain : u32 , base : StorageBaseAddress , value : Option <T >) -> SyscallResult <()> {
770776 match value {
771777 Some (x ) => {
772- Store :: write (address_domain , base , 1 )? ;
778+ Store :: write (address_domain , base , OPTION_SOME_INDICATOR )? ;
773779 Store :: write_at_offset (address_domain , base , 1_u8 , x )? ;
774780 },
775- None (_ ) => { Store :: write (address_domain , base , 0 )? ; },
781+ None (_ ) => { Store :: write (address_domain , base , OPTION_NONE_INDICATOR )? ; },
776782 }
777783 starknet :: SyscallResult :: Ok (())
778784 }
@@ -782,11 +788,11 @@ impl OptionStore<T, +Store<T>, +Drop<T>> of Store<Option<T>> {
782788 address_domain : u32 , base : StorageBaseAddress , offset : u8 ,
783789 ) -> SyscallResult <Option <T >> {
784790 let idx = Store :: <felt252 >:: read_at_offset (address_domain , base , offset )? ;
785- if idx == 1 {
791+ if idx == OPTION_SOME_INDICATOR {
786792 starknet :: SyscallResult :: Ok (
787793 Some (Store :: read_at_offset (address_domain , base , offset + 1_u8 )? ),
788794 )
789- } else if idx == 0 {
795+ } else if idx == OPTION_NONE_INDICATOR {
790796 starknet :: SyscallResult :: Ok (None )
791797 } else {
792798 starknet :: SyscallResult :: Err (array! [' Incorrect index:' ])
@@ -799,10 +805,12 @@ impl OptionStore<T, +Store<T>, +Drop<T>> of Store<Option<T>> {
799805 ) -> SyscallResult <()> {
800806 match value {
801807 Some (x ) => {
802- Store :: write_at_offset (address_domain , base , offset , 1 )? ;
808+ Store :: write_at_offset (address_domain , base , offset , OPTION_SOME_INDICATOR )? ;
803809 Store :: write_at_offset (address_domain , base , offset + 1_u8 , x )? ;
804810 },
805- None (_x ) => { Store :: write_at_offset (address_domain , base , offset , 0 )? ; },
811+ None (_x ) => {
812+ Store :: write_at_offset (address_domain , base , offset , OPTION_NONE_INDICATOR )? ;
813+ },
806814 }
807815 starknet :: SyscallResult :: Ok (())
808816 }
0 commit comments