pub use crate::traits::{
access_control::*,
errors::TimelockControllerError,
};
use brush::traits::{
AccountId,
Balance,
Hash,
Timestamp,
};
use ink_prelude::vec::Vec;
pub type OperationId = Hash;
#[derive(Default, Debug, Clone, PartialEq, scale::Encode, scale::Decode)]
#[cfg_attr(feature = "std", derive(scale_info::TypeInfo))]
pub struct Transaction {
pub callee: AccountId,
pub selector: [u8; 4],
pub input: Vec<u8>,
pub transferred_value: Balance,
pub gas_limit: u64,
}
#[brush::wrapper]
pub type TimelockControllerRef = dyn TimelockController + AccessControl;
#[brush::trait_definition]
pub trait TimelockController: AccessControl {
#[ink(message)]
fn is_operation(&self, id: OperationId) -> bool;
#[ink(message)]
fn is_operation_pending(&self, id: OperationId) -> bool;
#[ink(message)]
fn is_operation_ready(&self, id: OperationId) -> bool;
#[ink(message)]
fn is_operation_done(&self, id: OperationId) -> bool;
#[ink(message)]
fn get_timestamp(&self, id: OperationId) -> Timestamp;
#[ink(message)]
fn get_min_delay(&self) -> Timestamp;
#[ink(message)]
fn hash_operation(&self, transaction: Transaction, predecessor: Option<OperationId>, salt: [u8; 32]) -> Hash;
#[ink(message)]
fn hash_operation_batch(
&self,
transactions: Vec<Transaction>,
predecessor: Option<OperationId>,
salt: [u8; 32],
) -> Hash;
#[ink(message)]
fn schedule(
&mut self,
transaction: Transaction,
predecessor: Option<OperationId>,
salt: [u8; 32],
delay: Timestamp,
) -> Result<(), TimelockControllerError>;
#[ink(message)]
fn schedule_batch(
&mut self,
transactions: Vec<Transaction>,
predecessor: Option<OperationId>,
salt: [u8; 32],
delay: Timestamp,
) -> Result<(), TimelockControllerError>;
#[ink(message)]
fn cancel(&mut self, id: OperationId) -> Result<(), TimelockControllerError>;
#[ink(message, payable)]
fn execute(
&mut self,
transaction: Transaction,
predecessor: Option<OperationId>,
salt: [u8; 32],
) -> Result<(), TimelockControllerError>;
#[ink(message, payable)]
fn execute_batch(
&mut self,
transactions: Vec<Transaction>,
predecessor: Option<OperationId>,
salt: [u8; 32],
) -> Result<(), TimelockControllerError>;
#[ink(message)]
fn update_delay(&mut self, new_delay: Timestamp) -> Result<(), TimelockControllerError>;
}