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
f3407daa
Commit
f3407daa
authored
1 year ago
by
Hugo Trentesaux
Committed by
Hugo Trentesaux
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
move tech commands to subcommand
parent
91f70433
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!7
Big refacto
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/commands/collective.rs
+55
-7
55 additions, 7 deletions
src/commands/collective.rs
src/main.rs
+5
-45
5 additions, 45 deletions
src/main.rs
with
60 additions
and
52 deletions
src/commands/collective.rs
+
55
−
7
View file @
f3407daa
use
crate
::
*
;
use
anyhow
::
Result
;
use
sp_core
::{
sr25519
::
Pair
,
H256
};
use
subxt
::
tx
::{
BaseExtrinsicParamsBuilder
,
PairSigner
};
/// define technical committee subcommands
#[derive(Clone,
Default,
Debug,
clap::Parser)]
pub
enum
Subcommand
{
#[default]
/// List members of the technical committee
Members
,
/// List proposals to the technical committee
Proposals
,
/// Vote a proposal to the technical committee
Vote
{
/// Proposal hash
hash
:
Hash
,
/// Proposal index
index
:
u32
,
/// Vote (0=against, 1=for)
vote
:
u8
,
},
}
/// handle technical committee commands
pub
async
fn
handle_command
(
data
:
Data
,
command
:
Subcommand
)
->
anyhow
::
Result
<
()
>
{
let
mut
data
=
data
.build_client
()
.await
?
.build_indexer
()
.await
?
;
match
command
{
Subcommand
::
Members
=>
{
data
=
data
.build_client
()
.await
?
;
commands
::
collective
::
technical_committee_members
(
&
data
)
.await
?
}
Subcommand
::
Proposals
=>
{
data
=
data
.build_client
()
.await
?
;
commands
::
collective
::
technical_committee_proposals
(
data
.client
())
.await
?
}
Subcommand
::
Vote
{
hash
,
index
,
vote
}
=>
{
data
=
data
.build_client
()
.await
?
;
let
vote
=
match
vote
{
0
=>
false
,
1
=>
true
,
_
=>
panic!
(
"Vote must be written 0 if you disagree, or 1 if you agree."
),
};
commands
::
collective
::
technical_committee_vote
(
&
data
,
hash
,
//Hash::from_str(&hash).expect("Invalid hash formatting"),
index
,
vote
,
)
.await
?
;
}
};
Ok
(())
}
/// list technical committee members
pub
async
fn
technical_committee_members
(
data
:
&
Data
)
->
Result
<
()
>
{
let
client
=
data
.client
();
...
...
@@ -67,7 +115,7 @@ pub async fn technical_committee_proposals(client: &Client) -> Result<()> {
.iter
(
runtime
::
storage
()
.technical_committee
()
.proposal_of
(
H
256
::
default
()),
.proposal_of
(
H
ash
::
default
()),
10
,
Some
(
parent_hash
),
)
...
...
@@ -83,19 +131,19 @@ pub async fn technical_committee_proposals(client: &Client) -> Result<()> {
/// submit vote to technical committee
pub
async
fn
technical_committee_vote
(
pair
:
Pair
,
client
:
&
Client
,
proposal_hash
:
H256
,
data
:
&
Data
,
proposal_hash
:
Hash
,
proposal_index
:
u32
,
vote
:
bool
,
)
->
Result
<
(),
subxt
::
Error
>
{
let
progress
=
client
let
progress
=
data
.client
()
.tx
()
.sign_and_submit_then_watch
(
&
runtime
::
tx
()
.technical_committee
()
.vote
(
proposal_hash
,
proposal_index
,
vote
),
&
PairSigner
::
new
(
pair
),
&
PairSigner
::
new
(
data
.key
pair
()
),
BaseExtrinsicParamsBuilder
::
new
(),
)
.await
?
;
...
...
This diff is collapsed.
Click to expand it.
src/main.rs
+
5
−
45
View file @
f3407daa
...
...
@@ -11,7 +11,7 @@ use codec::Encode;
use
data
::
*
;
use
keys
::
*
;
use
serde
::
Deserialize
;
use
sp_core
::{
sr25519
::
Pair
,
Pair
as
_
,
H256
};
use
sp_core
::{
sr25519
::
Pair
,
Pair
as
_
};
use
subxt
::
blocks
::
ExtrinsicEvents
;
use
subxt
::
tx
::{
BaseExtrinsicParamsBuilder
,
PairSigner
,
TxStatus
};
...
...
@@ -174,19 +174,6 @@ pub enum Subcommand {
SpamRoll
{
actual_repart
:
usize
,
},
/// List members of the technical committee
TechMembers
,
/// List proposals to the technical committee
TechProposals
,
/// Vote a proposal to the technical committee
TechVote
{
/// Proposal hash
hash
:
H256
,
/// Proposal index
index
:
u32
,
/// Vote (0=against, 1=for)
vote
:
u8
,
},
Transfer
{
/// Amount to transfer
amount
:
u64
,
...
...
@@ -214,6 +201,9 @@ pub enum Subcommand {
/// Smith subcommands
#[clap(subcommand)]
Smith
(
commands
::
smith
::
Subcommand
),
/// Tech subcommands
#[clap(subcommand)]
Tech
(
commands
::
collective
::
Subcommand
),
/// Universal Dividend subcommands
#[clap(subcommand)]
Ud
(
commands
::
ud
::
Subcommand
),
...
...
@@ -287,37 +277,6 @@ async fn main() -> Result<(), GcliError> {
)
.await
?
}
Subcommand
::
TechMembers
=>
{
data
=
data
.build_client
()
.await
?
;
commands
::
collective
::
technical_committee_members
(
&
data
)
.await
?
}
Subcommand
::
TechProposals
=>
{
data
=
data
.build_client
()
.await
?
;
commands
::
collective
::
technical_committee_proposals
(
data
.client
())
.await
?
}
Subcommand
::
TechVote
{
hash
,
index
,
vote
}
=>
{
data
=
data
.build_client
()
.await
?
;
let
vote
=
match
vote
{
0
=>
false
,
1
=>
true
,
_
=>
panic!
(
"Vote must be written 0 if you disagree, or 1 if you agree."
),
};
commands
::
collective
::
technical_committee_vote
(
get_keys
(
args
.secret_format
,
&
args
.address
,
&
args
.secret
,
NeededKeys
::
Secret
,
)
?
.1
.unwrap
(),
data
.client
(),
hash
,
//H256::from_str(&hash).expect("Invalid hash formatting"),
index
,
vote
,
)
.await
?
;
}
Subcommand
::
Transfer
{
amount
,
dest
,
...
...
@@ -375,6 +334,7 @@ async fn main() -> Result<(), GcliError> {
}
Subcommand
::
Identity
(
subcommand
)
=>
commands
::
identity
::
handle_command
(
data
,
subcommand
)
.await
?
,
Subcommand
::
Smith
(
subcommand
)
=>
commands
::
smith
::
handle_command
(
data
,
subcommand
)
.await
?
,
Subcommand
::
Tech
(
subcommand
)
=>
commands
::
collective
::
handle_command
(
data
,
subcommand
)
.await
?
,
Subcommand
::
Ud
(
subcommand
)
=>
commands
::
ud
::
handle_command
(
data
,
subcommand
)
.await
?
,
Subcommand
::
Oneshot
(
subcommand
)
=>
{
commands
::
oneshot
::
handle_command
(
data
,
subcommand
)
.await
?
...
...
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