mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-29 17:18:08 -05:00
chore: add transaction_type field to callrequest (#2590)
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
use reth_primitives::{AccessList, Address, Bytes, U256, U64};
|
||||
use reth_primitives::{AccessList, Address, Bytes, U256, U64, U8};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Call request
|
||||
#[derive(Debug, Clone, Default, Eq, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(default, rename_all = "camelCase", deny_unknown_fields)]
|
||||
#[serde(default, rename_all = "camelCase")]
|
||||
pub struct CallRequest {
|
||||
/// From
|
||||
pub from: Option<Address>,
|
||||
@@ -19,7 +19,10 @@ pub struct CallRequest {
|
||||
pub gas: Option<U256>,
|
||||
/// Value
|
||||
pub value: Option<U256>,
|
||||
/// Data
|
||||
/// Transaction data
|
||||
///
|
||||
/// This accepts both `input` and `data`
|
||||
#[serde(alias = "input")]
|
||||
pub data: Option<Bytes>,
|
||||
/// Nonce
|
||||
pub nonce: Option<U256>,
|
||||
@@ -27,6 +30,9 @@ pub struct CallRequest {
|
||||
pub chain_id: Option<U64>,
|
||||
/// AccessList
|
||||
pub access_list: Option<AccessList>,
|
||||
/// EIP-2718 type
|
||||
#[serde(rename = "type")]
|
||||
pub transaction_type: Option<U8>,
|
||||
}
|
||||
|
||||
impl CallRequest {
|
||||
@@ -37,3 +43,14 @@ impl CallRequest {
|
||||
self.gas_price.or(self.max_fee_per_gas)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn serde_call_request() {
|
||||
let s = r#"{"accessList":[],"data":"0x0902f1ac","to":"0xa478c2975ab1ea89e8196811f51a7b7ade33eb11","type":"0x02"}"#;
|
||||
let _req = serde_json::from_str::<CallRequest>(s).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use crate::eth::transaction::typed::{
|
||||
EIP1559TransactionRequest, EIP2930TransactionRequest, LegacyTransactionRequest,
|
||||
TransactionKind, TypedTransactionRequest,
|
||||
};
|
||||
use reth_primitives::{AccessList, Address, Bytes, U128, U256};
|
||||
use reth_primitives::{AccessList, Address, Bytes, U128, U256, U8};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Represents _all_ transaction requests received from RPC
|
||||
@@ -28,6 +28,7 @@ pub struct TransactionRequest {
|
||||
/// value of th tx in wei
|
||||
pub value: Option<U256>,
|
||||
/// Any additional data sent
|
||||
#[serde(alias = "input")]
|
||||
pub data: Option<Bytes>,
|
||||
/// Transaction nonce
|
||||
pub nonce: Option<U256>,
|
||||
@@ -36,7 +37,7 @@ pub struct TransactionRequest {
|
||||
pub access_list: Option<AccessList>,
|
||||
/// EIP-2718 type
|
||||
#[serde(rename = "type")]
|
||||
pub transaction_type: Option<U256>,
|
||||
pub transaction_type: Option<U8>,
|
||||
}
|
||||
|
||||
// == impl TransactionRequest ==
|
||||
|
||||
@@ -368,6 +368,7 @@ where
|
||||
chain_id: Some(chain_id),
|
||||
access_list: request.access_list.clone(),
|
||||
max_priority_fee_per_gas: Some(U256::from(max_fee_per_gas)),
|
||||
transaction_type: None,
|
||||
},
|
||||
BlockId::Number(BlockNumberOrTag::Pending),
|
||||
)
|
||||
|
||||
@@ -211,6 +211,7 @@ pub(crate) fn create_txn_env(block_env: &BlockEnv, request: CallRequest) -> EthR
|
||||
nonce,
|
||||
access_list,
|
||||
chain_id,
|
||||
..
|
||||
} = request;
|
||||
|
||||
let CallFees { max_priority_fee_per_gas, gas_price } = CallFees::ensure_fees(
|
||||
|
||||
Reference in New Issue
Block a user