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
macro_rules! impl_authority_keys {
() => {
pub struct AuthorityKeys {
stash_key: AccountId,
session_keys: SessionKeys,
}
impl AuthorityKeys {
pub fn new(sr25519: &str, ed25519: &str, ecdsa: &str) -> Self {
let sr25519 = array_bytes::hex2array_unchecked(sr25519);
let ed25519 = array_bytes::hex2array_unchecked(ed25519);
let ecdsa = array_bytes::hex2array_unchecked(ecdsa);
Self {
stash_key: sr25519.into(),
session_keys: session_keys(
sr25519.unchecked_into(),
ed25519.unchecked_into(),
ecdsa.unchecked_into(),
sr25519.unchecked_into(),
sr25519.unchecked_into(),
),
}
}
pub fn testnet_authorities() -> Vec<Self> {
vec![
AuthorityKeys::new(
"0x9c43c00407c0a51e0d88ede9d531f165e370013b648e6b62f4b3bcff4689df02",
"0x63e122d962a835020bef656ad5a80dbcc994bb48a659f1af955552f4b3c27b09",
"0x021842ca1a9aff1549b811126a9c1171d18ffddbd4434478675606f840cfc2fd09",
),
AuthorityKeys::new(
"0x741a9f507722713ec0a5df1558ac375f62469b61d1f60fa60f5dedfc85425b2e",
"0x8a50704f41448fca63f608575debb626639ac00ad151a1db08af1368be9ccb1d",
"0x0312aed9a712318917535314973525902d09d298cb04520f7c9ed9959fe69678f3",
),
AuthorityKeys::new(
"0x2276a3162f1b63c21b3396c5846d43874c5b8ba69917d756142d460b2d70d036",
"0xb28fade2d023f08c0d5a131eac7d64a107a2660f22a0aca09b37a3f321259ef6",
"0x0374704a3dd21e01cff4d47e53f84fa4a91a0971ebde83007ef6b567b183344558",
),
AuthorityKeys::new(
"0x7a8b265c416eab5fdf8e5a1b3c7635131ca7164fbe6f66d8a70feeeba7c4dd7f",
"0x305bafd512366e7fd535fdc144c7034b8683e1814d229c84a116f3cb27a97643",
"0x034a972603f389797cad3705eacb90584c55aa004cf973206811b1e53e56a02f5a",
),
]
}
}
};
}
pub mod pangolin;
pub use pangolin::ChainSpec as PangolinChainSpec;
pub mod pangoro;
pub use pangoro::ChainSpec as PangoroChainSpec;
#[cfg(feature = "template")]
pub mod template;
#[cfg(feature = "template")]
pub use template::ChainSpec as TemplateChainSpec;
pub use beefy_primitives::crypto::AuthorityId as BeefyId;
pub use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
pub use sc_finality_grandpa::AuthorityId as GrandpaId;
pub use sp_consensus_babe::AuthorityId as BabeId;
use serde::{Deserialize, Serialize};
use sc_chain_spec::ChainSpecExtension;
use sc_client_api::{BadBlocks, ForkBlocks};
use sc_sync_state_rpc::LightSyncStateExtension;
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use sp_core::{sr25519, Pair, Public};
use sp_runtime::traits::IdentifyAccount;
use drml_primitives::{AccountId, AccountPublic, OpaqueBlock};
const DEFAULT_PROTOCOL_ID: &str = "drml";
const TEAM_MEMBERS: &[&str] = &[
"0x922b6854052ba1084c74dd323ee70047d58ae4eb068f20bc251831f1ec109030",
"0xb26268877f72c4dcd9c2459a99dde0d2caf5a816c6b4cd3bd1721252b26f4909",
"0xf41d3260d736f5b3db8a6351766e97619ea35972546a5f850bbf0b27764abe03",
"0xf29638cb649d469c317a4c64381e179d5f64ef4d30207b4c52f2725c9d2ec533",
"0x1a7008a33fa595398b509ef56841db3340931c28a42881e36c9f34b1f15f9271",
"0x500e3197e075610c1925ddcd86d66836bf93ae0a476c64f56f611afc7d64d16f",
"0x129f002b1c0787ea72c31b2dc986e66911fe1b4d6dc16f83a1127f33e5a74c7d",
"0x26fe37ba5d35ac650ba37c5cc84525ed135e772063941ae221a1caca192fff49",
"0x187c272f576b1999d6cf3dd529b59b832db12125b43e57fb088677eb0c570a6b",
"0xb4f7f03bebc56ebe96bc52ea5ed3159d45a0ce3a8d7f082983c33ef133274747",
"0x88d388115bd0df43e805b029207cfa4925cecfb29026e345979d9b0004466c49",
];
#[derive(Default, Clone, Serialize, Deserialize, ChainSpecExtension)]
#[serde(rename_all = "camelCase")]
pub struct Extensions {
pub fork_blocks: ForkBlocks<OpaqueBlock>,
pub bad_blocks: BadBlocks<OpaqueBlock>,
pub light_sync_state: LightSyncStateExtension,
}
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
TPublic::Pair::from_string(&format!("//{}", seed), None)
.expect("static values are valid; qed")
.public()
}
pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId
where
AccountPublic: From<<TPublic::Pair as Pair>::Public>,
{
AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
}
pub fn get_authority_keys_from_seed(
seed: &str,
) -> (AccountId, AccountId, BabeId, GrandpaId, BeefyId, ImOnlineId, AuthorityDiscoveryId) {
(
get_account_id_from_seed::<sr25519::Public>(&format!("{}//stash", seed)),
get_account_id_from_seed::<sr25519::Public>(seed),
get_from_seed::<BabeId>(seed),
get_from_seed::<GrandpaId>(seed),
get_from_seed::<BeefyId>(seed),
get_from_seed::<ImOnlineId>(seed),
get_from_seed::<AuthorityDiscoveryId>(seed),
)
}