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 ,
@@ -162,6 +163,14 @@ impl TryFrom<&str> for StarknetVersion {
162163 }
163164}
164165
166+ impl TryFrom < & StarknetVersion > for Felt {
167+ type Error = StarknetApiError ;
168+
169+ fn try_from ( starknet_version : & StarknetVersion ) -> Result < Self , Self :: Error > {
170+ ascii_as_felt ( & starknet_version. to_string ( ) )
171+ }
172+ }
173+
165174impl Serialize for StarknetVersion {
166175 fn serialize < S > (
167176 & self ,
Original file line number Diff line number Diff line change @@ -161,7 +161,7 @@ pub fn calculate_block_hash(
161161 . iter ( ) ,
162162 )
163163 . chain (
164- & ascii_as_felt ( & partial_block_hash_components. starknet_version . to_string ( ) )
164+ & Felt :: try_from ( & partial_block_hash_components. starknet_version )
165165 . expect ( "Expect ASCII version" ) ,
166166 )
167167 . 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_GAS_PRICES0 ,
2525} ;
2626use starknet_api:: core:: {
27- ascii_as_felt,
2827 EventCommitment ,
2928 GlobalRoot ,
3029 ReceiptCommitment ,
@@ -111,7 +110,7 @@ fn cairo_calculate_block_hash(
111110 EndpointArg :: from( gas_prices_hash) ,
112111 EndpointArg :: from( state_root) ,
113112 EndpointArg :: from( parent_hash) ,
114- EndpointArg :: from( ascii_as_felt ( & components. starknet_version. to_string ( ) ) . unwrap( ) ) ,
113+ EndpointArg :: from( Felt :: try_from ( & components. starknet_version) . unwrap( ) ) ,
115114 ] ;
116115
117116 // We expect one felt as return value (block_hash).
You can’t perform that action at this time.
0 commit comments