diff --git a/src/commands/smith.rs b/src/commands/smith.rs index da1a75b48f11dfb26b17a54f397ca39aa3c7734c..ab781512208b6c068ff49c56eb5f9ade1b91c204 100644 --- a/src/commands/smith.rs +++ b/src/commands/smith.rs @@ -16,6 +16,8 @@ pub enum Subcommand { Cert { to: u32 }, /// Claim smith membership Claim, + /// Renew smith membership + Renew, /// go online GoOnline, /// go offline @@ -48,6 +50,9 @@ pub async fn handle_command(data: Data, command: Subcommand) -> anyhow::Result<( Subcommand::Claim => { claim_smith_membership(&data).await?; } + Subcommand::Renew => { + renew_smith_membership(&data).await?; + } Subcommand::GoOnline => { go_online(&data).await?; } @@ -187,7 +192,7 @@ pub async fn go_online(data: &Data) -> Result<(), GcliError> { Ok(()) } -/// submit go_offline +/// claim smith membership pub async fn claim_smith_membership(data: &Data) -> Result<(), subxt::Error> { let progress = data .client() @@ -210,6 +215,29 @@ pub async fn claim_smith_membership(data: &Data) -> Result<(), subxt::Error> { Ok(()) } +/// renew smith membership +pub async fn renew_smith_membership(data: &Data) -> Result<(), subxt::Error> { + let progress = data + .client() + .tx() + .sign_and_submit_then_watch( + &runtime::tx().smith_membership().renew_membership(), + &PairSigner::new(data.keypair()), + BaseExtrinsicParamsBuilder::new(), + ) + .await?; + + if data.args.no_wait { + return Ok(()); + } + let events = track_progress(progress).await?; + if let Some(e) = events.find_first::<runtime::smith_membership::events::MembershipRenewed>()? { + println!("{e:?}"); + } + + Ok(()) +} + /// submit go_offline pub async fn go_offline(data: &Data) -> Result<(), subxt::Error> { let progress = data