Skip to content

Commit

Permalink
Only warn/error on RC SDK version if pubnet
Browse files Browse the repository at this point in the history
  • Loading branch information
stellarsaur committed Dec 4, 2023
1 parent d5acaf4 commit 71c4a9d
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions cmd/soroban-cli/src/commands/contract/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use crate::rpc::{self, Client};
use crate::{commands::config, utils, wasm};

const CONTRACT_META_SDK_KEY: &str = "rssdkver";
const PUBLIC_NETWORK_PASSPHRASE: &str = "Public Global Stellar Network ; September 2015";

#[derive(Parser, Debug, Clone)]
#[group(skip)]
Expand Down Expand Up @@ -70,29 +71,30 @@ impl Cmd {
}

pub async fn run_and_get_hash(&self) -> Result<Hash, Error> {
self.run_against_rpc_server(&self.wasm.read()?).await
}

async fn run_against_rpc_server(&self, contract: &[u8]) -> Result<Hash, Error> {
let network = self.config.get_network()?;
let client = Client::new(&network.rpc_url)?;
client
.verify_network_passphrase(Some(&network.network_passphrase))
.await?;
let wasm_spec = &self.wasm.parse().map_err(|e| Error::CannotParseWasm {
wasm: self.wasm.wasm.clone(),
error: e,
})?;
// Check Rust SDK version if using the public network.
if let Some(rs_sdk_ver) = get_contract_meta_sdk_version(wasm_spec) {
if rs_sdk_ver.contains("rc") && !self.ignore_checks {
if rs_sdk_ver.contains("rc") && !self.ignore_checks && network.network_passphrase == PUBLIC_NETWORK_PASSPHRASE {
return Err(Error::ContractCompiledWithReleaseCandidateSdk {
wasm: self.wasm.wasm.clone(),
version: rs_sdk_ver,
});
} else if rs_sdk_ver.contains("rc") {
} else if rs_sdk_ver.contains("rc") && network.network_passphrase == PUBLIC_NETWORK_PASSPHRASE{
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 = self.wasm.wasm.display());
}
}
self.run_against_rpc_server(&self.wasm.read()?).await
}

async fn run_against_rpc_server(&self, contract: &[u8]) -> Result<Hash, Error> {
let network = self.config.get_network()?;
let client = Client::new(&network.rpc_url)?;
client
.verify_network_passphrase(Some(&network.network_passphrase))
.await?;
let key = self.config.key_pair()?;

// Get the account sequence number
Expand Down

0 comments on commit 71c4a9d

Please sign in to comment.