pub async fn submit_and_watch_extrinsic<'a, E: Encode + 'static>(
        &self,
        extrinsic: E,
        decoder: &'a EventsDecoder<T>,
    ) -> Result<ExtrinsicSuccess<T>, Error> {
        let ext_hash = T::Hashing::hash_of(&extrinsic);
        log::info!("Submitting Extrinsic `{:?}`", ext_hash);

        let events_sub = if self.accept_weak_inclusion {
            self.subscribe_events().await
        } else {
            self.subscribe_finalized_events().await
        }?;
        let mut xt_sub = self.watch_extrinsic(extrinsic).await?;

        while let Ok(Some(status)) = xt_sub.next().await {
            log::info!("received status {:?}", status);
            match status {
                // ignore in progress extrinsic for now
                TransactionStatus::Future
                | TransactionStatus::Ready
                | TransactionStatus::Broadcast(_) => continue,
                TransactionStatus::InBlock(block_hash) => {
                    if self.accept_weak_inclusion {
                        return self
                            .process_block(events_sub, decoder, block_hash, ext_hash)
                            .await
                    }
                    continue
                }
                TransactionStatus::Invalid => return Err("Extrinsic Invalid".into()),
                TransactionStatus::Usurped(_) => return Err("Extrinsic Usurped".into()),
                TransactionStatus::Dropped => return Err("Extrinsic Dropped".into()),
                TransactionStatus::Retracted(_) => {
                    return Err("Extrinsic Retracted".into())
                }
                TransactionStatus::Finalized(block_hash) => {
                    // read finalized blocks by default
                    return self
                        .process_block(events_sub, decoder, block_hash, ext_hash)
                        .await
                }
                TransactionStatus::FinalityTimeout(_) => {
                    return Err("Extrinsic FinalityTimeout".into())
                }
            }
        }
        Err(RpcError::Custom("RPC subscription dropped".into()).into())
    }
/// Create and submit an extrinsic and return corresponding Event if successful
Create and submit an extrinsic and return corresponding Event if successful
Create and submit an extrinsic and return corresponding Event if successful
pub async fn submit_and_watch_extrinsic<'a, E: Encode + 'static>(
        &self,
        extrinsic: E,
        decoder: &'a EventsDecoder<T>,
    ) -> Result<ExtrinsicSuccess<T>, Error> {
        let ext_hash = T::Hashing::hash_of(&extrinsic);
        log::info!("Submitting Extrinsic `{:?}`", ext_hash);
        let events_sub = if self.accept_weak_inclusion {
            self.subscribe_events().await
        } else {
            self.subscribe_finalized_events().await
        }?;
        let mut xt_sub = self.watch_extrinsic(extrinsic).await?;
        while let Ok(Some(status)) = xt_sub.next().await {
            log::info!("received status {:?}", status);
            match status {
                // ignore in progress extrinsic for now
                TransactionStatus::Future
                | TransactionStatus::Ready
                | TransactionStatus::Broadcast(_) => continue,
                TransactionStatus::InBlock(block_hash) => {
                    if self.accept_weak_inclusion {
                        return self
                            .process_block(events_sub, decoder, block_hash, ext_hash)
                            .await
                    }
                    continue
                }
                TransactionStatus::Invalid => return Err("Extrinsic Invalid".into()),
                TransactionStatus::Usurped(_) => return Err("Extrinsic Usurped".into()),
                TransactionStatus::Dropped => return Err("Extrinsic Dropped".into()),
                TransactionStatus::Retracted(_) => {
                    return Err("Extrinsic Retracted".into())
                }
                TransactionStatus::Finalized(block_hash) => {
                    // read finalized blocks by default
                    return self
                        .process_block(events_sub, decoder, block_hash, ext_hash)
                        .await
                }
                TransactionStatus::FinalityTimeout(_) => {
                    return Err("Extrinsic FinalityTimeout".into())
                }
            }
        }
        Err(RpcError::Custom("RPC subscription dropped".into()).into())
    }
pub async fn submit_and_watch_extrinsic < ' a , E : Encode + ' static > ( & self , extrinsic : E , decoder : & ' a EventsDecoder < T > , ) -> Result < ExtrinsicSuccess < T > , Error > { let ext_hash = T :: Hashing :: hash_of ( & extrinsic ) ; log :: info ! ( " " ext_hash ) ; let events_sub = if self . accept_weak_inclusion { self . subscribe_events ( ) . await } else { self . subscribe_finalized_events ( ) . await } ? ; let mut xt_sub = self . watch_extrinsic ( extrinsic ) . await ? ; while let Ok ( Some ( status ) ) = xt_sub . next ( ) . await { log :: info ! ( " " status ) ; match status { // ignore in progress extrinsic for now TransactionStatus :: Future | TransactionStatus :: Ready | TransactionStatus :: Broadcast ( _ ) => continue , TransactionStatus :: InBlock ( block_hash ) => { if self . accept_weak_inclusion { return self . process_block ( events_sub , decoder , block_hash , ext_hash ) . await } continue } TransactionStatus :: Invalid => return Err ( " " . into ( ) ) , TransactionStatus :: Usurped ( _ ) => return Err ( " " . into ( ) ) , TransactionStatus :: Dropped => return Err ( " " . into ( ) ) , TransactionStatus :: Retracted ( _ ) => { return Err ( " " . into ( ) ) } TransactionStatus :: Finalized ( block_hash ) => { // read finalized blocks by default return self . process_block ( events_sub , decoder , block_hash , ext_hash ) . await } TransactionStatus :: FinalityTimeout ( _ ) => { return Err ( " " . into ( ) ) } } } Err ( RpcError :: Custom ( " " . into ( ) ) . into ( ) ) }
Create and submit an extrinsic and return corresponding Event if successful
Create and submit an extrinsic and return corresponding Event if successful
&self
extrinsic
E
decoder
&'a EventsDecoder<T>
&self
extrinsic
E
decoder
&'a EventsDecoder<T>