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
65
66
67
68
use crate::constants::{
BASE_ASSET_ID, DEFAULT_BYTE_PRICE, DEFAULT_FORWARDED_GAS, DEFAULT_GAS_LIMIT, DEFAULT_GAS_PRICE,
DEFAULT_MATURITY,
};
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,
pub gas_forwarded: u64,
}
impl CallParameters {
pub fn new(amount: Option<u64>, asset_id: Option<AssetId>, gas_forwarded: Option<u64>) -> Self {
Self {
amount: amount.unwrap_or(0),
asset_id: asset_id.unwrap_or(BASE_ASSET_ID),
gas_forwarded: gas_forwarded.unwrap_or(DEFAULT_FORWARDED_GAS),
}
}
}
impl Default for CallParameters {
fn default() -> Self {
Self {
amount: 0,
asset_id: BASE_ASSET_ID,
gas_forwarded: DEFAULT_FORWARDED_GAS,
}
}
}
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),
}
}
}