diff --git a/crates/edr_eth/src/transaction.rs b/crates/edr_eth/src/transaction.rs index 2162f5963..025e138ed 100644 --- a/crates/edr_eth/src/transaction.rs +++ b/crates/edr_eth/src/transaction.rs @@ -5,13 +5,13 @@ //! transaction related data mod fake_signature; -mod kind; mod request; mod signed; +pub use revm_primitives::alloy_primitives::TxKind; use revm_primitives::B256; -pub use self::{kind::TransactionKind, request::*, signed::*}; +pub use self::{request::*, signed::*}; use crate::{access_list::AccessListItem, Address, Bytes, U256}; /// Represents _all_ transaction requests received from RPC diff --git a/crates/edr_eth/src/transaction/kind.rs b/crates/edr_eth/src/transaction/kind.rs deleted file mode 100644 index 2cab0eff4..000000000 --- a/crates/edr_eth/src/transaction/kind.rs +++ /dev/null @@ -1,58 +0,0 @@ -use alloy_rlp::{Buf, BufMut}; - -use crate::Address; - -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] -#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] -pub enum TransactionKind { - Call(Address), - Create, -} - -impl TransactionKind { - /// If this transaction is a call this returns the address of the callee - pub fn as_call(&self) -> Option<&Address> { - match self { - TransactionKind::Call(to) => Some(to), - TransactionKind::Create => None, - } - } -} - -impl From> for TransactionKind { - fn from(value: Option
) -> Self { - if let Some(address) = value { - TransactionKind::Call(address) - } else { - TransactionKind::Create - } - } -} - -impl alloy_rlp::Decodable for TransactionKind { - fn decode(buf: &mut &[u8]) -> alloy_rlp::Result { - if !buf.is_empty() && buf[0] == alloy_rlp::EMPTY_STRING_CODE { - buf.advance(1); - - Ok(Self::Create) - } else { - Address::decode(buf).map(Self::Call) - } - } -} - -impl alloy_rlp::Encodable for TransactionKind { - fn length(&self) -> usize { - match self { - TransactionKind::Call(address) => address.length(), - TransactionKind::Create => 1, - } - } - - fn encode(&self, out: &mut dyn BufMut) { - match self { - TransactionKind::Call(address) => address.encode(out), - TransactionKind::Create => out.put_u8(alloy_rlp::EMPTY_STRING_CODE), - } - } -} diff --git a/crates/edr_eth/src/transaction/request/eip155.rs b/crates/edr_eth/src/transaction/request/eip155.rs index 1f0ebc30e..ef0388418 100644 --- a/crates/edr_eth/src/transaction/request/eip155.rs +++ b/crates/edr_eth/src/transaction/request/eip155.rs @@ -6,9 +6,7 @@ use revm_primitives::keccak256; use crate::{ signature::{Signature, SignatureError}, - transaction::{ - fake_signature::make_fake_signature, kind::TransactionKind, signed::Eip155SignedTransaction, - }, + transaction::{fake_signature::make_fake_signature, signed::Eip155SignedTransaction, TxKind}, Address, Bytes, B256, U256, }; @@ -18,7 +16,7 @@ pub struct Eip155TransactionRequest { pub nonce: u64, pub gas_price: U256, pub gas_limit: u64, - pub kind: TransactionKind, + pub kind: TxKind, pub value: U256, pub input: Bytes, pub chain_id: u64, @@ -142,7 +140,7 @@ mod tests { nonce: 1, gas_price: U256::from(2), gas_limit: 3, - kind: TransactionKind::Call(to), + kind: TxKind::Call(to), value: U256::from(4), input: Bytes::from(input), chain_id: 1, @@ -182,7 +180,7 @@ mod tests { nonce: 0, gas_price: U256::from(678_912), gas_limit: 30_000, - kind: TransactionKind::Call("0xb5bc06d4548a3ac17d72b372ae1e416bf65b8ead".parse()?), + kind: TxKind::Call("0xb5bc06d4548a3ac17d72b372ae1e416bf65b8ead".parse()?), value: U256::from(1), input: Bytes::default(), chain_id: 123, diff --git a/crates/edr_eth/src/transaction/request/eip1559.rs b/crates/edr_eth/src/transaction/request/eip1559.rs index 2d6f1f545..6e4ee10e0 100644 --- a/crates/edr_eth/src/transaction/request/eip1559.rs +++ b/crates/edr_eth/src/transaction/request/eip1559.rs @@ -7,10 +7,7 @@ use revm_primitives::keccak256; use crate::{ access_list::AccessListItem, signature::{Signature, SignatureError}, - transaction::{ - fake_signature::make_fake_signature, kind::TransactionKind, - signed::Eip1559SignedTransaction, - }, + transaction::{fake_signature::make_fake_signature, signed::Eip1559SignedTransaction, TxKind}, utils::envelop_bytes, Address, Bytes, B256, U256, }; @@ -23,7 +20,7 @@ pub struct Eip1559TransactionRequest { pub max_priority_fee_per_gas: U256, pub max_fee_per_gas: U256, pub gas_limit: u64, - pub kind: TransactionKind, + pub kind: TxKind, pub value: U256, pub input: Bytes, pub access_list: Vec, @@ -114,7 +111,7 @@ pub(crate) mod tests { max_priority_fee_per_gas: U256::from(2), max_fee_per_gas: U256::from(5), gas_limit: 3, - kind: TransactionKind::Call(to), + kind: TxKind::Call(to), value: U256::from(4), input: Bytes::from(input), access_list: vec![AccessListItem { @@ -150,7 +147,7 @@ pub(crate) mod tests { max_priority_fee_per_gas: U256::ZERO, max_fee_per_gas: U256::ZERO, gas_limit: 0, - kind: TransactionKind::Create, + kind: TxKind::Create, value: U256::ZERO, input: Bytes::new(), access_list: vec![], @@ -182,7 +179,7 @@ pub(crate) mod tests { max_priority_fee_per_gas: U256::from(2), max_fee_per_gas: U256::from(12), gas_limit: 30_000, - kind: TransactionKind::Call("0xb5bc06d4548a3ac17d72b372ae1e416bf65b8ead".parse()?), + kind: TxKind::Call("0xb5bc06d4548a3ac17d72b372ae1e416bf65b8ead".parse()?), value: U256::from(1), input: Bytes::default(), access_list: vec![], diff --git a/crates/edr_eth/src/transaction/request/eip2930.rs b/crates/edr_eth/src/transaction/request/eip2930.rs index 8c207c4f3..69db4ac85 100644 --- a/crates/edr_eth/src/transaction/request/eip2930.rs +++ b/crates/edr_eth/src/transaction/request/eip2930.rs @@ -7,10 +7,7 @@ use revm_primitives::keccak256; use crate::{ access_list::AccessListItem, signature::{Signature, SignatureError}, - transaction::{ - fake_signature::make_fake_signature, kind::TransactionKind, - signed::Eip2930SignedTransaction, - }, + transaction::{fake_signature::make_fake_signature, signed::Eip2930SignedTransaction, TxKind}, utils::envelop_bytes, Address, Bytes, B256, U256, }; @@ -22,7 +19,7 @@ pub struct Eip2930TransactionRequest { pub nonce: u64, pub gas_price: U256, pub gas_limit: u64, - pub kind: TransactionKind, + pub kind: TxKind, pub value: U256, pub input: Bytes, pub access_list: Vec, @@ -111,7 +108,7 @@ mod tests { nonce: 1, gas_price: U256::from(2), gas_limit: 3, - kind: TransactionKind::Call(to), + kind: TxKind::Call(to), value: U256::from(4), input: Bytes::from(input), access_list: vec![AccessListItem { @@ -157,7 +154,7 @@ mod tests { nonce: 0, gas_price: U256::from(1), gas_limit: 30_000, - kind: TransactionKind::Call("0xb5bc06d4548a3ac17d72b372ae1e416bf65b8ead".parse()?), + kind: TxKind::Call("0xb5bc06d4548a3ac17d72b372ae1e416bf65b8ead".parse()?), value: U256::from(1), input: Bytes::default(), access_list: vec![AccessListItem { diff --git a/crates/edr_eth/src/transaction/request/legacy.rs b/crates/edr_eth/src/transaction/request/legacy.rs index 364f96a1b..3bb21937d 100644 --- a/crates/edr_eth/src/transaction/request/legacy.rs +++ b/crates/edr_eth/src/transaction/request/legacy.rs @@ -6,9 +6,7 @@ use revm_primitives::keccak256; use crate::{ signature::{Signature, SignatureError}, - transaction::{ - fake_signature::make_fake_signature, kind::TransactionKind, signed::LegacySignedTransaction, - }, + transaction::{fake_signature::make_fake_signature, signed::LegacySignedTransaction, TxKind}, Address, Bytes, B256, U256, }; @@ -18,7 +16,7 @@ pub struct LegacyTransactionRequest { pub nonce: u64, pub gas_price: U256, pub gas_limit: u64, - pub kind: TransactionKind, + pub kind: TxKind, pub value: U256, pub input: Bytes, } @@ -93,7 +91,7 @@ mod tests { nonce: 1, gas_price: U256::from(2), gas_limit: 3, - kind: TransactionKind::Call(to), + kind: TxKind::Call(to), value: U256::from(4), input: Bytes::from(input), } @@ -131,7 +129,7 @@ mod tests { nonce: 0, gas_price: U256::from(678_912), gas_limit: 30_000, - kind: TransactionKind::Call("0xb5bc06d4548a3ac17d72b372ae1e416bf65b8ead".parse()?), + kind: TxKind::Call("0xb5bc06d4548a3ac17d72b372ae1e416bf65b8ead".parse()?), value: U256::from(1), input: Bytes::default(), }; diff --git a/crates/edr_eth/src/transaction/signed.rs b/crates/edr_eth/src/transaction/signed.rs index cd3637a0d..702c7a509 100644 --- a/crates/edr_eth/src/transaction/signed.rs +++ b/crates/edr_eth/src/transaction/signed.rs @@ -11,7 +11,7 @@ pub use self::{ eip2930::Eip2930SignedTransaction, eip4844::Eip4844SignedTransaction, legacy::LegacySignedTransaction, }; -use super::kind::TransactionKind; +use super::TxKind; use crate::{ access_list::AccessList, signature::{Signature, SignatureError}, @@ -227,19 +227,19 @@ impl SignedTransaction { } /// Returns what kind of transaction this is - pub fn kind(&self) -> TransactionKind { + pub fn kind(&self) -> TxKind { match self { SignedTransaction::PreEip155Legacy(tx) => tx.kind, SignedTransaction::PostEip155Legacy(tx) => tx.kind, SignedTransaction::Eip2930(tx) => tx.kind, SignedTransaction::Eip1559(tx) => tx.kind, - SignedTransaction::Eip4844(tx) => TransactionKind::Call(tx.to), + SignedTransaction::Eip4844(tx) => TxKind::Call(tx.to), } } /// Returns the callee if this transaction is a call pub fn to(&self) -> Option
{ - self.kind().as_call().copied() + self.kind().to().copied() } /// Returns the [`Signature`] of the transaction @@ -408,7 +408,7 @@ mod tests { assert_eq!(tx.gas_price, U256::from(0x01u64)); assert_eq!(tx.gas_limit, 0x5208u64); assert_eq!(tx.nonce, 0x00u64); - if let TransactionKind::Call(ref to) = tx.kind { + if let TxKind::Call(ref to) = tx.kind { assert_eq!( *to, "0x095e7baea6a6c7c4c2dfeb977efac326af552d87" @@ -452,7 +452,7 @@ mod tests { nonce: 0, gas_price: U256::from(1), gas_limit: 2, - kind: TransactionKind::Call(Address::default()), + kind: TxKind::Call(Address::default()), value: U256::from(3), input: Bytes::from(vec![1, 2]), signature: Signature { @@ -467,7 +467,7 @@ mod tests { nonce: 0, gas_price: U256::from(1), gas_limit: 2, - kind: TransactionKind::Create, + kind: TxKind::Create, value: U256::from(3), input: Bytes::from(vec![1, 2]), signature: Signature { @@ -483,7 +483,7 @@ mod tests { nonce: 0, gas_price: U256::from(1), gas_limit: 2, - kind: TransactionKind::Call(Address::random()), + kind: TxKind::Call(Address::random()), value: U256::from(3), input: Bytes::from(vec![1, 2]), odd_y_parity: true, @@ -499,7 +499,7 @@ mod tests { max_priority_fee_per_gas: U256::from(1), max_fee_per_gas: U256::from(2), gas_limit: 3, - kind: TransactionKind::Create, + kind: TxKind::Create, value: U256::from(4), input: Bytes::from(vec![1, 2]), access_list: vec![].into(), @@ -538,7 +538,7 @@ mod tests { nonce: 2u64, gas_price: U256::from(1000000000u64), gas_limit: 100000, - kind: TransactionKind::Call(Address::from_slice( + kind: TxKind::Call(Address::from_slice( &hex::decode("d3e8763675e4c425df46cc3b5c0f6cbdac396046").unwrap(), )), value: U256::from(1000000000000000u64), @@ -567,7 +567,7 @@ mod tests { nonce: 1, gas_price: U256::from(1000000000u64), gas_limit: 100000, - kind: TransactionKind::Call(Address::from_slice( + kind: TxKind::Call(Address::from_slice( &hex::decode("d3e8763675e4c425df46cc3b5c0f6cbdac396046").unwrap(), )), value: U256::from(693361000000000u64), @@ -596,7 +596,7 @@ mod tests { nonce: 3, gas_price: U256::from(2000000000u64), gas_limit: 10000000, - kind: TransactionKind::Call(Address::from_slice( + kind: TxKind::Call(Address::from_slice( &hex::decode("d3e8763675e4c425df46cc3b5c0f6cbdac396046").unwrap(), )), value: U256::from(1000000000000000u64), @@ -627,7 +627,7 @@ mod tests { max_priority_fee_per_gas: U256::from(1500000000u64), max_fee_per_gas: U256::from(1500000013u64), gas_limit: 21000, - kind: TransactionKind::Call(Address::from_slice( + kind: TxKind::Call(Address::from_slice( &hex::decode("61815774383099e24810ab832a5b2a5425c154d5").unwrap(), )), value: U256::from(3000000000000000000u64), @@ -651,7 +651,7 @@ mod tests { nonce: 15u64, gas_price: U256::from(2200000000u64), gas_limit: 34811, - kind: TransactionKind::Call(Address::from_slice( + kind: TxKind::Call(Address::from_slice( &hex::decode("cf7f9e66af820a19257a2108375b180b0ec49167").unwrap(), )), value: U256::from(1234u64), diff --git a/crates/edr_eth/src/transaction/signed/eip155.rs b/crates/edr_eth/src/transaction/signed/eip155.rs index c1be9070b..07d6605d7 100644 --- a/crates/edr_eth/src/transaction/signed/eip155.rs +++ b/crates/edr_eth/src/transaction/signed/eip155.rs @@ -7,8 +7,7 @@ use super::LegacySignedTransaction; use crate::{ signature::{Signature, SignatureError}, transaction::{ - fake_signature::recover_fake_signature, kind::TransactionKind, - request::Eip155TransactionRequest, + fake_signature::recover_fake_signature, request::Eip155TransactionRequest, TxKind, }, Address, Bytes, B256, U256, }; @@ -22,7 +21,7 @@ pub struct Eip155SignedTransaction { pub gas_price: U256, #[cfg_attr(feature = "serde", serde(with = "crate::serde::u64"))] pub gas_limit: u64, - pub kind: TransactionKind, + pub kind: TxKind, pub value: U256, pub input: Bytes, pub signature: Signature, @@ -102,7 +101,7 @@ mod tests { nonce: 1, gas_price: U256::from(2), gas_limit: 3, - kind: TransactionKind::Call(to), + kind: TxKind::Call(to), value: U256::from(4), input: Bytes::from(input), chain_id: 1, diff --git a/crates/edr_eth/src/transaction/signed/eip1559.rs b/crates/edr_eth/src/transaction/signed/eip1559.rs index d2ce26dd9..f2ef452b1 100644 --- a/crates/edr_eth/src/transaction/signed/eip1559.rs +++ b/crates/edr_eth/src/transaction/signed/eip1559.rs @@ -7,8 +7,7 @@ use crate::{ access_list::AccessList, signature::{Signature, SignatureError}, transaction::{ - fake_signature::recover_fake_signature, kind::TransactionKind, - request::Eip1559TransactionRequest, + fake_signature::recover_fake_signature, request::Eip1559TransactionRequest, TxKind, }, utils::envelop_bytes, Address, Bytes, B256, U256, @@ -26,7 +25,7 @@ pub struct Eip1559SignedTransaction { pub max_fee_per_gas: U256, #[cfg_attr(feature = "serde", serde(with = "crate::serde::u64"))] pub gas_limit: u64, - pub kind: TransactionKind, + pub kind: TxKind, pub value: U256, pub input: Bytes, pub access_list: AccessList, @@ -113,7 +112,7 @@ mod tests { max_priority_fee_per_gas: U256::from(2), max_fee_per_gas: U256::from(5), gas_limit: 3, - kind: TransactionKind::Call(to), + kind: TxKind::Call(to), value: U256::from(4), input: Bytes::from(input), access_list: vec![AccessListItem { diff --git a/crates/edr_eth/src/transaction/signed/eip2930.rs b/crates/edr_eth/src/transaction/signed/eip2930.rs index 1f7726a7f..771561b12 100644 --- a/crates/edr_eth/src/transaction/signed/eip2930.rs +++ b/crates/edr_eth/src/transaction/signed/eip2930.rs @@ -7,8 +7,7 @@ use crate::{ access_list::AccessList, signature::{Signature, SignatureError}, transaction::{ - fake_signature::recover_fake_signature, kind::TransactionKind, - request::Eip2930TransactionRequest, + fake_signature::recover_fake_signature, request::Eip2930TransactionRequest, TxKind, }, utils::envelop_bytes, Address, Bytes, B256, U256, @@ -25,7 +24,7 @@ pub struct Eip2930SignedTransaction { pub gas_price: U256, #[cfg_attr(feature = "serde", serde(with = "crate::serde::u64"))] pub gas_limit: u64, - pub kind: TransactionKind, + pub kind: TxKind, pub value: U256, pub input: Bytes, pub access_list: AccessList, @@ -104,7 +103,7 @@ mod tests { nonce: 1, gas_price: U256::from(2), gas_limit: 3, - kind: TransactionKind::Call(to), + kind: TxKind::Call(to), value: U256::from(4), input: Bytes::from(input), access_list: vec![AccessListItem { diff --git a/crates/edr_eth/src/transaction/signed/legacy.rs b/crates/edr_eth/src/transaction/signed/legacy.rs index 4097250c1..10899b491 100644 --- a/crates/edr_eth/src/transaction/signed/legacy.rs +++ b/crates/edr_eth/src/transaction/signed/legacy.rs @@ -6,8 +6,7 @@ use revm_primitives::keccak256; use crate::{ signature::{Signature, SignatureError}, transaction::{ - fake_signature::recover_fake_signature, kind::TransactionKind, - request::LegacyTransactionRequest, + fake_signature::recover_fake_signature, request::LegacyTransactionRequest, TxKind, }, Address, Bytes, B256, U256, }; @@ -21,7 +20,7 @@ pub struct LegacySignedTransaction { pub gas_price: U256, #[cfg_attr(feature = "serde", serde(with = "crate::serde::u64"))] pub gas_limit: u64, - pub kind: TransactionKind, + pub kind: TxKind, pub value: U256, pub input: Bytes, pub signature: Signature, @@ -81,7 +80,7 @@ mod tests { nonce: 1, gas_price: U256::from(2), gas_limit: 3, - kind: TransactionKind::Call(to), + kind: TxKind::Call(to), value: U256::from(4), input: Bytes::from(input), } diff --git a/crates/edr_evm/src/test_utils.rs b/crates/edr_evm/src/test_utils.rs index e8e9469d1..2fbfff763 100644 --- a/crates/edr_evm/src/test_utils.rs +++ b/crates/edr_evm/src/test_utils.rs @@ -1,7 +1,7 @@ use std::num::NonZeroU64; use edr_eth::{ - transaction::{Eip1559TransactionRequest, Eip155TransactionRequest, TransactionKind}, + transaction::{Eip1559TransactionRequest, Eip155TransactionRequest, TxKind}, AccountInfo, Address, Bytes, HashMap, SpecId, U256, }; @@ -106,7 +106,7 @@ pub fn dummy_eip155_transaction_with_price_limit_and_value( nonce, gas_price, gas_limit, - kind: TransactionKind::Call(from), + kind: TxKind::Call(from), value, input: Bytes::new(), chain_id: 123, @@ -131,7 +131,7 @@ pub fn dummy_eip1559_transaction( max_priority_fee_per_gas, max_fee_per_gas, gas_limit: 30_000, - kind: TransactionKind::Call(from), + kind: TxKind::Call(from), value: U256::ZERO, input: Bytes::new(), access_list: Vec::new(), diff --git a/crates/edr_evm/src/transaction/executable.rs b/crates/edr_evm/src/transaction/executable.rs index a5c669128..fd776fb0e 100644 --- a/crates/edr_evm/src/transaction/executable.rs +++ b/crates/edr_evm/src/transaction/executable.rs @@ -6,7 +6,7 @@ use edr_eth::{ signature::Signature, transaction::{ Eip1559SignedTransaction, Eip155SignedTransaction, Eip2930SignedTransaction, - Eip4844SignedTransaction, LegacySignedTransaction, SignedTransaction, TransactionKind, + Eip4844SignedTransaction, LegacySignedTransaction, SignedTransaction, TxKind, }, Address, U256, }; @@ -47,7 +47,7 @@ impl ExecutableTransaction { transaction: SignedTransaction, caller: Address, ) -> Result { - if transaction.kind() == TransactionKind::Create && transaction.data().is_empty() { + if transaction.kind() == TxKind::Create && transaction.data().is_empty() { return Err(TransactionCreationError::ContractMissingData); } @@ -106,10 +106,10 @@ impl alloy_rlp::Encodable for ExecutableTransaction { impl From for TxEnv { fn from(transaction: ExecutableTransaction) -> Self { - fn transact_to(kind: TransactionKind) -> TransactTo { + fn transact_to(kind: TxKind) -> TransactTo { match kind { - TransactionKind::Call(address) => TransactTo::Call(address), - TransactionKind::Create => TransactTo::Create(CreateScheme::Create), + TxKind::Call(address) => TransactTo::Call(address), + TxKind::Create => TransactTo::Create(CreateScheme::Create), } } @@ -254,9 +254,9 @@ impl TryFrom for ExecutableTransaction { fn try_from(value: Transaction) -> Result { let kind = if let Some(to) = &value.to { - TransactionKind::Call(*to) + TxKind::Call(*to) } else { - TransactionKind::Create + TxKind::Create }; let caller = value.from; @@ -412,7 +412,7 @@ fn initial_cost(spec_id: SpecId, transaction: &SignedTransaction) -> u64 { validate_initial_tx_gas( spec_id, transaction.data().as_ref(), - transaction.kind() == TransactionKind::Create, + transaction.kind() == TxKind::Create, access_list .as_ref() .map_or(&[], |access_list| access_list.as_slice()), @@ -435,7 +435,7 @@ mod tests { nonce: 0, gas_price: U256::ZERO, gas_limit: TOO_LOW_GAS_LIMIT, - kind: TransactionKind::Call(caller), + kind: TxKind::Call(caller), value: U256::ZERO, input: Bytes::new(), chain_id: 123, @@ -469,7 +469,7 @@ mod tests { nonce: 0, gas_price: U256::ZERO, gas_limit: 30_000, - kind: TransactionKind::Create, + kind: TxKind::Create, value: U256::ZERO, input: Bytes::new(), chain_id: 123, diff --git a/crates/edr_evm/tests/blockchain.rs b/crates/edr_evm/tests/blockchain.rs index 6e89385a8..e15e5b0d5 100644 --- a/crates/edr_evm/tests/blockchain.rs +++ b/crates/edr_evm/tests/blockchain.rs @@ -312,7 +312,7 @@ async fn block_by_number_some() { async fn block_by_number_with_create() -> anyhow::Result<()> { use std::str::FromStr; - use edr_eth::transaction::TransactionKind; + use edr_eth::transaction::TxKind; const DAI_CREATION_BLOCK_NUMBER: u64 = 4_719_568; const DAI_CREATION_TRANSACTION_INDEX: usize = 85; @@ -332,7 +332,7 @@ async fn block_by_number_with_create() -> anyhow::Result<()> { ); assert!(matches!( transactions[DAI_CREATION_TRANSACTION_INDEX].kind(), - TransactionKind::Create + TxKind::Create )); Ok(()) diff --git a/crates/edr_provider/src/console_log.rs b/crates/edr_provider/src/console_log.rs index ec2f1734c..288f54c54 100644 --- a/crates/edr_provider/src/console_log.rs +++ b/crates/edr_provider/src/console_log.rs @@ -53,8 +53,7 @@ pub(crate) mod tests { use anyhow::Context; use edr_eth::{ transaction::{ - Eip1559TransactionRequest, TransactionKind, TransactionRequest, - TransactionRequestAndSender, + Eip1559TransactionRequest, TransactionRequest, TransactionRequestAndSender, TxKind, }, Bytes, U256, }; @@ -89,7 +88,7 @@ pub(crate) mod tests { let byte_code = hex::decode("608060405234801561001057600080fd5b5061027a806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c806326121ff014610030575b600080fd5b61003861003a565b005b6100786040518060400160405280600581526020017f68656c6c6f00000000000000000000000000000000000000000000000000000081525061007a565b565b6101108160405160240161008e91906101f3565b6040516020818303038152906040527f41304fac000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050610113565b50565b61012a8161012261012d61014e565b63ffffffff16565b50565b60006a636f6e736f6c652e6c6f679050600080835160208501845afa505050565b610159819050919050565b610161610215565b565b600081519050919050565b600082825260208201905092915050565b60005b8381101561019d578082015181840152602081019050610182565b60008484015250505050565b6000601f19601f8301169050919050565b60006101c582610163565b6101cf818561016e565b93506101df81856020860161017f565b6101e8816101a9565b840191505092915050565b6000602082019050818103600083015261020d81846101ba565b905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052605160045260246000fdfea26469706673582212201e965281cb15cf946ada70867e2acb07debad82404e574500944a7b3e0b799ac64736f6c63430008110033")?; let deploy_tx = TransactionRequest::Eip1559(Eip1559TransactionRequest { - kind: TransactionKind::Create, + kind: TxKind::Create, gas_limit: 10_000_000, value: U256::ZERO, input: byte_code.into(), @@ -129,7 +128,7 @@ pub(crate) mod tests { let expected_call_data = hex::decode("41304fac0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000568656c6c6f000000000000000000000000000000000000000000000000000000")?.into(); let transaction_request = TransactionRequest::Eip1559(Eip1559TransactionRequest { - kind: TransactionKind::Call(contract_address), + kind: TxKind::Call(contract_address), gas_limit: 10_000_000, value: U256::ZERO, input: call_data.into(), diff --git a/crates/edr_provider/src/data.rs b/crates/edr_provider/src/data.rs index 035821b4d..a91b8d042 100644 --- a/crates/edr_provider/src/data.rs +++ b/crates/edr_provider/src/data.rs @@ -2433,7 +2433,7 @@ pub(crate) mod test_utils { use std::convert::Infallible; use anyhow::anyhow; - use edr_eth::transaction::{Eip155TransactionRequest, TransactionKind, TransactionRequest}; + use edr_eth::transaction::{Eip155TransactionRequest, TransactionRequest, TxKind}; use edr_test_utils::env::get_alchemy_url; use super::*; @@ -2524,7 +2524,7 @@ pub(crate) mod test_utils { nonce: Option, ) -> anyhow::Result { let request = TransactionRequest::Eip155(Eip155TransactionRequest { - kind: TransactionKind::Call(Address::ZERO), + kind: TxKind::Call(Address::ZERO), gas_limit, gas_price: U256::from(42_000_000_000_u64), value: U256::from(1), diff --git a/crates/edr_provider/src/requests/eth/transactions.rs b/crates/edr_provider/src/requests/eth/transactions.rs index c255eefb3..2b88716c4 100644 --- a/crates/edr_provider/src/requests/eth/transactions.rs +++ b/crates/edr_provider/src/requests/eth/transactions.rs @@ -7,8 +7,8 @@ use edr_eth::{ rlp::Decodable, transaction::{ Eip1559TransactionRequest, Eip155TransactionRequest, Eip2930TransactionRequest, - EthTransactionRequest, SignedTransaction, TransactionKind, TransactionRequest, - TransactionRequestAndSender, + EthTransactionRequest, SignedTransaction, TransactionRequest, TransactionRequestAndSender, + TxKind, }, Bytes, SpecId, B256, U256, }; @@ -377,8 +377,8 @@ fn resolve_transaction_request TransactionKind::Call(to), - None => TransactionKind::Create, + Some(to) => TxKind::Call(to), + None => TxKind::Create, }, chain_id, access_list: access_list.unwrap_or_default(), @@ -392,8 +392,8 @@ fn resolve_transaction_request TransactionKind::Call(to), - None => TransactionKind::Create, + Some(to) => TxKind::Call(to), + None => TxKind::Create, }, chain_id, access_list, @@ -406,8 +406,8 @@ fn resolve_transaction_request TransactionKind::Call(to), - None => TransactionKind::Create, + Some(to) => TxKind::Call(to), + None => TxKind::Create, }, chain_id, }), @@ -528,7 +528,7 @@ You can use them by running Hardhat Network with 'hardfork' {minimum_hardfork:?} mod tests { use anyhow::Context; use edr_eth::{ - transaction::{Eip155TransactionRequest, TransactionKind, TransactionRequest}, + transaction::{Eip155TransactionRequest, TransactionRequest, TxKind}, Address, Bytes, U256, }; use edr_evm::ExecutableTransaction; @@ -552,7 +552,7 @@ mod tests { let chain_id = fixture.provider_data.chain_id(); let request = TransactionRequest::Eip155(Eip155TransactionRequest { - kind: TransactionKind::Call(Address::ZERO), + kind: TxKind::Call(Address::ZERO), gas_limit: 30_000, gas_price: U256::from(42_000_000_000_u64), value: U256::from(1),