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

chore: serde misc CallRequest #5345

Merged
merged 1 commit into from
Nov 7, 2023
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
5 changes: 4 additions & 1 deletion crates/rpc/rpc-types/src/eth/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,13 @@ pub struct CallRequest {
/// AccessList
pub access_list: Option<AccessList>,
/// Max Fee per Blob gas for EIP-4844 transactions
#[serde(skip_serializing_if = "Option::is_none")]
pub max_fee_per_blob_gas: Option<U256>,
/// Blob Versioned Hashes for EIP-4844 transactions
#[serde(skip_serializing_if = "Option::is_none")]
pub blob_versioned_hashes: Option<Vec<B256>>,
/// EIP-2718 type
#[serde(rename = "type")]
#[serde(rename = "type", skip_serializing_if = "Option::is_none")]
pub transaction_type: Option<U8>,
}

Expand Down Expand Up @@ -160,10 +161,12 @@ impl CallRequest {
#[derive(Debug, Clone, Default, Eq, PartialEq, Serialize, Deserialize)]
pub struct CallInput {
/// Transaction data
#[serde(skip_serializing_if = "Option::is_none")]
pub input: Option<Bytes>,
/// Transaction data
///
/// This is the same as `input` but is used for backwards compatibility: <https://github.com/ethereum/go-ethereum/issues/15628>
#[serde(skip_serializing_if = "Option::is_none")]
pub data: Option<Bytes>,
}

Expand Down
16 changes: 6 additions & 10 deletions crates/rpc/rpc-types/src/eth/transaction/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,24 @@ pub struct TransactionRequest {
/// to address
pub to: Option<Address>,
/// legacy, gas Price
#[serde(default)]
pub gas_price: Option<U128>,
/// max base fee per gas sender is willing to pay
#[serde(default)]
pub max_fee_per_gas: Option<U128>,
/// miner tip
#[serde(default)]
pub max_priority_fee_per_gas: Option<U128>,
/// gas
pub gas: Option<U256>,
/// value of th tx in wei
pub value: Option<U256>,
/// Any additional data sent
#[serde(alias = "input")]
pub data: Option<Bytes>,
#[serde(alias = "data")]
pub input: Option<Bytes>,
/// Transaction nonce
pub nonce: Option<U64>,
/// warm storage access pre-payment
#[serde(default)]
pub access_list: Option<AccessList>,
/// EIP-2718 type
#[serde(rename = "type")]
#[serde(rename = "type", skip_serializing_if = "Option::is_none")]
pub transaction_type: Option<U8>,
}

Expand All @@ -58,7 +54,7 @@ impl TransactionRequest {
max_priority_fee_per_gas,
gas,
value,
data,
input: data,
nonce,
mut access_list,
..
Expand Down Expand Up @@ -161,8 +157,8 @@ impl TransactionRequest {
}

/// Sets the input data for the transaction.
pub fn input(mut self, input: Bytes) -> Self {
self.data = Some(input);
pub fn input(mut self, input: impl Into<Bytes>) -> Self {
self.input = Some(input.into());
self
}

Expand Down
2 changes: 1 addition & 1 deletion crates/rpc/rpc/src/eth/api/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ where
gas_price: Some(U256::from(gas_price)),
max_fee_per_gas: Some(U256::from(max_fee_per_gas)),
value: request.value,
input: request.data.clone().into(),
input: request.input.clone().into(),
nonce: request.nonce,
chain_id: Some(chain_id),
access_list: request.access_list.clone(),
Expand Down