#[cfg(feature = "subxthelper")]
use subxt::{OnlineClient, PolkadotConfig};
use subxt_signer::sr25519::Keypair;
use crate::error::Error;
use crate::types::{event_summary, H256};
use crate::jsonrpseeclient::JsonrpseeClient;
#[cfg(feature = "metadatadecode")]
use crate::ws_mod::event_watch;
pub async fn tx_schedule<Call: subxt::tx::TxPayload>(
from_account: Keypair,
api: OnlineClient<PolkadotConfig>,
call: &Call,
event: event_summary,
block_limit: u32,
ws_host: &str,
) -> Result<H256, Error> {
let client = JsonrpseeClient::new(ws_host).expect("could not create jsonrpsee client");
let _wait_for_event = event_watch(client, event, block_limit).await;
let events = api
.tx()
.sign_and_submit_then_watch_default(call, &from_account)
.await
.unwrap()
.wait_for_finalized_success()
.await
.unwrap();
let blockhash: H256 = events.block_hash().into();
Ok(blockhash)
}