Skip to content
Snippets Groups Projects
Commit 8a835b7a authored by Hugo Trentesaux's avatar Hugo Trentesaux
Browse files

add smith membership renewal

parent 10ced110
No related branches found
No related tags found
1 merge request!9add smith and membership commands
...@@ -16,6 +16,8 @@ pub enum Subcommand { ...@@ -16,6 +16,8 @@ pub enum Subcommand {
Cert { to: u32 }, Cert { to: u32 },
/// Claim smith membership /// Claim smith membership
Claim, Claim,
/// Renew smith membership
Renew,
/// go online /// go online
GoOnline, GoOnline,
/// go offline /// go offline
...@@ -48,6 +50,9 @@ pub async fn handle_command(data: Data, command: Subcommand) -> anyhow::Result<( ...@@ -48,6 +50,9 @@ pub async fn handle_command(data: Data, command: Subcommand) -> anyhow::Result<(
Subcommand::Claim => { Subcommand::Claim => {
claim_smith_membership(&data).await?; claim_smith_membership(&data).await?;
} }
Subcommand::Renew => {
renew_smith_membership(&data).await?;
}
Subcommand::GoOnline => { Subcommand::GoOnline => {
go_online(&data).await?; go_online(&data).await?;
} }
...@@ -187,7 +192,7 @@ pub async fn go_online(data: &Data) -> Result<(), GcliError> { ...@@ -187,7 +192,7 @@ pub async fn go_online(data: &Data) -> Result<(), GcliError> {
Ok(()) Ok(())
} }
/// submit go_offline /// claim smith membership
pub async fn claim_smith_membership(data: &Data) -> Result<(), subxt::Error> { pub async fn claim_smith_membership(data: &Data) -> Result<(), subxt::Error> {
let progress = data let progress = data
.client() .client()
...@@ -210,6 +215,29 @@ pub async fn claim_smith_membership(data: &Data) -> Result<(), subxt::Error> { ...@@ -210,6 +215,29 @@ pub async fn claim_smith_membership(data: &Data) -> Result<(), subxt::Error> {
Ok(()) 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 /// submit go_offline
pub async fn go_offline(data: &Data) -> Result<(), subxt::Error> { pub async fn go_offline(data: &Data) -> Result<(), subxt::Error> {
let progress = data let progress = data
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment