diff --git a/substrate/validator-sets/pallet/src/lib.rs b/substrate/validator-sets/pallet/src/lib.rs index cdd6e06f..7cb3f8c9 100644 --- a/substrate/validator-sets/pallet/src/lib.rs +++ b/substrate/validator-sets/pallet/src/lib.rs @@ -291,13 +291,30 @@ pub mod pallet { #[pallet::getter(fn keys)] pub type Keys = StorageMap<_, Twox64Concat, ValidatorSet, KeyPair, OptionQuery>; - // TODO: Expand #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { - NewSet { set: ValidatorSet }, - KeyGen { set: ValidatorSet, key_pair: KeyPair }, - SetRetired { set: ValidatorSet }, + NewSet { + set: ValidatorSet, + }, + KeyGen { + set: ValidatorSet, + key_pair: KeyPair, + }, + AllocationIncreased { + validator: T::AccountId, + network: NetworkId, + amount: Amount, + }, + AllocationDecreased { + validator: T::AccountId, + network: NetworkId, + amount: Amount, + delayed_until: Option, + }, + SetRetired { + set: ValidatorSet, + }, } impl Pallet { @@ -502,6 +519,7 @@ pub mod pallet { // Increase the allocation now Self::set_allocation(network, account, Amount(new_allocation)); + Self::deposit_event(Event::AllocationIncreased { validator: account, network, amount }); if let Some(was_bft) = was_bft { if was_bft && (!Self::is_bft(network)) { @@ -582,6 +600,12 @@ pub mod pallet { Some(Amount(TotalAllocatedStake::::get(network).unwrap_or(Amount(0)).0 - amount.0)), ); } + Self::deposit_event(Event::AllocationDecreased { + validator: account, + network, + amount, + delayed_until: None, + }); return Ok(true); } @@ -604,6 +628,13 @@ pub mod pallet { Some(Amount(existing.0 + amount.0)), ); + Self::deposit_event(Event::AllocationDecreased { + validator: account, + network, + amount, + delayed_until: Some(to_unlock_on), + }); + Ok(false) }