use ethers::contract::MultiAbigen;
use glob::glob;

fn main() {
    // Tell Cargo that if the given file changes, to rerun this build script.
    println!("cargo:rerun-if-changed=build.rs");
    println!("cargo:rerun-if-changed=Cargo.toml");
    glob("./abi/*.json").unwrap().for_each(|x| {
        if let Ok(x) = x {
            println!("cargo:rerun-if-changed={}", x.display());
        }
    });

    let gen = MultiAbigen::from_json_files("./abi").unwrap();

    let bindings = gen.build().unwrap();

    bindings.write_to_module("./src/contracts", false).unwrap();
}
