Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Ğ
Ğcli-v2s
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
Rust
Ğcli-v2s
Commits
d86db1b1
Commit
d86db1b1
authored
1 year ago
by
Hugo Trentesaux
Browse files
Options
Downloads
Patches
Plain Diff
refac membership renewal
parent
8a835b7a
No related branches found
No related tags found
1 merge request
!9
add smith and membership commands
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/commands/smith.rs
+5
-20
5 additions, 20 deletions
src/commands/smith.rs
src/main.rs
+2
-1
2 additions, 1 deletion
src/main.rs
src/utils.rs
+26
-0
26 additions, 0 deletions
src/utils.rs
with
33 additions
and
21 deletions
src/commands/smith.rs
+
5
−
20
View file @
d86db1b1
...
@@ -217,25 +217,10 @@ pub async fn claim_smith_membership(data: &Data) -> Result<(), subxt::Error> {
...
@@ -217,25 +217,10 @@ pub async fn claim_smith_membership(data: &Data) -> Result<(), subxt::Error> {
/// renew smith membership
/// renew smith membership
pub
async
fn
renew_smith_membership
(
data
:
&
Data
)
->
Result
<
(),
subxt
::
Error
>
{
pub
async
fn
renew_smith_membership
(
data
:
&
Data
)
->
Result
<
(),
subxt
::
Error
>
{
let
progress
=
data
submit_call_and_look_event
::
<
.client
()
runtime
::
smith_membership
::
events
::
MembershipRenewed
,
.tx
()
StaticTxPayload
<
runtime
::
smith_membership
::
calls
::
RenewMembership
>
,
.sign_and_submit_then_watch
(
>
(
data
,
&
runtime
::
tx
()
.smith_membership
()
.renew_membership
())
.await
&
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
...
...
This diff is collapsed.
Click to expand it.
src/main.rs
+
2
−
1
View file @
d86db1b1
...
@@ -16,7 +16,8 @@ use runtime_config::*;
...
@@ -16,7 +16,8 @@ use runtime_config::*;
use
serde
::
Deserialize
;
use
serde
::
Deserialize
;
use
sp_core
::{
sr25519
::
Pair
,
Pair
as
_
};
use
sp_core
::{
sr25519
::
Pair
,
Pair
as
_
};
use
subxt
::
blocks
::
ExtrinsicEvents
;
use
subxt
::
blocks
::
ExtrinsicEvents
;
use
subxt
::
tx
::{
BaseExtrinsicParamsBuilder
,
PairSigner
,
TxStatus
};
use
subxt
::
events
::
StaticEvent
;
use
subxt
::
tx
::{
BaseExtrinsicParamsBuilder
,
PairSigner
,
TxPayload
,
TxStatus
,
StaticTxPayload
};
use
utils
::
*
;
use
utils
::
*
;
/// define command line arguments
/// define command line arguments
...
...
This diff is collapsed.
Click to expand it.
src/utils.rs
+
26
−
0
View file @
d86db1b1
...
@@ -23,6 +23,32 @@ pub async fn track_progress(
...
@@ -23,6 +23,32 @@ pub async fn track_progress(
.await
.await
}
}
/// generic extrinsic submitter
pub
async
fn
submit_call_and_look_event
<
E
:
std
::
fmt
::
Debug
+
StaticEvent
,
Call
:
TxPayload
>
(
data
:
&
Data
,
call
:
&
Call
,
)
->
Result
<
(),
subxt
::
Error
>
{
let
progress
=
data
.client
()
.tx
()
.sign_and_submit_then_watch
(
call
,
&
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
::
<
E
>
()
?
{
println!
(
"{e:?}"
);
}
Ok
(())
}
/// custom error type intended to provide more convenient error message to user
/// custom error type intended to provide more convenient error message to user
#[derive(Debug)]
#[derive(Debug)]
pub
enum
GcliError
{
pub
enum
GcliError
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment