diff --git a/pallets/governance/src/application.rs b/pallets/governance/src/application.rs index 75cec30..c8e72bb 100644 --- a/pallets/governance/src/application.rs +++ b/pallets/governance/src/application.rs @@ -19,13 +19,15 @@ pub struct AgentApplication { pub data: BoundedVec, pub cost: BalanceOf, pub expires_at: Block, + pub action: ApplicationAction, pub status: ApplicationStatus, } -// pub enum ProposalAction { -// Add, -// Remove, -// } +#[derive(DebugNoBound, Decode, Encode, TypeInfo, MaxEncodedLen, PartialEq, Eq)] +pub enum ApplicationAction { + Add, + Remove, +} #[derive(DebugNoBound, Decode, Encode, TypeInfo, MaxEncodedLen, PartialEq, Eq)] pub enum ApplicationStatus { @@ -38,9 +40,12 @@ pub fn submit_application( payer: AccountIdOf, agent_key: AccountIdOf, data: Vec, + removing: bool, ) -> DispatchResult { - if whitelist::is_whitelisted::(&agent_key) { + if !removing && whitelist::is_whitelisted::(&agent_key) { return Err(crate::Error::::AlreadyWhitelisted.into()); + } else if whitelist::is_whitelisted::(&agent_key) { + return Err(crate::Error::::NotWhitelisted.into()); } let config = crate::GlobalGovernanceConfig::::get(); @@ -77,6 +82,12 @@ pub fn submit_application( last_id }); + let action = if removing { + ApplicationAction::Remove + } else { + ApplicationAction::Add + }; + let application = AgentApplication:: { id: next_id, payer_key: payer, @@ -85,6 +96,7 @@ pub fn submit_application( cost, expires_at, status: ApplicationStatus::Open, + action, }; crate::AgentApplications::::insert(next_id, application);