diff --git a/ethers-core/src/types/block.rs b/ethers-core/src/types/block.rs index c738ac99..cfe9d179 100644 --- a/ethers-core/src/types/block.rs +++ b/ethers-core/src/types/block.rs @@ -222,6 +222,16 @@ pub enum BlockNumber { Number(U64), } +impl BlockNumber { + /// Returns the numeric block number if explicitly set + pub fn as_number(&self) -> Option { + match *self { + BlockNumber::Number(num) => Some(num), + _ => None, + } + } +} + impl> From for BlockNumber { fn from(num: T) -> Self { BlockNumber::Number(num.into())