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 helper to set both input and data fields #1019

Merged
merged 1 commit into from
Jul 6, 2024
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
12 changes: 12 additions & 0 deletions crates/rpc-types-eth/src/transaction/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,11 +503,23 @@ impl TransactionInput {
Self::maybe_input(Some(data))
}

/// Creates a new instance with the given input data and sets both `input` and `data` fields to
/// the same value.
pub fn both(data: Bytes) -> Self {
Self::maybe_both(Some(data))
}

/// Creates a new instance with the given input data.
pub const fn maybe_input(input: Option<Bytes>) -> Self {
Self { input, data: None }
}

/// Creates a new instance with the given input data and sets both `input` and `data` fields to
/// the same value.
pub fn maybe_both(input: Option<Bytes>) -> Self {
Self { data: input.clone(), input }
}

/// Consumes the type and returns the optional input data.
#[inline]
pub fn into_input(self) -> Option<Bytes> {
Expand Down