16
16
17
17
// If you feel like getting in touch with us, you can do so at info@botlabs.org
18
18
19
- use std:: path:: { Path , PathBuf } ;
20
-
21
19
use runtime_common:: { AccountId , AccountPublic } ;
22
20
use sc_service:: Properties ;
23
21
use sp_core:: { Pair , Public } ;
@@ -57,18 +55,14 @@ pub(crate) fn load_spec(id: &str) -> Result<Box<dyn sc_service::ChainSpec>, Stri
57
55
"rococo_local" ,
58
56
) ) ) ,
59
57
PeregrineRuntime :: New => Ok ( Box :: new ( chain_spec:: peregrine:: new:: generate_chain_spec ( ) ) ) ,
60
- PeregrineRuntime :: Peregrine => Ok ( Box :: new ( chain_spec:: peregrine:: load_chain_spec (
61
- get_chainspec_full_path ( "peregrine/peregrine-paseo.json" )
62
- . to_str ( )
63
- . unwrap ( ) ,
58
+ PeregrineRuntime :: Peregrine => Ok ( Box :: new ( chain_spec:: peregrine:: ChainSpec :: from_json_bytes (
59
+ include_bytes ! ( "../../../../chainspecs/peregrine/peregrine-paseo.json" ) . as_slice ( ) ,
64
60
) ?) ) ,
65
- PeregrineRuntime :: PeregrineStg => Ok ( Box :: new ( chain_spec:: peregrine:: load_chain_spec (
66
- get_chainspec_full_path ( "peregrine-stg/peregrine-stg.json" )
67
- . to_str ( )
68
- . unwrap ( ) ,
61
+ PeregrineRuntime :: PeregrineStg => Ok ( Box :: new ( chain_spec:: peregrine:: ChainSpec :: from_json_bytes (
62
+ include_bytes ! ( "../../../../chainspecs/peregrine-stg/peregrine-stg.json" ) . as_slice ( ) ,
69
63
) ?) ) ,
70
- PeregrineRuntime :: Rilt => Ok ( Box :: new ( chain_spec:: rilt :: load_chain_spec (
71
- get_chainspec_full_path ( " rilt/peregrine-rilt.json") . to_str ( ) . unwrap ( ) ,
64
+ PeregrineRuntime :: Rilt => Ok ( Box :: new ( chain_spec:: peregrine :: ChainSpec :: from_json_bytes (
65
+ include_bytes ! ( "../../../../chainspecs/ rilt/peregrine-rilt.json") . as_slice ( ) ,
72
66
) ?) ) ,
73
67
PeregrineRuntime :: RiltNew => Ok ( Box :: new ( chain_spec:: rilt:: new:: generate_chain_spec ( ) ) ) ,
74
68
PeregrineRuntime :: Other ( s) => Ok ( Box :: new ( chain_spec:: peregrine:: load_chain_spec ( s. as_str ( ) ) ?) ) ,
@@ -78,38 +72,10 @@ pub(crate) fn load_spec(id: &str) -> Result<Box<dyn sc_service::ChainSpec>, Stri
78
72
"rococo_local" ,
79
73
) ) ) ,
80
74
SpiritnetRuntime :: New => Ok ( Box :: new ( chain_spec:: spiritnet:: new:: generate_chain_spec ( ) ) ) ,
81
- SpiritnetRuntime :: Spiritnet => Ok ( Box :: new ( chain_spec:: spiritnet:: load_chain_spec (
82
- get_chainspec_full_path ( " spiritnet/spiritnet.json") . to_str ( ) . unwrap ( ) ,
75
+ SpiritnetRuntime :: Spiritnet => Ok ( Box :: new ( chain_spec:: spiritnet:: ChainSpec :: from_json_bytes (
76
+ include_bytes ! ( "../../../../chainspecs/ spiritnet/spiritnet.json") . as_slice ( ) ,
83
77
) ?) ) ,
84
78
SpiritnetRuntime :: Other ( s) => Ok ( Box :: new ( chain_spec:: spiritnet:: load_chain_spec ( s. as_str ( ) ) ?) ) ,
85
79
} ,
86
80
}
87
81
}
88
-
89
- // Compile-time env variable used when running the binary with cargo or via
90
- // cargo (after `cargo build`).
91
- const MANIFEST_DIR : & str = env ! ( "CARGO_MANIFEST_DIR" ) ;
92
- // Name of the runtime-time env variable that can be used to configure the
93
- // chainspecs folder path, useful especially when running the binary in a Docker
94
- // container.
95
- const CHAINSPECS_FOLDER_VAR_NAME : & str = "CHAINSPECS_FOLDER" ;
96
-
97
- fn get_chainspec_full_path ( path : & str ) -> PathBuf {
98
- // Use the provided env variable, if present at runtime, or else uses the
99
- // compile-time `CARGO_MANIFEST_DIR` variable (e.g., if the binary is run via
100
- // cargo instead of in a Docker container).
101
- let chainspecs_root = match std:: env:: var ( CHAINSPECS_FOLDER_VAR_NAME ) {
102
- Ok ( chainspecs_folder_name) => chainspecs_folder_name. to_owned ( ) ,
103
- Err ( _) => Path :: new ( MANIFEST_DIR )
104
- . join ( ".." )
105
- . join ( ".." )
106
- . join ( "chainspecs" )
107
- . to_string_lossy ( )
108
- . into_owned ( ) ,
109
- } ;
110
-
111
- Path :: new ( chainspecs_root. as_str ( ) )
112
- . join ( path)
113
- . canonicalize ( )
114
- . expect ( "Invalid path provided." )
115
- }
0 commit comments