Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetch chain specs from Acala repo #2

Merged
merged 2 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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