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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use cosmwasm_std::{CanonicalAddr, Decimal, HumanAddr, ReadonlyStorage, Storage, Uint128};
use cosmwasm_storage::{
bucket, bucket_read, singleton, singleton_read, Bucket, ReadonlyBucket, ReadonlySingleton,
Singleton,
};
pub const KEY_INVESTMENT: &[u8] = b"invest";
pub const KEY_TOTAL_SUPPLY: &[u8] = b"total_supply";
pub const PREFIX_CLAIMS: &[u8] = b"claim";
pub fn claims<S: Storage>(storage: &mut S) -> Bucket<S, Uint128> {
bucket(PREFIX_CLAIMS, storage)
}
pub fn claims_read<S: ReadonlyStorage>(storage: &S) -> ReadonlyBucket<S, Uint128> {
bucket_read(PREFIX_CLAIMS, storage)
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct InvestmentInfo {
pub owner: CanonicalAddr,
pub bond_denom: String,
pub exit_tax: Decimal,
pub validator: HumanAddr,
pub min_withdrawal: Uint128,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema, Default)]
pub struct Supply {
pub issued: Uint128,
pub bonded: Uint128,
pub claims: Uint128,
}
pub fn invest_info<S: Storage>(storage: &mut S) -> Singleton<S, InvestmentInfo> {
singleton(storage, KEY_INVESTMENT)
}
pub fn invest_info_read<S: ReadonlyStorage>(storage: &S) -> ReadonlySingleton<S, InvestmentInfo> {
singleton_read(storage, KEY_INVESTMENT)
}
pub fn total_supply<S: Storage>(storage: &mut S) -> Singleton<S, Supply> {
singleton(storage, KEY_TOTAL_SUPPLY)
}
pub fn total_supply_read<S: ReadonlyStorage>(storage: &S) -> ReadonlySingleton<S, Supply> {
singleton_read(storage, KEY_TOTAL_SUPPLY)
}