Skip to content

Commit

Permalink
Remove dead code (#1492)
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmcculloch authored Jul 27, 2024
1 parent 0449dfd commit 40ac355
Showing 1 changed file with 0 additions and 67 deletions.
67 changes: 0 additions & 67 deletions cmd/soroban-cli/src/commands/contract/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,6 @@ use std::str::FromStr;
use std::{fmt::Debug, fs, io};

use clap::{arg, command, Parser};
use soroban_env_host::{
budget::Budget,
storage::Storage,
xdr::{
self, ContractCodeEntry, ContractDataDurability, ContractDataEntry, ContractExecutable,
Error as XdrError, LedgerEntryData, LedgerKey, LedgerKeyContractCode,
LedgerKeyContractData, ScAddress, ScContractInstance, ScVal,
},
};

use soroban_spec::read::FromWasmError;
use stellar_strkey::DecodeError;

use crate::commands::{global, NetworkRunnable};
use crate::config::{
Expand Down Expand Up @@ -69,21 +57,9 @@ pub enum Error {
#[error(transparent)]
Locator(#[from] locator::Error),
#[error(transparent)]
Xdr(#[from] XdrError),
#[error(transparent)]
Spec(#[from] soroban_spec::read::FromWasmError),
#[error(transparent)]
Io(#[from] std::io::Error),
#[error("missing result")]
MissingResult,
#[error("unexpected contract code data type: {0:?}")]
UnexpectedContractCodeDataType(LedgerEntryData),
#[error("reading file {0:?}: {1}")]
CannotWriteContractFile(PathBuf, io::Error),
#[error("cannot parse contract ID {0}: {1}")]
CannotParseContractId(String, DecodeError),
#[error("network details not provided")]
NetworkNotProvided,
#[error(transparent)]
Network(#[from] network::Error),
#[error("cannot create contract directory for {0:?}")]
Expand Down Expand Up @@ -153,46 +129,3 @@ impl NetworkRunnable for Cmd {
Ok(client.get_remote_wasm(&contract_id).await?)
}
}
pub fn get_contract_wasm_from_storage(
storage: &mut Storage,
contract_id: [u8; 32],
) -> Result<Vec<u8>, FromWasmError> {
let key = LedgerKey::ContractData(LedgerKeyContractData {
contract: ScAddress::Contract(contract_id.into()),
key: ScVal::LedgerKeyContractInstance,
durability: ContractDataDurability::Persistent,
});
match storage.get(&key.into(), &Budget::default()) {
Ok(rc) => match rc.as_ref() {
xdr::LedgerEntry {
data:
LedgerEntryData::ContractData(ContractDataEntry {
val: ScVal::ContractInstance(ScContractInstance { executable, .. }),
..
}),
..
} => match executable {
ContractExecutable::Wasm(hash) => {
if let Ok(rc) = storage.get(
&LedgerKey::ContractCode(LedgerKeyContractCode { hash: hash.clone() })
.into(),
&Budget::default(),
) {
match rc.as_ref() {
xdr::LedgerEntry {
data: LedgerEntryData::ContractCode(ContractCodeEntry { code, .. }),
..
} => Ok(code.to_vec()),
_ => Err(FromWasmError::NotFound),
}
} else {
Err(FromWasmError::NotFound)
}
}
ContractExecutable::StellarAsset => todo!(),
},
_ => Err(FromWasmError::NotFound),
},
_ => Err(FromWasmError::NotFound),
}
}

0 comments on commit 40ac355

Please sign in to comment.