Skip to content

Commit

Permalink
enable enactment and add command
Browse files Browse the repository at this point in the history
  • Loading branch information
brenzi committed Mar 24, 2024
1 parent 950bac2 commit 87e7509
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
30 changes: 30 additions & 0 deletions client/src/commands/encointer_democracy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,36 @@ pub fn list_proposals(_args: &str, matches: &ArgMatches<'_>) -> Result<(), clap:
})
.into()
}

pub fn list_enactment_queue(_args: &str, matches: &ArgMatches<'_>) -> Result<(), clap::Error> {
let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(async {
let api = get_chain_api(matches).await;
let maybe_at = matches.at_block_arg();
let key_prefix = api
.get_storage_map_key_prefix("EncointerDemocracy", "EnactmentQueue")
.await
.unwrap();
let max_keys = 1000;
let storage_keys = api
.get_storage_keys_paged(Some(key_prefix), max_keys, None, maybe_at)
.await
.unwrap();
if storage_keys.len() == max_keys as usize {
error!("results can be wrong because max keys reached for query")
}
for storage_key in storage_keys.iter() {
let maybe_proposal_id: Option<ProposalIdType> =
api.get_storage_by_key(storage_key.clone(), maybe_at).await.unwrap();
if let Some(proposal_id) = maybe_proposal_id {
println!("{}", proposal_id);
}
}
Ok(())
})
.into()
}

pub fn vote(_args: &str, matches: &ArgMatches<'_>) -> Result<(), clap::Error> {
let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(async {
Expand Down
9 changes: 9 additions & 0 deletions client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,15 @@ fn main() {
})
.runner(commands::encointer_democracy::list_proposals),
)
.add_cmd(
Command::new("list-enactment-queue")
.description("list queued proposal enactments")
.options(|app| {
app.setting(AppSettings::ColoredHelp)
.at_block_arg()
})
.runner(commands::encointer_democracy::list_enactment_queue),
)
.add_cmd(
Command::new("vote")
.description("Submit vote for porposal. Vote is either ay or nay. Reputation vec to be specified as cid1_cindex1,cid2_cindex2,...")
Expand Down
3 changes: 2 additions & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,8 @@ parameter_types! {

impl pallet_encointer_scheduler::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnCeremonyPhaseChange = pallet_encointer_ceremonies::Pallet<Runtime>;
type OnCeremonyPhaseChange =
(pallet_encointer_ceremonies::Pallet<Runtime>, pallet_encointer_democracy::Pallet<Runtime>);
type MomentsPerDay = MomentsPerDay;
type CeremonyMaster = EnsureRoot<AccountId>;
type WeightInfo = weights::pallet_encointer_scheduler::WeightInfo<Runtime>;
Expand Down

0 comments on commit 87e7509

Please sign in to comment.