serai/processor/ethereum/router/build.rs
Luke Parker 26230377b0
Define IRouterWithoutCollisions which Router inherits from
This ensures Router implements most of IRouterWithoutCollisions. It solely
leaves us to confirm Router implements the extensions defined in IRouter.
2024-11-02 19:10:39 -04:00

39 lines
1 KiB
Rust

use std::{env, fs};
use alloy_sol_macro_input::SolInputKind;
fn write(sol: syn_solidity::File, file: &str) {
let sol = alloy_sol_macro_expander::expand::expand(sol).unwrap();
fs::write(file, sol.to_string()).unwrap();
}
fn sol(sol_files: &[&str], file: &str) {
let mut sol = String::new();
for sol_file in sol_files {
sol += &fs::read_to_string(sol_file).unwrap();
}
let SolInputKind::Sol(sol) = syn::parse_str(&sol).unwrap() else {
panic!("parsed .sols file wasn't SolInputKind::Sol");
};
write(sol, file);
}
fn main() {
let artifacts_path =
env::var("OUT_DIR").unwrap().to_string() + "/serai-processor-ethereum-router";
if !fs::exists(&artifacts_path).unwrap() {
fs::create_dir(&artifacts_path).unwrap();
}
// This cannot be handled with the sol! macro. The Router requires an import
// https://github.com/alloy-rs/core/issues/602
sol(
&[
"../../../networks/ethereum/schnorr/contracts/Schnorr.sol",
"contracts/IRouter.sol",
"contracts/Router.sol",
],
&(artifacts_path + "/router.rs"),
);
}