2024-06-02 19:58:29 -04:00
|
|
|
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
|
2025-02-12 03:41:50 -05:00
|
|
|
#![doc = include_str!("../README.md")]
|
|
|
|
|
#![deny(missing_docs)]
|
2024-06-02 19:58:29 -04:00
|
|
|
#![cfg_attr(not(feature = "std"), no_std)]
|
2023-12-06 09:53:48 -05:00
|
|
|
#![allow(non_camel_case_types)]
|
|
|
|
|
|
2024-06-02 19:58:29 -04:00
|
|
|
extern crate alloc;
|
|
|
|
|
|
2025-02-12 03:41:50 -05:00
|
|
|
use borsh::{BorshSerialize, BorshDeserialize};
|
|
|
|
|
|
2024-06-02 19:58:29 -04:00
|
|
|
pub use serai_primitives as primitives;
|
|
|
|
|
|
2025-02-12 03:41:50 -05:00
|
|
|
/// Call/Event for the system.
|
2023-12-06 09:53:48 -05:00
|
|
|
pub mod system;
|
|
|
|
|
|
2025-02-12 03:41:50 -05:00
|
|
|
/// Call/Event for coins.
|
2023-12-06 09:53:48 -05:00
|
|
|
pub mod coins;
|
|
|
|
|
|
2025-02-12 03:41:50 -05:00
|
|
|
/// Call/Event for validator sets.
|
2023-12-06 09:53:48 -05:00
|
|
|
pub mod validator_sets;
|
2025-02-12 03:41:50 -05:00
|
|
|
/// Call/Event for signals.
|
|
|
|
|
pub mod signals;
|
2023-12-06 09:53:48 -05:00
|
|
|
|
2025-02-12 03:41:50 -05:00
|
|
|
/// Call/Event for the DEX.
|
|
|
|
|
pub mod dex;
|
2024-08-15 06:12:04 +03:00
|
|
|
|
2025-02-12 03:41:50 -05:00
|
|
|
/// Call/Event for genesis liquidity.
|
|
|
|
|
pub mod genesis_liquidity;
|
|
|
|
|
/// Event for economic security.
|
2024-09-01 01:55:42 +03:00
|
|
|
pub mod economic_security;
|
|
|
|
|
|
2025-02-12 03:41:50 -05:00
|
|
|
/// Call/Event for `InInstruction`s.
|
2024-08-15 06:12:04 +03:00
|
|
|
pub mod in_instructions;
|
|
|
|
|
|
2025-02-12 03:41:50 -05:00
|
|
|
mod transaction;
|
|
|
|
|
pub use transaction::*;
|
2023-12-06 09:53:48 -05:00
|
|
|
|
2025-02-12 03:41:50 -05:00
|
|
|
mod block;
|
|
|
|
|
pub use block::*;
|
2023-12-06 09:53:48 -05:00
|
|
|
|
2025-02-12 03:41:50 -05:00
|
|
|
/// All calls.
|
|
|
|
|
#[derive(Clone, PartialEq, Eq, Debug, BorshSerialize, BorshDeserialize)]
|
|
|
|
|
#[borsh(use_discriminant = true)]
|
|
|
|
|
#[repr(u8)]
|
2023-12-06 09:53:48 -05:00
|
|
|
pub enum Call {
|
2025-02-12 03:41:50 -05:00
|
|
|
// The call for the system.
|
|
|
|
|
// System(system::Call) = 0,
|
|
|
|
|
/// The call for coins.
|
|
|
|
|
Coins(coins::Call) = 1,
|
|
|
|
|
/// The call for validator sets.
|
|
|
|
|
ValidatorSets(validator_sets::Call) = 2,
|
|
|
|
|
/// The call for signals.
|
|
|
|
|
Signals(signals::Call) = 3,
|
|
|
|
|
/// The call for the DEX.
|
|
|
|
|
Dex(dex::Call) = 4,
|
|
|
|
|
/// The call for genesis liquidity.
|
|
|
|
|
GenesisLiquidity(genesis_liquidity::Call) = 5,
|
|
|
|
|
// The call for economic security.
|
|
|
|
|
// EconomicSecurity = 6,
|
|
|
|
|
/// The call for `InInstruction`s.
|
|
|
|
|
InInstructions(in_instructions::Call) = 7,
|
2023-12-06 09:53:48 -05:00
|
|
|
}
|
|
|
|
|
|
2025-02-12 03:41:50 -05:00
|
|
|
impl Call {
|
|
|
|
|
pub(crate) fn is_signed(&self) -> bool {
|
|
|
|
|
match self {
|
|
|
|
|
Call::Coins(call) => call.is_signed(),
|
|
|
|
|
Call::ValidatorSets(call) => call.is_signed(),
|
|
|
|
|
Call::Signals(call) => call.is_signed(),
|
|
|
|
|
Call::Dex(call) => call.is_signed(),
|
|
|
|
|
Call::GenesisLiquidity(call) => call.is_signed(),
|
|
|
|
|
Call::InInstructions(call) => call.is_signed(),
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-12-07 02:30:09 -05:00
|
|
|
}
|
|
|
|
|
|
2025-02-12 03:41:50 -05:00
|
|
|
/// All events.
|
|
|
|
|
#[derive(Clone, PartialEq, Eq, Debug, BorshSerialize, BorshDeserialize)]
|
|
|
|
|
#[borsh(use_discriminant = true)]
|
|
|
|
|
#[repr(u8)]
|
2023-12-06 09:53:48 -05:00
|
|
|
pub enum Event {
|
2025-02-12 03:41:50 -05:00
|
|
|
/// The event for the system.
|
|
|
|
|
System(system::Event) = 0,
|
|
|
|
|
/// The event for coins.
|
|
|
|
|
Coins(coins::Event) = 1,
|
|
|
|
|
/// The event for validator sets.
|
|
|
|
|
ValidatorSets(validator_sets::Event) = 2,
|
|
|
|
|
/// The event for signals.
|
|
|
|
|
Signals(signals::Event) = 3,
|
|
|
|
|
/// The event for the DEX.
|
|
|
|
|
Dex(dex::Event) = 4,
|
|
|
|
|
/// The event for genesis liquidity.
|
|
|
|
|
GenesisLiquidity(genesis_liquidity::Event) = 5,
|
|
|
|
|
/// The event for economic security.
|
|
|
|
|
EconomicSecurity(economic_security::Event) = 6,
|
|
|
|
|
/// The event for `InInstruction`s.
|
|
|
|
|
InInstructions(in_instructions::Event) = 7,
|
2023-12-07 02:30:09 -05:00
|
|
|
}
|
2025-09-19 22:12:45 -04:00
|
|
|
|
|
|
|
|
impl From<system::Event> for Event {
|
|
|
|
|
fn from(event: system::Event) -> Self {
|
|
|
|
|
Self::System(event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
impl From<coins::Event> for Event {
|
|
|
|
|
fn from(event: coins::Event) -> Self {
|
|
|
|
|
Self::Coins(event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
impl From<validator_sets::Event> for Event {
|
|
|
|
|
fn from(event: validator_sets::Event) -> Self {
|
|
|
|
|
Self::ValidatorSets(event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
impl From<signals::Event> for Event {
|
|
|
|
|
fn from(event: signals::Event) -> Self {
|
|
|
|
|
Self::Signals(event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
impl From<dex::Event> for Event {
|
|
|
|
|
fn from(event: dex::Event) -> Self {
|
|
|
|
|
Self::Dex(event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
impl From<genesis_liquidity::Event> for Event {
|
|
|
|
|
fn from(event: genesis_liquidity::Event) -> Self {
|
|
|
|
|
Self::GenesisLiquidity(event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
impl From<economic_security::Event> for Event {
|
|
|
|
|
fn from(event: economic_security::Event) -> Self {
|
|
|
|
|
Self::EconomicSecurity(event)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
impl From<in_instructions::Event> for Event {
|
|
|
|
|
fn from(event: in_instructions::Event) -> Self {
|
|
|
|
|
Self::InInstructions(event)
|
|
|
|
|
}
|
|
|
|
|
}
|