2025-02-12 03:41:50 -05:00
|
|
|
use borsh::{BorshSerialize, BorshDeserialize};
|
2023-12-06 09:53:48 -05:00
|
|
|
|
2025-02-12 03:41:50 -05:00
|
|
|
use serai_primitives::{
|
|
|
|
|
BlockHash, network_id::ExternalNetworkId, validator_sets::Session, instructions::SignedBatch,
|
|
|
|
|
};
|
2023-12-06 09:53:48 -05:00
|
|
|
|
2025-02-12 03:41:50 -05:00
|
|
|
/// A call to `InInstruction`s.
|
|
|
|
|
#[derive(Clone, PartialEq, Eq, Debug, BorshSerialize, BorshDeserialize)]
|
2023-12-06 09:53:48 -05:00
|
|
|
pub enum Call {
|
2025-02-12 03:41:50 -05:00
|
|
|
/// Execute a batch of `InInstruction`s.
|
|
|
|
|
execute_batch {
|
|
|
|
|
/// The batch to execute.
|
|
|
|
|
batch: SignedBatch,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Call {
|
|
|
|
|
pub(crate) fn is_signed(&self) -> bool {
|
|
|
|
|
match self {
|
|
|
|
|
Call::execute_batch { .. } => false,
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-12-06 09:53:48 -05:00
|
|
|
}
|
|
|
|
|
|
2025-02-12 03:41:50 -05:00
|
|
|
/// An event from `InInstruction`s.
|
|
|
|
|
#[derive(Clone, PartialEq, Eq, Debug, BorshSerialize, BorshDeserialize)]
|
2023-12-06 09:53:48 -05:00
|
|
|
pub enum Event {
|
2025-02-12 03:41:50 -05:00
|
|
|
/// A batch of `InInstruction`s was executed.
|
2024-12-31 10:37:19 -05:00
|
|
|
Batch {
|
2025-02-12 03:41:50 -05:00
|
|
|
/// The network for which a batch was executed.
|
2025-01-30 00:56:29 -05:00
|
|
|
network: ExternalNetworkId,
|
2025-02-12 03:41:50 -05:00
|
|
|
/// The session which published the batch.
|
2024-12-31 10:37:19 -05:00
|
|
|
publishing_session: Session,
|
2025-02-12 03:41:50 -05:00
|
|
|
/// The ID of the batch.
|
2024-12-31 10:37:19 -05:00
|
|
|
id: u32,
|
2025-02-12 03:41:50 -05:00
|
|
|
/// The hash of the block on the external network which caused this batch's creation.
|
2025-01-19 02:27:35 -05:00
|
|
|
external_network_block_hash: BlockHash,
|
2025-02-12 03:41:50 -05:00
|
|
|
/// The hash of the `InInstruction`s within this batch.
|
2024-12-31 10:37:19 -05:00
|
|
|
in_instructions_hash: [u8; 32],
|
2025-02-12 03:41:50 -05:00
|
|
|
/// The results of each `InInstruction` within the batch.
|
|
|
|
|
#[borsh(
|
|
|
|
|
serialize_with = "serai_primitives::sp_borsh::borsh_serialize_bitvec",
|
|
|
|
|
deserialize_with = "serai_primitives::sp_borsh::borsh_deserialize_bitvec"
|
|
|
|
|
)]
|
2024-12-31 10:37:19 -05:00
|
|
|
in_instruction_results: bitvec::vec::BitVec<u8, bitvec::order::Lsb0>,
|
|
|
|
|
},
|
2023-12-06 09:53:48 -05:00
|
|
|
}
|