Skip to content

Commit 719fd27

Browse files
committed
primitives - impl FromStr for ValidatorId
1 parent 1cc7a5f commit 719fd27

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

primitives/src/validator.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use serde::{Deserialize, Serialize};
2-
use std::{convert::TryFrom, fmt};
2+
use std::{convert::TryFrom, fmt, str::FromStr};
33

44
use crate::{targeting::Value, Address, BigNum, DomainError, ToETHChecksum, ToHex};
55

@@ -57,6 +57,14 @@ impl AsRef<[u8]> for ValidatorId {
5757
}
5858
}
5959

60+
impl FromStr for ValidatorId {
61+
type Err = crate::address::Error;
62+
63+
fn from_str(s: &str) -> Result<Self, Self::Err> {
64+
Address::try_from(s).map(Self)
65+
}
66+
}
67+
6068
impl TryFrom<&str> for ValidatorId {
6169
type Error = DomainError;
6270
fn try_from(value: &str) -> Result<Self, Self::Error> {
@@ -98,8 +106,7 @@ pub struct ValidatorDesc {
98106
pub fee: BigNum,
99107
}
100108

101-
// Validator Message Types
102-
109+
/// Validator Message Types
103110
pub mod messages {
104111
use std::{any::type_name, convert::TryFrom, fmt, marker::PhantomData};
105112
use thiserror::Error;

0 commit comments

Comments
 (0)