Skip to content

Commit

Permalink
debug wrapper build
Browse files Browse the repository at this point in the history
  • Loading branch information
dpaiton committed Apr 25, 2024
1 parent a7695c2 commit d081414
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions crates/hyperdrive-wrappers/build.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{io::Write, path::Path, process::Command};
use std::{fs, io::Write, path::Path, process::Command};

use ethers::prelude::Abigen;
use eyre::Result;
use eyre::{eyre, Result};
use heck::ToSnakeCase;

const TARGETS: &[&str] = &[
Expand Down Expand Up @@ -58,6 +58,18 @@ const TARGETS: &[&str] = &[

fn get_artifacts(artifacts_path: &Path) -> Result<Vec<(String, String)>> {
let mut artifacts = Vec::new();
println!("artifacts_path {:#?}", artifacts_path);
if !artifacts_path.exists() {
let paths = fs::read_dir(artifacts_path.join("../")).unwrap();

for path in paths {
println!("Name: {}", path.unwrap().path().display())
}
return Err(eyre!(
"artifacts_path={:#?} does not exist!",
artifacts_path
));
}
for entry in std::fs::read_dir(artifacts_path)? {
let entry = entry?;
let path = entry.path();
Expand Down Expand Up @@ -88,6 +100,7 @@ fn main() -> Result<()> {
// re-write these files.
let root = Path::new(std::env!("CARGO_MANIFEST_DIR"));
let generated = root.join("src/wrappers");
println!("generated {:#?}", generated);
if generated.exists() {
std::fs::remove_dir_all(&generated)?;
}
Expand All @@ -97,9 +110,11 @@ fn main() -> Result<()> {
.create(true)
.write(true)
.open(mod_file)?;
println!("mod_file {:#?}", mod_file);

// Generate the relevant contract wrappers from Foundry's artifacts.
let artifacts = root.join("../../hyperdrive/out");
println!("artifacts {:#?}", artifacts);
let mut artifacts = get_artifacts(&artifacts)?;
artifacts.sort_by(|a, b| a.1.cmp(&b.1));
artifacts.dedup_by(|a, b| a.1.eq(&b.1));
Expand Down

0 comments on commit d081414

Please sign in to comment.