feat: populate tx meta fields in tx by hash (#1884)

This commit is contained in:
Matthias Seitz
2023-03-21 16:12:26 +01:00
committed by GitHub
parent 92e2c4d2aa
commit 44d279b53e
3 changed files with 8 additions and 10 deletions

View File

@ -216,7 +216,7 @@ pub struct LocalizedTransactionTrace {
#[serde(flatten)]
pub trace: TransactionTrace,
/// Transaction index within the block, None if pending.
pub transaction_position: Option<usize>,
pub transaction_position: Option<u64>,
/// Hash of the transaction
pub transaction_hash: Option<H256>,
/// Block number the transaction is included in, None if pending.

View File

@ -9,7 +9,7 @@ pub struct TransactionInfo {
/// Hash of the transaction.
pub hash: Option<TxHash>,
/// Index of the transaction in the block
pub index: Option<usize>,
pub index: Option<u64>,
/// Hash of the block.
pub block_hash: Option<H256>,
/// Number of the block.

View File

@ -92,19 +92,17 @@ where
return Ok(Some(TransactionSource::Pool(tx)))
}
match self.client().transaction_by_hash(hash)? {
match self.client().transaction_by_hash_with_meta(hash)? {
None => Ok(None),
Some(tx) => {
Some((tx, meta)) => {
let transaction =
tx.into_ecrecovered().ok_or(EthApiError::InvalidTransactionSignature)?;
let tx = TransactionSource::Database {
transaction,
// TODO: this is just stubbed out for now still need to fully implement tx =>
// block
index: 0,
block_hash: Default::default(),
block_number: 0,
index: meta.index,
block_hash: meta.block_hash,
block_number: meta.block_number,
};
Ok(Some(tx))
}
@ -210,7 +208,7 @@ pub enum TransactionSource {
/// Transaction fetched via provider
transaction: TransactionSignedEcRecovered,
/// Index of the transaction in the block
index: usize,
index: u64,
/// Hash of the block.
block_hash: H256,
/// Number of the block.