Skip to content

Commit fb5c07f

Browse files
committed
compiler compiles
1 parent 713a707 commit fb5c07f

File tree

22 files changed

+46
-251
lines changed

22 files changed

+46
-251
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
wallets/
33
.env
44
lib/
5+
node_modules
6+
artifacts
7+
cache

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
[submodule "lib/forge-std"]
55
path = lib/forge-std
66
url = https://github.com/foundry-rs/forge-std
7+
[submodule "core/src/contracts/lib/openzeppelin-contracts"]
8+
path = core/src/contracts/lib/openzeppelin-contracts
9+
url = https://github.com/openzeppelin/openzeppelin-contracts

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[workspace]
22
members = ["core", "cli"]
3+
resolver = "3"

cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "cli"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55

66
[dependencies]
77
clap = { version = "4", features = ["derive"] }

core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "core"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = "2024"
55

66
[dependencies]
77
ethers = { version = "2", features = ["abigen"] }

core/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Set a global version is required.
2+
3+
`svm use 0.8.22`
4+
5+
Hardhat folder structure uses `contracts` folder for contracts; on `compiler.rs` we indicate the root directory.
6+
Remapping are taken from the `remappings` field in the `foundry.toml` file.
7+
8+
```sh
9+
cargo run -p cli -- --chain base_sepolia compile
10+
```

core/cache/solidity-files-cache.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

core/src/compiler.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
1-
use std::path::{Path, PathBuf};
1+
use std::{
2+
path::{Path, PathBuf},
3+
process::Output,
4+
};
25

3-
use foundry_compilers::{solc::Solc, Project, ProjectPathsConfig};
6+
use foundry_compilers::{Project, ProjectPathsConfig};
47

58
pub fn compile_contract() -> Result<(), anyhow::Error> {
6-
// configure the project with all its paths, solc, cache etc.
9+
let contracts_path = Path::new(env!("CARGO_MANIFEST_DIR"))
10+
.to_owned()
11+
.join(PathBuf::from("src/solidity"));
12+
713
let project = Project::builder()
8-
.paths(
9-
ProjectPathsConfig::hardhat(
10-
&Path::new(env!("CARGO_MANIFEST_DIR"))
11-
.to_owned()
12-
.join(PathBuf::from("src/contracts")),
13-
)
14-
.unwrap(),
15-
)
14+
.paths(ProjectPathsConfig::hardhat(&contracts_path).unwrap())
15+
.set_no_artifacts(false)
1616
.build(Default::default())
1717
.unwrap();
18-
// https://github.com/foundry-rs/compilers/blob/main/crates/compilers/tests/project.rs#L2627
1918

20-
println!("{:?}", project);
19+
println!("Project:\n {:?}\n", project);
2120
let output = project.compile().unwrap();
2221

23-
println!("{:?}\n", output);
22+
println!("Output:\n {:?}\n", output);
2423
Ok(())
2524
}

core/src/contracts/.github/workflows/test.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

core/src/contracts/README.md

Lines changed: 0 additions & 66 deletions
This file was deleted.

0 commit comments

Comments
 (0)