feat: impl Serialize for Chain (#1917)
* feat: impl Serialize for Chain * fix: add deps
This commit is contained in:
parent
d6fea13d23
commit
3bf9025d2f
|
@ -1,5 +1,5 @@
|
||||||
use super::U256;
|
use super::U256;
|
||||||
use serde::Deserialize;
|
use serde::{Deserialize, Serialize, Serializer};
|
||||||
use std::{
|
use std::{
|
||||||
convert::{TryFrom, TryInto},
|
convert::{TryFrom, TryInto},
|
||||||
fmt,
|
fmt,
|
||||||
|
@ -260,6 +260,15 @@ impl FromStr for Chain {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Serialize for Chain {
|
||||||
|
fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
|
||||||
|
where
|
||||||
|
S: Serializer,
|
||||||
|
{
|
||||||
|
s.serialize_str(self.to_string().as_ref())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Chain {
|
impl Chain {
|
||||||
/// The blocktime varies from chain to chain.
|
/// The blocktime varies from chain to chain.
|
||||||
///
|
///
|
||||||
|
@ -438,5 +447,5 @@ impl Chain {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_default_chain() {
|
fn test_default_chain() {
|
||||||
assert_eq!(Chain::default(), Chain::Mainnet);
|
assert_eq!(serde_json::to_string(&Chain::Mainnet).unwrap(), "\"mainnet\"");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue