Skip to content

Commit

Permalink
refactor: small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexD10S committed Dec 13, 2024
1 parent c335561 commit 223a2fd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 24 deletions.
41 changes: 18 additions & 23 deletions crates/pop-cli/src/commands/call/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ impl CallChainCommand {

if let Err(e) = result {
display_message(&e.to_string(), false, &mut cli)?;
break;
}

if !prompt_to_repeat_call
|| !cli
.confirm("Do you want to perform another call?")
if !prompt_to_repeat_call ||
!cli.confirm("Do you want to perform another call?")
.initial_value(false)
.interact()?
{
Expand Down Expand Up @@ -256,7 +256,7 @@ impl CallChainCommand {
let mut use_wallet = self.use_wallet;
let suri = match self.suri.as_ref() {
Some(suri) => suri.clone(),
None => {
None =>
if !self.use_wallet {
if cli.confirm("Do you want to use your browser wallet to sign the transaction? (Selecting 'No' will prompt you to manually enter the secret key URI for signing, e.g., '//Alice')")
.initial_value(true)
Expand All @@ -269,8 +269,7 @@ impl CallChainCommand {
}
} else {
DEFAULT_URI.to_string()
}
},
},
};
// Perform signing steps with wallet integration and return early.
if use_wallet {
Expand All @@ -283,9 +282,8 @@ impl CallChainCommand {
return Ok(());
}
cli.info(format!("Encoded call data: {}", call_data))?;
if !self.skip_confirm
&& !cli
.confirm("Do you want to submit the extrinsic?")
if !self.skip_confirm &&
!cli.confirm("Do you want to submit the extrinsic?")
.initial_value(true)
.interact()?
{
Expand Down Expand Up @@ -313,24 +311,22 @@ impl CallChainCommand {
// execute the call via `sudo`.
fn configure_sudo(&mut self, chain: &Chain, cli: &mut impl Cli) -> Result<()> {
match find_dispatchable_by_name(&chain.pallets, "Sudo", "sudo") {
Ok(_) => {
Ok(_) =>
if !self.sudo {
self.sudo = cli
.confirm(
"Would you like to dispatch this function call with `Root` origin?",
)
.initial_value(false)
.interact()?;
}
},
Err(_) => {
},
Err(_) =>
if self.sudo {
cli.warning(
"NOTE: sudo is not supported by the chain. Ignoring `--sudo` flag.",
)?;
self.sudo = false;
}
},
},
}
Ok(())
}
Expand All @@ -346,11 +342,11 @@ impl CallChainCommand {

// Function to check if all required fields are specified.
fn requires_user_input(&self) -> bool {
self.pallet.is_none()
|| self.function.is_none()
|| self.args.is_empty()
|| self.url.is_none()
|| self.suri.is_none()
self.pallet.is_none() ||
self.function.is_none() ||
self.args.is_empty() ||
self.url.is_none() ||
self.suri.is_none()
}

/// Replaces file arguments with their contents, leaving other arguments unchanged.
Expand Down Expand Up @@ -432,9 +428,8 @@ impl Call {
tx: DynamicPayload,
cli: &mut impl Cli,
) -> Result<()> {
if !self.skip_confirm
&& !cli
.confirm("Do you want to submit the extrinsic?")
if !self.skip_confirm &&
!cli.confirm("Do you want to submit the extrinsic?")
.initial_value(true)
.interact()?
{
Expand Down
1 change: 0 additions & 1 deletion crates/pop-contracts/src/up.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ pub async fn set_up_upload(

let upload_exec: UploadExec<DefaultConfig, DefaultEnvironment, Keypair> =
UploadCommandBuilder::new(extrinsic_opts).done().await?;

Ok(upload_exec)
}

Expand Down

0 comments on commit 223a2fd

Please sign in to comment.