Skip to content

Commit

Permalink
feat: add helper to set both input and data fields (#1019)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Jul 6, 2024
1 parent 96e3a84 commit 07d1de5
Showing 1 changed file with 12 additions and 0 deletions.
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

0 comments on commit 07d1de5

Please sign in to comment.