Skip to content

Commit

Permalink
Fix review
Browse files Browse the repository at this point in the history
  • Loading branch information
boundless-forest committed Aug 17, 2023
1 parent 0ea5085 commit b45e329
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion client/rpc-core/src/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub trait EthApi {
async fn block_transaction_receipts(
&self,
number: BlockNumber,
) -> RpcResult<Vec<Option<Receipt>>>;
) -> RpcResult<Option<Vec<Receipt>>>;

/// Returns the number of uncles in a block with given hash.
#[method(name = "eth_getUncleCountByBlockHash")]
Expand Down
22 changes: 13 additions & 9 deletions client/rpc/src/eth/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,20 +214,24 @@ where
pub async fn block_transaction_receipts(
&self,
number: BlockNumber,
) -> RpcResult<Vec<Option<Receipt>>> {
) -> RpcResult<Option<Vec<Receipt>>> {
let block_info = self.block_info_by_number(number).await?;
let Some(statuses) = block_info.clone().statuses else {
return Ok(None);
};

let mut receipts = Vec::new();
if let Some(statuses) = block_info.clone().statuses {
let transactions: Vec<(H256, usize)> = statuses
.iter()
.map(|tx| (tx.transaction_hash, tx.transaction_index as usize))
.collect();
for (hash, index) in transactions {
receipts.push(self.transaction_receipt(&block_info, hash, index).await?);
let transactions: Vec<(H256, usize)> = statuses
.iter()
.map(|tx| (tx.transaction_hash, tx.transaction_index as usize))
.collect();
for (hash, index) in transactions {
if let Some(receipt) = self.transaction_receipt(&block_info, hash, index).await? {
receipts.push(receipt);
}
}

Ok(receipts)
Ok(Some(receipts))
}

pub fn block_uncles_count_by_hash(&self, _: H256) -> RpcResult<U256> {
Expand Down
2 changes: 1 addition & 1 deletion client/rpc/src/eth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ where
async fn block_transaction_receipts(
&self,
number: BlockNumber,
) -> RpcResult<Vec<Option<Receipt>>> {
) -> RpcResult<Option<Vec<Receipt>>> {
self.block_transaction_receipts(number).await
}

Expand Down
2 changes: 1 addition & 1 deletion ts-tests/tests/test-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ describeWithFrontier("Frontier RPC (BlockReceipts)", (context) => {
).to.be.eq(N);
// block tags
expect((await customRequest(context.web3, "eth_getBlockReceipts", ["earliest"])).result.length).to.be.eq(0);
expect((await customRequest(context.web3, "eth_getBlockReceipts", ["pending"])).result.length).to.be.eq(0);
expect((await customRequest(context.web3, "eth_getBlockReceipts", ["pending"])).result).to.be.null;
expect((await customRequest(context.web3, "eth_getBlockReceipts", ["finalized"])).result.length).to.be.eq(N);
expect((await customRequest(context.web3, "eth_getBlockReceipts", ["latest"])).result.length).to.be.eq(N);
});
Expand Down

0 comments on commit b45e329

Please sign in to comment.