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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#![cfg_attr(not(feature = "std"), no_std)]
#![warn(missing_docs)]
#[cfg(feature = "std")]
use sp_core::sr25519::Pair;
use sp_core::{H160, H256};
use sp_runtime::{
generic,
traits::{BlakeTwo256, IdentifyAccount, LookupError, StaticLookup, Verify},
MultiAddress, MultiSignature, OpaqueExtrinsic,
};
use darwinia_support::evm::{ConcatConverter, DeriveSubstrateAddress};
macro_rules! development_or_production {
($doc:expr, $name:ident, $type:ty, $development_value:expr, $production_value:expr) => {
#[doc = $doc]
#[cfg(feature = "fast-runtime")]
pub const $name: $type = $development_value;
#[doc = $doc]
#[cfg(not(feature = "fast-runtime"))]
pub const $name: $type = $production_value;
};
}
pub type BlockNumber = u32;
pub type Hashing = BlakeTwo256;
pub type Hash = H256;
pub type Moment = u64;
#[cfg(feature = "std")]
pub type SigningParams = Pair;
pub type Signature = MultiSignature;
pub type AccountPublic = <Signature as Verify>::Signer;
pub type AccountId = <AccountPublic as IdentifyAccount>::AccountId;
pub type Address = MultiAddress<AccountId, ()>;
pub type Nonce = u32;
pub type Balance = u128;
pub type Power = u32;
pub type Header = generic::Header<BlockNumber, Hashing>;
pub type OpaqueBlock = generic::Block<Header, OpaqueExtrinsic>;
pub const NANO: Balance = 1;
pub const MICRO: Balance = 1_000 * NANO;
pub const MILLI: Balance = 1_000 * MICRO;
pub const COIN: Balance = 1_000 * MILLI;
pub const GWEI: Balance = 1_000_000_000;
pub const RING_HARD_CAP: Balance = 10_000_000_000 * COIN;
pub const TOTAL_POWER: Power = 1_000_000_000;
pub const fn pangoro_deposit(items: u32, bytes: u32) -> Balance {
items as Balance * 20 * MILLI + (bytes as Balance) * 100 * NANO
}
pub const fn pangolin_deposit(items: u32, bytes: u32) -> Balance {
items as Balance * 20 * COIN + (bytes as Balance) * 100 * MICRO
}
pub const MILLISECS_PER_BLOCK: Moment = 6000;
pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
development_or_production! {
"Hour in Pangoro/Pangolin.",
HOURS,
BlockNumber,
2 * MINUTES,
60 * MINUTES
}
development_or_production! {
"Day in Pangoro/Pangolin.",
DAYS,
BlockNumber,
2 * HOURS,
24 * HOURS
}
pub const SLOT_DURATION: Moment = MILLISECS_PER_BLOCK;
development_or_production! {
"Session length of Pangolin.",
PANGOLIN_BLOCKS_PER_SESSION,
BlockNumber,
MINUTES / 2,
30 * MINUTES
}
development_or_production! {
"Era length of Pangolin.",
PANGOLIN_SESSIONS_PER_ERA,
BlockNumber,
1,
3
}
development_or_production! {
"Session length of Pangoro.",
PANGORO_BLOCKS_PER_SESSION,
BlockNumber,
MINUTES / 2,
2 * HOURS
}
development_or_production! {
"Era length of Pangoro.",
PANGORO_SESSIONS_PER_ERA,
BlockNumber,
1,
3
}
pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4);
pub enum DarwiniaAccountLookup {}
impl StaticLookup for DarwiniaAccountLookup {
type Source = Address;
type Target = AccountId;
fn lookup(x: Self::Source) -> Result<Self::Target, LookupError> {
match x {
Self::Source::Id(i) => Ok(i),
Self::Source::Address20(address) =>
Ok(ConcatConverter::derive_substrate_address(&H160(address))),
_ => Err(LookupError),
}
}
fn unlookup(x: Self::Target) -> Self::Source {
Self::Source::Id(x)
}
}