feat: add method for parity_getBlockReceipts
This commit is contained in:
parent
84aafbbd1f
commit
d2d7a82a80
|
@ -455,4 +455,17 @@ pub trait Middleware: Sync + Send + Debug {
|
||||||
.await
|
.await
|
||||||
.map_err(FromErr::from)
|
.map_err(FromErr::from)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Parity namespace
|
||||||
|
|
||||||
|
/// Returns all receipts for that block. Must be done on a parity node.
|
||||||
|
async fn parity_block_receipts<T: Into<BlockNumber> + Send + Sync>(
|
||||||
|
&self,
|
||||||
|
block: T,
|
||||||
|
) -> Result<Vec<TransactionReceipt>, Self::Error> {
|
||||||
|
self.inner()
|
||||||
|
.parity_block_receipts(block)
|
||||||
|
.await
|
||||||
|
.map_err(FromErr::from)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -642,6 +642,17 @@ impl<P: JsonRpcClient> Middleware for Provider<P> {
|
||||||
.await
|
.await
|
||||||
.map_err(Into::into)
|
.map_err(Into::into)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns all receipts for that block. Must be done on a parity node.
|
||||||
|
async fn parity_block_receipts<T: Into<BlockNumber> + Send + Sync>(
|
||||||
|
&self,
|
||||||
|
block: T,
|
||||||
|
) -> Result<Vec<TransactionReceipt>, Self::Error> {
|
||||||
|
self.0
|
||||||
|
.request("parity_getBlockReceipts", vec![block.into()])
|
||||||
|
.await
|
||||||
|
.map_err(Into::into)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<P: JsonRpcClient> Provider<P> {
|
impl<P: JsonRpcClient> Provider<P> {
|
||||||
|
@ -879,4 +890,15 @@ mod tests {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.is_some());
|
.is_some());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn parity_block_receipts() {
|
||||||
|
let url = match std::env::var("PARITY") {
|
||||||
|
Ok(inner) => inner,
|
||||||
|
_ => return,
|
||||||
|
};
|
||||||
|
let provider = Provider::<Http>::try_from(url.as_str()).unwrap();
|
||||||
|
let receipts = provider.parity_block_receipts(10657200).await.unwrap();
|
||||||
|
assert!(!receipts.is_empty());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue