Skip to content

Commit

Permalink
feat(rpc-types): from U64 for BlockHashOrNumber and BlockId (#5385
Browse files Browse the repository at this point in the history
)

Co-authored-by: Matthias Seitz <[email protected]>
  • Loading branch information
Evalir and mattsse authored Nov 11, 2023
1 parent e8729dd commit 4f631cc
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions crates/rpc/rpc-types/src/eth/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,12 @@ impl From<u64> for BlockId {
}
}

impl From<U64> for BlockId {
fn from(value: U64) -> Self {
BlockNumberOrTag::Number(value.to()).into()
}
}

impl From<BlockNumberOrTag> for BlockId {
fn from(num: BlockNumberOrTag) -> Self {
BlockId::Number(num)
Expand Down Expand Up @@ -622,6 +628,12 @@ impl From<u64> for BlockHashOrNumber {
}
}

impl From<U64> for BlockHashOrNumber {
fn from(value: U64) -> Self {
value.to::<u64>().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) {
Expand Down

0 comments on commit 4f631cc

Please sign in to comment.