From 06005232ce97658bb1f841cc36dd7ae8ea6e11c8 Mon Sep 17 00:00:00 2001 From: Dylan Date: Thu, 25 Apr 2024 12:15:18 -0700 Subject: [PATCH] debug wrapper build --- .github/workflows/rust_test.yml | 13 ++++++++----- crates/hyperdrive-wrappers/build.rs | 29 +++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/.github/workflows/rust_test.yml b/.github/workflows/rust_test.yml index 38ae132d..49313070 100644 --- a/.github/workflows/rust_test.yml +++ b/.github/workflows/rust_test.yml @@ -24,17 +24,20 @@ jobs: submodules: recursive token: ${{ secrets.GITHUB_TOKEN }} + # NOTE: This is needed to ensure that hyperdrive-wrappers builds correctly. + - name: install foundry + uses: foundry-rs/foundry-toolchain@v1 + with: + version: nightly + - name: check out hyperdrive uses: actions/checkout@v3 with: repository: delvtech/hyperdrive path: "./hyperdrive" - # NOTE: This is needed to ensure that hyperdrive-wrappers builds correctly. - - name: install foundry - uses: foundry-rs/foundry-toolchain@v1 - with: - version: nightly + - name: build hyperdrive + run: cd hyperdrive && make build-sol - uses: actions-rs/toolchain@v1 with: diff --git a/crates/hyperdrive-wrappers/build.rs b/crates/hyperdrive-wrappers/build.rs index 06561a57..43d1d189 100644 --- a/crates/hyperdrive-wrappers/build.rs +++ b/crates/hyperdrive-wrappers/build.rs @@ -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] = &[ @@ -58,6 +58,28 @@ const TARGETS: &[&str] = &[ fn get_artifacts(artifacts_path: &Path) -> Result> { let mut artifacts = Vec::new(); + println!("artifacts_path {:#?}", artifacts_path); + if !artifacts_path.exists() { + let parent = artifacts_path.join("/.."); + println!("parent {:#?}", parent); + let paths = fs::read_dir(parent).unwrap(); + + for path in paths { + println!("hyperdrive/ name: {}", path.unwrap().path().display()) + } + + let parent = artifacts_path.join("/..").join("/.."); + println!("parent {:#?}", parent); + let paths = fs::read_dir(parent).unwrap(); + + for path in paths { + println!("hyperdrive-rs/ 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(); @@ -88,6 +110,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)?; } @@ -97,9 +120,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));