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

fix: remove unwrap when getting tx receipt #4231

Merged
merged 2 commits into from
Nov 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions engine/src/eth/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,21 +162,23 @@ impl EthRpcApi for EthRpcClient {
}

async fn transaction_receipt(&self, tx_hash: TxHash) -> Result<TransactionReceipt> {
Ok(self.signer.get_transaction_receipt(tx_hash).await?.unwrap())
self.signer.get_transaction_receipt(tx_hash).await?.ok_or_else(|| {
anyhow!("Getting ETH transaction receipt for tx hash {tx_hash} returned None")
})
}

/// Gets block, returning error when either:
/// - Request fails
/// - Request succeeds, but doesn't return a block
async fn block(&self, block_number: U64) -> Result<Block<H256>> {
self.signer.get_block(block_number).await?.ok_or_else(|| {
anyhow!("Getting ETH block for block number {} returned None", block_number)
anyhow!("Getting ETH block for block number {block_number} returned None")
})
}

async fn block_with_txs(&self, block_number: U64) -> Result<Block<Transaction>> {
self.signer.get_block_with_txs(block_number).await?.ok_or_else(|| {
anyhow!("Getting ETH block with txs for block number {} returned None", block_number)
anyhow!("Getting ETH block with txs for block number {block_number} returned None")
})
}

Expand All @@ -193,7 +195,7 @@ impl EthRpcApi for EthRpcClient {
self.signer
.get_transaction(tx_hash)
.await?
.ok_or_else(|| anyhow!("Getting ETH transaction for tx hash {} returned None", tx_hash))
.ok_or_else(|| anyhow!("Getting ETH transaction for tx hash {tx_hash} returned None"))
}
}

Expand Down