feat: add method for parity_getBlockReceipts

This commit is contained in:
Georgios Konstantopoulos 2020-11-19 19:30:10 +02:00
parent 84aafbbd1f
commit d2d7a82a80
2 changed files with 35 additions and 0 deletions

View File

@ -455,4 +455,17 @@ pub trait Middleware: Sync + Send + Debug {
.await
.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)
}
}

View File

@ -642,6 +642,17 @@ impl<P: JsonRpcClient> Middleware for Provider<P> {
.await
.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> {
@ -879,4 +890,15 @@ mod tests {
.unwrap()
.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());
}
}