From 1ef451eb432f441cf1116376c21db7ef0510947f Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 5 Jul 2024 15:07:01 +0200 Subject: [PATCH] feat: add helper to set both input and data fields --- crates/rpc-types-eth/src/transaction/request.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/rpc-types-eth/src/transaction/request.rs b/crates/rpc-types-eth/src/transaction/request.rs index c5ffd89d78e..ed27bae7ea4 100644 --- a/crates/rpc-types-eth/src/transaction/request.rs +++ b/crates/rpc-types-eth/src/transaction/request.rs @@ -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) -> 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) -> Self { + Self { data: input.clone(), input } + } + /// Consumes the type and returns the optional input data. #[inline] pub fn into_input(self) -> Option {