Skip to content

Commit

Permalink
fix: manifest name without :: (starkware-libs#1770)
Browse files Browse the repository at this point in the history
* fix: remove  from manifests name and use

* fix: generate new manifests

* ci: re-enable ensure-windows

* fix: add new generated manifests for tests

* fix: adjust clean command to new manifests path
  • Loading branch information
glihm authored Apr 4, 2024
1 parent ba1b250 commit 33d2835
Show file tree
Hide file tree
Showing 33 changed files with 43 additions and 37 deletions.
26 changes: 13 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ jobs:
- uses: Swatinem/rust-cache@v2
- run: cargo build -r --target wasm32-unknown-unknown -p torii-client

# ensure-windows:
# runs-on: windows-latest
# steps:
# - uses: actions/checkout@v3
# - uses: actions-rs/toolchain@v1
# with:
# toolchain: ${{ env.rust_version }}
# target: x86_64-pc-windows-msvc
# - uses: swatinem/rust-cache@v2
# - uses: arduino/setup-protoc@v2
# with:
# repo-token: ${{ secrets.github_token }}
# - run: cargo build --target x86_64-pc-windows-msvc --bins
ensure-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.rust_version }}
target: x86_64-pc-windows-msvc
- uses: swatinem/rust-cache@v2
- uses: arduino/setup-protoc@v2
with:
repo-token: ${{ secrets.github_token }}
- run: cargo build --target x86_64-pc-windows-msvc --bins

# cairofmt:
# runs-on: ubuntu-latest
Expand Down
11 changes: 7 additions & 4 deletions bin/sozo/src/commands/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ pub struct CleanArgs {
}

