Skip to content

Commit 7b67527

Browse files
authored
fetch chain specs from Acala repo (#2)
* fetch chain specs from Acala repo * fix
1 parent e593677 commit 7b67527

6 files changed

Lines changed: 76 additions & 53637 deletions

File tree

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,8 @@ target/
1414
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
1515
# and can be added to the global gitignore or merged into this file. For a more nuclear
1616
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
17-
#.idea/
17+
#.idea/
18+
19+
20+
# fetched by build.rs
21+
chainspecs

Cargo.lock

Lines changed: 43 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ sc-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2
1818
[build-dependencies]
1919
substrate-build-script-utils = "11.0.0"
2020
orml-build-script-utils = "1.0.0"
21+
ureq = "2.12.1"
2122

2223
[profile.release]
2324
lto = true

build.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,34 @@
1616
// You should have received a copy of the GNU General Public License
1717
// along with this program. If not, see <https://www.gnu.org/licenses/>.
1818

19+
use std::fs;
20+
use std::path::Path;
21+
1922
fn main() {
2023
substrate_build_script_utils::generate_cargo_keys();
2124
orml_build_script_utils::check_file_licenses("./src", include_bytes!("./HEADER-GPL3"), &[]);
25+
26+
let out_dir = "chainspecs";
27+
fs::create_dir_all(out_dir).expect("Failed to create chainspecs directory");
28+
29+
let files = [
30+
(
31+
"acala-dist.json",
32+
"https://github.com/AcalaNetwork/Acala/raw/refs/heads/master/resources/acala-dist.json",
33+
),
34+
(
35+
"karura-dist.json",
36+
"https://github.com/AcalaNetwork/Acala/raw/refs/heads/master/resources/karura-dist.json",
37+
),
38+
];
39+
40+
for (filename, url) in files.iter() {
41+
let path = Path::new(out_dir).join(filename);
42+
if !path.exists() {
43+
let response = ureq::get(url).call().expect("Failed to fetch chainspec");
44+
let mut file = fs::File::create(&path).expect("Failed to create file");
45+
let mut reader = response.into_reader();
46+
std::io::copy(&mut reader, &mut file).expect("Failed to copy data");
47+
}
48+
}
2249
}

0 commit comments

Comments
 (0)