mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Tidy serai-signals-pallet
Adds `serai-validator-sets-pallet` and `serai-signals-pallet` to the runtime.
This commit is contained in:
@@ -26,7 +26,7 @@ const HUMAN_READABLE_PART: bech32::Hrp = bech32::Hrp::parse_unchecked("sri");
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Zeroize, BorshSerialize, BorshDeserialize)]
|
||||
#[cfg_attr(
|
||||
feature = "non_canonical_scale_derivations",
|
||||
derive(scale::Encode, scale::Decode, scale::MaxEncodedLen)
|
||||
derive(scale::Encode, scale::Decode, scale::MaxEncodedLen, scale::DecodeWithMemTracking)
|
||||
)]
|
||||
pub struct SeraiAddress(pub [u8; 32]);
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ pub mod prelude {
|
||||
pub use crate::coin::*;
|
||||
pub use crate::balance::*;
|
||||
pub use crate::network_id::*;
|
||||
pub use crate::validator_sets::{Session, ValidatorSet, ExternalValidatorSet, Slash, SlashReport};
|
||||
pub use crate::validator_sets::*;
|
||||
pub use crate::instructions::*;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,19 +5,21 @@ use crate::{network_id::ExternalNetworkId, address::SeraiAddress};
|
||||
|
||||
/// The ID of an protocol.
|
||||
pub type ProtocolId = [u8; 32];
|
||||
/// The ID of a signal.
|
||||
pub type SignalId = [u8; 32];
|
||||
|
||||
/// A signal.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, Zeroize, BorshSerialize, BorshDeserialize)]
|
||||
#[cfg_attr(
|
||||
feature = "non_canonical_scale_derivations",
|
||||
allow(clippy::cast_possible_truncation),
|
||||
derive(scale::Encode, scale::Decode, scale::MaxEncodedLen)
|
||||
derive(scale::Encode, scale::Decode, scale::MaxEncodedLen, scale::DecodeWithMemTracking)
|
||||
)]
|
||||
pub enum Signal {
|
||||
/// A signal to retire the current protocol.
|
||||
Retire {
|
||||
/// The protocol to retire in favor of.
|
||||
in_favor_of: ProtocolId,
|
||||
/// The ID of the retirement signal being favored.
|
||||
signal_id: SignalId,
|
||||
},
|
||||
/// A signal to halt an external network.
|
||||
Halt(ExternalNetworkId),
|
||||
@@ -27,7 +29,7 @@ pub enum Signal {
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, Zeroize, BorshSerialize, BorshDeserialize)]
|
||||
#[cfg_attr(
|
||||
feature = "non_canonical_scale_derivations",
|
||||
derive(scale::Encode, scale::Decode, scale::MaxEncodedLen)
|
||||
derive(scale::Encode, scale::Decode, scale::MaxEncodedLen, scale::DecodeWithMemTracking)
|
||||
)]
|
||||
pub struct RegisteredRetirementSignal {
|
||||
/// The protocol to retire in favor of.
|
||||
@@ -40,7 +42,7 @@ pub struct RegisteredRetirementSignal {
|
||||
|
||||
impl RegisteredRetirementSignal {
|
||||
/// The ID of this signal.
|
||||
pub fn id(&self) -> ProtocolId {
|
||||
pub fn id(&self) -> SignalId {
|
||||
sp_core::blake2_256(&borsh::to_vec(self).unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,6 +112,8 @@ impl ExternalValidatorSet {
|
||||
pub struct KeyShares(pub u16);
|
||||
|
||||
impl KeyShares {
|
||||
/// Zero key shares.
|
||||
pub const ZERO: KeyShares = KeyShares(0);
|
||||
/// One key share.
|
||||
pub const ONE: KeyShares = KeyShares(1);
|
||||
/// The maximum amount of key shares per set.
|
||||
|
||||
Reference in New Issue
Block a user