Skip to content

Commit ca85eb2

Browse files
prestwichEvalir
authored andcommitted
feat: TryFrom impl for known chains on relevant types (#97)
1 parent 3af31bc commit ca85eb2

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

crates/constants/src/types/environment.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ impl SignetEnvironmentConstants {
5151

5252
impl TryFrom<KnownChains> for SignetEnvironmentConstants {
5353
type Error = ParseChainError;
54+
<<<<<<< HEAD
5455

5556
fn try_from(chain: KnownChains) -> Result<Self, Self::Error> {
5657
match chain {
@@ -61,6 +62,22 @@ impl TryFrom<KnownChains> for SignetEnvironmentConstants {
6162
}
6263
}
6364

65+
impl FromStr for SignetEnvironmentConstants {
66+
type Err = ParseChainError;
67+
68+
fn from_str(s: &str) -> Result<Self, Self::Err> {
69+
s.parse::<KnownChains>()?.try_into()
70+
=======
71+
72+
fn try_from(chain: KnownChains) -> Result<Self, Self::Error> {
73+
match chain {
74+
#[cfg(any(test, feature = "test-utils"))]
75+
KnownChains::Test => Ok(Self::test()),
76+
}
77+
>>>>>>> 0dd5b37 (feat: TryFrom impl for known chains on relevant types (#97))
78+
}
79+
}
80+
6481
impl FromStr for SignetEnvironmentConstants {
6582
type Err = ParseChainError;
6683

crates/constants/src/types/mod.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ impl SignetSystemConstants {
223223

224224
impl TryFrom<KnownChains> for SignetSystemConstants {
225225
type Error = ParseChainError;
226+
<<<<<<< HEAD
226227

227228
fn try_from(chain: KnownChains) -> Result<Self, Self::Error> {
228229
match chain {
@@ -233,6 +234,22 @@ impl TryFrom<KnownChains> for SignetSystemConstants {
233234
}
234235
}
235236

237+
impl FromStr for SignetSystemConstants {
238+
type Err = ParseChainError;
239+
240+
fn from_str(s: &str) -> Result<Self, Self::Err> {
241+
s.parse::<KnownChains>()?.try_into()
242+
=======
243+
244+
fn try_from(chain: KnownChains) -> Result<Self, Self::Error> {
245+
match chain {
246+
#[cfg(any(test, feature = "test-utils"))]
247+
KnownChains::Test => Ok(Self::test()),
248+
}
249+
>>>>>>> 0dd5b37 (feat: TryFrom impl for known chains on relevant types (#97))
250+
}
251+
}
252+
236253
impl FromStr for SignetSystemConstants {
237254
type Err = ParseChainError;
238255

0 commit comments

Comments
 (0)