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: add back transaction type #552

Merged
merged 1 commit into from
Apr 16, 2024
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
1 change: 1 addition & 0 deletions crates/rpc-types/src/eth/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ impl Transaction {
nonce: Some(self.nonce),
chain_id: self.chain_id,
access_list: self.access_list,
transaction_type: self.transaction_type,
max_fee_per_gas: self.max_fee_per_gas,
max_priority_fee_per_gas: self.max_priority_fee_per_gas,
max_fee_per_blob_gas: self.max_fee_per_blob_gas,
Expand Down
15 changes: 15 additions & 0 deletions crates/rpc-types/src/eth/transaction/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ pub struct TransactionRequest {
/// An EIP-2930 access list, which lowers cost for accessing accounts and storages in the list. See [EIP-2930](https://eips.ethereum.org/EIPS/eip-2930) for more information.
#[serde(default)]
pub access_list: Option<AccessList>,
/// The EIP-2718 transaction type. See [EIP-2718](https://eips.ethereum.org/EIPS/eip-2718) for more information.
#[serde(default, rename = "type", with = "alloy_serde::num::u8_hex_opt")]
pub transaction_type: Option<u8>,
/// Blob versioned hashes for EIP-4844 transactions.
#[serde(skip_serializing_if = "Option::is_none")]
pub blob_versioned_hashes: Option<Vec<B256>>,
Expand All @@ -84,6 +87,7 @@ impl Hash for TransactionRequest {
self.nonce.hash(state);
self.chain_id.hash(state);
self.access_list.hash(state);
self.transaction_type.hash(state);
self.blob_versioned_hashes.hash(state);
self.sidecar.hash(state);
}
Expand All @@ -99,6 +103,12 @@ impl TransactionRequest {
self
}

/// Sets the transactions type for the transactions.
pub const fn transaction_type(mut self, transaction_type: u8) -> Self {
self.transaction_type = Some(transaction_type);
self
}

/// Sets the gas limit for the transaction.
pub const fn gas_limit(mut self, gas_limit: u128) -> Self {
self.gas = Some(gas_limit);
Expand Down Expand Up @@ -579,6 +589,7 @@ impl From<TxLegacy> for TransactionRequest {
input: TransactionInput::from(tx.input),
nonce: Some(tx.nonce),
chain_id: tx.chain_id,
transaction_type: Some(0),
..Default::default()
}
}
Expand All @@ -596,6 +607,7 @@ impl From<TxEip2930> for TransactionRequest {
nonce: Some(tx.nonce),
chain_id: Some(tx.chain_id),
access_list: Some(tx.access_list),
transaction_type: Some(1),
..Default::default()
}
}
Expand All @@ -614,6 +626,7 @@ impl From<TxEip1559> for TransactionRequest {
nonce: Some(tx.nonce),
chain_id: Some(tx.chain_id),
access_list: Some(tx.access_list),
transaction_type: Some(2),
..Default::default()
}
}
Expand All @@ -634,6 +647,7 @@ impl From<TxEip4844> for TransactionRequest {
chain_id: Some(tx.chain_id),
access_list: Some(tx.access_list),
blob_versioned_hashes: Some(tx.blob_versioned_hashes),
transaction_type: Some(3),
..Default::default()
}
}
Expand All @@ -657,6 +671,7 @@ impl From<TxEip4844WithSidecar> for TransactionRequest {
access_list: Some(tx.access_list),
blob_versioned_hashes: Some(tx.blob_versioned_hashes),
sidecar: Some(sidecar),
transaction_type: Some(3),
..Default::default()
}
}
Expand Down
Loading