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(anvil): Return transaction hash in ots_getTransactionBySenderAndNonce #7741

Merged
Merged
Show file tree
Hide file tree
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
8 changes: 3 additions & 5 deletions crates/anvil/src/eth/otterscan/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ use crate::eth::{
EthApi,
};
use alloy_primitives::{Address, Bytes, B256, U256};
use alloy_rpc_types::{
Block, BlockId, BlockNumberOrTag as BlockNumber, Transaction, WithOtherFields,
};
use alloy_rpc_types::{Block, BlockId, BlockNumberOrTag as BlockNumber};
use alloy_rpc_types_trace::parity::{
Action, CallAction, CreateAction, CreateOutput, RewardAction, TraceOutput,
};
Expand Down Expand Up @@ -240,7 +238,7 @@ impl EthApi {
&self,
address: Address,
nonce: U256,
) -> Result<Option<WithOtherFields<Transaction>>> {
) -> Result<Option<B256>> {
node_info!("ots_getTransactionBySenderAndNonce");

let from = self.get_fork().map(|f| f.block_number() + 1).unwrap_or_default();
Expand All @@ -250,7 +248,7 @@ impl EthApi {
if let Some(txs) = self.backend.mined_transactions_by_block_number(n.into()).await {
for tx in txs {
if U256::from(tx.nonce) == nonce && tx.from == address {
return Ok(Some(tx))
return Ok(Some(tx.hash))
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/anvil/tests/it/otterscan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,8 @@ async fn can_call_ots_get_transaction_by_sender_and_nonce() {
.await
.unwrap();

assert_eq!(result1.unwrap().hash, receipt1.transaction_hash.to_alloy());
assert_eq!(result2.unwrap().hash, receipt2.transaction_hash.to_alloy());
assert_eq!(result1.unwrap(), receipt1.transaction_hash.to_alloy());
assert_eq!(result2.unwrap(), receipt2.transaction_hash.to_alloy());
}

#[tokio::test(flavor = "multi_thread")]
Expand Down
Loading