feat(solc): add missing helper functions (#1592)

This commit is contained in:
Matthias Seitz 2022-08-12 01:42:52 +02:00 committed by GitHub
parent 845c10d154
commit 6f8dc93fc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

View File

@ -200,6 +200,20 @@ contract {} {{}}
) )
} }
/// Adds a new test file inside the project's test dir
pub fn add_test(&self, name: impl AsRef<str>, content: impl AsRef<str>) -> Result<PathBuf> {
let name = contract_file_name(name);
let tests = self.paths().tests.join(name);
create_contract_file(tests, content)
}
/// Adds a new script file inside the project's script dir
pub fn add_script(&self, name: impl AsRef<str>, content: impl AsRef<str>) -> Result<PathBuf> {
let name = contract_file_name(name);
let script = self.paths().scripts.join(name);
create_contract_file(script, content)
}
/// Adds a new source file inside the project's source dir /// Adds a new source file inside the project's source dir
pub fn add_source(&self, name: impl AsRef<str>, content: impl AsRef<str>) -> Result<PathBuf> { pub fn add_source(&self, name: impl AsRef<str>, content: impl AsRef<str>) -> Result<PathBuf> {
let name = contract_file_name(name); let name = contract_file_name(name);