feat(rpc-types): from U64 for BlockHashOrNumber and BlockId (#5385)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
evalir
2023-11-11 04:30:37 -04:00
committed by GitHub
parent e8729dda4a
commit 4f631cc773

View File

@ -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)
@ -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) {