From c22dd8eab4c7e4c848446f80ec1dc0e4a8e76079 Mon Sep 17 00:00:00 2001 From: Tarrence van As Date: Thu, 27 Jan 2022 10:33:01 -0800 Subject: [PATCH] feat(types/chain): is_legacy helper (#835) moving this into ethers-rs from foundry so it can be more easily use elsewhere --- ethers-core/src/types/chain.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ethers-core/src/types/chain.rs b/ethers-core/src/types/chain.rs index 49fc1f81..4f70e107 100644 --- a/ethers-core/src/types/chain.rs +++ b/ethers-core/src/types/chain.rs @@ -116,3 +116,15 @@ impl FromStr for Chain { }) } } + +impl Chain { + /// Helper function for checking if a chainid corresponds to a legacy chainid + /// without eip1559 + pub fn is_legacy(&self) -> bool { + // TODO: Add other chains which do not support EIP1559. + matches!( + self, + Chain::Optimism | Chain::OptimismKovan | Chain::Fantom | Chain::FantomTestnet + ) + } +}