Skip to content

Commit

Permalink
Changed url() method of ExtrinsicOpts to return String
Browse files Browse the repository at this point in the history
  • Loading branch information
smiasojed committed Sep 14, 2023
1 parent f19dd58 commit decf1c5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 16 deletions.
7 changes: 3 additions & 4 deletions crates/extrinsics/src/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use super::{
state,
state_call,
submit_extrinsic,
url_to_string,
AccountId32,
Balance,
BalanceVariant,
Expand Down Expand Up @@ -179,8 +178,8 @@ impl CallCommandBuilder<state::Message, state::ExtrinsicOptions> {

let signer = self.opts.extrinsic_opts.signer()?;

let url = url_to_string(self.opts.extrinsic_opts.url());
let client = OnlineClient::from_url(url.clone()).await?;
let url = self.opts.extrinsic_opts.url();
let client = OnlineClient::from_url(url).await?;
Ok(CallExec {
contract: self.opts.contract.clone(),
message: self.opts.message.clone(),
Expand Down Expand Up @@ -222,7 +221,7 @@ impl CallExec {
/// Returns the dry run simulation result of type [`ContractExecResult`], which
/// includes information about the simulated call, or an error in case of failure.
pub async fn call_dry_run(&self) -> Result<ContractExecResult<Balance, ()>> {
let url = url_to_string(self.opts.url());
let url = self.opts.url();
let token_metadata = TokenMetadata::query(&self.client).await?;
let storage_deposit_limit = self
.opts
Expand Down
5 changes: 3 additions & 2 deletions crates/extrinsics/src/extrinsic_opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use anyhow::{
};

use crate::{
url_to_string,
Balance,
BalanceVariant,
ContractArtifacts,
Expand Down Expand Up @@ -180,8 +181,8 @@ impl ExtrinsicOpts {
}

/// Return the URL of the substrate node.
pub fn url(&self) -> &Url {
&self.url
pub fn url(&self) -> String {
url_to_string(&self.url)
}

/// Return the secret URI of the signer.
Expand Down
5 changes: 2 additions & 3 deletions crates/extrinsics/src/instantiate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use super::{
state,
state_call,
submit_extrinsic,
url_to_string,
Balance,
BalanceVariant,
Client,
Expand Down Expand Up @@ -166,7 +165,7 @@ impl InstantiateCommandBuilder<state::ExtrinsicOptions> {
let transcoder = artifacts.contract_transcoder()?;
let data = transcoder.encode(&self.opts.constructor, &self.opts.args)?;
let signer = self.opts.extrinsic_opts.signer()?;
let url = url_to_string(self.opts.extrinsic_opts.url());
let url = self.opts.extrinsic_opts.url();
let code = if let Some(code) = artifacts.code {
Code::Upload(code.0)
} else {
Expand All @@ -175,7 +174,7 @@ impl InstantiateCommandBuilder<state::ExtrinsicOptions> {
};
let salt = self.opts.salt.clone().map(|s| s.0).unwrap_or_default();

let client = OnlineClient::from_url(url.clone()).await?;
let client = OnlineClient::from_url(&url).await?;

let token_metadata = TokenMetadata::query(&client).await?;

Expand Down
5 changes: 2 additions & 3 deletions crates/extrinsics/src/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use super::{
},
state,
submit_extrinsic,
url_to_string,
Client,
ContractMessageTranscoder,
DefaultConfig,
Expand Down Expand Up @@ -119,8 +118,8 @@ impl RemoveCommandBuilder<state::ExtrinsicOptions> {
artifacts_path.display()
)),
}?;
let url = url_to_string(self.opts.extrinsic_opts.url());
let client = OnlineClient::from_url(url.clone()).await?;
let url = self.opts.extrinsic_opts.url();
let client = OnlineClient::from_url(url).await?;

Ok(RemoveExec {
final_code_hash,
Expand Down
7 changes: 3 additions & 4 deletions crates/extrinsics/src/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use super::{
state,
state_call,
submit_extrinsic,
url_to_string,
Balance,
Client,
CodeHash,
Expand Down Expand Up @@ -106,8 +105,8 @@ impl UploadCommandBuilder<state::ExtrinsicOptions> {
artifacts_path.display()
)
})?;
let url = url_to_string(self.opts.extrinsic_opts.url());
let client = OnlineClient::from_url(url.clone()).await?;
let url = self.opts.extrinsic_opts.url();
let client = OnlineClient::from_url(url).await?;
Ok(UploadExec {
opts: self.opts.extrinsic_opts.clone(),
client,
Expand All @@ -132,7 +131,7 @@ impl UploadExec {
/// then sends the request using the provided URL. This operation does not modify
/// the state of the blockchain.
pub async fn upload_code_rpc(&self) -> Result<CodeUploadResult<CodeHash, Balance>> {
let url = url_to_string(self.opts.url());
let url = self.opts.url();
let token_metadata = TokenMetadata::query(&self.client).await?;
let storage_deposit_limit = self
.opts
Expand Down

0 comments on commit decf1c5

Please sign in to comment.