Skip to content

Commit

Permalink
refactor: remove unnecessary function
Browse files Browse the repository at this point in the history
  • Loading branch information
Daanvdplas committed Dec 12, 2024
1 parent 310ab40 commit b2e8221
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 27 deletions.
5 changes: 3 additions & 2 deletions crates/pop-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ pub fn find_free_port() -> u16 {

/// Provides functionality for making calls to parachains or smart contracts.
pub mod call {
// Note: cargo contract logic is used for parsing events after calling a chain. This could be refactored
// in the future so that we don't have to use cargo contract code in `pop-parachains`.
// Note: cargo contract logic is used for parsing events after calling a chain. This could be
// refactored in the future so that we don't have to use cargo contract code in
// `pop-parachains`.
pub use contract_build::Verbosity;
pub use contract_extrinsics::{DisplayEvents, TokenMetadata};
pub use ink_env::DefaultEnvironment;
Expand Down
26 changes: 1 addition & 25 deletions crates/pop-parachains/src/call/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub async fn sign_and_submit_extrinsic<C: Payload>(
let events =
events.display_events::<DefaultEnvironment>(Verbosity::Default, &token_metadata)?;

Ok(format!("Extrinsic Submitted with hash: {:?}\n\n{}", result.extrinsic_hash(), events,))
Ok(format!("Extrinsic Submitted with hash: {:?}\n\n{}", result.extrinsic_hash(), events))
}

/// Encodes the call data for a given extrinsic into a hexadecimal string.
Expand Down Expand Up @@ -128,30 +128,6 @@ impl Payload for CallData {
}
}

/// Signs and submits a given extrinsic.
///
/// # Arguments
/// * `client` - Reference to an `OnlineClient` connected to the chain.
/// * `call_data` - SCALE encoded bytes representing the extrinsic's call data.
/// * `suri` - The secret URI (e.g., mnemonic or private key) for signing the extrinsic.
pub async fn sign_and_submit_extrinsic_with_call_data(
client: &OnlineClient<SubstrateConfig>,
call_data: Vec<u8>,
suri: &str,
) -> Result<String, Error> {
let signer = create_signer(suri)?;
let payload = CallData(call_data);
let result = client
.tx()
.sign_and_submit_then_watch_default(&payload, &signer)
.await
.map_err(|e| Error::ExtrinsicSubmissionError(format!("{:?}", e)))?
.wait_for_finalized_success()
.await
.map_err(|e| Error::ExtrinsicSubmissionError(format!("{:?}", e)))?;
Ok(format!("{:?}", result.extrinsic_hash()))
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down

0 comments on commit b2e8221

Please sign in to comment.