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
use crate::{util::decode_addr, Result};
use ceres_sandbox::Transaction;
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
pub struct Tx {
pub method: String,
#[structopt(long)]
pub caller: Option<String>,
#[structopt(long)]
pub address: Option<String>,
#[structopt(long, short)]
pub balance: Option<u64>,
#[structopt(long, short)]
pub value_transferred: Option<u64>,
#[structopt(long, short)]
pub now: Option<String>,
#[structopt(long, short)]
pub minimum_balance: Option<u64>,
#[structopt(long, short, name = "string,")]
pub args: Vec<String>,
}
impl Tx {
pub fn tx(&self) -> Result<Transaction> {
Ok(Transaction {
caller: if let Some(caller) = self.caller.clone() {
decode_addr(&caller)?
} else {
Default::default()
},
address: if let Some(addr) = self.address.clone() {
decode_addr(&addr)?
} else {
Default::default()
},
balance: self.balance.unwrap_or(0),
value_transferred: self.value_transferred.unwrap_or(0),
now: Default::default(),
minimum_balance: self.minimum_balance.unwrap_or_default(),
})
}
}