mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
validator-sets pallet event expansion
This commit is contained in:
@@ -291,13 +291,30 @@ pub mod pallet {
|
|||||||
#[pallet::getter(fn keys)]
|
#[pallet::getter(fn keys)]
|
||||||
pub type Keys<T: Config> = StorageMap<_, Twox64Concat, ValidatorSet, KeyPair, OptionQuery>;
|
pub type Keys<T: Config> = StorageMap<_, Twox64Concat, ValidatorSet, KeyPair, OptionQuery>;
|
||||||
|
|
||||||
// TODO: Expand
|
|
||||||
#[pallet::event]
|
#[pallet::event]
|
||||||
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
||||||
pub enum Event<T: Config> {
|
pub enum Event<T: Config> {
|
||||||
NewSet { set: ValidatorSet },
|
NewSet {
|
||||||
KeyGen { set: ValidatorSet, key_pair: KeyPair },
|
set: ValidatorSet,
|
||||||
SetRetired { 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<Session>,
|
||||||
|
},
|
||||||
|
SetRetired {
|
||||||
|
set: ValidatorSet,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Config> Pallet<T> {
|
impl<T: Config> Pallet<T> {
|
||||||
@@ -502,6 +519,7 @@ pub mod pallet {
|
|||||||
|
|
||||||
// Increase the allocation now
|
// Increase the allocation now
|
||||||
Self::set_allocation(network, account, Amount(new_allocation));
|
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 let Some(was_bft) = was_bft {
|
||||||
if was_bft && (!Self::is_bft(network)) {
|
if was_bft && (!Self::is_bft(network)) {
|
||||||
@@ -582,6 +600,12 @@ pub mod pallet {
|
|||||||
Some(Amount(TotalAllocatedStake::<T>::get(network).unwrap_or(Amount(0)).0 - amount.0)),
|
Some(Amount(TotalAllocatedStake::<T>::get(network).unwrap_or(Amount(0)).0 - amount.0)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Self::deposit_event(Event::AllocationDecreased {
|
||||||
|
validator: account,
|
||||||
|
network,
|
||||||
|
amount,
|
||||||
|
delayed_until: None,
|
||||||
|
});
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -604,6 +628,13 @@ pub mod pallet {
|
|||||||
Some(Amount(existing.0 + amount.0)),
|
Some(Amount(existing.0 + amount.0)),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Self::deposit_event(Event::AllocationDecreased {
|
||||||
|
validator: account,
|
||||||
|
network,
|
||||||
|
amount,
|
||||||
|
delayed_until: Some(to_unlock_on),
|
||||||
|
});
|
||||||
|
|
||||||
Ok(false)
|
Ok(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user