cfx_executor/executive/
transact_options.rs

1use crate::executive_observer::ExecutiveObserver;
2
3/// Transaction execution options.
4pub struct TransactOptions<O: ExecutiveObserver> {
5    pub observer: O,
6    pub settings: TransactSettings,
7}
8
9impl Default for TransactOptions<()> {
10    fn default() -> Self {
11        Self {
12            observer: (),
13            settings: TransactSettings::all_checks(),
14        }
15    }
16}
17
18#[derive(Debug, Clone, Copy)]
19pub struct TransactSettings {
20    pub charge_collateral: ChargeCollateral,
21    pub charge_gas: bool,
22    pub check_base_price: bool,
23    pub check_epoch_bound: bool,
24    pub forbid_eoa_with_code: bool,
25}
26
27#[derive(Debug, Clone, Copy)]
28pub enum ChargeCollateral {
29    /// Charge normal collateral.
30    Normal,
31    /// Estimate collateral which would be charged to the sender.
32    /// This mode does not actually charge the sender.
33    EstimateSender,
34    /// Estimate collateral which would be charged to the sponsor.
35    /// This mode does not actually charge the sponsor.
36    EstimateSponsor,
37}
38
39impl TransactSettings {
40    pub fn all_checks() -> Self {
41        Self {
42            charge_collateral: ChargeCollateral::Normal,
43            charge_gas: true,
44            check_epoch_bound: true,
45            check_base_price: true,
46            forbid_eoa_with_code: true,
47        }
48    }
49}