Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
steinerkelvin committed Dec 31, 2024
1 parent ca8d224 commit dda71f4
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions pallets/governance/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ pub struct AgentApplication<T: crate::Config> {
pub data: BoundedVec<u8, T::MaxApplicationDataLength>,
pub cost: BalanceOf<T>,
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 {
Expand All @@ -38,9 +40,12 @@ pub fn submit_application<T: crate::Config>(
payer: AccountIdOf<T>,
agent_key: AccountIdOf<T>,
data: Vec<u8>,
removing: bool,
) -> DispatchResult {
if whitelist::is_whitelisted::<T>(&agent_key) {
if !removing && whitelist::is_whitelisted::<T>(&agent_key) {
return Err(crate::Error::<T>::AlreadyWhitelisted.into());
} else if whitelist::is_whitelisted::<T>(&agent_key) {
return Err(crate::Error::<T>::NotWhitelisted.into());
}

let config = crate::GlobalGovernanceConfig::<T>::get();
Expand Down Expand Up @@ -77,6 +82,12 @@ pub fn submit_application<T: crate::Config>(
last_id
});

let action = if removing {
ApplicationAction::Remove
} else {
ApplicationAction::Add
};

let application = AgentApplication::<T> {
id: next_id,
payer_key: payer,
Expand All @@ -85,6 +96,7 @@ pub fn submit_application<T: crate::Config>(
cost,
expires_at,
status: ApplicationStatus::Open,
action,
};

crate::AgentApplications::<T>::insert(next_id, application);
Expand Down

0 comments on commit dda71f4

Please sign in to comment.