Skip to content

Commit

Permalink
Add conversion from BlockHashOrNumber to BlockId (#1127)
Browse files Browse the repository at this point in the history
  • Loading branch information
emhane authored Aug 5, 2024
1 parent 35e170d commit 68c8bfc
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions crates/eips/src/eip1898.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,17 @@ impl From<BlockNumberOrTag> for BlockId {
}
}

impl From<BlockHashOrNumber> for BlockId {
fn from(block: BlockHashOrNumber) -> Self {
match block {
BlockHashOrNumber::Hash(hash) => {
Self::Hash(RpcBlockHash { block_hash: hash, require_canonical: None })
}
BlockHashOrNumber::Number(num) => Self::Number(BlockNumberOrTag::Number(num)),
}
}
}

impl From<B256> for BlockId {
fn from(block_hash: B256) -> Self {
Self::Hash(RpcBlockHash { block_hash, require_canonical: None })
Expand Down

0 comments on commit 68c8bfc

Please sign in to comment.