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 { ...@@ -89,7 +89,7 @@ impl CallCommand {
let signer = super::pair_signer(self.extrinsic_opts.signer()?); let signer = super::pair_signer(self.extrinsic_opts.signer()?);
async_std::task::block_on(async { 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() let api = ClientBuilder::new()
.set_url(&url) .set_url(&url)
.build() .build()
...@@ -111,7 +111,7 @@ impl CallCommand { ...@@ -111,7 +111,7 @@ impl CallCommand {
signer: &PairSigner, signer: &PairSigner,
transcoder: &ContractMessageTranscoder<'_>, transcoder: &ContractMessageTranscoder<'_>,
) -> Result<()> { ) -> 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 cli = WsClientBuilder::default().build(&url).await?;
let storage_deposit_limit = self let storage_deposit_limit = self
.extrinsic_opts .extrinsic_opts
......
...@@ -136,7 +136,7 @@ impl InstantiateCommand { ...@@ -136,7 +136,7 @@ impl InstantiateCommand {
let transcoder = ContractMessageTranscoder::new(&contract_metadata); let transcoder = ContractMessageTranscoder::new(&contract_metadata);
let data = transcoder.encode(&self.constructor, &self.args)?; let data = transcoder.encode(&self.constructor, &self.args)?;
let signer = super::pair_signer(self.extrinsic_opts.signer()?); 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()?; let verbosity = self.extrinsic_opts.verbosity()?;
fn load_code(wasm_path: &Path) -> Result<Code> { fn load_code(wasm_path: &Path) -> Result<Code> {
...@@ -195,7 +195,7 @@ struct InstantiateArgs { ...@@ -195,7 +195,7 @@ struct InstantiateArgs {
pub struct Exec<'a> { pub struct Exec<'a> {
args: InstantiateArgs, args: InstantiateArgs,
verbosity: Verbosity, verbosity: Verbosity,
url: url::Url, url: String,
signer: PairSigner, signer: PairSigner,
transcoder: ContractMessageTranscoder<'a>, transcoder: ContractMessageTranscoder<'a>,
} }
...@@ -203,7 +203,7 @@ pub struct Exec<'a> { ...@@ -203,7 +203,7 @@ pub struct Exec<'a> {
impl<'a> Exec<'a> { impl<'a> Exec<'a> {
async fn subxt_api(&self) -> Result<RuntimeApi> { async fn subxt_api(&self) -> Result<RuntimeApi> {
let api = ClientBuilder::new() let api = ClientBuilder::new()
.set_url(self.url.to_string()) .set_url(&self.url)
.build() .build()
.await? .await?
.to_runtime_api::<RuntimeApi>(); .to_runtime_api::<RuntimeApi>();
...@@ -326,8 +326,7 @@ impl<'a> Exec<'a> { ...@@ -326,8 +326,7 @@ impl<'a> Exec<'a> {
} }
async fn instantiate_dry_run(&self, code: Code) -> Result<ContractInstantiateResult> { async fn instantiate_dry_run(&self, code: Code) -> Result<ContractInstantiateResult> {
let url = self.url.to_string(); let cli = WsClientBuilder::default().build(&self.url).await?;
let cli = WsClientBuilder::default().build(&url).await?;
let storage_deposit_limit = self let storage_deposit_limit = self
.args .args
.storage_deposit_limit .storage_deposit_limit
......
...@@ -111,6 +111,18 @@ impl ExtrinsicOpts { ...@@ -111,6 +111,18 @@ impl ExtrinsicOpts {
pub fn verbosity(&self) -> Result<Verbosity> { pub fn verbosity(&self) -> Result<Verbosity> {
TryFrom::try_from(&self.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 /// For a contract project with its `Cargo.toml` at the specified `manifest_path`, load the cargo
......
...@@ -82,7 +82,7 @@ impl UploadCommand { ...@@ -82,7 +82,7 @@ impl UploadCommand {
.context(format!("Failed to read from {}", wasm_path.display()))?; .context(format!("Failed to read from {}", wasm_path.display()))?;
async_std::task::block_on(async { 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() let api = ClientBuilder::new()
.set_url(&url) .set_url(&url)
.build() .build()
...@@ -121,7 +121,7 @@ impl UploadCommand { ...@@ -121,7 +121,7 @@ impl UploadCommand {
code: Vec<u8>, code: Vec<u8>,
signer: &PairSigner, signer: &PairSigner,
) -> Result<CodeUploadResult> { ) -> 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 cli = WsClientBuilder::default().build(&url).await?;
let storage_deposit_limit = self let storage_deposit_limit = self
.extrinsic_opts .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