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

feat: add other fields support in Transaction #68

Merged
merged 1 commit into from
Dec 11, 2023
Merged
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
7 changes: 7 additions & 0 deletions crates/rpc-types/src/eth/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ mod typed;

pub use tx_type::*;

use crate::other::OtherFields;

/// Transaction object used in RPC
#[derive(Debug, Default, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
Expand Down Expand Up @@ -71,6 +73,9 @@ pub struct Transaction {
/// EIP2718
#[serde(rename = "type", skip_serializing_if = "Option::is_none")]
pub transaction_type: Option<U64>,
/// Arbitrary extra fields.
#[serde(flatten)]
pub other: OtherFields,
}

#[cfg(test)]
Expand Down Expand Up @@ -105,6 +110,7 @@ mod tests {
max_fee_per_gas: Some(U128::from(21)),
max_priority_fee_per_gas: Some(U128::from(22)),
max_fee_per_blob_gas: None,
other: Default::default(),
};
let serialized = serde_json::to_string(&transaction).unwrap();
assert_eq!(
Expand Down Expand Up @@ -142,6 +148,7 @@ mod tests {
max_fee_per_gas: Some(U128::from(21)),
max_priority_fee_per_gas: Some(U128::from(22)),
max_fee_per_blob_gas: None,
other: Default::default(),
};
let serialized = serde_json::to_string(&transaction).unwrap();
assert_eq!(
Expand Down