impl CleanArgs {
pub fn clean_manifests_abis(&self, root_dir: &Utf8PathBuf) -> Result<()> {
pub fn clean_manifests_abis(&self, root_dir: &Utf8PathBuf, profile_name: &str) -> Result<()> {
let dirs = vec![
root_dir.join(MANIFESTS_DIR).join(BASE_DIR),
root_dir.join(ABIS_DIR).join(BASE_DIR),
root_dir.join(MANIFESTS_DIR).join(profile_name).join(BASE_DIR),
root_dir.join(MANIFESTS_DIR).join(profile_name).join(ABIS_DIR).join(BASE_DIR),
];

for d in dirs {
Expand All @@ -38,12 +38,15 @@ impl CleanArgs {
pub fn run(self, config: &Config) -> Result<()> {
let ws = scarb::ops::read_workspace(config.manifest_path(), config)?;

let profile_name =
ws.current_profile().expect("Scarb profile is expected at this point.").to_string();

let clean_manifests_abis = self.manifests_abis || !self.artifacts;
let clean_artifacts = self.artifacts || !self.manifests_abis;

if clean_manifests_abis {
let manifest_dir = ws.manifest_path().parent().unwrap().to_path_buf();
self.clean_manifests_abis(&manifest_dir)?;
self.clean_manifests_abis(&manifest_dir, &profile_name)?;
}

if clean_artifacts {
Expand Down
2 changes: 1 addition & 1 deletion crates/dojo-lang/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ fn write_manifest_and_abi<T>(
where
T: Serialize + DeserializeOwned + ManifestMethods,
{
let name = manifest.name.to_string();
let name = manifest.name.to_string().replace("::", "_");

let relative_manifest_path = relative_manifest_dir.join(name.clone()).with_extension("toml");
let relative_abi_path = relative_abis_dir.join(name.clone()).with_extension("json");
Expand Down
8 changes: 4 additions & 4 deletions crates/dojo-world/src/manifest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ impl BaseManifest {
let model_dir = path.join("models");

let world: Manifest<Class> = toml::from_str(&fs::read_to_string(
path.join(WORLD_CONTRACT_NAME).with_extension("toml"),
path.join(WORLD_CONTRACT_NAME.replace("::", "_")).with_extension("toml"),
)?)?;

let base: Manifest<Class> = toml::from_str(&fs::read_to_string(
path.join(BASE_CONTRACT_NAME).with_extension("toml"),
path.join(BASE_CONTRACT_NAME.replace("::", "_")).with_extension("toml"),
)?)?;

let contracts = elements_from_path::<DojoContract>(&contract_dir)?;
Expand Down Expand Up @@ -138,14 +138,14 @@ impl OverlayManifest {
pub fn load_from_path(path: &Utf8PathBuf) -> Result<Self, AbstractManifestError> {
let mut world: Option<OverlayClass> = None;

let world_path = path.join(WORLD_CONTRACT_NAME).with_extension("toml");
let world_path = path.join(WORLD_CONTRACT_NAME.replace("::", "_")).with_extension("toml");

if world_path.exists() {
world = Some(toml::from_str(&fs::read_to_string(world_path)?)?);
}

let mut base: Option<OverlayClass> = None;
let base_path = path.join(BASE_CONTRACT_NAME).with_extension("toml");
let base_path = path.join(BASE_CONTRACT_NAME.replace("::", "_")).with_extension("toml");

if base_path.exists() {
base = Some(toml::from_str(&fs::read_to_string(base_path)?)?);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ kind = "DojoContract"
class_hash = "0x658309df749cea1c32e21920740011e829626ab06c9b4d0c05b75f82a20693b"
original_class_hash = "0x658309df749cea1c32e21920740011e829626ab06c9b4d0c05b75f82a20693b"
base_class_hash = "0x0"
abi = "manifests/dev/abis/base/contracts/types_test::contracts::records.json"
abi = "manifests/dev/abis/base/contracts/types_test_contracts_records.json"
reads = []
writes = []
computed = []
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
kind = "Class"
class_hash = "0x799bc4e9da10bfb3dd88e6f223c9cfbf7745435cd14f5d69675ea448e578cd"
original_class_hash = "0x799bc4e9da10bfb3dd88e6f223c9cfbf7745435cd14f5d69675ea448e578cd"
abi = "manifests/dev/abis/base/dojo::world::world.json"
abi = "manifests/dev/abis/base/dojo_world_world.json"
name = "dojo::world::world"
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kind = "DojoModel"
class_hash = "0x134456282bbaf00e0895ff43f286af8d490202baf6279d2b05be9bc0c05f059"
original_class_hash = "0x134456282bbaf00e0895ff43f286af8d490202baf6279d2b05be9bc0c05f059"
abi = "manifests/dev/abis/base/models/types_test::models::record.json"
abi = "manifests/dev/abis/base/models/types_test_models_record.json"
name = "types_test::models::record"

[[members]]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kind = "DojoModel"
class_hash = "0x4e92336e21ac7970b9bd9f4e294705f7864c0b29f53fdbf42ff7a9d7f0a53f3"
original_class_hash = "0x4e92336e21ac7970b9bd9f4e294705f7864c0b29f53fdbf42ff7a9d7f0a53f3"
abi = "manifests/dev/abis/base/models/types_test::models::record_sibling.json"
abi = "manifests/dev/abis/base/models/types_test_models_record_sibling.json"
name = "types_test::models::record_sibling"

[[members]]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kind = "DojoModel"
class_hash = "0x7a47c3a9c8509a1d4a0379e50799eba7b173db6e41961341fe3f856a51d627"
original_class_hash = "0x7a47c3a9c8509a1d4a0379e50799eba7b173db6e41961341fe3f856a51d627"
abi = "manifests/dev/abis/base/models/types_test::models::subrecord.json"
abi = "manifests/dev/abis/base/models/types_test_models_subrecord.json"
name = "types_test::models::subrecord"

[[members]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ kind = "DojoContract"
class_hash = "0x16b1037beb348c3cf11c7f10733d366c7f29bc9d9172ba663421e2af4dab83c"
original_class_hash = "0x16b1037beb348c3cf11c7f10733d366c7f29bc9d9172ba663421e2af4dab83c"
base_class_hash = "0x0"
abi = "manifests/dev/abis/base/contracts/dojo_examples::actions::actions.json"
abi = "manifests/dev/abis/base/contracts/dojo_examples_actions_actions.json"
reads = []
writes = []
computed = []
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
kind = "Class"
class_hash = "0x799bc4e9da10bfb3dd88e6f223c9cfbf7745435cd14f5d69675ea448e578cd"
original_class_hash = "0x799bc4e9da10bfb3dd88e6f223c9cfbf7745435cd14f5d69675ea448e578cd"
abi = "manifests/dev/abis/base/dojo::world::world.json"
abi = "manifests/dev/abis/base/dojo_world_world.json"
name = "dojo::world::world"
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kind = "DojoModel"
class_hash = "0x52659850f9939482810d9f6b468b91dc99e0b7fa42c2016cf12833ec06ce911"
original_class_hash = "0x52659850f9939482810d9f6b468b91dc99e0b7fa42c2016cf12833ec06ce911"
abi = "manifests/dev/abis/base/models/dojo_examples::actions::actions::moved.json"
abi = "manifests/dev/abis/base/models/dojo_examples_actions_actions_moved.json"
name = "dojo_examples::actions::actions::moved"

[[members]]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kind = "DojoModel"
class_hash = "0x511fbd833938f5c4b743eea1e67605a125d7ff60e8a09e8dc227ad2fb59ca54"
original_class_hash = "0x511fbd833938f5c4b743eea1e67605a125d7ff60e8a09e8dc227ad2fb59ca54"
abi = "manifests/dev/abis/base/models/dojo_examples::models::moves.json"
abi = "manifests/dev/abis/base/models/dojo_examples_models_moves.json"
name = "dojo_examples::models::moves"

[[members]]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kind = "DojoModel"
class_hash = "0xb33ae053213ccb2a57967ffc4411901f3efab24781ca867adcd0b90f2fece5"
original_class_hash = "0xb33ae053213ccb2a57967ffc4411901f3efab24781ca867adcd0b90f2fece5"
abi = "manifests/dev/abis/base/models/dojo_examples::models::position.json"
abi = "manifests/dev/abis/base/models/dojo_examples_models_position.json"
name = "dojo_examples::models::position"

[[members]]
Expand Down
10 changes: 5 additions & 5 deletions examples/spawn-and-move/manifests/dev/manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
kind = "Contract"
class_hash = "0x799bc4e9da10bfb3dd88e6f223c9cfbf7745435cd14f5d69675ea448e578cd"
original_class_hash = "0x799bc4e9da10bfb3dd88e6f223c9cfbf7745435cd14f5d69675ea448e578cd"
abi = "abis/deployments/dojo::world::world.json"
abi = "abis/deployments/dojo_world_world.json"
address = "0x1385f25d20a724edc9c7b3bd9636c59af64cbaf9fcd12f33b3af96b2452f295"
transaction_hash = "0x6afefdcc49b3563a4f3657900ba71e9f9356861b15b942a73f2018f046a1048"
block_number = 3
Expand All @@ -21,7 +21,7 @@ address = "0x3539c9b89b08095ba914653fb0f20e55d4b172a415beade611bc260b346d0f7"
class_hash = "0x16b1037beb348c3cf11c7f10733d366c7f29bc9d9172ba663421e2af4dab83c"
original_class_hash = "0x16b1037beb348c3cf11c7f10733d366c7f29bc9d9172ba663421e2af4dab83c"
base_class_hash = "0x679177a2cb757694ac4f326d01052ff0963eac0bc2a17116a2b87badcdf6f76"
abi = "abis/deployments/contracts/dojo_examples::actions::actions.json"
abi = "abis/deployments/contracts/dojo_examples_actions_actions.json"
reads = []
writes = []
computed = []
Expand All @@ -31,7 +31,7 @@ name = "dojo_examples::actions::actions"
kind = "DojoModel"
class_hash = "0x52659850f9939482810d9f6b468b91dc99e0b7fa42c2016cf12833ec06ce911"
original_class_hash = "0x52659850f9939482810d9f6b468b91dc99e0b7fa42c2016cf12833ec06ce911"
abi = "abis/deployments/models/dojo_examples::actions::actions::moved.json"
abi = "abis/deployments/models/dojo_examples_actions_actions_moved.json"
name = "dojo_examples::actions::actions::moved"

[[models.members]]
Expand All @@ -48,7 +48,7 @@ key = false
kind = "DojoModel"
class_hash = "0x511fbd833938f5c4b743eea1e67605a125d7ff60e8a09e8dc227ad2fb59ca54"
original_class_hash = "0x511fbd833938f5c4b743eea1e67605a125d7ff60e8a09e8dc227ad2fb59ca54"
abi = "abis/deployments/models/dojo_examples::models::moves.json"
abi = "abis/deployments/models/dojo_examples_models_moves.json"
name = "dojo_examples::models::moves"

[[models.members]]
Expand All @@ -70,7 +70,7 @@ key = false
kind = "DojoModel"
class_hash = "0xb33ae053213ccb2a57967ffc4411901f3efab24781ca867adcd0b90f2fece5"
original_class_hash = "0xb33ae053213ccb2a57967ffc4411901f3efab24781ca867adcd0b90f2fece5"
abi = "abis/deployments/models/dojo_examples::models::position.json"
abi = "abis/deployments/models/dojo_examples_models_position.json"
name = "dojo_examples::models::position"

[[models.members]]
Expand Down
3 changes: 3 additions & 0 deletions scripts/teardown_test_artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@
# This script gives an easy way to remove those artifacts.

rm -rf examples/spawn-and-move/target
rm -rf examples/spawn-and-move/manifests

rm -rf crates/torii/types-test/target
rm -rf crates/torii/types-test/manifests

0 comments on commit 33d2835

Please sign in to comment.