-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix-contract-init-conflict
- Loading branch information
Showing
6 changed files
with
87 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
use std::fmt::Display; | ||
|
||
use soroban_env_host::xdr::{Error as XdrError, Transaction}; | ||
|
||
use crate::{ | ||
config::network::Network, | ||
utils::{explorer_url_for_transaction, transaction_hash}, | ||
}; | ||
|
||
pub struct Print { | ||
pub quiet: bool, | ||
} | ||
|
||
impl Print { | ||
pub fn new(quiet: bool) -> Print { | ||
Print { quiet } | ||
} | ||
|
||
/// # Errors | ||
/// | ||
/// Might return an error | ||
pub fn log_transaction( | ||
&self, | ||
tx: &Transaction, | ||
network: &Network, | ||
show_link: bool, | ||
) -> Result<(), XdrError> { | ||
let tx_hash = transaction_hash(tx, &network.network_passphrase)?; | ||
let hash = hex::encode(tx_hash); | ||
|
||
self.infoln(format!("Transaction hash is {hash}").as_str()); | ||
|
||
if show_link { | ||
if let Some(url) = explorer_url_for_transaction(network, &hash) { | ||
self.linkln(url); | ||
} | ||
} | ||
|
||
Ok(()) | ||
} | ||
} | ||
|
||
macro_rules! create_print_functions { | ||
($name:ident, $nameln:ident, $icon:expr) => { | ||
impl Print { | ||
#[allow(dead_code)] | ||
pub fn $name<T: Display + Sized>(&self, message: T) { | ||
if !self.quiet { | ||
print!("{} {}", $icon, message); | ||
} | ||
} | ||
|
||
#[allow(dead_code)] | ||
pub fn $nameln<T: Display + Sized>(&self, message: T) { | ||
if !self.quiet { | ||
println!("{} {}", $icon, message); | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
|
||
create_print_functions!(bucket, bucketln, "🪣"); | ||
create_print_functions!(check, checkln, "✅"); | ||
create_print_functions!(error, errorln, "❌"); | ||
create_print_functions!(globe, globeln, "🌎"); | ||
create_print_functions!(info, infoln, "ℹ️"); | ||
create_print_functions!(link, linkln, "🔗"); | ||
create_print_functions!(save, saveln, "💾"); | ||
create_print_functions!(search, searchln, "🔎"); |