1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
use crate::constants::{
DEFAULT_BYTE_PRICE, DEFAULT_GAS_LIMIT, DEFAULT_GAS_PRICE, DEFAULT_MATURITY, NATIVE_ASSET_ID,
};
use fuel_tx::AssetId;
#[derive(Debug)]
pub struct TxParameters {
pub gas_price: u64,
pub gas_limit: u64,
pub byte_price: u64,
pub maturity: u64,
}
#[derive(Debug)]
pub struct CallParameters {
pub amount: u64,
pub asset_id: AssetId,
}
impl CallParameters {
pub fn new(amount: Option<u64>, asset_id: Option<AssetId>) -> Self {
Self {
amount: amount.unwrap_or(0),
asset_id: asset_id.unwrap_or(NATIVE_ASSET_ID),
}
}
}
impl Default for CallParameters {
fn default() -> Self {
Self {
amount: 0,
asset_id: NATIVE_ASSET_ID,
}
}
}
impl Default for TxParameters {
fn default() -> Self {
Self {
gas_price: DEFAULT_GAS_PRICE,
gas_limit: DEFAULT_GAS_LIMIT,
byte_price: DEFAULT_BYTE_PRICE,
maturity: DEFAULT_MATURITY,
}
}
}
impl TxParameters {
pub fn new(
gas_price: Option<u64>,
gas_limit: Option<u64>,
byte_price: Option<u64>,
maturity: Option<u64>,
) -> Self {
Self {
gas_price: gas_price.unwrap_or(DEFAULT_GAS_PRICE),
gas_limit: gas_limit.unwrap_or(DEFAULT_GAS_LIMIT),
byte_price: byte_price.unwrap_or(DEFAULT_BYTE_PRICE),
maturity: maturity.unwrap_or(DEFAULT_MATURITY),
}
}
}