Skip to content

Commit 06b6c87

Browse files
committed
refactor: introduce CARDANO_ERA constant to improve readability
1 parent 9442381 commit 06b6c87

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

mithril-common/src/chain_observer/cli_observer.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ use crate::crypto_helper::{encode_bech32, KESPeriod, OpCert, SerDeShelleyFileFor
1515
use crate::entities::{BlockNumber, ChainPoint, Epoch, SlotNumber, StakeDistribution};
1616
use crate::{CardanoNetwork, StdResult};
1717

18+
const CARDANO_ERA: &str = "latest";
19+
1820
/// `CliRunner` trait defines the asynchronous methods
1921
/// for interaction with the Cardano CLI.
2022
#[async_trait]
@@ -66,7 +68,7 @@ impl CardanoCliRunner {
6668
fn command_for_utxo(&self, address: &str, out_file: PathBuf) -> Command {
6769
let mut command = self.get_command();
6870
command
69-
.arg("latest")
71+
.arg(CARDANO_ERA)
7072
.arg("query")
7173
.arg("utxo")
7274
.arg("--address")
@@ -80,7 +82,10 @@ impl CardanoCliRunner {
8082

8183
fn command_for_stake_distribution(&self) -> Command {
8284
let mut command = self.get_command();
83-
command.arg("latest").arg("query").arg("stake-distribution");
85+
command
86+
.arg(CARDANO_ERA)
87+
.arg("query")
88+
.arg("stake-distribution");
8489
self.post_config_command(&mut command);
8590

8691
command
@@ -89,7 +94,7 @@ impl CardanoCliRunner {
8994
fn command_for_stake_snapshot(&self, stake_pool_id: &str) -> Command {
9095
let mut command = self.get_command();
9196
command
92-
.arg("latest")
97+
.arg(CARDANO_ERA)
9398
.arg("query")
9499
.arg("stake-snapshot")
95100
.arg("--stake-pool-id")
@@ -102,7 +107,7 @@ impl CardanoCliRunner {
102107
fn command_for_stake_snapshot_all_pools(&self) -> Command {
103108
let mut command = self.get_command();
104109
command
105-
.arg("latest")
110+
.arg(CARDANO_ERA)
106111
.arg("query")
107112
.arg("stake-snapshot")
108113
.arg("--all-stake-pools");
@@ -113,15 +118,15 @@ impl CardanoCliRunner {
113118

114119
fn command_for_epoch(&self) -> Command {
115120
let mut command = self.get_command();
116-
command.arg("latest").arg("query").arg("tip");
121+
command.arg(CARDANO_ERA).arg("query").arg("tip");
117122
self.post_config_command(&mut command);
118123

119124
command
120125
}
121126

122127
fn command_for_chain_point(&self) -> Command {
123128
let mut command = self.get_command();
124-
command.arg("latest").arg("query").arg("tip");
129+
command.arg(CARDANO_ERA).arg("query").arg("tip");
125130
self.post_config_command(&mut command);
126131

127132
command
@@ -130,7 +135,7 @@ impl CardanoCliRunner {
130135
fn command_for_kes_period(&self, opcert_file: &str) -> Command {
131136
let mut command = self.get_command();
132137
command
133-
.arg("latest")
138+
.arg(CARDANO_ERA)
134139
.arg("query")
135140
.arg("kes-period-info")
136141
.arg("--op-cert-file")

0 commit comments

Comments
 (0)