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 1e3f3f3
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 7 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/rust_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
35 changes: 33 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,34 @@ 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() {
println!("----");
let paths = fs::read_dir(artifacts_path).unwrap();
for path in paths {
println!("artifacts_path/ name: {}", path.unwrap().path().display())
}

println!("----");
let parent = artifacts_path.join("/..");
println!("parent {:#?}", parent);
let paths = fs::read_dir(parent).unwrap();
for path in paths {
println!("parent/ name: {}", path.unwrap().path().display())
}

println!("----");
let parent_parent = artifacts_path.join("/..").join("/..");
println!("parent_parent {:#?}", parent_parent);
let paths = fs::read_dir(parent_parent).unwrap();
for path in paths {
println!("parent_parent/ 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 +116,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 +126,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 1e3f3f3

Please sign in to comment.