Skip to content

Commit

Permalink
feat : added script for artifact conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
ocdbytes committed Nov 25, 2024
1 parent 374bcb5 commit 0fb2522
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,5 @@ l2-artifacts:
make local-contracts
make starkgate-contracts-latest
make starkgate-contracts-old
echo "L2 Artifacts built ✅"
python3 build-artifacts/convert.py
echo "L2 Artifacts built ✅"
22 changes: 22 additions & 0 deletions build-artifacts/convert.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import json
import os

def edit_json_file(filepath):
with open(filepath, 'r') as f:
data = json.load(f)

if isinstance(data.get('bytecode'), str):
data['bytecode'] = {'object': data['bytecode']}

with open(filepath, 'w') as f:
json.dump(data, f, indent=4)

script_dir = os.path.dirname(os.path.abspath(__file__))
artifacts_dir = os.path.join(script_dir, "..", "artifacts")

for root, dirs, files in os.walk(artifacts_dir):
for filename in files:
if filename.endswith('.json'):
full_path = os.path.join(root, filename)
print(f"Editing {filename}")
edit_json_file(full_path)
14 changes: 1 addition & 13 deletions crates/l2/utils/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

Command::new("make")
.current_dir(root_dir)
.arg("cairo-lang")
.status()?;
Command::new("make")
.current_dir(root_dir)
.arg("local-contracts")
.status()?;
Command::new("make")
.current_dir(root_dir)
.arg("starkgate-contracts-latest")
.status()?;
Command::new("make")
.current_dir(root_dir)
.arg("starkgate-contracts-old")
.arg("l2-artifacts")
.status()?;
Ok(())
}
Expand Down

0 comments on commit 0fb2522

Please sign in to comment.