From 45418525a417e6f204a9d76d1e5709029270eab7 Mon Sep 17 00:00:00 2001 From: clearloop <26088946+clearloop@users.noreply.github.com> Date: Sat, 22 Jul 2023 23:44:28 +0800 Subject: [PATCH] feat(gsdk): allow transaction retracted (#2963) --- gsdk/src/signer/calls.rs | 12 ++++++------ gsdk/src/signer/mod.rs | 15 +++++++-------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/gsdk/src/signer/calls.rs b/gsdk/src/signer/calls.rs index 5f832e3dbef..901a41a928e 100644 --- a/gsdk/src/signer/calls.rs +++ b/gsdk/src/signer/calls.rs @@ -343,16 +343,16 @@ impl Signer { b.block_hash(), b.extrinsic_hash() ), - TxStatus::Retracted(h) => log::info!(" Status: Retracted( {h} )"), - TxStatus::FinalityTimeout(h) => log::info!(" Status: FinalityTimeout( {h} )"), + TxStatus::Retracted(h) => log::warn!(" Status: Retracted( {h} )"), + TxStatus::FinalityTimeout(h) => log::error!(" Status: FinalityTimeout( {h} )"), TxStatus::Finalized(b) => log::info!( " Status: Finalized( block hash: {}, extrinsic hash: {} )", b.block_hash(), b.extrinsic_hash() ), - TxStatus::Usurped(h) => log::info!(" Status: Usurped( {h} )"), - TxStatus::Dropped => log::info!(" Status: Dropped"), - TxStatus::Invalid => log::info!(" Status: Invalid"), + TxStatus::Usurped(h) => log::error!(" Status: Usurped( {h} )"), + TxStatus::Dropped => log::error!(" Status: Dropped"), + TxStatus::Invalid => log::error!(" Status: Invalid"), } } @@ -389,7 +389,7 @@ impl Signer { let status = status?; self.log_status(&status); match status { - Future | Ready | Broadcast(_) | InBlock(_) => (), + Future | Ready | Broadcast(_) | InBlock(_) | Retracted(_) => (), Finalized(b) => { log::info!( "Successfully submitted call {}::{} {} at {}!", diff --git a/gsdk/src/signer/mod.rs b/gsdk/src/signer/mod.rs index f0de6c90a76..c421673bc69 100644 --- a/gsdk/src/signer/mod.rs +++ b/gsdk/src/signer/mod.rs @@ -52,16 +52,15 @@ impl Signer { } /// Change inner signer. - pub fn change(self, suri: &str, passwd: Option<&str>) -> Result { - Ok(Self { - api: self.api, - signer: PairSigner::new( - Pair::from_string(suri, passwd).map_err(|_| Error::InvalidSecret)?, - ), - nonce: None, - }) + pub fn change(mut self, suri: &str, passwd: Option<&str>) -> Result { + let signer = + PairSigner::new(Pair::from_string(suri, passwd).map_err(|_| Error::InvalidSecret)?); + self.signer = signer; + + Ok(self) } + /// Set nonce of the signer pub fn set_nonce(&mut self, nonce: u32) { self.nonce = Some(nonce) }