Function builder for TransacitonRequest (#5104)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
DoTheBestToGetTheBest
2023-10-22 02:06:20 -07:00
committed by GitHub
parent 2fd2b429a4
commit c74abbc6b1

View File

@ -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
}
}