File tree Expand file tree Collapse file tree 3 files changed +13
-6
lines changed
crates/starknet-types-core/src Expand file tree Collapse file tree 3 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,13 @@ use crate::{
2424) ]
2525pub struct ContractAddress ( PatriciaKey ) ;
2626
27+ impl ContractAddress {
28+ pub const ZERO : Self = Self :: from_hex_unchecked ( "0x0" ) ;
29+ pub const ONE : Self = Self :: from_hex_unchecked ( "0x1" ) ;
30+ pub const TWO : Self = Self :: from_hex_unchecked ( "0x2" ) ;
31+ pub const THREE : Self = Self :: from_hex_unchecked ( "0x3" ) ;
32+ }
33+
2734impl core:: fmt:: Display for ContractAddress {
2835 fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
2936 write ! ( f, "{}" , self . 0 )
@@ -84,10 +91,10 @@ impl FromStr for ContractAddress {
8491}
8592
8693impl ContractAddress {
87- pub const fn from_hex_unwrap ( s : & ' static str ) -> ContractAddress {
88- let felt = PatriciaKey :: from_hex_unwrap ( s) ;
94+ pub const fn from_hex_unchecked ( s : & ' static str ) -> ContractAddress {
95+ let patricia_key = PatriciaKey :: from_hex_unchecked ( s) ;
8996
90- ContractAddress ( felt )
97+ ContractAddress ( patricia_key )
9198 }
9299}
93100
Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ impl FromStr for PatriciaKey {
102102}
103103
104104impl PatriciaKey {
105- pub const fn from_hex_unwrap ( s : & ' static str ) -> PatriciaKey {
105+ pub const fn from_hex_unchecked ( s : & ' static str ) -> PatriciaKey {
106106 let felt = Felt :: from_hex_unwrap ( s) ;
107107
108108 PatriciaKey ( felt)
Original file line number Diff line number Diff line change @@ -218,8 +218,8 @@ impl FromStr for RegularContractAddress {
218218}
219219
220220impl RegularContractAddress {
221- pub const fn from_hex_unwrap ( s : & ' static str ) -> RegularContractAddress {
222- let contract_address = ContractAddress :: from_hex_unwrap ( s) ;
221+ pub const fn from_hex_unchecked ( s : & ' static str ) -> RegularContractAddress {
222+ let contract_address = ContractAddress :: from_hex_unchecked ( s) ;
223223
224224 RegularContractAddress ( contract_address)
225225 }
You can’t perform that action at this time.
0 commit comments