Skip to content

Commit

Permalink
fetch chain specs from Acala repo (#2)
Browse files Browse the repository at this point in the history
* fetch chain specs from Acala repo

* fix
  • Loading branch information
xlc authored Dec 9, 2024
1 parent e593677 commit 7b67527
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 53,637 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ target/
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
#.idea/


# fetched by build.rs
chainspecs
44 changes: 43 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ sc-cli = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2
[build-dependencies]
substrate-build-script-utils = "11.0.0"
orml-build-script-utils = "1.0.0"
ureq = "2.12.1"

[profile.release]
lto = true
Expand Down
27 changes: 27 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,34 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use std::fs;
use std::path::Path;

fn main() {
substrate_build_script_utils::generate_cargo_keys();
orml_build_script_utils::check_file_licenses("./src", include_bytes!("./HEADER-GPL3"), &[]);

let out_dir = "chainspecs";
fs::create_dir_all(out_dir).expect("Failed to create chainspecs directory");

let files = [
(
"acala-dist.json",
"https://github.com/AcalaNetwork/Acala/raw/refs/heads/master/resources/acala-dist.json",
),
(
"karura-dist.json",
"https://github.com/AcalaNetwork/Acala/raw/refs/heads/master/resources/karura-dist.json",
),
];

for (filename, url) in files.iter() {
let path = Path::new(out_dir).join(filename);
if !path.exists() {
let response = ureq::get(url).call().expect("Failed to fetch chainspec");
let mut file = fs::File::create(&path).expect("Failed to create file");
let mut reader = response.into_reader();
std::io::copy(&mut reader, &mut file).expect("Failed to copy data");
}
}
}
Loading

0 comments on commit 7b67527

Please sign in to comment.