From 4fd9c7800ee9afd5395d8c7b8652d788b9e80f35 Mon Sep 17 00:00:00 2001 From: Meet Mangukiya Date: Tue, 1 Mar 2022 02:28:04 +0530 Subject: [PATCH] feat(ethers-core/Chain): implement Default trait (#976) --- ethers-core/src/types/chain.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ethers-core/src/types/chain.rs b/ethers-core/src/types/chain.rs index 66facef5..01da44d4 100644 --- a/ethers-core/src/types/chain.rs +++ b/ethers-core/src/types/chain.rs @@ -2,7 +2,7 @@ use serde::Deserialize; use thiserror::Error; use core::convert::TryFrom; -use std::{fmt, str::FromStr}; +use std::{default, fmt, str::FromStr}; use crate::types::U256; @@ -177,3 +177,14 @@ impl Chain { ) } } + +impl default::Default for Chain { + fn default() -> Self { + Chain::Mainnet + } +} + +#[test] +fn test_default_chain() { + assert_eq!(Chain::default(), Chain::Mainnet); +}