File tree Expand file tree Collapse file tree 3 files changed +11
-3
lines changed
starknet_os/src/hints/hint_implementation/block_hash Expand file tree Collapse file tree 3 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ use strum_macros::EnumIter;
1414use time:: OffsetDateTime ;
1515
1616use crate :: core:: {
17+ ascii_as_felt,
1718 ContractAddress ,
1819 EventCommitment ,
1920 GlobalRoot ,
@@ -166,6 +167,14 @@ impl TryFrom<&str> for StarknetVersion {
166167 }
167168}
168169
170+ impl TryFrom < & StarknetVersion > for Felt {
171+ type Error = StarknetApiError ;
172+
173+ fn try_from ( starknet_version : & StarknetVersion ) -> Result < Self , Self :: Error > {
174+ ascii_as_felt ( & starknet_version. to_string ( ) )
175+ }
176+ }
177+
169178impl Serialize for StarknetVersion {
170179 fn serialize < S > (
171180 & self ,
Original file line number Diff line number Diff line change @@ -162,7 +162,7 @@ pub fn calculate_block_hash(
162162 . iter ( ) ,
163163 )
164164 . chain (
165- & ascii_as_felt ( & partial_block_hash_components. starknet_version . to_string ( ) )
165+ & Felt :: try_from ( & partial_block_hash_components. starknet_version )
166166 . expect ( "Expect ASCII version" ) ,
167167 )
168168 . chain ( & Felt :: ZERO )
Original file line number Diff line number Diff line change @@ -24,7 +24,6 @@ use starknet_api::block_hash::block_hash_calculator::{
2424 STARKNET_BLOCK_HASH1 ,
2525} ;
2626use starknet_api:: core:: {
27- ascii_as_felt,
2827 EventCommitment ,
2928 GlobalRoot ,
3029 ReceiptCommitment ,
@@ -109,7 +108,7 @@ fn cairo_calculate_block_hash(
109108 EndpointArg :: from( gas_prices_hash) ,
110109 EndpointArg :: from( state_root) ,
111110 EndpointArg :: from( parent_hash) ,
112- EndpointArg :: from( ascii_as_felt ( & components. starknet_version. to_string ( ) ) . unwrap( ) ) ,
111+ EndpointArg :: from( Felt :: try_from ( & components. starknet_version) . unwrap( ) ) ,
113112 ] ;
114113
115114 // We expect one felt as return value (block_hash).
You can’t perform that action at this time.
0 commit comments