Skip to content

Commit

Permalink
Rust fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
stellarsaur committed Oct 31, 2023
1 parent 14ee085 commit 301a298
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions cmd/soroban-cli/src/commands/contract/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use soroban_env_host::{
AccountId, ContractExecutable, ContractIdPreimage, ContractIdPreimageFromAddress,
CreateContractArgs, Error as XdrError, Hash, HashIdPreimage, HashIdPreimageContractId,
HostFunction, InvokeHostFunctionOp, Memo, MuxedAccount, Operation, OperationBody,
Preconditions, PublicKey, ScAddress, SequenceNumber, Transaction, TransactionExt, Uint256,
VecM, WriteXdr, ScMetaV0, ScMetaEntry,
Preconditions, PublicKey, ScAddress, ScMetaEntry, ScMetaV0, SequenceNumber, Transaction,
TransactionExt, Uint256, VecM, WriteXdr,
},
HostError,
};
Expand Down Expand Up @@ -81,14 +81,14 @@ pub enum Error {
#[error("cannot parse WASM file {wasm}: {error}")]
CannotParseWasm {
wasm: std::path::PathBuf,
error: wasm::Error
error: wasm::Error,
},
#[error("Must provide either --wasm or --wash-hash")]
WasmNotProvided,
#[error("the deployed smart contract {wasm} was built with Soroban Rust SDK v{version}, a release candidate version not intended for use with the Stellar Public Network. To deploy anyway, use --ignore-checks")]
ContractCompiledWithReleaseCandidateSdk {
wasm: std::path::PathBuf,
version: String
version: String,
},
#[error(transparent)]
Rpc(#[from] rpc::Error),
Expand All @@ -107,18 +107,18 @@ impl Cmd {

pub async fn run_and_get_contract_id(&self) -> Result<String, Error> {
if let Some(wasm_path) = &self.wasm {
let wasm_args = wasm::Args { wasm: wasm_path.clone() };
let wasm_spec = wasm_args.parse().map_err(|e| {
Error::CannotParseWasm {
wasm: wasm_path.clone(),
error: e
}
let wasm_args = wasm::Args {
wasm: wasm_path.clone(),
};
let wasm_spec = wasm_args.parse().map_err(|e| Error::CannotParseWasm {
wasm: wasm_path.clone(),
error: e,
})?;
if let Some(rs_sdk_ver) = get_contract_meta_sdk_version(&wasm_spec) {
if rs_sdk_ver.contains("rc") && !self.ignore_checks {
return Err(Error::ContractCompiledWithReleaseCandidateSdk {
return Err(Error::ContractCompiledWithReleaseCandidateSdk {
wasm: wasm_path.clone(),
version: rs_sdk_ver
version: rs_sdk_ver,
});
} else if rs_sdk_ver.contains("rc") {
tracing::warn!("the deployed smart contract {path} was built with Soroban Rust SDK v{rs_sdk_ver}, a release candidate version not intended for use with the Stellar Public Network", path = wasm_path.display());
Expand Down Expand Up @@ -190,11 +190,9 @@ impl Cmd {

fn get_contract_meta_sdk_version(wasm_spec: &utils::contract_spec::ContractSpec) -> Option<String> {
let rs_sdk_version_option = if let Some(_meta) = &wasm_spec.meta_base64 {
wasm_spec.meta.iter().find(|entry| {
match entry {
ScMetaEntry::ScMetaV0(ScMetaV0 { key, .. }) => {
key.to_string_lossy().contains(CONTRACT_META_SDK_KEY)
}
wasm_spec.meta.iter().find(|entry| match entry {
ScMetaEntry::ScMetaV0(ScMetaV0 { key, .. }) => {
key.to_string_lossy().contains(CONTRACT_META_SDK_KEY)
}
})
} else {
Expand Down

0 comments on commit 301a298

Please sign in to comment.