Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

soroban-cli: Only Give RC SDK Contract Compilation Warning/Errors if Using Pubnet #1108

Merged
merged 3 commits into from
Dec 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 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,35 @@ 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
Loading