Skip to content
This repository has been archived by the owner on Nov 11, 2024. It is now read-only.

feat: generate contracts for Dojo events #11

Merged
merged 11 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: ci

on:
push:
branches:
- main
pull_request:

env:
CARGO_TERM_COLOR: always
RUST_VERSION: 1.80.0

jobs:
test:
runs-on: ubuntu-latest-4-cores
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- uses: dtolnay/[email protected]
- run: |
scripts/tests.sh

cairofmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: software-mansion/setup-scarb@v1
with:
scarb-version: "2.7.1"
- run: |
bash scripts/cairo_fmt.sh --check

rustfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- uses: dtolnay/[email protected]
- run: scripts/rust_fmt.sh --check

docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
- uses: dtolnay/[email protected]
- run: >
scripts/docs.sh
16 changes: 12 additions & 4 deletions bins/abigen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use std::collections::HashMap;
use std::fs;
use std::path::Path;
use std::process::Command;

use anyhow::{anyhow, Result};
use cainome::rs::Abigen;
Expand Down Expand Up @@ -82,19 +83,26 @@ fn generate_bindings(
let out_path = format!("{OUT_DIR}/{bindings_filename}");

if is_check_only {
let generated_bindings = fs::read_to_string(tmp_file)?;
Command::new("rustfmt")
.arg(&tmp_file)
.status()
.expect("Failed to run rustfmt on generated bindings");

let generated_bindings = fs::read_to_string(tmp_file)?.replace(char::is_whitespace, "");

if Path::new(&out_path).exists() {
let existing_bindings = fs::read_to_string(out_path)?;
let existing_bindings = fs::read_to_string(out_path)?.replace(char::is_whitespace, "");

if existing_bindings != generated_bindings {
return Err(anyhow!(
"{contract_name} ABI bindings are not up to date. Consider generating them \
running `cargo run -p dojo-abigen`"
running `cargo run -p dojo-abigen`.",
));
}
} else {
println!("No bindings found for {contract_name}, check skipped");
return Err(anyhow!(
"No bindings found for {contract_name}, expected at {out_path}."
));
}
} else {
// Rename the temporary file to the output file is enough to update the bindings.
Expand Down
6 changes: 1 addition & 5 deletions bins/demo-compiler/src/commands/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ use tracing::trace;

#[derive(Debug, Args)]
pub struct CleanArgs {
#[arg(long)]
#[arg(help = "Removes the scarb artifacts AND the dojo compiler manifests.")]
pub remove_dojo_manifests: bool,

#[arg(long)]
#[arg(help = "Clean all profiles.")]
pub all_profiles: bool,
Expand All @@ -27,7 +23,7 @@ impl CleanArgs {
ProfileSpec::WorkspaceCurrent
};

DojoCompiler::clean(config, profile_spec, self.remove_dojo_manifests)?;
DojoCompiler::clean(config, profile_spec)?;

Ok(())
}
Expand Down
136 changes: 0 additions & 136 deletions bins/demo-compiler/src/utils.rs

This file was deleted.

Loading