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
a89d7eae
Verified
Commit
a89d7eae
authored
2 years ago
by
Pascal Engélibert
Browse files
Options
Downloads
Patches
Plain Diff
feat: tech comm vote command
parent
21a9b4e4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/commands/collective.rs
+25
-1
25 additions, 1 deletion
src/commands/collective.rs
src/main.rs
+26
-0
26 additions, 0 deletions
src/main.rs
with
51 additions
and
1 deletion
src/commands/collective.rs
+
25
−
1
View file @
a89d7eae
use
crate
::{
gdev
,
indexer
::
*
,
Args
,
Client
};
use
anyhow
::
Result
;
use
sp_core
::
sr25519
::
Pair
;
use
sp_core
::
H256
;
use
subxt
::
tx
::{
BaseExtrinsicParamsBuilder
,
PairSigner
};
pub
async
fn
technical_committee_members
(
client
:
Client
,
args
:
&
Args
)
->
Result
<
()
>
{
let
parent_hash
=
client
...
...
@@ -73,7 +76,7 @@ pub async fn technical_committee_proposals(client: Client) -> Result<()> {
.iter
(
gdev
::
storage
()
.technical_committee
()
.proposal_of
(
sp_core
::
H256
::
default
()),
.proposal_of
(
H256
::
default
()),
10
,
Some
(
parent_hash
),
)
...
...
@@ -86,3 +89,24 @@ pub async fn technical_committee_proposals(client: Client) -> Result<()> {
Ok
(())
}
pub
async
fn
technical_committee_vote
(
pair
:
Pair
,
client
:
Client
,
proposal_hash
:
H256
,
proposal_index
:
u32
,
vote
:
bool
,
)
->
Result
<
()
>
{
client
.tx
()
.sign_and_submit_then_watch
(
&
gdev
::
tx
()
.technical_committee
()
.vote
(
proposal_hash
,
proposal_index
,
vote
),
&
PairSigner
::
new
(
pair
),
BaseExtrinsicParamsBuilder
::
new
(),
)
.await
?
;
Ok
(())
}
This diff is collapsed.
Click to expand it.
src/main.rs
+
26
−
0
View file @
a89d7eae
...
...
@@ -8,6 +8,7 @@ use codec::Encode;
use
sp_core
::{
crypto
::{
Pair
as
_
,
Ss58Codec
},
sr25519
::
Pair
,
H256
,
};
use
std
::
str
::
FromStr
;
...
...
@@ -142,7 +143,17 @@ pub enum Subcommand {
},
/// 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
,
...
...
@@ -320,6 +331,21 @@ async fn main() -> Result<()> {
Subcommand
::
TechProposals
=>
{
commands
::
collective
::
technical_committee_proposals
(
client
)
.await
?
}
Subcommand
::
TechVote
{
hash
,
index
,
vote
}
=>
{
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
(
pair
.expect
(
"This subcommand needs a secret."
),
client
,
hash
,
//H256::from_str(&hash).expect("Invalid hash formatting"),
index
,
vote
,
)
.await
?
}
Subcommand
::
Transfer
{
amount
,
dest
,
...
...
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