@@ -22,6 +22,12 @@ use std::{borrow::Cow, str::FromStr};
22
22
/// Collects all supported Coretime configurations.
23
23
#[ derive( Debug , PartialEq , Clone , Copy ) ]
24
24
pub enum CoretimeRuntimeType {
25
+ Kusama ,
26
+ KusamaLocal ,
27
+
28
+ Polkadot ,
29
+ PolkadotLocal ,
30
+
25
31
// Live
26
32
Rococo ,
27
33
// Local
@@ -42,6 +48,10 @@ impl FromStr for CoretimeRuntimeType {
42
48
43
49
fn from_str ( value : & str ) -> Result < Self , Self :: Err > {
44
50
match value {
51
+ kusama:: CORETIME_KUSAMA => Ok ( CoretimeRuntimeType :: Kusama ) ,
52
+ kusama:: CORETIME_KUSAMA_LOCAL => Ok ( CoretimeRuntimeType :: KusamaLocal ) ,
53
+ polkadot:: CORETIME_POLKADOT => Ok ( CoretimeRuntimeType :: Polkadot ) ,
54
+ polkadot:: CORETIME_POLKADOT_LOCAL => Ok ( CoretimeRuntimeType :: PolkadotLocal ) ,
45
55
rococo:: CORETIME_ROCOCO => Ok ( CoretimeRuntimeType :: Rococo ) ,
46
56
rococo:: CORETIME_ROCOCO_LOCAL => Ok ( CoretimeRuntimeType :: RococoLocal ) ,
47
57
rococo:: CORETIME_ROCOCO_DEVELOPMENT => Ok ( CoretimeRuntimeType :: RococoDevelopment ) ,
@@ -56,6 +66,10 @@ impl FromStr for CoretimeRuntimeType {
56
66
impl From < CoretimeRuntimeType > for & str {
57
67
fn from ( runtime_type : CoretimeRuntimeType ) -> Self {
58
68
match runtime_type {
69
+ CoretimeRuntimeType :: Kusama => kusama:: CORETIME_KUSAMA ,
70
+ CoretimeRuntimeType :: KusamaLocal => kusama:: CORETIME_KUSAMA_LOCAL ,
71
+ CoretimeRuntimeType :: Polkadot => polkadot:: CORETIME_POLKADOT ,
72
+ CoretimeRuntimeType :: PolkadotLocal => polkadot:: CORETIME_POLKADOT_LOCAL ,
59
73
CoretimeRuntimeType :: Rococo => rococo:: CORETIME_ROCOCO ,
60
74
CoretimeRuntimeType :: RococoLocal => rococo:: CORETIME_ROCOCO_LOCAL ,
61
75
CoretimeRuntimeType :: RococoDevelopment => rococo:: CORETIME_ROCOCO_DEVELOPMENT ,
@@ -69,9 +83,14 @@ impl From<CoretimeRuntimeType> for &str {
69
83
impl From < CoretimeRuntimeType > for ChainType {
70
84
fn from ( runtime_type : CoretimeRuntimeType ) -> Self {
71
85
match runtime_type {
72
- CoretimeRuntimeType :: Rococo | CoretimeRuntimeType :: Westend => ChainType :: Live ,
73
- CoretimeRuntimeType :: RococoLocal | CoretimeRuntimeType :: WestendLocal =>
74
- ChainType :: Local ,
86
+ CoretimeRuntimeType :: Kusama |
87
+ CoretimeRuntimeType :: Polkadot |
88
+ CoretimeRuntimeType :: Rococo |
89
+ CoretimeRuntimeType :: Westend => ChainType :: Live ,
90
+ CoretimeRuntimeType :: KusamaLocal |
91
+ CoretimeRuntimeType :: PolkadotLocal |
92
+ CoretimeRuntimeType :: RococoLocal |
93
+ CoretimeRuntimeType :: WestendLocal => ChainType :: Local ,
75
94
CoretimeRuntimeType :: RococoDevelopment | CoretimeRuntimeType :: WestendDevelopment =>
76
95
ChainType :: Development ,
77
96
}
@@ -85,6 +104,11 @@ impl CoretimeRuntimeType {
85
104
86
105
pub fn load_config ( & self ) -> Result < Box < dyn ChainSpec > , String > {
87
106
match self {
107
+ CoretimeRuntimeType :: Kusama => Ok ( Box :: new ( GenericChainSpec :: from_json_bytes (
108
+ & include_bytes ! ( "../../chain-specs/coretime-kusama.json" ) [ ..] ,
109
+ ) ?) ) ,
110
+ CoretimeRuntimeType :: Polkadot =>
111
+ todo ! ( "Generate chain-spec: ../../chain-specs/coretime-polkadot.json" ) ,
88
112
CoretimeRuntimeType :: Rococo => Ok ( Box :: new ( GenericChainSpec :: from_json_bytes (
89
113
& include_bytes ! ( "../../chain-specs/coretime-rococo.json" ) [ ..] ,
90
114
) ?) ) ,
@@ -99,6 +123,10 @@ impl CoretimeRuntimeType {
99
123
Ok ( Box :: new ( westend:: local_config ( * self , "westend-local" ) ) ) ,
100
124
CoretimeRuntimeType :: WestendDevelopment =>
101
125
Ok ( Box :: new ( westend:: local_config ( * self , "westend-dev" ) ) ) ,
126
+ other => Err ( std:: format!(
127
+ "No default config present for {:?}, you should provide a chain-spec as json file!" ,
128
+ other
129
+ ) ) ,
102
130
}
103
131
}
104
132
}
@@ -296,3 +324,13 @@ pub mod westend {
296
324
} )
297
325
}
298
326
}
327
+
328
+ pub mod kusama {
329
+ pub ( crate ) const CORETIME_KUSAMA : & str = "coretime-kusama" ;
330
+ pub ( crate ) const CORETIME_KUSAMA_LOCAL : & str = "coretime-kusama-local" ;
331
+ }
332
+
333
+ pub mod polkadot {
334
+ pub ( crate ) const CORETIME_POLKADOT : & str = "coretime-polkadot" ;
335
+ pub ( crate ) const CORETIME_POLKADOT_LOCAL : & str = "coretime-polkadot-local" ;
336
+ }
0 commit comments