fuels_programs/
calls.rs

1mod call_handler;
2mod contract_call;
3pub mod receipt_parser;
4mod script_call;
5pub mod traits;
6pub mod utils;
7
8pub use call_handler::*;
9pub use contract_call::*;
10use fuel_types::BlockHeight;
11pub use script_call::*;
12
13/// Used to control simulations/dry-runs
14#[derive(Debug, Clone)]
15pub struct Execution {
16    execution_type: ExecutionType,
17    at_height: Option<BlockHeight>,
18}
19
20impl Execution {
21    /// The transaction will be subject to all validations.
22    /// The tx fee must be covered, witnesses and UTXOs must be valid, etc.
23    pub fn realistic() -> Self {
24        Self {
25            execution_type: ExecutionType::Realistic,
26            at_height: None,
27        }
28    }
29    /// Most validation is disabled. Witnesses are replaced with fake ones, fake base assets are
30    /// added if necessary. Useful for fetching state without needing an account with base assets.
31    pub fn state_read_only() -> Self {
32        Self {
33            execution_type: ExecutionType::StateReadOnly,
34            at_height: None,
35        }
36    }
37
38    /// Simulating at as specific block height is only available if the node is using
39    /// `rocksdb` and has been started with the `historical_execution` flag.
40    pub fn at_height(mut self, height: impl Into<BlockHeight>) -> Self {
41        self.at_height = Some(height.into());
42        self
43    }
44}
45
46impl Default for Execution {
47    fn default() -> Self {
48        Self::realistic()
49    }
50}
51
52#[derive(Debug, Clone)]
53pub(crate) enum ExecutionType {
54    Realistic,
55    StateReadOnly,
56}