Skip to content

Commit

Permalink
Remove guard from function and bring it to the caller.
Browse files Browse the repository at this point in the history
  • Loading branch information
fnando committed Jun 14, 2024
1 parent 1f540a7 commit 1348467
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
8 changes: 2 additions & 6 deletions cmd/soroban-cli/src/commands/config/alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub enum Error {
}

impl Args {
pub fn load(&self, alias: &str) -> Result<Option<Data>, Error> {
fn load(&self, alias: &str) -> Result<Option<Data>, Error> {
let path = self.alias_path(alias)?;

if !path.exists() {
Expand All @@ -51,11 +51,7 @@ impl Args {
Ok(config_dir.join("contract-ids").join(file_name))
}

pub fn save_contract_id(&self, contract_id: &str, alias: Option<&String>) -> Result<(), Error> {
let Some(alias) = alias else {
return Ok(());
};

pub fn save_contract_id(&self, contract_id: &str, alias: &str) -> Result<(), Error> {
let path = self.alias_path(alias)?;
let dir = path.parent().ok_or(Error::CannotAccessConfigDir)?;

Expand Down
5 changes: 3 additions & 2 deletions cmd/soroban-cli/src/commands/contract/deploy/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ impl Cmd {
match res {
TxnEnvelopeResult::TxnEnvelope(tx) => println!("{}", tx.to_xdr_base64(Limits::none())?),
TxnEnvelopeResult::Res(contract) => {
self.config
.save_contract_id(&contract, self.alias.as_ref())?;
if let Some(alias) = self.alias.clone() {
self.config.save_contract_id(&contract, &alias)?;
}

println!("{contract}");
}
Expand Down

0 comments on commit 1348467

Please sign in to comment.