Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
Daanvdplas committed Dec 12, 2024
2 parents 48aceff + e99f719 commit 310ab40
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/pop-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ pub fn find_free_port() -> u16 {

/// Provides functionality for making calls to parachains or smart contracts.
pub mod call {
// Note: parsing events after calling a chain is done using cargo contract logic. This could be
// refactored in the future.
// 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
24 changes: 24 additions & 0 deletions crates/pop-parachains/src/call/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,30 @@ 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 310ab40

Please sign in to comment.