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
67
68
69
70
71
72
73
74
75
76
use crate::{
events::EventsDecoder,
metadata::{
Metadata,
MetadataError,
},
};
use codec::{
Decode,
Encode,
};
use tet_core::storage::StorageKey;
pub mod balances;
pub mod contracts;
pub mod session;
pub mod staking;
pub mod sudo;
pub mod system;
pub trait Store<T>: Encode {
const MODULE: &'static str;
const FIELD: &'static str;
type Returns: Decode;
fn prefix(metadata: &Metadata) -> Result<StorageKey, MetadataError>;
fn key(&self, metadata: &Metadata) -> Result<StorageKey, MetadataError>;
fn default(&self, metadata: &Metadata) -> Result<Self::Returns, MetadataError> {
Ok(metadata
.module(Self::MODULE)?
.storage(Self::FIELD)?
.default()?)
}
}
pub trait Call<T>: Encode {
const MODULE: &'static str;
const FUNCTION: &'static str;
fn events_decoder(_decoder: &mut EventsDecoder<T>) {}
}
pub trait Event<T>: Decode {
const MODULE: &'static str;
const EVENT: &'static str;
}