Skip to content

Commit

Permalink
use terms simulate and send for consistency with actions a user performs
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmcculloch authored May 2, 2024
1 parent a0e1104 commit 6d5a5e3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions cmd/soroban-cli/src/commands/cache/actionlog/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ impl Cmd {
let (action, _) = data::read(&self.ulid()?)?;
let output = if self.output.is_some() {
match action {
data::Action::Transaction(sim) => sim.envelope_xdr.expect("missing envelope"),
data::Action::Simulation(_) => todo!("Only read transactions"),
data::Action::Send(sim) => sim.envelope_xdr.expect("missing envelope"),
data::Action::Simulate(_) => todo!("Only read transactions"),
}
} else {
serde_json::to_string_pretty(&action)?
Expand Down
18 changes: 9 additions & 9 deletions cmd/soroban-cli/src/commands/config/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ impl std::fmt::Display for DatedAction {
let (id, a, uri) = (&self.0, &self.1, &self.2);
let datetime = to_datatime(id).format("%b %d %H:%M");
let status = match a {
Action::Simulation(sim) => sim
Action::Simulate(sim) => sim
.error
.as_ref()
.map_or_else(|| "SUCCESS".to_string(), |_| "ERROR".to_string()),
Action::Transaction(txn) => txn.status.to_string(),
Action::Send(txn) => txn.status.to_string(),
};
write!(f, "{id} {} {status} {datetime} {uri} ", a.type_str(),)
}
Expand All @@ -142,30 +142,30 @@ struct Data {

#[derive(Serialize, Deserialize, Clone)]
pub enum Action {
Simulation(SimulateTransactionResponse),
Transaction(GetTransactionResponseRaw),
Simulate(SimulateTransactionResponse),
Send(GetTransactionResponseRaw),
}

impl Action {
pub fn type_str(&self) -> String {
match self {
Action::Simulation(_) => "Sim",
Action::Transaction(_) => "Txn",
Action::Simulate(_) => "Sim",
Action::Send(_) => "Txn",
}
.to_string()
}
}

impl From<SimulateTransactionResponse> for Action {
fn from(res: SimulateTransactionResponse) -> Self {
Self::Simulation(res)
Self::Simulate(res)
}
}

impl TryFrom<GetTransactionResponse> for Action {
type Error = xdr::Error;
fn try_from(res: GetTransactionResponse) -> Result<Self, Self::Error> {
Ok(Self::Transaction(GetTransactionResponseRaw {
Ok(Self::Send(GetTransactionResponseRaw {
status: res.status,
envelope_xdr: res.envelope.as_ref().map(to_xdr).transpose()?,
result_xdr: res.result.as_ref().map(to_xdr).transpose()?,
Expand Down Expand Up @@ -194,7 +194,7 @@ mod test {
let (action, new_rpc_uri) = read(&id).unwrap();
assert_eq!(rpc_uri, new_rpc_uri);
match (action, original_action) {
(Action::Simulation(a), Action::Simulation(b)) => {
(Action::Simulate(a), Action::Simulate(b)) => {
assert_eq!(a.cost.cpu_insns, b.cost.cpu_insns);
}
_ => panic!("Action mismatch"),
Expand Down

0 comments on commit 6d5a5e3

Please sign in to comment.