1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use crate::{
error::CoreError,
types::{BoundaryValidated, SlotType},
};
use cosmwasm_std::{Addr, Env};
use cw20::Balance;
pub trait GenericBalances {
fn add_tokens(&mut self, add: Balance);
fn minus_tokens(&mut self, minus: Balance);
}
pub trait FindAndMutate<'a, T, Rhs = &'a T>
where
Self: IntoIterator<Item = T>,
{
fn find_checked_add(&mut self, add: Rhs) -> Result<(), CoreError>;
fn find_checked_sub(&mut self, sub: Rhs) -> Result<(), CoreError>;
}
pub trait BalancesOperations<'a, T, Rhs> {
fn checked_add_coins(&mut self, add: Rhs) -> Result<(), CoreError>;
fn checked_sub_coins(&mut self, sub: Rhs) -> Result<(), CoreError>;
}
pub trait ResultFailed {
fn failed(&self) -> bool;
}
pub trait Intervals {
fn next(
&self,
env: &Env,
boundary: BoundaryValidated,
slot_granularity_time: u64,
) -> (u64, SlotType);
fn is_valid(&self) -> bool;
}
pub trait TaskHash {
fn to_hash(&self) -> String;
fn to_hash_vec(&self) -> Vec<u8>;
fn is_valid_msg(&self, self_addr: &Addr, sender: &Addr, owner_id: &Addr) -> bool;
fn to_gas_total(&self) -> u64;
}