Skip to content

Commit

Permalink
chore(script): save transaction pretty formatted (#2217)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse committed Jul 6, 2022
1 parent 110c0c2 commit 1eb6756
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cli/src/cmd/forge/script/sequence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,15 @@ impl ScriptSequence {
serde_json::from_str(&file).map_err(|e| e.into())
}

/// Saves the transactions as files
pub fn save(&mut self) -> eyre::Result<()> {
if !self.transactions.is_empty() {
self.timestamp = SystemTime::now().duration_since(UNIX_EPOCH)?.as_secs();
let path = self.path.to_string_lossy();
//../run-latest.json
serde_json::to_writer(BufWriter::new(fs::create_file(&self.path)?), &self)?;
serde_json::to_writer_pretty(BufWriter::new(fs::create_file(&self.path)?), &self)?;
//../run-[timestamp].json
serde_json::to_writer(
serde_json::to_writer_pretty(
BufWriter::new(fs::create_file(
path.replace("latest.json", &format!("{}.json", self.timestamp)),
)?),
Expand Down

0 comments on commit 1eb6756

Please sign in to comment.