From 4f631cc77334d725ab680bfe79c0b166c20e1d9a Mon Sep 17 00:00:00 2001 From: evalir Date: Sat, 11 Nov 2023 04:30:37 -0400 Subject: [PATCH] feat(`rpc-types`): from U64 for `BlockHashOrNumber` and `BlockId` (#5385) Co-authored-by: Matthias Seitz --- crates/rpc/rpc-types/src/eth/block.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/rpc/rpc-types/src/eth/block.rs b/crates/rpc/rpc-types/src/eth/block.rs index c4522c7844..985e93e24f 100644 --- a/crates/rpc/rpc-types/src/eth/block.rs +++ b/crates/rpc/rpc-types/src/eth/block.rs @@ -410,6 +410,12 @@ impl From for BlockId { } } +impl From for BlockId { + fn from(value: U64) -> Self { + BlockNumberOrTag::Number(value.to()).into() + } +} + impl From for BlockId { fn from(num: BlockNumberOrTag) -> Self { BlockId::Number(num) @@ -622,6 +628,12 @@ impl From for BlockHashOrNumber { } } +impl From for BlockHashOrNumber { + fn from(value: U64) -> Self { + value.to::().into() + } +} + /// Allows for RLP encoding of either a block hash or block number impl Encodable for BlockHashOrNumber { fn encode(&self, out: &mut dyn bytes::BufMut) {