Skip to content

Commit

Permalink
fix: don't install contract if it is already installed
Browse files Browse the repository at this point in the history
  • Loading branch information
willemneal committed Feb 17, 2024
1 parent 41b79ac commit f11b0ac
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/soroban-cli/src/commands/contract/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::num::ParseIntError;

use clap::{command, Parser};
use soroban_env_host::xdr::{
self,
Error as XdrError, Hash, HostFunction, InvokeHostFunctionOp, Memo, MuxedAccount, Operation,
OperationBody, Preconditions, ScMetaEntry, ScMetaV0, SequenceNumber, Transaction,
TransactionExt, TransactionResult, TransactionResultResult, Uint256, VecM,
Expand Down Expand Up @@ -117,6 +118,13 @@ impl NetworkRunnable for Cmd {

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


let code_key = xdr::LedgerKey::ContractCode(xdr::LedgerKeyContractCode { hash: hash.clone() });
let contract_data = client.get_ledger_entries(&[code_key]).await?;
if !contract_data.entries.unwrap_or_default().is_empty() {
return Ok(hash);
}

// Currently internal errors are not returned if the contract code is expired
if let Some(TransactionResult {
Expand Down

0 comments on commit f11b0ac

Please sign in to comment.