-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: removed executor, created utils
- Loading branch information
Showing
5 changed files
with
75 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
pub mod constants; | ||
pub mod executor; | ||
pub mod katana; | ||
pub mod scarb; | ||
pub mod utils; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use std::fs; | ||
|
||
use anyhow::{anyhow, Error}; | ||
use regex::Regex; | ||
|
||
#[allow(dead_code)] | ||
pub fn update_account(path: &str) -> Result<(), Error> { | ||
let lib_path = path.to_owned() + "/src/lib.cairo"; | ||
let account_old = fs::read_to_string(lib_path.clone())?; | ||
let re = Regex::new(r"self.id.write\((?<number>\d+)\);")?; | ||
|
||
let Some(val) = re.captures(&account_old) else { | ||
return Err(anyhow!("Could not find pattern in lib.cairo.")); | ||
}; | ||
let num_old = &val["number"].parse::<u64>().expect("Failed to read number"); | ||
let num_new = num_old + 1; | ||
let account_new = account_old.replace( | ||
&format!("self.id.write({num_old})"), | ||
&format!("self.id.write({num_new})"), | ||
); | ||
fs::write(lib_path, account_new)?; | ||
|
||
Ok(()) | ||
} | ||
|
||
#[allow(dead_code)] | ||
pub fn copy_to_target() -> Result<(), Error> { | ||
if !fs::metadata("./target/account").is_ok() { | ||
fs::create_dir("./target/account/")?; | ||
fs::create_dir("./target/account/src/")?; | ||
fs::copy( | ||
"./tests/starknet/contract/account/src/lib.cairo", | ||
"./target/account/src/lib.cairo", | ||
)?; | ||
fs::copy( | ||
"./tests/starknet/contract/account/Scarb.toml", | ||
"./target/account/Scarb.toml", | ||
)?; | ||
} | ||
Ok(()) | ||
} |