From c74abbc6b11069fbf070967fe87b8dbddd22e0db Mon Sep 17 00:00:00 2001 From: DoTheBestToGetTheBest <146037313+DoTheBestToGetTheBest@users.noreply.github.com> Date: Sun, 22 Oct 2023 02:06:20 -0700 Subject: [PATCH] Function builder for TransacitonRequest (#5104) Co-authored-by: Matthias Seitz --- .../rpc-types/src/eth/transaction/request.rs | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/crates/rpc/rpc-types/src/eth/transaction/request.rs b/crates/rpc/rpc-types/src/eth/transaction/request.rs index e77699efb..a7420ae03 100644 --- a/crates/rpc/rpc-types/src/eth/transaction/request.rs +++ b/crates/rpc/rpc-types/src/eth/transaction/request.rs @@ -111,7 +111,62 @@ impl TransactionRequest { access_list: access_list.unwrap_or_default(), })) } + _ => None, } } + + /// Sets the gas limit for the transaction. + pub fn gas_limit(mut self, gas_limit: u64) -> Self { + self.gas = Some(U256::from(gas_limit)); + self + } + + /// Sets the nonce for the transaction. + pub fn nonce(mut self, nonce: u64) -> Self { + self.nonce = Some(U64::from(nonce)); + self + } + + /// Sets the maximum fee per gas for the transaction. + pub fn max_fee_per_gas(mut self, max_fee_per_gas: u128) -> Self { + self.max_fee_per_gas = Some(U128::from(max_fee_per_gas)); + self + } + + /// Sets the maximum priority fee per gas for the transaction. + pub fn max_priority_fee_per_gas(mut self, max_priority_fee_per_gas: u128) -> Self { + self.max_priority_fee_per_gas = Some(U128::from(max_priority_fee_per_gas)); + self + } + + /// Sets the recipient address for the transaction. + pub fn to(mut self, to: Address) -> Self { + self.to = Some(to); + self + } + /// Sets the value (amount) for the transaction. + + pub fn value(mut self, value: u128) -> Self { + self.value = Some(U256::from(value)); + self + } + + /// Sets the access list for the transaction. + pub fn access_list(mut self, access_list: AccessList) -> Self { + self.access_list = Some(access_list); + self + } + + /// Sets the input data for the transaction. + pub fn input(mut self, input: Bytes) -> Self { + self.data = Some(input); + self + } + + /// Sets the transactions type for the transactions. + pub fn transaction_type(mut self, transaction_type: u8) -> Self { + self.transaction_type = Some(U8::from(transaction_type)); + self + } }