-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use timer job to submit proposals (#4508)
- Loading branch information
Showing
7 changed files
with
106 additions
and
45 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
backend/canisters/proposals_bot/impl/src/timer_job_types.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use crate::updates::c2c_submit_proposal::submit_proposal; | ||
use canister_timer_jobs::Job; | ||
use proposals_bot_canister::ProposalToSubmit; | ||
use serde::{Deserialize, Serialize}; | ||
use types::{CanisterId, SnsNeuronId, UserId}; | ||
|
||
#[derive(Serialize, Deserialize, Clone)] | ||
pub enum TimerJob { | ||
SubmitProposal(SubmitProposalJob), | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Clone)] | ||
pub struct SubmitProposalJob { | ||
pub governance_canister_id: CanisterId, | ||
pub user_id: UserId, | ||
pub neuron_id: SnsNeuronId, | ||
pub proposal: ProposalToSubmit, | ||
} | ||
|
||
impl Job for TimerJob { | ||
fn execute(self) { | ||
match self { | ||
TimerJob::SubmitProposal(job) => job.execute(), | ||
} | ||
} | ||
} | ||
|
||
impl Job for SubmitProposalJob { | ||
fn execute(self) { | ||
ic_cdk::spawn(async move { | ||
submit_proposal(self.user_id, self.governance_canister_id, self.neuron_id, self.proposal).await; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
mod add_governance_canister; | ||
mod appoint_admins; | ||
mod c2c_submit_proposal; | ||
mod import_proposals_group_into_community; | ||
mod remove_governance_canister; | ||
mod stake_neuron_for_submitting_proposals; | ||
mod wallet_receive; | ||
pub mod add_governance_canister; | ||
pub mod appoint_admins; | ||
pub mod c2c_submit_proposal; | ||
pub mod import_proposals_group_into_community; | ||
pub mod remove_governance_canister; | ||
pub mod stake_neuron_for_submitting_proposals; | ||
pub mod wallet_receive; |