Skip to content

Commit

Permalink
fix: don't fail if wasm already exists and log associated error as debug
Browse files Browse the repository at this point in the history
  • Loading branch information
willemneal committed Aug 23, 2023
1 parent 008c24b commit 16a5402
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
11 changes: 5 additions & 6 deletions cmd/soroban-cli/src/commands/contract/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,27 +87,26 @@ impl Cmd {
let public_strkey = stellar_strkey::ed25519::PublicKey(key.public.to_bytes()).to_string();
let account_details = client.get_account(&public_strkey).await?;
let sequence: i64 = account_details.seq_num.into();

let (tx_without_preflight, hash) =
build_install_contract_code_tx(contract.clone(), sequence + 1, self.fee.fee, &key)?;

// Currently internal errors are not returned if the contract code is expired
if let (
if let Ok((
TransactionResult {
result: TransactionResultResult::TxInternalError,
..
},
meta,
_,
_,
) = client
)) = client
.prepare_and_send_transaction(
&tx_without_preflight,
&key,
&network.network_passphrase,
None,
)
.await?
.await
{
tracing::trace!("{meta:#?}");
// Now just need to restore it and don't have to install again
restore::Cmd {
contract_id: None,
Expand Down
4 changes: 4 additions & 0 deletions cmd/soroban-cli/src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ pub mod auth;
pub mod budget;
pub mod event;
pub mod footprint;
pub mod txn_error;
pub mod txn_response_error;

pub use auth::*;
pub use budget::*;
pub use event::*;
pub use footprint::*;
pub use txn_error::*;
pub use txn_response_error::*;
3 changes: 3 additions & 0 deletions cmd/soroban-cli/src/log/txn_error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub fn txn_error(error: &crate::rpc::Error) {
tracing::debug!(?error);
}
5 changes: 5 additions & 0 deletions cmd/soroban-cli/src/log/txn_response_error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use crate::rpc::GetTransactionResponse;

pub fn txn_response_error(error: &GetTransactionResponse) {
tracing::debug!(?error);
}
9 changes: 6 additions & 3 deletions cmd/soroban-cli/src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,11 @@ soroban config identity fund {address} --helper-url <url>"#
TransactionResult::read_xdr_base64(&mut x.as_bytes())
.map_err(|_| Error::InvalidResponse)
})
.map(|r| r.result);
tracing::error!(?error);
.map(|r| r.result)
.map_err(|e| {
crate::log::txn_error::txn_error(&e);
e
});
return Err(Error::TransactionSubmissionFailed(format!("{:#?}", error?)));
}
// even if status == "success" we need to query the transaction status in order to get the result
Expand All @@ -535,7 +538,7 @@ soroban config identity fund {address} --helper-url <url>"#
return Ok((result, meta, events));
}
"FAILED" => {
tracing::error!(?response);
crate::log::txn_response_error(&response);
// TODO: provide a more elaborate error
return Err(Error::TransactionSubmissionFailed(format!("{response:#?}")));
}
Expand Down

0 comments on commit 16a5402

Please sign in to comment.