feat: convert hash field to OnceLock<TxHash> on TransactionSigned (#12596)

Co-authored-by: joshieDo <93316087+joshieDo@users.noreply.github.com>
This commit is contained in:
Steven
2024-11-21 16:40:29 -06:00
committed by GitHub
parent 6f6fb005ab
commit 4442b5d6fa
29 changed files with 127 additions and 87 deletions

View File

@ -92,16 +92,17 @@ fn txs_provider_example<T: TransactionsProvider>(provider: T) -> eyre::Result<()
// Can query the tx by hash
let tx_by_hash =
provider.transaction_by_hash(tx.hash)?.ok_or(eyre::eyre!("txhash not found"))?;
provider.transaction_by_hash(tx.hash())?.ok_or(eyre::eyre!("txhash not found"))?;
assert_eq!(tx, tx_by_hash);
// Can query the tx by hash with info about the block it was included in
let (tx, meta) =
provider.transaction_by_hash_with_meta(tx.hash)?.ok_or(eyre::eyre!("txhash not found"))?;
assert_eq!(tx.hash, meta.tx_hash);
let (tx, meta) = provider
.transaction_by_hash_with_meta(tx.hash())?
.ok_or(eyre::eyre!("txhash not found"))?;
assert_eq!(tx.hash(), meta.tx_hash);
// Can reverse lookup the key too
let id = provider.transaction_id(tx.hash)?.ok_or(eyre::eyre!("txhash not found"))?;
let id = provider.transaction_id(tx.hash())?.ok_or(eyre::eyre!("txhash not found"))?;
assert_eq!(id, txid);
// Can find the block of a transaction given its key
@ -171,7 +172,7 @@ fn receipts_provider_example<T: ReceiptProvider + TransactionsProvider + HeaderP
// Can query receipt by txhash too
let tx = provider.transaction_by_id(txid)?.unwrap();
let receipt_by_hash =
provider.receipt_by_hash(tx.hash)?.ok_or(eyre::eyre!("tx receipt by hash not found"))?;
provider.receipt_by_hash(tx.hash())?.ok_or(eyre::eyre!("tx receipt by hash not found"))?;
assert_eq!(receipt, receipt_by_hash);
// Can query all the receipts in a block