Unverified Commit 9902ee6f authored by Michal Handzlik's avatar Michal Handzlik Committed by GitHub
Browse files

Manually convert Url::url to String in order to include the default port (#591)

parent 7035710e
Pipeline #196133 passed with stages
in 11 minutes and 53 seconds
......@@ -89,7 +89,7 @@ impl CallCommand {
let signer = super::pair_signer(self.extrinsic_opts.signer()?);
async_std::task::block_on(async {
let url = self.extrinsic_opts.url.to_string();
let url = self.extrinsic_opts.url_to_string();
let api = ClientBuilder::new()
.set_url(&url)
.build()
......@@ -111,7 +111,7 @@ impl CallCommand {
signer: &PairSigner,
transcoder: &ContractMessageTranscoder<'_>,
) -> Result<()> {
let url = self.extrinsic_opts.url.to_string();
let url = self.extrinsic_opts.url_to_string();
let cli = WsClientBuilder::default().build(&url).await?;
let storage_deposit_limit = self
.extrinsic_opts
......
......@@ -136,7 +136,7 @@ impl InstantiateCommand {
let transcoder = ContractMessageTranscoder::new(&contract_metadata);
let data = transcoder.encode(&self.constructor, &self.args)?;
let signer = super::pair_signer(self.extrinsic_opts.signer()?);
let url = self.extrinsic_opts.url.clone();
let url = self.extrinsic_opts.url_to_string();
let verbosity = self.extrinsic_opts.verbosity()?;
fn load_code(wasm_path: &Path) -> Result<Code> {
......@@ -195,7 +195,7 @@ struct InstantiateArgs {
pub struct Exec<'a> {
args: InstantiateArgs,
verbosity: Verbosity,
url: url::Url,
url: String,
signer: PairSigner,
transcoder: ContractMessageTranscoder<'a>,
}
......@@ -203,7 +203,7 @@ pub struct Exec<'a> {
impl<'a> Exec<'a> {
async fn subxt_api(&self) -> Result<RuntimeApi> {
let api = ClientBuilder::new()
.set_url(self.url.to_string())
.set_url(&self.url)
.build()
.await?
.to_runtime_api::<RuntimeApi>();
......@@ -326,8 +326,7 @@ impl<'a> Exec<'a> {
}
async fn instantiate_dry_run(&self, code: Code) -> Result<ContractInstantiateResult> {
let url = self.url.to_string();
let cli = WsClientBuilder::default().build(&url).await?;
let cli = WsClientBuilder::default().build(&self.url).await?;
let storage_deposit_limit = self
.args
.storage_deposit_limit
......
......@@ -111,6 +111,18 @@ impl ExtrinsicOpts {
pub fn verbosity(&self) -> Result<Verbosity> {
TryFrom::try_from(&self.verbosity)
}
/// Convert URL to String without omitting the default port
pub 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)) => {
res.insert_str(res.len() - 1, &format!(":{}", port));
res
}
_ => res,
}
}
}
/// For a contract project with its `Cargo.toml` at the specified `manifest_path`, load the cargo
......
......@@ -82,7 +82,7 @@ impl UploadCommand {
.context(format!("Failed to read from {}", wasm_path.display()))?;
async_std::task::block_on(async {
let url = self.extrinsic_opts.url.to_string();
let url = self.extrinsic_opts.url_to_string();
let api = ClientBuilder::new()
.set_url(&url)
.build()
......@@ -121,7 +121,7 @@ impl UploadCommand {
code: Vec<u8>,
signer: &PairSigner,
) -> Result<CodeUploadResult> {
let url = self.extrinsic_opts.url.to_string();
let url = self.extrinsic_opts.url_to_string();
let cli = WsClientBuilder::default().build(&url).await?;
let storage_deposit_limit = self
.extrinsic_opts
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment