Skip to content

Commit 0f3e898

Browse files
committed
rebase and rename method
1 parent 8d09db4 commit 0f3e898

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

crates/starknet-types-core/src/contract_address.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ use crate::{
2424
)]
2525
pub 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+
2734
impl 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

8693
impl 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

crates/starknet-types-core/src/patricia_key.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl FromStr for PatriciaKey {
102102
}
103103

104104
impl 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)

crates/starknet-types-core/src/regular_contract_address.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ impl FromStr for RegularContractAddress {
218218
}
219219

220220
impl 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
}

0 commit comments

Comments
 (0)