From 84833a40835271c0c94491615006fc6746a3f14b Mon Sep 17 00:00:00 2001 From: SkymanOne Date: Mon, 21 Aug 2023 18:22:13 +0100 Subject: [PATCH 1/8] prod chain macro, prompt for instantiation --- Cargo.lock | 7 +++ crates/extrinsics/Cargo.toml | 1 + crates/extrinsics/src/instantiate.rs | 17 +++++- crates/extrinsics/src/lib.rs | 76 ++++++++++++++++++++++++- crates/extrinsics/src/prod_chains.rs | 83 ++++++++++++++++++++++++++++ 5 files changed, 181 insertions(+), 3 deletions(-) create mode 100644 crates/extrinsics/src/prod_chains.rs diff --git a/Cargo.lock b/Cargo.lock index c638fb88b..8fda1f140 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -400,6 +400,12 @@ dependencies = [ "serde", ] +[[package]] +name = "bimap" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "230c5f1ca6a325a32553f8640d31ac9b49f2411e901e427570154868b46da4f7" + [[package]] name = "bincode" version = "1.3.3" @@ -980,6 +986,7 @@ name = "contract-extrinsics" version = "4.0.0-alpha" dependencies = [ "anyhow", + "bimap", "clap", "colored", "contract-build", diff --git a/crates/extrinsics/Cargo.toml b/crates/extrinsics/Cargo.toml index 5322ea790..cbb9020f6 100644 --- a/crates/extrinsics/Cargo.toml +++ b/crates/extrinsics/Cargo.toml @@ -38,3 +38,4 @@ subxt = "0.31.0" subxt-signer = { version = "0.31.0", features = ["subxt", "sr25519"] } hex = "0.4.3" jsonrpsee = { version = "0.20.0", features = ["ws-client"] } +bimap = "0.6.3" diff --git a/crates/extrinsics/src/instantiate.rs b/crates/extrinsics/src/instantiate.rs index f2f22aa29..51b318cee 100644 --- a/crates/extrinsics/src/instantiate.rs +++ b/crates/extrinsics/src/instantiate.rs @@ -14,6 +14,11 @@ // You should have received a copy of the GNU General Public License // along with cargo-contract. If not, see . +use crate::{ + prompt_confirm_unverifiable_upload, + Chain, +}; + use super::{ account_id, display_contract_exec_result, @@ -113,7 +118,8 @@ impl InstantiateCommand { let transcoder = artifacts.contract_transcoder()?; let data = transcoder.encode(&self.constructor, &self.args)?; let signer = self.extrinsic_opts.signer()?; - let url = self.extrinsic_opts.url_to_string(); + let (chain, url) = self.extrinsic_opts.chain_and_endpoint(); + let is_verifiable = artifacts.is_verifiable(); let verbosity = self.extrinsic_opts.verbosity()?; let code = if let Some(code) = artifacts.code { Code::Upload(code.0) @@ -154,6 +160,8 @@ impl InstantiateCommand { signer, transcoder, output_json: self.output_json, + chain, + is_verifiable, }; exec.exec(self.extrinsic_opts.execute).await @@ -188,6 +196,8 @@ pub struct Exec { signer: Keypair, transcoder: ContractMessageTranscoder, output_json: bool, + chain: Chain, + is_verifiable: bool, } impl Exec { @@ -240,6 +250,11 @@ impl Exec { let gas_limit = self.pre_submit_dry_run_gas_estimate().await?; match self.args.code.clone() { Code::Upload(code) => { + if let Chain::Production(name) = &self.chain { + if !self.is_verifiable { + prompt_confirm_unverifiable_upload(name)?; + } + } self.instantiate_with_code(code, gas_limit).await?; } Code::Existing(code_hash) => { diff --git a/crates/extrinsics/src/lib.rs b/crates/extrinsics/src/lib.rs index 01df9aa54..047949fd9 100644 --- a/crates/extrinsics/src/lib.rs +++ b/crates/extrinsics/src/lib.rs @@ -19,6 +19,7 @@ mod call; mod error; mod events; mod instantiate; +mod prod_chains; mod remove; mod runtime_api; mod upload; @@ -27,12 +28,12 @@ mod upload; #[cfg(feature = "integration-tests")] mod integration_tests; +use prod_chains::ProductionChain; use subxt::utils::AccountId32; use anyhow::{ anyhow, Context, - Ok, Result, }; use colored::Colorize; @@ -119,6 +120,9 @@ pub struct ExtrinsicOpts { default_value = "ws://localhost:9944" )] url: url::Url, + /// A name of a production chain to upload or instantiate on the contract on. + #[clap(name = "chain", long, conflicts_with = "url")] + chain: Option, /// Secret key URI for the account deploying the contract. /// /// e.g. @@ -165,7 +169,7 @@ impl ExtrinsicOpts { } /// Convert URL to String without omitting the default port - pub fn url_to_string(&self) -> String { + fn url_to_string(&self) -> String { let mut res = self.url.to_string(); match (self.url.port(), self.url.port_or_known_default()) { (None, Some(port)) => { @@ -176,6 +180,29 @@ impl ExtrinsicOpts { } } + /// Get the chain name and its URL endpoint. + /// If the user specify the endpoint manually, + /// but it still appears to be the production chain, + /// we still convert it. + pub fn chain_and_endpoint(&self) -> (Chain, String) { + if let Some(chain) = &self.chain { + ( + Chain::Production(chain.to_string()), + chain.end_point().to_string(), + ) + } else { + let url = self.url_to_string(); + if let Some(chain) = ProductionChain::chain_by_endpoint(&url) { + ( + Chain::Production(chain.to_string()), + chain.end_point().to_string(), + ) + } else { + (Chain::Custom, url) + } + } + } + /// Get the storage deposit limit converted to compact for passing to extrinsics. pub fn storage_deposit_limit( &self, @@ -190,6 +217,12 @@ impl ExtrinsicOpts { } } +#[derive(Debug)] +pub enum Chain { + Production(String), + Custom, +} + /// Contract artifacts for use with extrinsic commands. #[derive(Debug)] pub struct ContractArtifacts { @@ -308,6 +341,15 @@ impl ContractArtifacts { ContractMessageTranscoder::try_from(metadata) .context("Failed to deserialize ink project metadata from contract metadata") } + + /// Return true if the image is verifiable. + /// If the metadata can not be extracted then we assume that it can't be verified. + pub fn is_verifiable(&self) -> bool { + match self.metadata() { + Ok(m) => m.image.is_some(), + Err(_) => false, + } + } } /// The Wasm code of a contract. @@ -443,6 +485,36 @@ fn prompt_confirm_tx(show_details: F) -> Result<()> { } } +/// Prompt the user to confirm the upload of unverifiable code to the production chain. +fn prompt_confirm_unverifiable_upload(chain: &str) -> Result<()> { + println!( + "{} (skip with --skip-validate)", + "Confirm upload:".bright_white().bold() + ); + let warning = format!( + "You are trying to upload unverifiable code to {} mainnet", + chain + ) + .bold() + .red(); + print!("{}", warning); + println!( + "{} ({}/n): ", + "Continue?".bright_white().bold(), + "Y".bright_white().bold() + ); + + let mut buf = String::new(); + io::stdout().flush()?; + io::stdin().read_line(&mut buf)?; + match buf.trim().to_lowercase().as_str() { + // default is 'y' + "y" | "" => Ok(()), + "n" => Err(anyhow!("Upload canceled!")), + c => Err(anyhow!("Expected either 'y' or 'n', got '{}'", c)), + } +} + fn print_dry_running_status(msg: &str) { println!( "{:>width$} {} (skip with --skip-dry-run)", diff --git a/crates/extrinsics/src/prod_chains.rs b/crates/extrinsics/src/prod_chains.rs new file mode 100644 index 000000000..a6195926a --- /dev/null +++ b/crates/extrinsics/src/prod_chains.rs @@ -0,0 +1,83 @@ +// Copyright (C) Parity Technologies (UK) Ltd. +// This file is part of cargo-contract. +// +// cargo-contract is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// cargo-contract is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with cargo-contract. If not, see . + +//! This file simply contains the end points of the production chains +//! We hard-code these values to ensure that a user uploads a verifiable bundle + +use std::str::FromStr; + +/// Macro to generate enums with production chains and their respective endpoints +/// and generate required trait implementation +macro_rules! define_chains { + ( + $(#[$($attrs:tt)*])* + pub enum $root:ident { $( $c:ident = $ep:tt ),* $(,)? } + ) => { + $(#[$($attrs)*])* + #[derive(Debug, Clone, PartialEq, Eq)] + pub enum $root { $($c),* } + + impl $root { + pub fn end_point(&self) -> &str { + match self { + $( + $root::$c => $ep + ),* + } + } + + pub fn chain_by_endpoint(ep: &str) -> Option { + match ep { + $( + $ep => Some($root::$c), + )* + _ => None + } + } + } + + impl std::fmt::Display for $root { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + $( + $root::$c => f.write_str(stringify!($c)) + ),* + } + } + } + + impl FromStr for $root { + type Err = anyhow::Error; + fn from_str(s: &str) -> Result { + match s { + $( + stringify!($c) => Ok($root::$c), + )* + _ => Err(anyhow::anyhow!("Unrecognised chain name")) + } + } + } + }; +} + +define_chains! { + /// A list of all production chains where the contract can be deployed to. + pub enum ProductionChain { + AlephZero = "wss://ws.azero.dev", + Astar = "wss://rpc.astar.network", + Shiden = "wss://rpc.shiden.astar.network" + } +} From 700849ce5166a9787d1c7416bbabb2ab58b05e00 Mon Sep 17 00:00:00 2001 From: SkymanOne Date: Mon, 21 Aug 2023 18:43:26 +0100 Subject: [PATCH 2/8] warning upon upload --- crates/extrinsics/src/call.rs | 4 ++-- crates/extrinsics/src/remove.rs | 2 +- crates/extrinsics/src/upload.rs | 23 ++++++++++++++++++++--- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/crates/extrinsics/src/call.rs b/crates/extrinsics/src/call.rs index 689098b2f..12aa4d296 100644 --- a/crates/extrinsics/src/call.rs +++ b/crates/extrinsics/src/call.rs @@ -106,7 +106,7 @@ impl CallCommand { Runtime::new()? .block_on(async { - let url = self.extrinsic_opts.url_to_string(); + let (_, url) = self.extrinsic_opts.chain_and_endpoint(); let client = OnlineClient::from_url(url.clone()).await?; if !self.extrinsic_opts.execute { @@ -171,7 +171,7 @@ impl CallCommand { client: &Client, signer: &Keypair, ) -> Result> { - let url = self.extrinsic_opts.url_to_string(); + let (_, url) = self.extrinsic_opts.chain_and_endpoint(); let token_metadata = TokenMetadata::query(client).await?; let storage_deposit_limit = self .extrinsic_opts diff --git a/crates/extrinsics/src/remove.rs b/crates/extrinsics/src/remove.rs index d721eadba..a922bd55d 100644 --- a/crates/extrinsics/src/remove.rs +++ b/crates/extrinsics/src/remove.rs @@ -83,7 +83,7 @@ impl RemoveCommand { }?; Runtime::new()?.block_on(async { - let url = self.extrinsic_opts.url_to_string(); + let (_, url) = self.extrinsic_opts.chain_and_endpoint(); let client = OnlineClient::from_url(url.clone()).await?; if let Some(code_removed) = self .remove_code( diff --git a/crates/extrinsics/src/upload.rs b/crates/extrinsics/src/upload.rs index 2d1e81fbe..b53a2ed69 100644 --- a/crates/extrinsics/src/upload.rs +++ b/crates/extrinsics/src/upload.rs @@ -14,6 +14,12 @@ // You should have received a copy of the GNU General Public License // along with cargo-contract. If not, see . +use crate::{ + prompt_confirm_unverifiable_upload, + Chain, + GenericError, +}; + use super::{ account_id, display_dry_run_result_warning, @@ -63,6 +69,7 @@ impl UploadCommand { pub fn run(&self) -> Result<(), ErrorVariant> { let artifacts = self.extrinsic_opts.contract_artifacts()?; let signer = self.extrinsic_opts.signer()?; + let is_verifiable = artifacts.is_verifiable(); let artifacts_path = artifacts.artifact_path().to_path_buf(); let code = artifacts.code.ok_or_else(|| { @@ -75,7 +82,7 @@ impl UploadCommand { Runtime::new()? .block_on(async { - let url = self.extrinsic_opts.url_to_string(); + let (chain, url) = self.extrinsic_opts.chain_and_endpoint(); let client = OnlineClient::from_url(url.clone()).await?; if !self.extrinsic_opts.execute { @@ -104,7 +111,7 @@ impl UploadCommand { } } } else if let Some(code_stored) = - self.upload_code(&client, code, &signer).await? + self.upload_code(&client, code, &signer, chain, is_verifiable).await? { let upload_result = UploadResult { code_hash: format!("{:?}", code_stored.code_hash), @@ -131,7 +138,7 @@ impl UploadCommand { client: &Client, signer: &Keypair, ) -> Result> { - let url = self.extrinsic_opts.url_to_string(); + let (_, url) = self.extrinsic_opts.chain_and_endpoint(); let token_metadata = TokenMetadata::query(client).await?; let storage_deposit_limit = self .extrinsic_opts @@ -153,7 +160,17 @@ impl UploadCommand { client: &Client, code: WasmCode, signer: &Keypair, + chain: Chain, + is_verifiable: bool, ) -> Result, ErrorVariant> { + if let Chain::Production(name) = chain { + if !is_verifiable { + prompt_confirm_unverifiable_upload(&name).map_err(|e| { + ErrorVariant::Generic(GenericError::from_message(e.to_string())) + })?; + } + } + let token_metadata = TokenMetadata::query(client).await?; let storage_deposit_limit = self.extrinsic_opts.storage_deposit_limit(&token_metadata)?; From d7b7952d40f16c14a258b256e89a23347ff6621e Mon Sep 17 00:00:00 2001 From: SkymanOne Date: Mon, 21 Aug 2023 23:00:23 +0100 Subject: [PATCH 3/8] add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50eb4b1bd..c5331af01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Adds workflow for publishing docker images for the verifiable builds - [#1267](https://github.com/paritytech/cargo-contract/pull/1267) +- Specify prod chain URL with names and check for the verifiable build upon upload - [#1290](https://github.com/paritytech/cargo-contract/pull/1290) ## [4.0.0-alpha] From 51b7513e861123a793a1d298a3a04725b9d6886d Mon Sep 17 00:00:00 2001 From: SkymanOne Date: Mon, 21 Aug 2023 23:01:54 +0100 Subject: [PATCH 4/8] explicitly specify ports of prod chains --- crates/extrinsics/src/prod_chains.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/extrinsics/src/prod_chains.rs b/crates/extrinsics/src/prod_chains.rs index a6195926a..730e350cd 100644 --- a/crates/extrinsics/src/prod_chains.rs +++ b/crates/extrinsics/src/prod_chains.rs @@ -76,8 +76,8 @@ macro_rules! define_chains { define_chains! { /// A list of all production chains where the contract can be deployed to. pub enum ProductionChain { - AlephZero = "wss://ws.azero.dev", - Astar = "wss://rpc.astar.network", - Shiden = "wss://rpc.shiden.astar.network" + AlephZero = "wss://ws.azero.dev:443", + Astar = "wss://rpc.astar.network:443", + Shiden = "wss://rpc.shiden.astar.network:443" } } From 1282148ca6bfd9d98c3a4f04a37e532554588d3a Mon Sep 17 00:00:00 2001 From: SkymanOne Date: Mon, 21 Aug 2023 23:20:59 +0100 Subject: [PATCH 5/8] add docs --- crates/extrinsics/src/prod_chains.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/extrinsics/src/prod_chains.rs b/crates/extrinsics/src/prod_chains.rs index 730e350cd..d4e5942e8 100644 --- a/crates/extrinsics/src/prod_chains.rs +++ b/crates/extrinsics/src/prod_chains.rs @@ -31,6 +31,7 @@ macro_rules! define_chains { pub enum $root { $($c),* } impl $root { + /// Returns the endpoint URL of a chain. pub fn end_point(&self) -> &str { match self { $( @@ -39,6 +40,7 @@ macro_rules! define_chains { } } + /// Returns the chain type from the endpoint URL pub fn chain_by_endpoint(ep: &str) -> Option { match ep { $( From 93d51c6af94ff3de5a0c0fce08d8206d77382f72 Mon Sep 17 00:00:00 2001 From: SkymanOne Date: Mon, 21 Aug 2023 23:32:05 +0100 Subject: [PATCH 6/8] fix comment --- crates/extrinsics/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/extrinsics/src/lib.rs b/crates/extrinsics/src/lib.rs index 047949fd9..daafbe1bb 100644 --- a/crates/extrinsics/src/lib.rs +++ b/crates/extrinsics/src/lib.rs @@ -120,7 +120,7 @@ pub struct ExtrinsicOpts { default_value = "ws://localhost:9944" )] url: url::Url, - /// A name of a production chain to upload or instantiate on the contract on. + /// A name of a production chain to upload or instantiate the contract on. #[clap(name = "chain", long, conflicts_with = "url")] chain: Option, /// Secret key URI for the account deploying the contract. From 347480e887fbcf1ec1f6f5a922b9d104c8fd26f4 Mon Sep 17 00:00:00 2001 From: German Nikolishin Date: Thu, 21 Mar 2024 15:15:40 +0000 Subject: [PATCH 7/8] fix url resolution --- crates/cargo-contract/src/cmd/call.rs | 8 ++++++-- crates/cargo-contract/src/cmd/info.rs | 10 +++++++++- crates/cargo-contract/src/cmd/instantiate.rs | 9 +++++++-- crates/cargo-contract/src/cmd/mod.rs | 8 ++++---- crates/cargo-contract/src/cmd/rpc.rs | 10 +++++++++- crates/cargo-contract/src/cmd/upload.rs | 8 ++++++-- 6 files changed, 41 insertions(+), 12 deletions(-) diff --git a/crates/cargo-contract/src/cmd/call.rs b/crates/cargo-contract/src/cmd/call.rs index 68cd28c16..b32ba21dc 100644 --- a/crates/cargo-contract/src/cmd/call.rs +++ b/crates/cargo-contract/src/cmd/call.rs @@ -29,6 +29,7 @@ use std::{ }, str::FromStr, }; +use url::Url; use super::{ config::SignerConfig, @@ -126,8 +127,11 @@ impl CallCommand { .map_err(|e| anyhow::anyhow!("Failed to parse contract option: {}", e))?; let signer = C::Signer::from_str(&self.extrinsic_cli_opts.suri) .map_err(|_| anyhow::anyhow!("Failed to parse suri option"))?; - let token_metadata = - TokenMetadata::query::(&self.extrinsic_cli_opts.url).await?; + let token_metadata = if let Some(chain) = &self.extrinsic_cli_opts.chain { + TokenMetadata::query::(&Url::parse(chain.end_point()).unwrap()).await? + } else { + TokenMetadata::query::(&self.extrinsic_cli_opts.url).await? + }; let storage_deposit_limit = self .extrinsic_cli_opts .storage_deposit_limit diff --git a/crates/cargo-contract/src/cmd/info.rs b/crates/cargo-contract/src/cmd/info.rs index 73a9573ec..e0682e6aa 100644 --- a/crates/cargo-contract/src/cmd/info.rs +++ b/crates/cargo-contract/src/cmd/info.rs @@ -30,6 +30,7 @@ use contract_extrinsics::{ url_to_string, ContractInfo, ErrorVariant, + ProductionChain, TrieId, }; use ink_env::Environment; @@ -74,6 +75,9 @@ pub struct InfoCommand { default_value = "ws://localhost:9944" )] url: url::Url, + /// A name of a production chain to upload or instantiate the contract on. + #[clap(name = "chain", long, conflicts_with = "url")] + chain: Option, /// Export the instantiate output in JSON format. #[clap(name = "output-json", long)] output_json: bool, @@ -102,7 +106,11 @@ impl InfoCommand { <::AccountId as FromStr>::Err: Into> + Display, { - let rpc_cli = RpcClient::from_url(url_to_string(&self.url)).await?; + let rpc_cli = if let Some(chain) = &self.chain { + RpcClient::from_url(chain.end_point()).await? + } else { + RpcClient::from_url(url_to_string(&self.url)).await? + }; let client = OnlineClient::::from_rpc_client(rpc_cli.clone()).await?; let rpc = LegacyRpcMethods::::new(rpc_cli.clone()); diff --git a/crates/cargo-contract/src/cmd/instantiate.rs b/crates/cargo-contract/src/cmd/instantiate.rs index 0fd858729..5311ea844 100644 --- a/crates/cargo-contract/src/cmd/instantiate.rs +++ b/crates/cargo-contract/src/cmd/instantiate.rs @@ -72,6 +72,7 @@ use subxt::{ }, Config, }; +use url::Url; #[derive(Debug, clap::Args)] pub struct InstantiateCommand { @@ -136,8 +137,12 @@ impl InstantiateCommand { { let signer = C::Signer::from_str(&self.extrinsic_cli_opts.suri) .map_err(|_| anyhow::anyhow!("Failed to parse suri option"))?; - let token_metadata = - TokenMetadata::query::(&self.extrinsic_cli_opts.url).await?; + let token_metadata = if let Some(chain) = &self.extrinsic_cli_opts.chain { + TokenMetadata::query::(&Url::parse(chain.end_point()).unwrap()).await? + } else { + TokenMetadata::query::(&self.extrinsic_cli_opts.url).await? + }; + let storage_deposit_limit = self .extrinsic_cli_opts .storage_deposit_limit diff --git a/crates/cargo-contract/src/cmd/mod.rs b/crates/cargo-contract/src/cmd/mod.rs index 414896b07..a2329b917 100644 --- a/crates/cargo-contract/src/cmd/mod.rs +++ b/crates/cargo-contract/src/cmd/mod.rs @@ -325,12 +325,12 @@ pub fn prompt_confirm_unverifiable_upload(chain: &str) -> Result<()> { chain ) .bold() - .red(); + .yellow(); print!("{}", warning); println!( - "{} ({}/n): ", - "Continue?".bright_white().bold(), - "Y".bright_white().bold() + "{} ({}): ", + "\nContinue?".bright_white().bold(), + "Y/n".bright_white().bold() ); let mut buf = String::new(); diff --git a/crates/cargo-contract/src/cmd/rpc.rs b/crates/cargo-contract/src/cmd/rpc.rs index cf9c1af6d..0ee62937a 100644 --- a/crates/cargo-contract/src/cmd/rpc.rs +++ b/crates/cargo-contract/src/cmd/rpc.rs @@ -17,6 +17,7 @@ use contract_build::name_value_println; use contract_extrinsics::{ ErrorVariant, + ProductionChain, RawParams, RpcRequest, }; @@ -40,6 +41,9 @@ pub struct RpcCommand { default_value = "ws://localhost:9944" )] url: url::Url, + /// A name of a production chain to upload or instantiate the contract on. + #[clap(name = "chain", long, conflicts_with = "url")] + chain: Option, /// Export the call output in JSON format. #[clap(long)] output_json: bool, @@ -47,7 +51,11 @@ pub struct RpcCommand { impl RpcCommand { pub async fn run(&self) -> Result<(), ErrorVariant> { - let request = RpcRequest::new(&self.url).await?; + let request = if let Some(chain) = &self.chain { + RpcRequest::new(&url::Url::parse(chain.end_point()).unwrap()).await? + } else { + RpcRequest::new(&self.url).await? + }; let params = RawParams::new(&self.params)?; let result = request.raw_call(&self.method, params).await; diff --git a/crates/cargo-contract/src/cmd/upload.rs b/crates/cargo-contract/src/cmd/upload.rs index 56f96ce44..c6d97daec 100644 --- a/crates/cargo-contract/src/cmd/upload.rs +++ b/crates/cargo-contract/src/cmd/upload.rs @@ -53,6 +53,7 @@ use subxt::{ }, Config, }; +use url::Url; #[derive(Debug, clap::Args)] #[clap(name = "upload", about = "Upload a contract's code")] @@ -90,8 +91,11 @@ impl UploadCommand { { let signer = C::Signer::from_str(&self.extrinsic_cli_opts.suri) .map_err(|_| anyhow::anyhow!("Failed to parse suri option"))?; - let token_metadata = - TokenMetadata::query::(&self.extrinsic_cli_opts.url).await?; + let token_metadata = if let Some(chain) = &self.extrinsic_cli_opts.chain { + TokenMetadata::query::(&Url::parse(chain.end_point()).unwrap()).await? + } else { + TokenMetadata::query::(&self.extrinsic_cli_opts.url).await? + }; let storage_deposit_limit = self .extrinsic_cli_opts .storage_deposit_limit From c9d6a2b70c7387463c61e719e2c6c5b92e1e2720 Mon Sep 17 00:00:00 2001 From: German Nikolishin Date: Thu, 21 Mar 2024 16:46:26 +0000 Subject: [PATCH 8/8] add krest mainnet --- crates/extrinsics/src/prod_chains.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/extrinsics/src/prod_chains.rs b/crates/extrinsics/src/prod_chains.rs index d4e5942e8..dd5239142 100644 --- a/crates/extrinsics/src/prod_chains.rs +++ b/crates/extrinsics/src/prod_chains.rs @@ -80,6 +80,7 @@ define_chains! { pub enum ProductionChain { AlephZero = "wss://ws.azero.dev:443", Astar = "wss://rpc.astar.network:443", - Shiden = "wss://rpc.shiden.astar.network:443" + Shiden = "wss://rpc.shiden.astar.network:443", + Krest = "wss://wss-krest.peaq.network" } }