mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-24 06:37:57 -05:00
refactor: replace to_primitive_transaction_kind by From impl (#7831)
This commit is contained in:
@@ -868,6 +868,15 @@ impl TransactionKind {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<reth_rpc_types::TransactionKind> for TransactionKind {
|
||||
fn from(kind: reth_rpc_types::TransactionKind) -> Self {
|
||||
match kind {
|
||||
reth_rpc_types::TransactionKind::Call(to) => Self::Call(to),
|
||||
reth_rpc_types::TransactionKind::Create => Self::Create,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Compact for TransactionKind {
|
||||
fn to_compact<B>(self, buf: &mut B) -> usize
|
||||
where
|
||||
|
||||
@@ -16,7 +16,7 @@ pub fn to_primitive_transaction(
|
||||
nonce: tx.nonce,
|
||||
gas_price: tx.gas_price.to(),
|
||||
gas_limit: tx.gas_limit.try_into().ok()?,
|
||||
to: to_primitive_transaction_kind(tx.kind),
|
||||
to: tx.kind.into(),
|
||||
value: tx.value,
|
||||
input: tx.input,
|
||||
}),
|
||||
@@ -25,7 +25,7 @@ pub fn to_primitive_transaction(
|
||||
nonce: tx.nonce,
|
||||
gas_price: tx.gas_price.to(),
|
||||
gas_limit: tx.gas_limit.try_into().ok()?,
|
||||
to: to_primitive_transaction_kind(tx.kind),
|
||||
to: tx.kind.into(),
|
||||
value: tx.value,
|
||||
input: tx.input,
|
||||
access_list: tx.access_list,
|
||||
@@ -35,7 +35,7 @@ pub fn to_primitive_transaction(
|
||||
nonce: tx.nonce,
|
||||
max_fee_per_gas: tx.max_fee_per_gas.to(),
|
||||
gas_limit: tx.gas_limit.try_into().ok()?,
|
||||
to: to_primitive_transaction_kind(tx.kind),
|
||||
to: tx.kind.into(),
|
||||
value: tx.value,
|
||||
input: tx.input,
|
||||
access_list: tx.access_list,
|
||||
@@ -47,7 +47,7 @@ pub fn to_primitive_transaction(
|
||||
gas_limit: tx.gas_limit.to(),
|
||||
max_fee_per_gas: tx.max_fee_per_gas.to(),
|
||||
max_priority_fee_per_gas: tx.max_priority_fee_per_gas.to(),
|
||||
to: to_primitive_transaction_kind(tx.kind),
|
||||
to: tx.kind.into(),
|
||||
value: tx.value,
|
||||
access_list: tx.access_list,
|
||||
blob_versioned_hashes: tx.blob_versioned_hashes,
|
||||
@@ -56,13 +56,3 @@ pub fn to_primitive_transaction(
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
||||
/// Transforms a [reth_rpc_types::TransactionKind] into a [reth_primitives::TransactionKind]
|
||||
pub fn to_primitive_transaction_kind(
|
||||
kind: reth_rpc_types::TransactionKind,
|
||||
) -> reth_primitives::TransactionKind {
|
||||
match kind {
|
||||
reth_rpc_types::TransactionKind::Call(to) => reth_primitives::TransactionKind::Call(to),
|
||||
reth_rpc_types::TransactionKind::Create => reth_primitives::TransactionKind::Create,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user