Skip to content

Commit

Permalink
forge: add script/ to project paths (#1877)
Browse files Browse the repository at this point in the history
* add script/ to project

* add canonic to script

* update ethers
  • Loading branch information
joshieDo committed Jun 8, 2022
1 parent 12939e4 commit e6efd2d
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 12 deletions.
22 changes: 11 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions cli/assets/ContractTemplate.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import "forge-std/Script.sol";

import {Contract} from "src/Contract.sol";

contract ContractScript is Script {
function setUp() public {}

function run() public {
vm.broadcast();
new Contract();
}
}
2 changes: 1 addition & 1 deletion cli/src/cmd/forge/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ impl BuildArgs {
// use the path arguments or if none where provided the `src` dir
self.watch.watchexec_config(|| {
let config = Config::from(self);
vec![config.src, config.test]
vec![config.src, config.test, config.script]
})
}
}
Expand Down
6 changes: 6 additions & 0 deletions cli/src/cmd/forge/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,18 @@ impl Cmd for InitArgs {
let test = root.join("test");
std::fs::create_dir_all(&test)?;

let script = root.join("script");
std::fs::create_dir_all(&script)?;

// write the contract file
let contract_path = src.join("Contract.sol");
std::fs::write(contract_path, include_str!("../../../assets/ContractTemplate.sol"))?;
// write the tests
let contract_path = test.join("Contract.t.sol");
std::fs::write(contract_path, include_str!("../../../assets/ContractTemplate.t.sol"))?;
// write the script
let contract_path = script.join("Contract.s.sol");
std::fs::write(contract_path, include_str!("../../../assets/ContractTemplate.s.sol"))?;

let dest = root.join(Config::FILE_NAME);
if !dest.exists() {
Expand Down
2 changes: 2 additions & 0 deletions config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ impl Config {

self.src = p(&root, &self.src);
self.test = p(&root, &self.test);
self.script = p(&root, &self.script);
self.out = p(&root, &self.out);

self.libs = self.libs.into_iter().map(|lib| p(&root, &lib)).collect();
Expand Down Expand Up @@ -594,6 +595,7 @@ impl Config {
.cache(&self.cache_path.join(SOLIDITY_FILES_CACHE_FILENAME))
.sources(&self.src)
.tests(&self.test)
.scripts(&self.script)
.artifacts(&self.out)
.libs(self.libs.clone())
.remappings(self.get_all_remappings())
Expand Down

0 comments on commit e6efd2d

Please sign in to comment.