Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eth_getBlockReceipts support #606

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/api/eth.rs
Expand Up @@ -247,6 +247,13 @@ impl<T: Transport> Eth<T> {
CallFuture::new(self.transport.execute("eth_getTransactionReceipt", vec![hash]))
}

/// Get block receipts
pub fn block_receipts(&self, block: BlockNumber) -> CallFuture<Option<Vec<TransactionReceipt>>, T::Out> {
let block = helpers::serialize(&block);

CallFuture::new(self.transport.execute("eth_getBlockReceipts", vec![block]))
}

/// Get uncle header by block ID and uncle index.
///
/// This method is meant for TurboGeth compatiblity,
Expand Down Expand Up @@ -506,6 +513,21 @@ mod tests {
"effectiveGasPrice": "0x100"
}"#;

const EXAMPLE_BLOCK_RECEIPTS: &str = r#"[{
"transactionHash": "0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238",
"transactionIndex": "0x1",
"from": "0xa7d9ddbe1f17865597fbd27ec712455208b6b76d",
"blockNumber": "0xb",
"blockHash": "0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b",
"cumulativeGasUsed": "0x33bc",
"gasUsed": "0x4dc",
"contractAddress": "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
"logsBloom": "0x0e670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d15273310e670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d15273310e670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d15273310e670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d15273310e670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d15273310e670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d15273310e670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d15273310e670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331",
"logs": [],
"status": "0x1",
"effectiveGasPrice": "0x100"
}]"#;

const EXAMPLE_FEE_HISTORY: &str = r#"{
"baseFeePerGas": [
"0x15f794d04b",
Expand Down Expand Up @@ -768,6 +790,14 @@ mod tests {
=> Some(::serde_json::from_str::<TransactionReceipt>(EXAMPLE_RECEIPT).unwrap())
);

rpc_test! (
Eth:block_receipts, BlockNumber::Number(100i64.into())
=>
"eth_getBlockReceipts", vec![r#""0x64""#];
::serde_json::from_str(EXAMPLE_BLOCK_RECEIPTS).unwrap()
=> Some(::serde_json::from_str::<Vec<TransactionReceipt>>(EXAMPLE_BLOCK_RECEIPTS).unwrap())
);

rpc_test! (
Eth:uncle:uncle_by_hash, BlockId::Hash(H256::from_low_u64_be(0x123)), 5
=>
Expand Down