From 35ca97454678ab5e91aa31b53f372ddc914b88de Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 24 May 2024 17:50:52 +0200 Subject: [PATCH 01/16] Katana and ArgentX wallet (#1958) * fix: path to Argent account compiled contracts in declare script * fix: allow some headers in CORS layer of Katana to work with ArgentX wallet * refactor: clean forgotten logs in declare-argent-account.sh script and remove unnecessary var * fix: remove vec in favor of array --------- Co-authored-by: glihm --- crates/katana/rpc/rpc/src/lib.rs | 2 +- crates/katana/scripts/declare-argent-account.sh | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/crates/katana/rpc/rpc/src/lib.rs b/crates/katana/rpc/rpc/src/lib.rs index edc855f0a3..a3ee286fca 100644 --- a/crates/katana/rpc/rpc/src/lib.rs +++ b/crates/katana/rpc/rpc/src/lib.rs @@ -65,7 +65,7 @@ pub async fn spawn( let cors = CorsLayer::new() // Allow `POST` when accessing the resource .allow_methods([Method::POST, Method::GET]) - .allow_headers([hyper::header::CONTENT_TYPE]); + .allow_headers([hyper::header::CONTENT_TYPE, "argent-client".parse().unwrap(), "argent-version".parse().unwrap()]); let cors = config.allowed_origins.clone().map(|allowed_origins| match allowed_origins.as_slice() { diff --git a/crates/katana/scripts/declare-argent-account.sh b/crates/katana/scripts/declare-argent-account.sh index ae11f3be80..ca04d2ccab 100755 --- a/crates/katana/scripts/declare-argent-account.sh +++ b/crates/katana/scripts/declare-argent-account.sh @@ -1,15 +1,14 @@ #! /bin/bash STD_ARGENT_ACCOUNT_0_3_0_CLASS_HASH="0x01a736d6ed154502257f02b1ccdf4d9d1089f80811cd6acad48e6b6a9d1f2003" -STD_ARGENT_ACCOUNT_0_3_0_COMPILED_FILE="../primitives/contracts/compiled/argent_ArgentAccount_0.3.0.json" +STD_ARGENT_ACCOUNT_0_3_0_COMPILED_FILE="../contracts/compiled/argent_ArgentAccount_0.3.0.json" STD_ARGENT_ACCOUNT_0_3_1_CLASS_HASH="0x29927c8af6bccf3f6fda035981e765a7bdbf18a2dc0d630494f8758aa908e2b" -STD_ARGENT_ACCOUNT_0_3_1_COMPILED_FILE="../primitives/contracts/compiled/argent_ArgentAccount_0.3.1.json" +STD_ARGENT_ACCOUNT_0_3_1_COMPILED_FILE="../contracts/compiled/argent_ArgentAccount_0.3.1.json" TEMP_ACCOUNT_FILE="temp-account.json" -TEMP_KEYSTORE_FILE="temp-keystore.json" -trap "rm -f $TEMP_ACCOUNT_FILE $TEMP_KEYSTORE_FILE" EXIT +trap "rm -f $TEMP_ACCOUNT_FILE" EXIT # This is helper script is for declaring the standard Argent account to Katana as it doesn't come as a default. # Argent account contract source code: https://github.com/argentlabs/argent-contracts-starknet/blob/53d01c0d6dce4fd30db955c3d698f658cdda1796/contracts/account/src/argent_account.cairo @@ -57,7 +56,6 @@ else exit 1 fi - starkli account fetch $ACCOUNT_ADDRESS --rpc $RPC_URL --output $TEMP_ACCOUNT_FILE &> /dev/null for file in "${CLASS_TO_DECLARE[@]}"; do From 6ae661d4e272c0c0920858e255a5fd89aa40ad53 Mon Sep 17 00:00:00 2001 From: Larko <59736843+Larkooo@users.noreply.github.com> Date: Sun, 26 May 2024 17:40:33 -0400 Subject: [PATCH 02/16] chore: remove debug log (#1996) --- crates/torii/graphql/src/query/mod.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/crates/torii/graphql/src/query/mod.rs b/crates/torii/graphql/src/query/mod.rs index 10d18fe9a9..b2f8f8a005 100644 --- a/crates/torii/graphql/src/query/mod.rs +++ b/crates/torii/graphql/src/query/mod.rs @@ -65,8 +65,6 @@ fn build_type_mapping( }) .collect::>()?; - println!("{:#?}", type_mapping); - Ok(type_mapping) } From 666d835021f5a4271c914de30cc7a672c8be5979 Mon Sep 17 00:00:00 2001 From: mgrunwaldt Date: Mon, 27 May 2024 04:34:40 -0300 Subject: [PATCH 03/16] Update README.md - Getting Started Link (#2000) Getting Started Link was broken --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ccb9389ad3..04797aa69b 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ It is designed to significantly reduce the complexity of developing provable app ## Getting Started -See the [getting started](https://book.dojoengine.org/getting-started/quick-start) section in the Dojo book to start building provable applications with Dojo. +See the [getting started](https://book.dojoengine.org/getting-started) section in the Dojo book to start building provable applications with Dojo. You can find more detailed documentation in the Dojo Book [here](https://book.dojoengine.org/). From 492f5aeaa717f5f911e0281be3794c5d7ce9e3ec Mon Sep 17 00:00:00 2001 From: Ammar Arif Date: Mon, 27 May 2024 03:35:37 -0400 Subject: [PATCH 04/16] Unified crate for Cairo deps used in Katana (#1999) * unified cairo crate forr katana * update * remove license file field --- Cargo.lock | 890 +++++++++++++----- Cargo.toml | 1 + crates/katana/cairo/Cargo.toml | 19 + crates/katana/cairo/src/lib.rs | 13 + crates/katana/executor/Cargo.toml | 8 +- crates/katana/executor/benches/utils.rs | 2 +- .../src/implementation/blockifier/utils.rs | 6 +- crates/katana/executor/tests/fixtures/mod.rs | 2 +- crates/katana/primitives/Cargo.toml | 5 +- crates/katana/primitives/src/class.rs | 8 +- .../katana/primitives/src/conversion/rpc.rs | 6 +- crates/katana/primitives/src/genesis/json.rs | 4 +- crates/katana/primitives/src/utils/class.rs | 4 +- 13 files changed, 718 insertions(+), 250 deletions(-) create mode 100644 crates/katana/cairo/Cargo.toml create mode 100644 crates/katana/cairo/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 93ccdbed07..a4158a0ae4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1525,7 +1525,7 @@ dependencies = [ [[package]] name = "blockifier" version = "0.6.0-rc.2" -source = "git+https://github.com/dojoengine/blockifier?rev=7d866a24#7d866a24260e5259e684eff3d1b044ec600ab3ff" +source = "git+https://github.com/dojoengine/blockifier?rev=57c11586#57c115864b5d2e9876efe289bd3dfbf05744a76b" dependencies = [ "anyhow", "ark-ec", @@ -1534,10 +1534,10 @@ dependencies = [ "ark-secp256r1", "cached", "cairo-felt", - "cairo-lang-casm", - "cairo-lang-runner", - "cairo-lang-starknet-classes", - "cairo-lang-utils", + "cairo-lang-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-runner 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-starknet-classes 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", "cairo-vm", "derive_more", "indexmap 2.2.6", @@ -1834,12 +1834,25 @@ dependencies = [ "serde", ] +[[package]] +name = "cairo-lang-casm" +version = "2.6.3" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +dependencies = [ + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "indoc 2.0.5", + "num-bigint", + "num-traits 0.2.19", + "parity-scale-codec", + "serde", +] + [[package]] name = "cairo-lang-casm" version = "2.6.3" source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" dependencies = [ - "cairo-lang-utils", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "indoc 2.0.5", "num-bigint", "num-traits 0.2.19", @@ -1847,35 +1860,81 @@ dependencies = [ "serde", ] +[[package]] +name = "cairo-lang-compiler" +version = "2.6.3" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +dependencies = [ + "anyhow", + "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-lowering 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-project 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-semantic 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-sierra-generator 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "salsa", + "smol_str", + "thiserror", +] + [[package]] name = "cairo-lang-compiler" version = "2.6.3" source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" dependencies = [ "anyhow", - "cairo-lang-defs", - "cairo-lang-diagnostics", - "cairo-lang-filesystem", - "cairo-lang-lowering", - "cairo-lang-parser", - "cairo-lang-project", - "cairo-lang-semantic", - "cairo-lang-sierra", - "cairo-lang-sierra-generator", - "cairo-lang-syntax", - "cairo-lang-utils", + "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-lowering 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-project 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-semantic 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra-generator 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "indoc 2.0.5", "salsa", "smol_str", "thiserror", ] +[[package]] +name = "cairo-lang-debug" +version = "2.6.3" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +dependencies = [ + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", +] + [[package]] name = "cairo-lang-debug" version = "2.6.3" source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" dependencies = [ - "cairo-lang-utils", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", +] + +[[package]] +name = "cairo-lang-defs" +version = "2.6.3" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +dependencies = [ + "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "itertools 0.11.0", + "salsa", + "smol_str", ] [[package]] @@ -1883,44 +1942,77 @@ name = "cairo-lang-defs" version = "2.6.3" source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" dependencies = [ - "cairo-lang-debug", - "cairo-lang-diagnostics", - "cairo-lang-filesystem", - "cairo-lang-parser", - "cairo-lang-syntax", - "cairo-lang-utils", + "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "itertools 0.12.1", "salsa", "smol_str", ] +[[package]] +name = "cairo-lang-diagnostics" +version = "2.6.3" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +dependencies = [ + "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "itertools 0.11.0", +] + [[package]] name = "cairo-lang-diagnostics" version = "2.6.3" source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" dependencies = [ - "cairo-lang-debug", - "cairo-lang-filesystem", - "cairo-lang-utils", + "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "itertools 0.12.1", ] +[[package]] +name = "cairo-lang-eq-solver" +version = "2.6.3" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +dependencies = [ + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "good_lp", +] + [[package]] name = "cairo-lang-eq-solver" version = "2.6.3" source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" dependencies = [ - "cairo-lang-utils", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "good_lp", ] +[[package]] +name = "cairo-lang-filesystem" +version = "2.6.3" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +dependencies = [ + "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "path-clean", + "salsa", + "serde", + "smol_str", +] + [[package]] name = "cairo-lang-filesystem" version = "2.6.3" source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" dependencies = [ - "cairo-lang-debug", - "cairo-lang-utils", + "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "path-clean", "salsa", "serde", @@ -1933,11 +2025,11 @@ version = "2.6.3" source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" dependencies = [ "anyhow", - "cairo-lang-diagnostics", - "cairo-lang-filesystem", - "cairo-lang-parser", - "cairo-lang-syntax", - "cairo-lang-utils", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "diffy", "ignore", "itertools 0.12.1", @@ -1953,19 +2045,19 @@ version = "2.6.3" source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" dependencies = [ "anyhow", - "cairo-lang-compiler", - "cairo-lang-defs", - "cairo-lang-diagnostics", - "cairo-lang-filesystem", + "cairo-lang-compiler 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "cairo-lang-formatter", - "cairo-lang-lowering", - "cairo-lang-parser", - "cairo-lang-project", - "cairo-lang-semantic", - "cairo-lang-starknet", - "cairo-lang-syntax", + "cairo-lang-lowering 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-project 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-semantic 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "cairo-lang-test-plugin", - "cairo-lang-utils", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "salsa", "scarb-metadata 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde", @@ -1977,20 +2069,44 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "cairo-lang-lowering" +version = "2.6.3" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +dependencies = [ + "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-proc-macros 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-semantic 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "id-arena", + "itertools 0.11.0", + "log", + "num-bigint", + "num-traits 0.2.19", + "once_cell", + "salsa", + "smol_str", +] + [[package]] name = "cairo-lang-lowering" version = "2.6.3" source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" dependencies = [ - "cairo-lang-debug", - "cairo-lang-defs", - "cairo-lang-diagnostics", - "cairo-lang-filesystem", - "cairo-lang-parser", - "cairo-lang-proc-macros", - "cairo-lang-semantic", - "cairo-lang-syntax", - "cairo-lang-utils", + "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-proc-macros 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-semantic 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "id-arena", "itertools 0.12.1", "log", @@ -2026,16 +2142,35 @@ name = "cairo-lang-macro-stable" version = "1.0.0" source = "git+https://github.com/software-mansion/scarb?rev=e813dbab8f0ec606b5846827ad65951ef8bd6b92#e813dbab8f0ec606b5846827ad65951ef8bd6b92" +[[package]] +name = "cairo-lang-parser" +version = "2.6.3" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +dependencies = [ + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-syntax-codegen 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "colored", + "itertools 0.11.0", + "num-bigint", + "num-traits 0.2.19", + "salsa", + "smol_str", + "unescaper", +] + [[package]] name = "cairo-lang-parser" version = "2.6.3" source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" dependencies = [ - "cairo-lang-diagnostics", - "cairo-lang-filesystem", - "cairo-lang-syntax", - "cairo-lang-syntax-codegen", - "cairo-lang-utils", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-syntax-codegen 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "colored", "itertools 0.12.1", "num-bigint", @@ -2045,17 +2180,35 @@ dependencies = [ "unescaper", ] +[[package]] +name = "cairo-lang-plugins" +version = "2.6.3" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +dependencies = [ + "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "indent", + "indoc 2.0.5", + "itertools 0.11.0", + "salsa", + "smol_str", +] + [[package]] name = "cairo-lang-plugins" version = "2.6.3" source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" dependencies = [ - "cairo-lang-defs", - "cairo-lang-diagnostics", - "cairo-lang-filesystem", - "cairo-lang-parser", - "cairo-lang-syntax", - "cairo-lang-utils", + "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "indent", "indoc 2.0.5", "itertools 0.12.1", @@ -2063,29 +2216,82 @@ dependencies = [ "smol_str", ] +[[package]] +name = "cairo-lang-proc-macros" +version = "2.6.3" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +dependencies = [ + "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "quote", + "syn 2.0.64", +] + [[package]] name = "cairo-lang-proc-macros" version = "2.6.3" source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" dependencies = [ - "cairo-lang-debug", + "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "quote", "syn 2.0.64", ] +[[package]] +name = "cairo-lang-project" +version = "2.6.3" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +dependencies = [ + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "serde", + "smol_str", + "thiserror", + "toml 0.8.13", +] + [[package]] name = "cairo-lang-project" version = "2.6.3" source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" dependencies = [ - "cairo-lang-filesystem", - "cairo-lang-utils", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "serde", "smol_str", "thiserror", "toml 0.8.13", ] +[[package]] +name = "cairo-lang-runner" +version = "2.6.3" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +dependencies = [ + "ark-ff 0.4.2", + "ark-secp256k1", + "ark-secp256r1", + "ark-std 0.4.0", + "cairo-felt", + "cairo-lang-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-lowering 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-sierra-ap-change 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-sierra-generator 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-sierra-to-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-sierra-type-size 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-vm", + "itertools 0.11.0", + "keccak", + "num-bigint", + "num-integer", + "num-traits 0.2.19", + "smol_str", + "starknet-crypto 0.6.2", + "thiserror", +] + [[package]] name = "cairo-lang-runner" version = "2.6.3" @@ -2095,15 +2301,15 @@ dependencies = [ "ark-secp256k1", "ark-secp256r1", "cairo-felt", - "cairo-lang-casm", - "cairo-lang-lowering", - "cairo-lang-sierra", - "cairo-lang-sierra-ap-change", - "cairo-lang-sierra-generator", - "cairo-lang-sierra-to-casm", - "cairo-lang-sierra-type-size", - "cairo-lang-starknet", - "cairo-lang-utils", + "cairo-lang-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-lowering 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra-ap-change 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra-generator 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra-to-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra-type-size 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "cairo-vm", "itertools 0.12.1", "keccak", @@ -2117,21 +2323,45 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cairo-lang-semantic" +version = "2.6.3" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +dependencies = [ + "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-plugins 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-proc-macros 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "id-arena", + "indoc 2.0.5", + "itertools 0.11.0", + "num-bigint", + "num-traits 0.2.19", + "once_cell", + "salsa", + "smol_str", +] + [[package]] name = "cairo-lang-semantic" version = "2.6.3" source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" dependencies = [ - "cairo-lang-debug", - "cairo-lang-defs", - "cairo-lang-diagnostics", - "cairo-lang-filesystem", - "cairo-lang-parser", - "cairo-lang-plugins", - "cairo-lang-proc-macros", - "cairo-lang-syntax", + "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-plugins 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-proc-macros 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "cairo-lang-test-utils", - "cairo-lang-utils", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "id-arena", "indoc 2.0.5", "itertools 0.12.1", @@ -2143,6 +2373,31 @@ dependencies = [ "toml 0.8.13", ] +[[package]] +name = "cairo-lang-sierra" +version = "2.6.3" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +dependencies = [ + "anyhow", + "cairo-felt", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "const-fnv1a-hash", + "convert_case 0.6.0", + "derivative", + "itertools 0.11.0", + "lalrpop", + "lalrpop-util", + "num-bigint", + "num-traits 0.2.19", + "regex", + "salsa", + "serde", + "serde_json", + "sha3", + "smol_str", + "thiserror", +] + [[package]] name = "cairo-lang-sierra" version = "2.6.3" @@ -2150,7 +2405,7 @@ source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d9 dependencies = [ "anyhow", "cairo-felt", - "cairo-lang-utils", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "const-fnv1a-hash", "convert_case 0.6.0", "derivative", @@ -2168,51 +2423,101 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cairo-lang-sierra-ap-change" +version = "2.6.3" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +dependencies = [ + "cairo-lang-eq-solver 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-sierra-type-size 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "itertools 0.11.0", + "num-traits 0.2.19", + "thiserror", +] + [[package]] name = "cairo-lang-sierra-ap-change" version = "2.6.3" source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" dependencies = [ - "cairo-lang-eq-solver", - "cairo-lang-sierra", - "cairo-lang-sierra-type-size", - "cairo-lang-utils", + "cairo-lang-eq-solver 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra-type-size 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "itertools 0.12.1", "num-bigint", "num-traits 0.2.19", "thiserror", ] +[[package]] +name = "cairo-lang-sierra-gas" +version = "2.6.3" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +dependencies = [ + "cairo-lang-eq-solver 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-sierra-type-size 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "itertools 0.11.0", + "num-traits 0.2.19", + "thiserror", +] + [[package]] name = "cairo-lang-sierra-gas" version = "2.6.3" source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" dependencies = [ - "cairo-lang-eq-solver", - "cairo-lang-sierra", - "cairo-lang-sierra-type-size", - "cairo-lang-utils", + "cairo-lang-eq-solver 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra-type-size 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "itertools 0.12.1", "num-bigint", "num-traits 0.2.19", "thiserror", ] +[[package]] +name = "cairo-lang-sierra-generator" +version = "2.6.3" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +dependencies = [ + "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-lowering 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-semantic 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "itertools 0.11.0", + "num-traits 0.2.19", + "once_cell", + "salsa", + "smol_str", +] + [[package]] name = "cairo-lang-sierra-generator" version = "2.6.3" source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" dependencies = [ - "cairo-lang-debug", - "cairo-lang-defs", - "cairo-lang-diagnostics", - "cairo-lang-filesystem", - "cairo-lang-lowering", - "cairo-lang-parser", - "cairo-lang-semantic", - "cairo-lang-sierra", - "cairo-lang-syntax", - "cairo-lang-utils", + "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-lowering 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-semantic 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "itertools 0.12.1", "num-traits 0.2.19", "once_cell", @@ -2222,6 +2527,26 @@ dependencies = [ "smol_str", ] +[[package]] +name = "cairo-lang-sierra-to-casm" +version = "2.6.3" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +dependencies = [ + "assert_matches", + "cairo-felt", + "cairo-lang-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-sierra-ap-change 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-sierra-gas 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-sierra-type-size 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "indoc 2.0.5", + "itertools 0.11.0", + "num-bigint", + "num-traits 0.2.19", + "thiserror", +] + [[package]] name = "cairo-lang-sierra-to-casm" version = "2.6.3" @@ -2229,12 +2554,12 @@ source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d9 dependencies = [ "assert_matches", "cairo-felt", - "cairo-lang-casm", - "cairo-lang-sierra", - "cairo-lang-sierra-ap-change", - "cairo-lang-sierra-gas", - "cairo-lang-sierra-type-size", - "cairo-lang-utils", + "cairo-lang-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra-ap-change 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra-gas 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra-type-size 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "indoc 2.0.5", "itertools 0.12.1", "num-bigint", @@ -2242,13 +2567,52 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cairo-lang-sierra-type-size" +version = "2.6.3" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +dependencies = [ + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", +] + [[package]] name = "cairo-lang-sierra-type-size" version = "2.6.3" source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" dependencies = [ - "cairo-lang-sierra", - "cairo-lang-utils", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", +] + +[[package]] +name = "cairo-lang-starknet" +version = "2.6.3" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +dependencies = [ + "anyhow", + "cairo-felt", + "cairo-lang-compiler 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-lowering 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-plugins 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-semantic 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-sierra-generator 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-starknet-classes 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "const_format", + "indent", + "indoc 2.0.5", + "itertools 0.11.0", + "once_cell", + "serde", + "serde_json", + "smol_str", + "thiserror", ] [[package]] @@ -2258,18 +2622,18 @@ source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d9 dependencies = [ "anyhow", "cairo-felt", - "cairo-lang-compiler", - "cairo-lang-defs", - "cairo-lang-diagnostics", - "cairo-lang-filesystem", - "cairo-lang-lowering", - "cairo-lang-plugins", - "cairo-lang-semantic", - "cairo-lang-sierra", - "cairo-lang-sierra-generator", - "cairo-lang-starknet-classes", - "cairo-lang-syntax", - "cairo-lang-utils", + "cairo-lang-compiler 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-lowering 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-plugins 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-semantic 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra-generator 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-starknet-classes 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "const_format", "indent", "indoc 2.0.5", @@ -2281,16 +2645,40 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cairo-lang-starknet-classes" +version = "2.6.3" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +dependencies = [ + "cairo-felt", + "cairo-lang-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-sierra-to-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "convert_case 0.6.0", + "itertools 0.11.0", + "num-bigint", + "num-integer", + "num-traits 0.2.19", + "once_cell", + "serde", + "serde_json", + "sha3", + "smol_str", + "starknet-crypto 0.6.2", + "thiserror", +] + [[package]] name = "cairo-lang-starknet-classes" version = "2.6.3" source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" dependencies = [ "cairo-felt", - "cairo-lang-casm", - "cairo-lang-sierra", - "cairo-lang-sierra-to-casm", - "cairo-lang-utils", + "cairo-lang-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra-to-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "convert_case 0.6.0", "itertools 0.12.1", "num-bigint", @@ -2305,14 +2693,29 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cairo-lang-syntax" +version = "2.6.3" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +dependencies = [ + "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "num-bigint", + "num-traits 0.2.19", + "salsa", + "smol_str", + "unescaper", +] + [[package]] name = "cairo-lang-syntax" version = "2.6.3" source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" dependencies = [ - "cairo-lang-debug", - "cairo-lang-filesystem", - "cairo-lang-utils", + "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "num-bigint", "num-traits 0.2.19", "salsa", @@ -2320,6 +2723,15 @@ dependencies = [ "unescaper", ] +[[package]] +name = "cairo-lang-syntax-codegen" +version = "2.6.3" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +dependencies = [ + "genco", + "xshell", +] + [[package]] name = "cairo-lang-syntax-codegen" version = "2.6.3" @@ -2336,19 +2748,19 @@ source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d9 dependencies = [ "anyhow", "cairo-felt", - "cairo-lang-compiler", - "cairo-lang-debug", - "cairo-lang-defs", - "cairo-lang-diagnostics", - "cairo-lang-filesystem", - "cairo-lang-lowering", - "cairo-lang-semantic", - "cairo-lang-sierra", - "cairo-lang-sierra-generator", - "cairo-lang-starknet", - "cairo-lang-starknet-classes", - "cairo-lang-syntax", - "cairo-lang-utils", + "cairo-lang-compiler 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-lowering 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-semantic 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra-generator 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-starknet-classes 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "indoc 2.0.5", "itertools 0.12.1", "num-bigint", @@ -2363,15 +2775,15 @@ source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d9 dependencies = [ "anyhow", "cairo-felt", - "cairo-lang-compiler", - "cairo-lang-filesystem", - "cairo-lang-runner", - "cairo-lang-sierra", - "cairo-lang-sierra-generator", - "cairo-lang-sierra-to-casm", - "cairo-lang-starknet", + "cairo-lang-compiler 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-runner 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra-generator 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra-to-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "cairo-lang-test-plugin", - "cairo-lang-utils", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "colored", "itertools 0.12.1", "num-traits 0.2.19", @@ -2384,12 +2796,27 @@ version = "2.6.3" source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" dependencies = [ "cairo-lang-formatter", - "cairo-lang-utils", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "colored", "log", "pretty_assertions", ] +[[package]] +name = "cairo-lang-utils" +version = "2.6.3" +source = "git+https://github.com/starkware-libs/cairo?tag=v2.6.3#2203a47f8a098cd4718d03bd109ca014049419e7" +dependencies = [ + "hashbrown 0.14.5", + "indexmap 2.2.6", + "itertools 0.11.0", + "num-bigint", + "num-traits 0.2.19", + "parity-scale-codec", + "schemars", + "serde", +] + [[package]] name = "cairo-lang-utils" version = "2.6.3" @@ -2402,7 +2829,6 @@ dependencies = [ "log", "num-bigint", "num-traits 0.2.19", - "parity-scale-codec", "schemars", "serde", "time", @@ -3661,24 +4087,24 @@ name = "dojo-lang" version = "0.7.0-alpha.4" dependencies = [ "anyhow", - "cairo-lang-compiler", - "cairo-lang-debug", - "cairo-lang-defs", - "cairo-lang-diagnostics", - "cairo-lang-filesystem", + "cairo-lang-compiler 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "cairo-lang-formatter", - "cairo-lang-lowering", - "cairo-lang-parser", - "cairo-lang-plugins", - "cairo-lang-project", - "cairo-lang-semantic", - "cairo-lang-sierra-generator", - "cairo-lang-starknet", - "cairo-lang-starknet-classes", - "cairo-lang-syntax", + "cairo-lang-lowering 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-plugins 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-project 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-semantic 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra-generator 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-starknet-classes 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "cairo-lang-test-plugin", "cairo-lang-test-utils", - "cairo-lang-utils", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "camino", "convert_case 0.6.0", "directories", @@ -3712,14 +4138,14 @@ name = "dojo-language-server" version = "0.7.0-alpha.4" dependencies = [ "anyhow", - "cairo-lang-compiler", - "cairo-lang-filesystem", + "cairo-lang-compiler 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "cairo-lang-language-server", - "cairo-lang-plugins", - "cairo-lang-semantic", - "cairo-lang-starknet", + "cairo-lang-plugins 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-semantic 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "cairo-lang-test-plugin", - "cairo-lang-utils", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "clap", "dojo-lang", "log", @@ -3754,10 +4180,10 @@ dependencies = [ "anyhow", "assert_fs", "async-trait", - "cairo-lang-compiler", - "cairo-lang-filesystem", - "cairo-lang-project", - "cairo-lang-starknet", + "cairo-lang-compiler 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-project 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "camino", "dojo-lang", "dojo-world", @@ -3806,10 +4232,10 @@ dependencies = [ "assert_matches", "async-trait", "cainome", - "cairo-lang-filesystem", - "cairo-lang-project", - "cairo-lang-starknet", - "cairo-lang-starknet-classes", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-project 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-starknet-classes 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "camino", "convert_case 0.6.0", "dojo-lang", @@ -3839,8 +4265,8 @@ dependencies = [ name = "dojo-world-abigen" version = "0.7.0-alpha.4" dependencies = [ - "cairo-lang-starknet", - "cairo-lang-starknet-classes", + "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-starknet-classes 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "camino", "scarb", "scarb-ui", @@ -6904,6 +7330,19 @@ dependencies = [ "url", ] +[[package]] +name = "katana-cairo" +version = "0.7.0-alpha.4" +dependencies = [ + "cairo-lang-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-runner 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-starknet-classes 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", + "cairo-vm", +] + [[package]] name = "katana-codecs" version = "0.7.0-alpha.4" @@ -6938,8 +7377,8 @@ dependencies = [ "anyhow", "assert_matches", "async-trait", - "cairo-lang-casm", - "cairo-lang-starknet", + "cairo-lang-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "cairo-vm", "convert_case 0.6.0", "derive_more", @@ -6975,7 +7414,7 @@ name = "katana-db" version = "0.7.0-alpha.4" dependencies = [ "anyhow", - "cairo-lang-starknet", + "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "cairo-vm", "criterion", "katana-primitives", @@ -6999,10 +7438,10 @@ dependencies = [ "alloy-primitives", "anyhow", "blockifier", - "cairo-vm", "convert_case 0.6.0", "criterion", "futures", + "katana-cairo", "katana-primitives", "katana-provider", "katana-rpc-types", @@ -7026,12 +7465,9 @@ dependencies = [ "alloy-primitives", "anyhow", "base64 0.21.7", - "cairo-lang-sierra", - "cairo-lang-starknet", - "cairo-lang-starknet-classes", - "cairo-vm", "derive_more", "flate2", + "katana-cairo", "lazy_static", "rand", "rayon", @@ -7079,8 +7515,8 @@ version = "0.7.0-alpha.4" dependencies = [ "anyhow", "assert_matches", - "cairo-lang-starknet", - "cairo-lang-starknet-classes", + "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-starknet-classes 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "dojo-metrics", "dojo-test-utils", "dojo-world", @@ -10813,21 +11249,21 @@ source = "git+https://github.com/software-mansion/scarb?rev=e813dbab8f0ec606b584 dependencies = [ "anyhow", "async-trait", - "cairo-lang-compiler", - "cairo-lang-defs", - "cairo-lang-diagnostics", - "cairo-lang-filesystem", + "cairo-lang-compiler 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "cairo-lang-formatter", "cairo-lang-macro", "cairo-lang-macro-stable", - "cairo-lang-semantic", - "cairo-lang-sierra", - "cairo-lang-sierra-to-casm", - "cairo-lang-starknet", - "cairo-lang-starknet-classes", - "cairo-lang-syntax", + "cairo-lang-semantic 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra-to-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-starknet-classes 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "cairo-lang-test-plugin", - "cairo-lang-utils", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "camino", "clap", "create-output-dir", @@ -11549,17 +11985,17 @@ dependencies = [ "async-trait", "bigdecimal 0.4.3", "cainome", - "cairo-lang-compiler", - "cairo-lang-defs", - "cairo-lang-filesystem", - "cairo-lang-plugins", - "cairo-lang-project", - "cairo-lang-sierra", - "cairo-lang-sierra-to-casm", - "cairo-lang-starknet", + "cairo-lang-compiler 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-plugins 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-project 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra-to-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "cairo-lang-test-plugin", "cairo-lang-test-runner", - "cairo-lang-utils", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "camino", "clap", "clap-verbosity-flag", @@ -11607,17 +12043,17 @@ dependencies = [ "assert_fs", "async-trait", "cainome", - "cairo-lang-compiler", - "cairo-lang-defs", - "cairo-lang-filesystem", - "cairo-lang-plugins", - "cairo-lang-project", - "cairo-lang-sierra", - "cairo-lang-sierra-to-casm", - "cairo-lang-starknet", + "cairo-lang-compiler 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-plugins 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-project 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra-to-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "cairo-lang-test-plugin", "cairo-lang-test-runner", - "cairo-lang-utils", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "camino", "clap", "clap-verbosity-flag", @@ -12134,7 +12570,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "365ec5c0662466f299762bd012012da30e9a28319000cfade372b8787111f202" dependencies = [ - "cairo-lang-starknet-classes", + "cairo-lang-starknet-classes 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "derive_more", "hex", "indexmap 2.2.6", diff --git a/Cargo.toml b/Cargo.toml index 0d3c21f692..8c2d72ad0a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -69,6 +69,7 @@ dojo-types = { path = "crates/dojo-types" } dojo-world = { path = "crates/dojo-world" } # katana +katana-cairo = { path = "crates/katana/cairo" } katana-codecs = { path = "crates/katana/storage/codecs" } katana-codecs-derive = { path = "crates/katana/storage/codecs/derive" } katana-core = { path = "crates/katana/core", default-features = false } diff --git a/crates/katana/cairo/Cargo.toml b/crates/katana/cairo/Cargo.toml new file mode 100644 index 0000000000..db98902c83 --- /dev/null +++ b/crates/katana/cairo/Cargo.toml @@ -0,0 +1,19 @@ +[package] +description = "Collection of Cairo language dependencies that are used throughout Katana. Unifying the Cairo language based dependencies to avoid dependency conflict with the versions used by Dojo." +edition.workspace = true +license.workspace = true +name = "katana-cairo" +repository.workspace = true +version.workspace = true + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +# Use from git instead of crates.io registry so that the workspace patches aren't applied. +[dependencies] +cairo-lang-casm = { git = "https://github.com/starkware-libs/cairo", tag = "v2.6.3" } +cairo-lang-runner = { git = "https://github.com/starkware-libs/cairo", tag = "v2.6.3" } +cairo-lang-sierra = { git = "https://github.com/starkware-libs/cairo", tag = "v2.6.3" } +cairo-lang-starknet = { git = "https://github.com/starkware-libs/cairo", tag = "v2.6.3" } +cairo-lang-starknet-classes = { git = "https://github.com/starkware-libs/cairo", tag = "v2.6.3" } +cairo-lang-utils = { git = "https://github.com/starkware-libs/cairo", tag = "v2.6.3" } +cairo-vm = "0.9.2" diff --git a/crates/katana/cairo/src/lib.rs b/crates/katana/cairo/src/lib.rs new file mode 100644 index 0000000000..c8e39061e4 --- /dev/null +++ b/crates/katana/cairo/src/lib.rs @@ -0,0 +1,13 @@ +#![warn(unused_crate_dependencies)] + +//! Re-export of the Cairo language crates used throughout Katana. + +pub mod lang { + pub use { + cairo_lang_casm as casm, cairo_lang_runner as runner, cairo_lang_sierra as sierra, + cairo_lang_starknet as starknet, cairo_lang_starknet_classes as starknet_classes, + cairo_lang_utils as utils, + }; +} + +pub use cairo_vm; diff --git a/crates/katana/executor/Cargo.toml b/crates/katana/executor/Cargo.toml index 4693dbb3f0..5e984c5bae 100644 --- a/crates/katana/executor/Cargo.toml +++ b/crates/katana/executor/Cargo.toml @@ -22,8 +22,8 @@ tracing.workspace = true alloy-primitives.workspace = true # blockifier deps -blockifier = { git = "https://github.com/dojoengine/blockifier", rev = "7d866a24", features = [ "testing" ], optional = true } -cairo-vm = { workspace = true, optional = true } +blockifier = { git = "https://github.com/dojoengine/blockifier", rev = "57c11586", features = [ "testing" ], optional = true } +katana-cairo = { workspace = true, optional = true } # Disable SIR for now until they support Cairo 2.6.3 # # starknet_in_rust deps @@ -33,7 +33,7 @@ cairo-vm = { workspace = true, optional = true } [dev-dependencies] anyhow.workspace = true -cairo-vm.workspace = true +katana-cairo.workspace = true katana-provider = { workspace = true, features = [ "test-utils" ] } katana-rpc-types.workspace = true rstest.workspace = true @@ -46,7 +46,7 @@ criterion.workspace = true pprof = { version = "0.13.0", features = [ "criterion", "flamegraph" ] } [features] -blockifier = [ "dep:blockifier", "dep:cairo-vm" ] +blockifier = [ "dep:blockifier", "dep:katana-cairo" ] default = [ "blockifier" ] # native = [ "sir", "sir/cairo-native" ] # sir = [ "dep:sir", "dep:starknet-types-core" ] diff --git a/crates/katana/executor/benches/utils.rs b/crates/katana/executor/benches/utils.rs index fb05d0bbae..369aeb0984 100644 --- a/crates/katana/executor/benches/utils.rs +++ b/crates/katana/executor/benches/utils.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use cairo_vm::vm::runners::builtin_runner::{ +use katana_cairo::cairo_vm::vm::runners::builtin_runner::{ BITWISE_BUILTIN_NAME, EC_OP_BUILTIN_NAME, HASH_BUILTIN_NAME, KECCAK_BUILTIN_NAME, OUTPUT_BUILTIN_NAME, POSEIDON_BUILTIN_NAME, RANGE_CHECK_BUILTIN_NAME, SEGMENT_ARENA_BUILTIN_NAME, SIGNATURE_BUILTIN_NAME, diff --git a/crates/katana/executor/src/implementation/blockifier/utils.rs b/crates/katana/executor/src/implementation/blockifier/utils.rs index 06e32d3866..0298d8426f 100644 --- a/crates/katana/executor/src/implementation/blockifier/utils.rs +++ b/crates/katana/executor/src/implementation/blockifier/utils.rs @@ -26,8 +26,8 @@ use blockifier::transaction::transactions::{ L1HandlerTransaction, }; use blockifier::versioned_constants::VersionedConstants; -use cairo_vm::types::errors::program_errors::ProgramError; -use cairo_vm::vm::runners::cairo_runner::ExecutionResources; +use katana_cairo::cairo_vm::types::errors::program_errors::ProgramError; +use katana_cairo::cairo_vm::vm::runners::cairo_runner::ExecutionResources; use katana_primitives::env::{BlockEnv, CfgEnv}; use katana_primitives::fee::TxFeeInfo; use katana_primitives::state::{StateUpdates, StateUpdatesWithDeclaredClasses}; @@ -656,7 +656,7 @@ mod tests { use std::collections::HashSet; - use cairo_vm::vm::runners::cairo_runner::ExecutionResources; + use katana_cairo::cairo_vm::vm::runners::cairo_runner::ExecutionResources; use katana_primitives::chain::{ChainId, NamedChainId}; use starknet_api::core::EntryPointSelector; use starknet_api::hash::StarkFelt; diff --git a/crates/katana/executor/tests/fixtures/mod.rs b/crates/katana/executor/tests/fixtures/mod.rs index 67a4871fea..bae80c0613 100644 --- a/crates/katana/executor/tests/fixtures/mod.rs +++ b/crates/katana/executor/tests/fixtures/mod.rs @@ -3,7 +3,7 @@ pub mod transaction; use std::collections::HashMap; use alloy_primitives::U256; -use cairo_vm::vm::runners::builtin_runner::{ +use katana_cairo::cairo_vm::vm::runners::builtin_runner::{ BITWISE_BUILTIN_NAME, EC_OP_BUILTIN_NAME, HASH_BUILTIN_NAME, KECCAK_BUILTIN_NAME, OUTPUT_BUILTIN_NAME, POSEIDON_BUILTIN_NAME, RANGE_CHECK_BUILTIN_NAME, SEGMENT_ARENA_BUILTIN_NAME, SIGNATURE_BUILTIN_NAME, diff --git a/crates/katana/primitives/Cargo.toml b/crates/katana/primitives/Cargo.toml index 7c2e3f0cc7..1d01902fa9 100644 --- a/crates/katana/primitives/Cargo.toml +++ b/crates/katana/primitives/Cargo.toml @@ -9,7 +9,6 @@ version.workspace = true [dependencies] anyhow.workspace = true base64.workspace = true -cairo-vm.workspace = true derive_more.workspace = true lazy_static.workspace = true rand = { workspace = true, features = [ "small_rng" ] } @@ -24,10 +23,8 @@ strum_macros.workspace = true thiserror.workspace = true alloy-primitives.workspace = true -cairo-lang-sierra.workspace = true -cairo-lang-starknet-classes.workspace = true -cairo-lang-starknet.workspace = true flate2.workspace = true +katana-cairo.workspace = true starknet_api.workspace = true [dev-dependencies] diff --git a/crates/katana/primitives/src/class.rs b/crates/katana/primitives/src/class.rs index 58d54c182e..2d73310fb5 100644 --- a/crates/katana/primitives/src/class.rs +++ b/crates/katana/primitives/src/class.rs @@ -1,4 +1,6 @@ -use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; +use katana_cairo::lang::sierra::program::Program; +use katana_cairo::lang::starknet_classes::casm_contract_class::CasmContractClass; +use katana_cairo::lang::starknet_classes::contract_class::ContractEntryPoints; use crate::FieldElement; @@ -17,8 +19,8 @@ pub type DeprecatedCompiledClass = ::starknet_api::deprecated_contract_class::Co #[derive(Debug, Clone, Eq, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SierraProgram { - pub program: cairo_lang_sierra::program::Program, - pub entry_points_by_type: cairo_lang_starknet_classes::contract_class::ContractEntryPoints, + pub program: Program, + pub entry_points_by_type: ContractEntryPoints, } #[derive(Debug, Clone, Eq, PartialEq)] diff --git a/crates/katana/primitives/src/conversion/rpc.rs b/crates/katana/primitives/src/conversion/rpc.rs index 36786a7ff0..25ec978a31 100644 --- a/crates/katana/primitives/src/conversion/rpc.rs +++ b/crates/katana/primitives/src/conversion/rpc.rs @@ -3,7 +3,7 @@ use std::io::{self, Read, Write}; use std::mem; use anyhow::{Context, Result}; -use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; +use katana_cairo::lang::starknet_classes::casm_contract_class::CasmContractClass; use serde::Deserialize; use serde_json::json; use serde_with::serde_as; @@ -186,10 +186,10 @@ pub fn legacy_rpc_to_compiled_class( /// [ContractClass](cairo_lang_starknet::contract_class::ContractClass) type. fn rpc_to_cairo_contract_class( contract_class: &FlattenedSierraClass, -) -> Result { +) -> Result { let value = serde_json::to_value(contract_class)?; - Ok(cairo_lang_starknet_classes::contract_class::ContractClass { + Ok(katana_cairo::lang::starknet_classes::contract_class::ContractClass { abi: serde_json::from_value(value["abi"].clone()).ok(), sierra_program: serde_json::from_value(value["sierra_program"].clone())?, entry_points_by_type: serde_json::from_value(value["entry_points_by_type"].clone())?, diff --git a/crates/katana/primitives/src/genesis/json.rs b/crates/katana/primitives/src/genesis/json.rs index 2a312baa40..4372a5a424 100644 --- a/crates/katana/primitives/src/genesis/json.rs +++ b/crates/katana/primitives/src/genesis/json.rs @@ -12,8 +12,8 @@ use std::sync::Arc; use alloy_primitives::U256; use base64::prelude::*; -use cairo_lang_starknet_classes::casm_contract_class::StarknetSierraCompilationError; -use cairo_vm::types::errors::program_errors::ProgramError; +use katana_cairo::cairo_vm::types::errors::program_errors::ProgramError; +use katana_cairo::lang::starknet_classes::casm_contract_class::StarknetSierraCompilationError; use serde::de::value::MapAccessDeserializer; use serde::de::Visitor; use serde::{Deserialize, Serialize}; diff --git a/crates/katana/primitives/src/utils/class.rs b/crates/katana/primitives/src/utils/class.rs index b45af97186..ed3602872c 100644 --- a/crates/katana/primitives/src/utils/class.rs +++ b/crates/katana/primitives/src/utils/class.rs @@ -1,6 +1,6 @@ use anyhow::Result; -use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; -use cairo_lang_starknet_classes::contract_class::ContractClass; +use katana_cairo::lang::starknet_classes::casm_contract_class::CasmContractClass; +use katana_cairo::lang::starknet_classes::contract_class::ContractClass; use serde_json::Value; use crate::class::{ From 03aefc36ea4e8256c50dd7541549f5177b0f21e7 Mon Sep 17 00:00:00 2001 From: lambda-0x <0xlambda@protonmail.com> Date: Mon, 27 May 2024 14:45:59 +0530 Subject: [PATCH 05/16] docs(sozo): update error message for more context (#2005) docs: update error message for more context --- bin/sozo/src/main.rs | 3 +-- crates/dojo-world/src/migration/strategy.rs | 9 +++++++-- crates/sozo/ops/src/migration/mod.rs | 5 ++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/bin/sozo/src/main.rs b/bin/sozo/src/main.rs index a0ac206689..eea47706c5 100644 --- a/bin/sozo/src/main.rs +++ b/bin/sozo/src/main.rs @@ -23,8 +23,7 @@ fn main() { let ui = Ui::new(args.ui_verbosity(), OutputFormat::Text); if let Err(err) = cli_main(args) { - ui.error(format!("{err}")); - err.chain().skip(1).for_each(|clause| eprintln!("reason: {:?}", clause)); + ui.anyhow(&err); exit(1); } } diff --git a/crates/dojo-world/src/migration/strategy.rs b/crates/dojo-world/src/migration/strategy.rs index 1e0b573ff7..8dddb832b0 100644 --- a/crates/dojo-world/src/migration/strategy.rs +++ b/crates/dojo-world/src/migration/strategy.rs @@ -69,8 +69,13 @@ pub fn prepare_for_migration( target_dir: &Utf8PathBuf, diff: WorldDiff, ) -> Result { - let entries = fs::read_dir(target_dir) - .map_err(|err| anyhow!("Failed reading source directory: {err}"))?; + let entries = fs::read_dir(target_dir).with_context(|| { + format!( + "Failed trying to read target directory ({target_dir})\nNOTE: build files are profile \ + specified so make sure to run build command with correct profile. For e.g. `sozo -P \ + my_profile build`" + ) + })?; let mut artifact_paths = HashMap::new(); for entry in entries.flatten() { diff --git a/crates/sozo/ops/src/migration/mod.rs b/crates/sozo/ops/src/migration/mod.rs index bf5e417a2f..e998b0fa36 100644 --- a/crates/sozo/ops/src/migration/mod.rs +++ b/crates/sozo/ops/src/migration/mod.rs @@ -75,9 +75,8 @@ where |e| { ui.error(e.to_string()); anyhow!( - "\n Use `sozo clean` to clean your project, or `sozo clean --manifests-abis` \ - to clean manifest and abi files only.\nThen, rebuild your project with `sozo \ - build`.", + "\n Use `sozo clean` to clean your project.\nThen, rebuild your project with \ + `sozo build`.", ) }, )?; From 3a19201938f79cc522b5d357663864c6bafef19e Mon Sep 17 00:00:00 2001 From: Larko <59736843+Larkooo@users.noreply.github.com> Date: Mon, 27 May 2024 13:22:41 -0400 Subject: [PATCH 06/16] refactor(torii-core): fix double pending indexing & use btreemap for sorted blocks (#2009) --- crates/torii/core/src/engine.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/crates/torii/core/src/engine.rs b/crates/torii/core/src/engine.rs index 3c0d732a1e..2fb4935e6d 100644 --- a/crates/torii/core/src/engine.rs +++ b/crates/torii/core/src/engine.rs @@ -1,4 +1,4 @@ -use std::collections::HashMap; +use std::collections::BTreeMap; use std::time::Duration; use anyhow::Result; @@ -207,7 +207,7 @@ impl Engine

{ &mut self, from: u64, to: u64, - mut pending_block_tx: Option, + pending_block_tx: Option, ) -> Result> { // Process all blocks from current to latest. let get_events = |token: Option| { @@ -232,10 +232,11 @@ impl Engine

{ // Transactions & blocks to process let mut last_block = 0_u64; - let mut blocks = HashMap::new(); + let mut blocks = BTreeMap::new(); // Flatten events pages and events according to the pending block cursor // to array of (block_number, transaction_hash) + let mut pending_block_tx_cursor = pending_block_tx; let mut transactions = vec![]; for events_page in &events_pages { for event in &events_page.events { @@ -269,14 +270,20 @@ impl Engine

{ // Then we skip all transactions until we reach the last pending processed // transaction (if any) - if let Some(tx) = pending_block_tx { + if let Some(tx) = pending_block_tx_cursor { if event.transaction_hash != tx { continue; } - // Then we skip that processed transaction - pending_block_tx = None; - continue; + pending_block_tx_cursor = None; + } + + // Skip the latest pending block transaction events + // * as we might have multiple events for the same transaction + if let Some(tx) = pending_block_tx { + if event.transaction_hash == tx { + continue; + } } if let Some((_, last_tx_hash)) = transactions.last() { From 1836367b4d0f689317c89fc374949867cfc4e3f1 Mon Sep 17 00:00:00 2001 From: Larko <59736843+Larkooo@users.noreply.github.com> Date: Tue, 28 May 2024 11:01:14 -0400 Subject: [PATCH 07/16] fix(torii-grpc): layout decoding (#2011) * fix(torii-grpc): layout decoding * remove uused import --- crates/torii/grpc/src/server/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/torii/grpc/src/server/mod.rs b/crates/torii/grpc/src/server/mod.rs index b4fec0933e..3d0f8cbd81 100644 --- a/crates/torii/grpc/src/server/mod.rs +++ b/crates/torii/grpc/src/server/mod.rs @@ -132,7 +132,7 @@ impl DojoWorld { contract_address: model.3, packed_size: model.4, unpacked_size: model.5, - layout: hex::decode(&model.6).unwrap(), + layout: model.6.as_bytes().to_vec(), schema: serde_json::to_vec(&schema).unwrap(), }); } @@ -474,7 +474,7 @@ impl DojoWorld { .await?; let schema = self.model_cache.schema(&model).await?; - let layout = hex::decode(&layout).unwrap(); + let layout = layout.as_bytes().to_vec(); Ok(proto::types::ModelMetadata { name, From 3aae095dea4bfa1110dedf85d563e6d769458d10 Mon Sep 17 00:00:00 2001 From: lambda-0x <0xlambda@protonmail.com> Date: Wed, 29 May 2024 14:56:23 +0530 Subject: [PATCH 08/16] feat: init calldata for dojo contract (#1964) * initial commit * add tests * pass calldata during deploy_contract * complete todo in world.cairo * wip: work on dojo-lang macro for dojo init * wip: add dojo init impl * wip: work on compiler extension for dojo contract * clean up macro code * use logic similar to functions in other implementations and add to spawn-and-move that is: * allow ref self only if specified * add world if specified in parameters * update example, handle case where no dojo_init is specified and add plugin test * clean up fix tests * fix tests and lints * make suggested changes * fix class hash and address after world update * rename constructor_calldata to init_calldata --------- Co-authored-by: glihm --- Cargo.lock | 7 + Cargo.toml | 3 + crates/dojo-bindgen/src/lib.rs | 2 +- crates/dojo-core/src/base_test.cairo | 28 +- crates/dojo-core/src/world.cairo | 39 +- crates/dojo-core/src/world_test.cairo | 24 + crates/dojo-lang/src/contract.rs | 87 ++- .../dev/abis/base/dojo_world_world.json | 4 + .../compiler_cairo_cairo_24_cairo_v240.toml | 1 + .../compiler_cairo_cairo_26_cairo_v260.toml | 1 + .../manifests/dev/base/dojo_world_world.toml | 4 +- crates/dojo-lang/src/plugin.rs | 2 +- crates/dojo-lang/src/plugin_test_data/system | 368 ++++++++++- crates/dojo-test-utils/src/compiler.rs | 3 +- crates/dojo-test-utils/src/migration.rs | 15 +- crates/dojo-world/Cargo.toml | 1 + crates/dojo-world/src/contracts/abi/world.rs | 4 + crates/dojo-world/src/contracts/world_test.rs | 22 +- .../dojo-world/src/manifest/manifest_test.rs | 23 +- crates/dojo-world/src/manifest/mod.rs | 3 + crates/dojo-world/src/manifest/types.rs | 6 + crates/dojo-world/src/metadata_test.rs | 7 +- crates/dojo-world/src/migration/class.rs | 2 +- crates/dojo-world/src/migration/contract.rs | 3 +- crates/dojo-world/src/migration/mod.rs | 21 +- crates/dojo-world/src/migration/strategy.rs | 27 +- crates/dojo-world/src/migration/world.rs | 63 ++ crates/dojo-world/src/migration/world_test.rs | 67 ++ crates/sozo/ops/src/migration/migrate.rs | 6 +- crates/sozo/ops/src/migration/mod.rs | 5 +- crates/sozo/ops/src/tests/migration.rs | 3 +- crates/torii/core/src/sql_test.rs | 5 +- .../grpc/src/server/tests/entities_test.rs | 7 +- .../manifests/dev/base/dojo_world_world.toml | 4 +- examples/spawn-and-move/Scarb.toml | 2 +- .../dojo_examples_actions_actions.json | 18 + .../dojo_examples_others_others.json | 146 +++++ .../dev/abis/base/dojo_world_world.json | 4 + ...es_others_others_contract_initialized.json | 367 +++++++++++ .../dojo_examples_actions_actions.json | 18 + .../dojo_examples_others_others.json | 146 +++++ .../abis/deployments/dojo_world_world.json | 4 + ...es_others_others_contract_initialized.json | 367 +++++++++++ .../dojo_examples_actions_actions.toml | 5 +- .../dojo_examples_others_others.toml | 10 + .../manifests/dev/base/dojo_world_world.toml | 4 +- ...es_others_others_contract_initialized.toml | 20 + .../manifests/dev/manifest.json | 589 +++++++++++++++++- .../manifests/dev/manifest.toml | 54 +- .../dojo_examples_actions_actions.toml | 2 + .../dojo_examples_others_others.toml | 5 + examples/spawn-and-move/src/actions.cairo | 2 +- examples/spawn-and-move/src/lib.cairo | 1 + examples/spawn-and-move/src/others.cairo | 31 + 54 files changed, 2585 insertions(+), 77 deletions(-) create mode 100644 examples/spawn-and-move/manifests/dev/abis/base/contracts/dojo_examples_others_others.json create mode 100644 examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_others_others_contract_initialized.json create mode 100644 examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples_others_others.json create mode 100644 examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_others_others_contract_initialized.json create mode 100644 examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples_others_others.toml create mode 100644 examples/spawn-and-move/manifests/dev/base/models/dojo_examples_others_others_contract_initialized.toml create mode 100644 examples/spawn-and-move/manifests/dev/overlays/contracts/dojo_examples_others_others.toml create mode 100644 examples/spawn-and-move/src/others.cairo diff --git a/Cargo.lock b/Cargo.lock index a4158a0ae4..e021fa153f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4257,6 +4257,7 @@ dependencies = [ "thiserror", "tokio", "toml 0.8.13", + "topological-sort", "tracing", "url", ] @@ -13339,6 +13340,12 @@ dependencies = [ "web-sys", ] +[[package]] +name = "topological-sort" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea68304e134ecd095ac6c3574494fc62b909f416c4fca77e440530221e549d3d" + [[package]] name = "torii" version = "0.7.0-alpha.4" diff --git a/Cargo.toml b/Cargo.toml index 8c2d72ad0a..3fefe8f63b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,6 +68,9 @@ dojo-test-utils = { path = "crates/dojo-test-utils" } dojo-types = { path = "crates/dojo-types" } dojo-world = { path = "crates/dojo-world" } +# dojo-world +topological-sort = "0.2" + # katana katana-cairo = { path = "crates/katana/cairo" } katana-codecs = { path = "crates/katana/storage/codecs" } diff --git a/crates/dojo-bindgen/src/lib.rs b/crates/dojo-bindgen/src/lib.rs index ed2605f18a..3b25f4528d 100644 --- a/crates/dojo-bindgen/src/lib.rs +++ b/crates/dojo-bindgen/src/lib.rs @@ -261,7 +261,7 @@ mod tests { ) .unwrap(); - assert_eq!(data.models.len(), 5); + assert_eq!(data.models.len(), 6); assert_eq!(data.world.name, "dojo_example"); diff --git a/crates/dojo-core/src/base_test.cairo b/crates/dojo-core/src/base_test.cairo index 84ef74bf15..f52aea79f4 100644 --- a/crates/dojo-core/src/base_test.cairo +++ b/crates/dojo-core/src/base_test.cairo @@ -52,12 +52,20 @@ fn deploy_world() -> IWorldDispatcher { spawn_test_world(array![]) } +// A test contract needs to be used instead of previously used base contract since. +// contracts now require a `dojo_init` method which normal base contract doesn't have +#[dojo::contract] +mod test_contract {} + #[test] #[available_gas(6000000)] fn test_upgrade_from_world() { let world = deploy_world(); - let base_address = world.deploy_contract('salt', base::TEST_CLASS_HASH.try_into().unwrap()); + let base_address = world + .deploy_contract( + 'salt', test_contract::TEST_CLASS_HASH.try_into().unwrap(), array![].span() + ); let new_class_hash: ClassHash = contract_upgrade::TEST_CLASS_HASH.try_into().unwrap(); world.upgrade_contract(base_address, new_class_hash); @@ -74,7 +82,10 @@ fn test_upgrade_from_world() { fn test_upgrade_from_world_not_world_provider() { let world = deploy_world(); - let base_address = world.deploy_contract('salt', base::TEST_CLASS_HASH.try_into().unwrap()); + let base_address = world + .deploy_contract( + 'salt', test_contract::TEST_CLASS_HASH.try_into().unwrap(), array![].span() + ); let new_class_hash: ClassHash = contract_invalid_upgrade::TEST_CLASS_HASH.try_into().unwrap(); world.upgrade_contract(base_address, new_class_hash); @@ -86,7 +97,10 @@ fn test_upgrade_from_world_not_world_provider() { fn test_upgrade_direct() { let world = deploy_world(); - let base_address = world.deploy_contract('salt', base::TEST_CLASS_HASH.try_into().unwrap()); + let base_address = world + .deploy_contract( + 'salt', test_contract::TEST_CLASS_HASH.try_into().unwrap(), array![].span() + ); let new_class_hash: ClassHash = contract_upgrade::TEST_CLASS_HASH.try_into().unwrap(); let upgradeable_dispatcher = IUpgradeableDispatcher { contract_address: base_address }; @@ -144,8 +158,9 @@ mod invalid_model { #[abi(embed_v0)] impl InvalidModelSelector of super::IMetadataOnly { fn selector(self: @ContractState) -> felt252 { + // NOTE: Need to update this value if address changes // Pre-computed address of a contract deployed through the world. - 0x455fe9471cb954574b16581868043841391545b9225af00bf545f9acf923295 + 0x3dc3b5d2f73350ccda67b655bfae01e747c5db6e6f570743ee2867649da2a73 } fn name(self: @ContractState) -> ByteArray { @@ -179,12 +194,13 @@ mod invalid_model_world { fn test_deploy_from_world_invalid_model() { let world = deploy_world(); - let base_address = world.deploy_contract(0, base::TEST_CLASS_HASH.try_into().unwrap()); + let contract_address = world + .deploy_contract(0, test_contract::TEST_CLASS_HASH.try_into().unwrap(), array![].span()); // This print allows to know the address of the deployed contract which must be returned // by the selector() function of invalid model, to simulate a ACL issue // (see register_model function) - base_address.print(); + contract_address.print(); world.register_model(invalid_model::TEST_CLASS_HASH.try_into().unwrap()); } diff --git a/crates/dojo-core/src/world.cairo b/crates/dojo-core/src/world.cairo index 0544b1d385..6517a21d21 100644 --- a/crates/dojo-core/src/world.cairo +++ b/crates/dojo-core/src/world.cairo @@ -9,7 +9,9 @@ trait IWorld { fn set_metadata(ref self: T, metadata: ResourceMetadata); fn model(self: @T, selector: felt252) -> (ClassHash, ContractAddress); fn register_model(ref self: T, class_hash: ClassHash); - fn deploy_contract(ref self: T, salt: felt252, class_hash: ClassHash) -> ContractAddress; + fn deploy_contract( + ref self: T, salt: felt252, class_hash: ClassHash, init_calldata: Span + ) -> ContractAddress; fn upgrade_contract(ref self: T, address: ContractAddress, class_hash: ClassHash) -> ClassHash; fn uuid(ref self: T) -> usize; fn emit(self: @T, keys: Array, values: Span); @@ -97,9 +99,11 @@ mod world { const WORLD: felt252 = 0; - // the minimum internal size of an empty ByteArray + // the minimum internal size of an empty ByteArray const MIN_BYTE_ARRAY_SIZE: u32 = 3; + const DOJO_INIT_SELECTOR: felt252 = selector!("dojo_init"); + component!(path: Config, storage: config, event: ConfigEvent); #[abi(embed_v0)] @@ -204,6 +208,7 @@ mod world { writers: LegacyMap::<(felt252, ContractAddress), bool>, #[substorage(v0)] config: Config::Storage, + initialized_contract: LegacyMap::, } #[constructor] @@ -430,12 +435,16 @@ mod world { /// /// * `salt` - The salt use for contract deployment. /// * `class_hash` - The class hash of the contract. + /// * `init_calldata` - Calldata used to initialize the contract. /// /// # Returns /// /// * `ContractAddress` - The address of the newly deployed contract. fn deploy_contract( - ref self: ContractState, salt: felt252, class_hash: ClassHash + ref self: ContractState, + salt: felt252, + class_hash: ClassHash, + init_calldata: Span, ) -> ContractAddress { let (contract_address, _) = deploy_syscall( self.contract_base.read(), salt, array![].span(), false @@ -444,6 +453,14 @@ mod world { let upgradeable_dispatcher = IUpgradeableDispatcher { contract_address }; upgradeable_dispatcher.upgrade(class_hash); + if self.initialized_contract.read(contract_address.into()) { + panic!("Contract has already been initialized"); + } else { + starknet::call_contract_syscall(contract_address, DOJO_INIT_SELECTOR, init_calldata) + .unwrap_syscall(); + self.initialized_contract.write(contract_address.into(), true); + } + self.owners.write((contract_address.into(), get_caller_address()), true); self.deployed_contracts.write(contract_address.into(), class_hash.into()); @@ -796,7 +813,7 @@ mod world { } /// Write values to the world storage. - /// + /// /// # Arguments /// * `model` - the model selector. /// * `key` - the object key. @@ -829,7 +846,7 @@ mod world { } /// Write fixed layout model record to the world storage. - /// + /// /// # Arguments /// * `model` - the model selector. /// * `key` - the model record key. @@ -844,7 +861,7 @@ mod world { } /// Write array layout model record to the world storage. - /// + /// /// # Arguments /// * `model` - the model selector. /// * `key` - the model record key. @@ -894,7 +911,7 @@ mod world { // data: Array, // pending_word: felt252, // pending_word_len: usize, - // } + // } // // That means, the length of data to write from 'values' is: // 1 + len(data) + 1 + 1 = len(data) + 3 @@ -914,7 +931,7 @@ mod world { } /// Write struct layout model record to the world storage. - /// + /// /// # Arguments /// * `model` - the model selector. /// * `key` - the model record key. @@ -944,7 +961,7 @@ mod world { } /// Write tuple layout model record to the world storage. - /// + /// /// # Arguments /// * `model` - the model selector. /// * `key` - the model record key. @@ -1018,7 +1035,7 @@ mod world { // data: Array, // pending_word: felt252, // pending_word_len: usize, - // } + // } // // So, just set the 3 first values to 0 (len(data), pending_world and pending_word_len) @@ -1185,7 +1202,7 @@ mod world { // data: Array, // pending_word: felt252, // pending_word_len: usize, - // } + // } // // So, read the length of data and compute the full size to read diff --git a/crates/dojo-core/src/world_test.cairo b/crates/dojo-core/src/world_test.cairo index 7cf10a7010..5106cba9a4 100644 --- a/crates/dojo-core/src/world_test.cairo +++ b/crates/dojo-core/src/world_test.cairo @@ -819,6 +819,7 @@ fn test_program_hash_event_emit() { Option::Some(ProgramHashUpdate { program_hash: 98758347158781475198374598718743 }) ); } + #[test] #[available_gas(6000000)] fn test_facts_registry_event_emit() { @@ -833,6 +834,29 @@ fn test_facts_registry_event_emit() { Option::Some(FactsRegistryUpdate { address: contract_address_const::<0x12>() }) ); } + +#[starknet::interface] +trait IDojoInit { + fn dojo_init(self: @ContractState) -> felt252; +} + +#[dojo::contract] +mod test_contract {} + +#[test] +#[available_gas(6000000)] +#[should_panic(expected: ('Only world can init', 'ENTRYPOINT_FAILED'))] +fn test_can_call_init() { + let world = deploy_world(); + let address = world + .deploy_contract( + 'salt1', test_contract::TEST_CLASS_HASH.try_into().unwrap(), array![].span() + ); + + let dojo_init = IDojoInitDispatcher { contract_address: address }; + dojo_init.dojo_init(); +} + #[test] fn test_set_entity_with_fixed_layout() { let world = deploy_world(); diff --git a/crates/dojo-lang/src/contract.rs b/crates/dojo-lang/src/contract.rs index 570d7606cf..fac9667ba0 100644 --- a/crates/dojo-lang/src/contract.rs +++ b/crates/dojo-lang/src/contract.rs @@ -17,6 +17,7 @@ use dojo_types::system::Dependency; use crate::plugin::{DojoAuxData, SystemAuxData, DOJO_CONTRACT_ATTR}; const ALLOW_REF_SELF_ARG: &str = "allow_ref_self"; +const DOJO_INIT_FN: &str = "dojo_init"; pub struct DojoContract { diagnostics: Vec, @@ -36,6 +37,7 @@ impl DojoContract { DojoContract { diagnostics: vec![], dependencies: HashMap::new(), do_allow_ref_self }; let mut has_event = false; let mut has_storage = false; + let mut has_init = false; if let MaybeModuleBody::Some(body) = module_ast.body(db) { let mut body_nodes: Vec<_> = body @@ -60,12 +62,44 @@ impl DojoContract { if trait_path.contains("") { return system.rewrite_impl(db, impl_ast.clone()); } + } else if let ast::ModuleItem::FreeFunction(fn_ast) = el { + let fn_decl = fn_ast.declaration(db); + let fn_name = fn_decl.name(db).text(db); + + if fn_name == DOJO_INIT_FN { + has_init = true; + return system.handle_init_fn(db, fn_ast); + } } vec![RewriteNode::Copied(el.as_syntax_node())] }) .collect(); + if !has_init { + let node = RewriteNode::interpolate_patched( + " + #[starknet::interface] + trait IDojoInit { + fn $init_name$(self: @ContractState); + } + + #[abi(embed_v0)] + impl IDojoInitImpl of IDojoInit { + fn $init_name$(self: @ContractState) { + assert(starknet::get_caller_address() == \ + self.world().contract_address, 'Only world can init'); + } + } + ", + &UnorderedHashMap::from([( + "init_name".to_string(), + RewriteNode::Text(DOJO_INIT_FN.to_string()), + )]), + ); + body_nodes.append(&mut vec![node]); + } + if !has_event { body_nodes.append(&mut system.create_event()) } @@ -84,8 +118,8 @@ impl DojoContract { use dojo::world::IWorldDispatcherTrait; use dojo::world::IWorldProvider; use dojo::world::IDojoResourceProvider; - - + + component!(path: dojo::components::upgradeable::upgradeable, storage: \ upgradeable, event: UpgradeableEvent); @@ -140,6 +174,55 @@ impl DojoContract { PluginResult::default() } + fn handle_init_fn( + &mut self, + db: &dyn SyntaxGroup, + fn_ast: &ast::FunctionWithBody, + ) -> Vec { + let fn_decl = fn_ast.declaration(db); + let fn_name = fn_decl.name(db).text(db); + + let (params_str, _, world_removed) = self.rewrite_parameters( + db, + fn_decl.signature(db).parameters(db), + fn_ast.stable_ptr().untyped(), + ); + + let mut world_read = ""; + if world_removed { + world_read = "let world = self.world_dispatcher.read();"; + } + + let body = fn_ast.body(db).as_syntax_node().get_text(db); + + let node = RewriteNode::interpolate_patched( + " + #[starknet::interface] + trait IDojoInit { + fn $name$($params_str$); + } + + #[abi(embed_v0)] + impl IDojoInitImpl of IDojoInit { + fn $name$($params_str$) { + $world_read$ + assert(starknet::get_caller_address() == self.world().contract_address, \ + 'Only world can init'); + $body$ + } + } + ", + &UnorderedHashMap::from([ + ("name".to_string(), RewriteNode::Text(fn_name.to_string())), + ("params_str".to_string(), RewriteNode::Text(params_str)), + ("body".to_string(), RewriteNode::Text(body)), + ("world_read".to_string(), RewriteNode::Text(world_read.to_string())), + ]), + ); + + vec![node] + } + pub fn merge_event( &mut self, db: &dyn SyntaxGroup, diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/abis/base/dojo_world_world.json b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/abis/base/dojo_world_world.json index d800e7d191..63207ddec9 100644 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/abis/base/dojo_world_world.json +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/abis/base/dojo_world_world.json @@ -205,6 +205,10 @@ { "name": "class_hash", "type": "core::starknet::class_hash::ClassHash" + }, + { + "name": "init_calldata", + "type": "core::array::Span::" } ], "outputs": [ diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/contracts/compiler_cairo_cairo_24_cairo_v240.toml b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/contracts/compiler_cairo_cairo_24_cairo_v240.toml index a62805594e..d253e1bd66 100644 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/contracts/compiler_cairo_cairo_24_cairo_v240.toml +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/contracts/compiler_cairo_cairo_24_cairo_v240.toml @@ -6,4 +6,5 @@ abi = "manifests/dev/abis/base/contracts/compiler_cairo_cairo_24_cairo_v240.json reads = [] writes = [] computed = [] +init_calldata = [] name = "compiler_cairo::cairo_24::cairo_v240" diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/contracts/compiler_cairo_cairo_26_cairo_v260.toml b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/contracts/compiler_cairo_cairo_26_cairo_v260.toml index e4f5304c0d..4ac01d6fdb 100644 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/contracts/compiler_cairo_cairo_26_cairo_v260.toml +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/contracts/compiler_cairo_cairo_26_cairo_v260.toml @@ -6,4 +6,5 @@ abi = "manifests/dev/abis/base/contracts/compiler_cairo_cairo_26_cairo_v260.json reads = [] writes = [] computed = [] +init_calldata = [] name = "compiler_cairo::cairo_26::cairo_v260" diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo_world_world.toml b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo_world_world.toml index 5a021e2793..efc6f0ca39 100644 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo_world_world.toml +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo_world_world.toml @@ -1,5 +1,5 @@ kind = "Class" -class_hash = "0x64728e0c0713811c751930f8d3292d683c23f107c89b0a101425d9e80adb1c0" -original_class_hash = "0x64728e0c0713811c751930f8d3292d683c23f107c89b0a101425d9e80adb1c0" +class_hash = "0x34aafe3ca8fd1aec61deea58541aefd0ec6647299939ad96e4cd3a79c47bb8e" +original_class_hash = "0x34aafe3ca8fd1aec61deea58541aefd0ec6647299939ad96e4cd3a79c47bb8e" abi = "manifests/dev/abis/base/dojo_world_world.json" name = "dojo::world::world" diff --git a/crates/dojo-lang/src/plugin.rs b/crates/dojo-lang/src/plugin.rs index 0be64f4c6e..fdd7d28419 100644 --- a/crates/dojo-lang/src/plugin.rs +++ b/crates/dojo-lang/src/plugin.rs @@ -514,9 +514,9 @@ impl MacroPlugin for BuiltinDojoPlugin { DOJO_INTERFACE_ATTR.to_string(), DOJO_CONTRACT_ATTR.to_string(), DOJO_EVENT_ATTR.to_string(), + DOJO_MODEL_ATTR.to_string(), "key".to_string(), "computed".to_string(), - DOJO_MODEL_ATTR.to_string(), ] } } diff --git a/crates/dojo-lang/src/plugin_test_data/system b/crates/dojo-lang/src/plugin_test_data/system index 7b55dc83b5..c23d1a35a0 100644 --- a/crates/dojo-lang/src/plugin_test_data/system +++ b/crates/dojo-lang/src/plugin_test_data/system @@ -202,6 +202,26 @@ mod MyNominalContract { } } +#[dojo::contract] +mod init_test { + fn dojo_init( + world: IWorldDispatcher, + actions_address: ContractAddress, + actions_class: ClassHash, + value: u8 + ) { + emit!( + world, + ContractInitialized { + contract_address: actions_address, contract_class: actions_class, value + } + ); + } +} + +#[dojo::contract] +mod no_init_test {} + //! > generated_cairo_code #[starknet::contract] mod spawn { @@ -407,6 +427,16 @@ error: Unsupported attribute. #[dojo::contract] ^***************^ +error: Unsupported attribute. + --> test_src/lib.cairo:199:1 +#[dojo::contract] +^***************^ + +error: Unsupported attribute. + --> test_src/lib.cairo:216:1 +#[dojo::contract] +^***************^ + error: Unsupported attribute. --> test_src/lib.cairo:44:5 #[storage] @@ -452,6 +482,11 @@ error: Unsupported attribute. #[dojo::contract] ^***************^ +error: Unsupported attribute. + --> test_src/lib.cairo:1:1 +#[dojo::contract] +^***************^ + error: Unknown inline item macro: 'component'. --> test_src/lib.cairo:11:1 #[dojo::contract] @@ -487,6 +522,11 @@ error: Unsupported attribute. #[dojo::contract] ^***************^ +error: Unsupported attribute. + --> test_src/lib.cairo:11:1 +#[dojo::contract] +^***************^ + error: Unknown inline item macro: 'component'. --> test_src/lib.cairo:18:1 #[dojo::contract] @@ -522,6 +562,11 @@ error: Unsupported attribute. #[dojo::contract] ^***************^ +error: Unsupported attribute. + --> test_src/lib.cairo:18:1 +#[dojo::contract] +^***************^ + error: Unknown inline item macro: 'component'. --> test_src/lib.cairo:28:1 #[dojo::contract] @@ -557,6 +602,11 @@ error: Unsupported attribute. #[dojo::contract] ^***************^ +error: Unsupported attribute. + --> test_src/lib.cairo:28:1 +#[dojo::contract] +^***************^ + error: Unknown inline item macro: 'component'. --> test_src/lib.cairo:54:1 #[dojo::contract] @@ -617,6 +667,11 @@ error: Unsupported attribute. #[dojo::contract] ^***************^ +error: Unsupported attribute. + --> test_src/lib.cairo:54:1 +#[dojo::contract] +^***************^ + error: Unknown inline item macro: 'component'. --> test_src/lib.cairo:93:1 #[dojo::contract(allow_ref_self)] @@ -657,6 +712,11 @@ error: Unsupported attribute. #[dojo::contract(allow_ref_self)] ^*******************************^ +error: Unsupported attribute. + --> test_src/lib.cairo:93:1 +#[dojo::contract(allow_ref_self)] +^*******************************^ + error: Unknown inline item macro: 'component'. --> test_src/lib.cairo:126:1 #[dojo::contract] @@ -697,6 +757,11 @@ error: Unsupported attribute. #[dojo::contract] ^***************^ +error: Unsupported attribute. + --> test_src/lib.cairo:126:1 +#[dojo::contract] +^***************^ + error: Unknown inline item macro: 'component'. --> test_src/lib.cairo:162:1 #[dojo::contract] @@ -737,6 +802,91 @@ error: Unsupported attribute. #[dojo::contract] ^***************^ +error: Unsupported attribute. + --> test_src/lib.cairo:162:1 +#[dojo::contract] +^***************^ + +error: Unknown inline item macro: 'component'. + --> test_src/lib.cairo:199:1 +#[dojo::contract] +^***************^ + +error: Unsupported attribute. + --> test_src/lib.cairo:199:1 +#[dojo::contract] +^***************^ + +error: Unsupported attribute. + --> test_src/lib.cairo:199:1 +#[dojo::contract] +^***************^ + +error: Unsupported attribute. + --> test_src/lib.cairo:199:1 +#[dojo::contract] +^***************^ + +error: Unsupported attribute. + --> test_src/lib.cairo:199:1 +#[dojo::contract] +^***************^ + +error: Unsupported attribute. + --> test_src/lib.cairo:199:1 +#[dojo::contract] +^***************^ + +error: Unsupported attribute. + --> test_src/lib.cairo:199:1 +#[dojo::contract] +^***************^ + +error: Unsupported attribute. + --> test_src/lib.cairo:199:1 +#[dojo::contract] +^***************^ + +error: Unknown inline item macro: 'component'. + --> test_src/lib.cairo:216:1 +#[dojo::contract] +^***************^ + +error: Unsupported attribute. + --> test_src/lib.cairo:216:1 +#[dojo::contract] +^***************^ + +error: Unsupported attribute. + --> test_src/lib.cairo:216:1 +#[dojo::contract] +^***************^ + +error: Unsupported attribute. + --> test_src/lib.cairo:216:1 +#[dojo::contract] +^***************^ + +error: Unsupported attribute. + --> test_src/lib.cairo:216:1 +#[dojo::contract] +^***************^ + +error: Unsupported attribute. + --> test_src/lib.cairo:216:1 +#[dojo::contract] +^***************^ + +error: Unsupported attribute. + --> test_src/lib.cairo:216:1 +#[dojo::contract] +^***************^ + +error: Unsupported attribute. + --> test_src/lib.cairo:216:1 +#[dojo::contract] +^***************^ + //! > expanded_cairo_code #[starknet::component] @@ -788,6 +938,18 @@ trait IAllowedRefSelf { return (); } + #[starknet::interface] + trait IDojoInit { + fn dojo_init(self: @ContractState); + } + + #[abi(embed_v0)] + impl IDojoInitImpl of IDojoInit { + fn dojo_init(self: @ContractState) { + assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); + } + } + #[event] #[derive(Drop, starknet::Event)] enum Event { @@ -833,6 +995,18 @@ impl EventDrop of core::traits::Drop::; value } + #[starknet::interface] + trait IDojoInit { + fn dojo_init(self: @ContractState); + } + + #[abi(embed_v0)] + impl IDojoInitImpl of IDojoInit { + fn dojo_init(self: @ContractState) { + assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); + } + } + #[event] #[derive(Drop, starknet::Event)] enum Event { @@ -881,6 +1055,18 @@ impl EventDrop of core::traits::Drop::; return (); } + #[starknet::interface] + trait IDojoInit { + fn dojo_init(self: @ContractState); + } + + #[abi(embed_v0)] + impl IDojoInitImpl of IDojoInit { + fn dojo_init(self: @ContractState) { + assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); + } + } + #[event] #[derive(Drop, starknet::Event)] enum Event { @@ -935,6 +1121,18 @@ impl EventDrop of core::traits::Drop::; address: ContractAddress, } + #[starknet::interface] + trait IDojoInit { + fn dojo_init(self: @ContractState); + } + + #[abi(embed_v0)] + impl IDojoInitImpl of IDojoInit { + fn dojo_init(self: @ContractState) { + assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); + } + } + #[storage] struct Storage { world_dispatcher: IWorldDispatcher, @@ -990,8 +1188,20 @@ impl TestEventDrop of core::traits::Drop::; testcomponent1_event: testcomponent1::Event, testcomponent2_event: testcomponent2::Event } -impl EventDrop of core::traits::Drop::; + #[starknet::interface] + trait IDojoInit { + fn dojo_init(self: @ContractState); + } + + #[abi(embed_v0)] + impl IDojoInitImpl of IDojoInit { + fn dojo_init(self: @ContractState) { + assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); + } + } +impl EventDrop of core::traits::Drop::; + } #[starknet::interface] @@ -1037,6 +1247,18 @@ impl EventDrop of core::traits::Drop::; fn spawn(ref self: ContractState) {} } + #[starknet::interface] + trait IDojoInit { + fn dojo_init(self: @ContractState); + } + + #[abi(embed_v0)] + impl IDojoInitImpl of IDojoInit { + fn dojo_init(self: @ContractState) { + assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); + } + } + #[event] #[derive(Drop, starknet::Event)] enum Event { @@ -1138,6 +1360,18 @@ self: @ContractState, world: IWorldDispatcher, vec: Vec2, another_wo } } + #[starknet::interface] + trait IDojoInit { + fn dojo_init(self: @ContractState); + } + + #[abi(embed_v0)] + impl IDojoInitImpl of IDojoInit { + fn dojo_init(self: @ContractState) { + assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); + } + } + #[event] #[derive(Drop, starknet::Event)] enum Event { @@ -1215,6 +1449,18 @@ let world = self.world_dispatcher.read(); } } + #[starknet::interface] + trait IDojoInit { + fn dojo_init(self: @ContractState); + } + + #[abi(embed_v0)] + impl IDojoInitImpl of IDojoInit { + fn dojo_init(self: @ContractState) { + assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); + } + } + #[event] #[derive(Drop, starknet::Event)] enum Event { @@ -1234,3 +1480,123 @@ impl ActionDrop of core::traits::Drop::; impl EventDrop of core::traits::Drop::; } + + #[starknet::contract] + mod init_test { + use dojo::world; + use dojo::world::IWorldDispatcher; + use dojo::world::IWorldDispatcherTrait; + use dojo::world::IWorldProvider; + use dojo::world::IDojoResourceProvider; + + #[abi(embed_v0)] + impl DojoResourceProviderImpl of IDojoResourceProvider { + fn dojo_resource(self: @ContractState) -> felt252 { + 'init_test' + } + } + + #[abi(embed_v0)] + impl WorldProviderImpl of IWorldProvider { + fn world(self: @ContractState) -> IWorldDispatcher { + self.world_dispatcher.read() + } + } + + #[abi(embed_v0)] + impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; + + + #[starknet::interface] + trait IDojoInit { + fn dojo_init(self: @ContractState, actions_address: ContractAddress, actions_class: ClassHash, value: u8 +); + } + + #[abi(embed_v0)] + impl IDojoInitImpl of IDojoInit { + fn dojo_init(self: @ContractState, actions_address: ContractAddress, actions_class: ClassHash, value: u8 +) { + let world = self.world_dispatcher.read(); + assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); + { + emit!( + world, + ContractInitialized { + contract_address: actions_address, contract_class: actions_class, value + } + ); + } + + } + } + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, + } + + #[storage] + struct Storage { + world_dispatcher: IWorldDispatcher, + #[substorage(v0)] + upgradeable: dojo::components::upgradeable::upgradeable::Storage, + } +impl EventDrop of core::traits::Drop::; + + } + + #[starknet::contract] + mod no_init_test { + use dojo::world; + use dojo::world::IWorldDispatcher; + use dojo::world::IWorldDispatcherTrait; + use dojo::world::IWorldProvider; + use dojo::world::IDojoResourceProvider; + + #[abi(embed_v0)] + impl DojoResourceProviderImpl of IDojoResourceProvider { + fn dojo_resource(self: @ContractState) -> felt252 { + 'no_init_test' + } + } + + #[abi(embed_v0)] + impl WorldProviderImpl of IWorldProvider { + fn world(self: @ContractState) -> IWorldDispatcher { + self.world_dispatcher.read() + } + } + + #[abi(embed_v0)] + impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; + + + #[starknet::interface] + trait IDojoInit { + fn dojo_init(self: @ContractState); + } + + #[abi(embed_v0)] + impl IDojoInitImpl of IDojoInit { + fn dojo_init(self: @ContractState) { + assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); + } + } + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, + } + + #[storage] + struct Storage { + world_dispatcher: IWorldDispatcher, + #[substorage(v0)] + upgradeable: dojo::components::upgradeable::upgradeable::Storage, + } +impl EventDrop of core::traits::Drop::; + + } diff --git a/crates/dojo-test-utils/src/compiler.rs b/crates/dojo-test-utils/src/compiler.rs index c5c3e5a7f1..b8d30c5775 100644 --- a/crates/dojo-test-utils/src/compiler.rs +++ b/crates/dojo-test-utils/src/compiler.rs @@ -58,7 +58,8 @@ pub fn copy_build_project_temp( let temp_project_path = temp_project_dir.join("Scarb").with_extension("toml").to_string(); let dojo_core_path = Utf8PathBuf::from(dojo_core_path); - let ignore_dirs = ["manifests", "target"]; + // we don't ignore `manifests` because `overylays` are required for successful migration + let ignore_dirs = ["target"]; copy_project_temp(&source_project_dir, &temp_project_dir, &dojo_core_path, &ignore_dirs) .unwrap(); diff --git a/crates/dojo-test-utils/src/migration.rs b/crates/dojo-test-utils/src/migration.rs index fbf52d5e1c..7ad6f25843 100644 --- a/crates/dojo-test-utils/src/migration.rs +++ b/crates/dojo-test-utils/src/migration.rs @@ -15,12 +15,20 @@ pub fn prepare_migration( // In testing, profile name is always dev. let profile_name = "dev"; - let manifest = BaseManifest::load_from_path( + let mut manifest = BaseManifest::load_from_path( &manifest_dir.join(MANIFESTS_DIR).join(profile_name).join(BASE_DIR), ) .unwrap(); - let world = WorldDiff::compute(manifest, None); + let overlay_manifest = OverlayManifest::load_from_path( + &manifest_dir.join(MANIFESTS_DIR).join(profile_name).join(OVERLAYS_DIR), + ) + .unwrap(); + + manifest.merge(overlay_manifest); + + let mut world = WorldDiff::compute(manifest, None); + world.update_order().unwrap(); prepare_for_migration(None, felt!("0x12345"), &target_dir, world) } @@ -46,7 +54,8 @@ pub fn prepare_migration_with_world_and_seed( manifest.merge(overlay_manifest); - let world = WorldDiff::compute(manifest, None); + let mut world = WorldDiff::compute(manifest, None); + world.update_order().unwrap(); let seed = cairo_short_string_to_felt(seed).unwrap(); prepare_for_migration(world_address, seed, &target_dir, world) diff --git a/crates/dojo-world/Cargo.toml b/crates/dojo-world/Cargo.toml index afc946495a..8504077caa 100644 --- a/crates/dojo-world/Cargo.toml +++ b/crates/dojo-world/Cargo.toml @@ -23,6 +23,7 @@ smol_str.workspace = true starknet-crypto.workspace = true starknet.workspace = true thiserror.workspace = true +topological-sort.workspace = true tracing.workspace = true cainome.workspace = true diff --git a/crates/dojo-world/src/contracts/abi/world.rs b/crates/dojo-world/src/contracts/abi/world.rs index 7e23eee81f..e2958635f1 100644 --- a/crates/dojo-world/src/contracts/abi/world.rs +++ b/crates/dojo-world/src/contracts/abi/world.rs @@ -211,6 +211,10 @@ abigen!( { "name": "class_hash", "type": "core::starknet::class_hash::ClassHash" + }, + { + "name": "init_calldata", + "type": "core::array::Span::" } ], "outputs": [ diff --git a/crates/dojo-world/src/contracts/world_test.rs b/crates/dojo-world/src/contracts/world_test.rs index 3c5afe8886..b96f25476b 100644 --- a/crates/dojo-world/src/contracts/world_test.rs +++ b/crates/dojo-world/src/contracts/world_test.rs @@ -1,14 +1,14 @@ use std::time::Duration; use camino::Utf8PathBuf; -use dojo_lang::compiler::{BASE_DIR, MANIFESTS_DIR}; +use dojo_lang::compiler::{BASE_DIR, MANIFESTS_DIR, OVERLAYS_DIR}; use dojo_test_utils::compiler; use katana_runner::KatanaRunner; use starknet::accounts::{Account, ConnectedAccount}; use starknet::core::types::FieldElement; use super::{WorldContract, WorldContractReader}; -use crate::manifest::BaseManifest; +use crate::manifest::{BaseManifest, OverlayManifest}; use crate::migration::strategy::prepare_for_migration; use crate::migration::world::WorldDiff; use crate::migration::{Declarable, Deployable, TxnConfig}; @@ -40,20 +40,31 @@ pub async fn deploy_world( // Dev profile is used by default for testing: let profile_name = "dev"; - let manifest = BaseManifest::load_from_path( + let mut manifest = BaseManifest::load_from_path( &manifest_dir.join(MANIFESTS_DIR).join(profile_name).join(BASE_DIR), ) .unwrap(); - let world = WorldDiff::compute(manifest.clone(), None); + + let overlay_manifest = OverlayManifest::load_from_path( + &manifest_dir.join(MANIFESTS_DIR).join(profile_name).join(OVERLAYS_DIR), + ) + .unwrap(); + + manifest.merge(overlay_manifest); + + let mut world = WorldDiff::compute(manifest.clone(), None); + world.update_order().unwrap(); + let account = sequencer.account(0); - let strategy = prepare_for_migration( + let mut strategy = prepare_for_migration( None, FieldElement::from_hex_be("0x12345").unwrap(), target_dir, world, ) .unwrap(); + strategy.resolve_variable(strategy.world_address().unwrap()).unwrap(); let base_class_hash = strategy.base.unwrap().declare(&account, &TxnConfig::default()).await.unwrap().class_hash; @@ -104,6 +115,7 @@ pub async fn deploy_world( base_class_hash, &account, &TxnConfig::default(), + &contract.diff.init_calldata, ) .await .unwrap(); diff --git a/crates/dojo-world/src/manifest/manifest_test.rs b/crates/dojo-world/src/manifest/manifest_test.rs index 33f09297b6..bc92e1a4f8 100644 --- a/crates/dojo-world/src/manifest/manifest_test.rs +++ b/crates/dojo-world/src/manifest/manifest_test.rs @@ -2,7 +2,7 @@ use std::io::Write; use cainome::cairo_serde::{ByteArray, CairoSerde}; use camino::Utf8PathBuf; -use dojo_lang::compiler::{BASE_DIR, MANIFESTS_DIR}; +use dojo_lang::compiler::{BASE_DIR, MANIFESTS_DIR, OVERLAYS_DIR}; use dojo_test_utils::compiler; use dojo_test_utils::rpc::MockJsonRpcTransport; use katana_runner::KatanaRunner; @@ -13,7 +13,9 @@ use starknet::core::types::{EmittedEvent, FieldElement}; use starknet::macros::{felt, selector}; use starknet::providers::jsonrpc::{JsonRpcClient, JsonRpcMethod}; -use super::{parse_contracts_events, AbiFormat, BaseManifest, DojoContract, DojoModel}; +use super::{ + parse_contracts_events, AbiFormat, BaseManifest, DojoContract, DojoModel, OverlayManifest, +}; use crate::contracts::world::test::deploy_world; use crate::manifest::{parse_models_events, AbstractManifestError, DeploymentManifest, Manifest}; use crate::migration::world::WorldDiff; @@ -382,20 +384,27 @@ fn fetch_remote_manifest() { .tokio_handle() .block_on(async { deploy_world(&runner, &temp_project_dir, &artifacts_path).await }); - let local_manifest = BaseManifest::load_from_path( + let mut local_manifest = BaseManifest::load_from_path( &temp_project_dir.join(MANIFESTS_DIR).join(profile_name).join(BASE_DIR), ) .unwrap(); + let overlay_manifest = OverlayManifest::load_from_path( + &temp_project_dir.join(MANIFESTS_DIR).join(profile_name).join(OVERLAYS_DIR), + ) + .unwrap(); + + local_manifest.merge(overlay_manifest); + let remote_manifest = config.tokio_handle().block_on(async { DeploymentManifest::load_from_remote(provider, world_address).await.unwrap() }); - assert_eq!(local_manifest.models.len(), 5); - assert_eq!(local_manifest.contracts.len(), 1); + assert_eq!(local_manifest.models.len(), 6); + assert_eq!(local_manifest.contracts.len(), 2); - assert_eq!(remote_manifest.models.len(), 5); - assert_eq!(remote_manifest.contracts.len(), 1); + assert_eq!(remote_manifest.models.len(), 6); + assert_eq!(remote_manifest.contracts.len(), 2); // compute diff from local and remote manifest diff --git a/crates/dojo-world/src/manifest/mod.rs b/crates/dojo-world/src/manifest/mod.rs index 04fc8624aa..d3aa32877a 100644 --- a/crates/dojo-world/src/manifest/mod.rs +++ b/crates/dojo-world/src/manifest/mod.rs @@ -579,6 +579,9 @@ impl ManifestMethods for DojoContract { if let Some(writes) = old.writes { self.writes = writes; } + if let Some(init_calldata) = old.init_calldata { + self.init_calldata = init_calldata; + } } } diff --git a/crates/dojo-world/src/manifest/types.rs b/crates/dojo-world/src/manifest/types.rs index afc6f13406..dbbee2fd58 100644 --- a/crates/dojo-world/src/manifest/types.rs +++ b/crates/dojo-world/src/manifest/types.rs @@ -94,9 +94,14 @@ pub struct DojoContract { #[serde_as(as = "UfeHex")] pub base_class_hash: FieldElement, pub abi: Option, + #[serde(default)] pub reads: Vec, + #[serde(default)] pub writes: Vec, + #[serde(default)] pub computed: Vec, + #[serde(default)] + pub init_calldata: Vec, } /// Represents a declaration of a model. @@ -152,6 +157,7 @@ pub struct OverlayDojoContract { pub original_class_hash: Option, pub reads: Option>, pub writes: Option>, + pub init_calldata: Option>, } #[serde_as] diff --git a/crates/dojo-world/src/metadata_test.rs b/crates/dojo-world/src/metadata_test.rs index 1245313aa9..eeaf797188 100644 --- a/crates/dojo-world/src/metadata_test.rs +++ b/crates/dojo-world/src/metadata_test.rs @@ -148,7 +148,7 @@ async fn get_full_dojo_metadata_from_workspace() { assert!( env.world_address .unwrap() - .eq("0x1c958955aedbc7b8e2f051767d3369168e88bc5074b0f39e5f8cd2539138281") + .eq("0x29aea29955b6b0c0aabf92e265cd0bca14069575511ec9b6819ca2917277962") ); assert!(env.keystore_path.is_none()); @@ -175,6 +175,7 @@ async fn get_full_dojo_metadata_from_workspace() { let artifacts = get_artifacts_from_manifest(&manifest_dir); + dbg!(&artifacts); for (abi_subdir, name) in artifacts { let artifact = dojo_metadata.artifacts.get(&name); assert!(artifact.is_some(), "bad artifact for {}", name); @@ -224,6 +225,9 @@ fn get_artifacts_from_manifest(manifest_dir: &Utf8PathBuf) -> Vec<(String, Strin // Some models are inside actions, we need a better way to gather those. let name = name.replace("_actions_", "::actions::"); let name = name.replace("::actions_", "::actions::"); + + let name = name.replace("_others_", "::others::"); + let name = name.replace("::others_", "::others::"); artifacts.push(("models".to_string(), name)); } @@ -231,6 +235,7 @@ fn get_artifacts_from_manifest(manifest_dir: &Utf8PathBuf) -> Vec<(String, Strin for entry in fs::read_dir(contracts_dir).unwrap().flatten() { let name = entry.path().file_stem().unwrap().to_string_lossy().to_string(); let name = name.replace("_actions_", "::actions::"); + let name = name.replace("_others_", "::others::"); artifacts.push(("contracts".to_string(), name)); } diff --git a/crates/dojo-world/src/migration/class.rs b/crates/dojo-world/src/migration/class.rs index 7f2376694f..e5b29f16d9 100644 --- a/crates/dojo-world/src/migration/class.rs +++ b/crates/dojo-world/src/migration/class.rs @@ -38,7 +38,7 @@ impl Display for ClassDiff { } } -#[derive(Debug, Default)] +#[derive(Debug, Default, Clone)] pub struct ClassMigration { pub diff: ClassDiff, pub artifact_path: PathBuf, diff --git a/crates/dojo-world/src/migration/contract.rs b/crates/dojo-world/src/migration/contract.rs index 166fbfbed8..59e6c929f9 100644 --- a/crates/dojo-world/src/migration/contract.rs +++ b/crates/dojo-world/src/migration/contract.rs @@ -16,6 +16,7 @@ pub struct ContractDiff { pub original_class_hash: FieldElement, pub base_class_hash: FieldElement, pub remote_class_hash: Option, + pub init_calldata: Vec, } impl StateDiff for ContractDiff { @@ -44,7 +45,7 @@ impl Display for ContractDiff { } // Represents a contract that needs to be migrated to the remote state -#[derive(Debug, Default)] +#[derive(Debug, Default, Clone)] pub struct ContractMigration { pub salt: FieldElement, pub diff: ContractDiff, diff --git a/crates/dojo-world/src/migration/mod.rs b/crates/dojo-world/src/migration/mod.rs index eb83aa4b62..4f6b306bad 100644 --- a/crates/dojo-world/src/migration/mod.rs +++ b/crates/dojo-world/src/migration/mod.rs @@ -1,5 +1,6 @@ use std::fs::File; use std::path::PathBuf; +use std::str::FromStr; use std::sync::Arc; use anyhow::{anyhow, Result}; @@ -72,6 +73,8 @@ pub enum MigrationError { WaitingError(#[from] TransactionWaitingError), #[error(transparent)] ArtifactError(#[from] anyhow::Error), + #[error("Bad init calldata.")] + BadInitCalldata, } /// Represents the type of migration that should be performed. @@ -172,6 +175,7 @@ pub trait Deployable: Declarable + Sync { base_class_hash: FieldElement, account: &SingleOwnerAccount, txn_config: &TxnConfig, + calldata: &[String], ) -> Result as Account>::SignError>> where P: Provider + Sync + Send, @@ -203,11 +207,18 @@ pub trait Deployable: Declarable + Sync { } } - Err(ProviderError::StarknetError(StarknetError::ContractNotFound)) => Call { - calldata: vec![self.salt(), class_hash], - selector: selector!("deploy_contract"), - to: world_address, - }, + Err(ProviderError::StarknetError(StarknetError::ContractNotFound)) => { + let init_calldata: Vec = calldata + .iter() + .map(|s| FieldElement::from_str(s)) + .collect::, _>>() + .map_err(|_| MigrationError::BadInitCalldata)?; + + let mut calldata = + vec![self.salt(), class_hash, FieldElement::from(calldata.len())]; + calldata.extend(init_calldata); + Call { calldata, selector: selector!("deploy_contract"), to: world_address } + } Ok(_) => { return Err(MigrationError::ContractAlreadyDeployed(contract_address)); diff --git a/crates/dojo-world/src/migration/strategy.rs b/crates/dojo-world/src/migration/strategy.rs index 8dddb832b0..2a1ce96155 100644 --- a/crates/dojo-world/src/migration/strategy.rs +++ b/crates/dojo-world/src/migration/strategy.rs @@ -13,7 +13,7 @@ use super::contract::{ContractDiff, ContractMigration}; use super::world::WorldDiff; use super::MigrationType; -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct MigrationStrategy { pub world_address: Option, pub world: Option, @@ -59,6 +59,31 @@ impl MigrationStrategy { MigrationItemsInfo { new, update } } + + pub fn resolve_variable(&mut self, world_address: FieldElement) -> Result<()> { + let contracts_clone = self.contracts.clone(); + for contract in self.contracts.iter_mut() { + for field in contract.diff.init_calldata.iter_mut() { + if let Some(dependency) = field.strip_prefix("$contract_address:") { + let dependency_contract = + contracts_clone.iter().find(|c| c.diff.name == dependency).unwrap(); + let contract_address = get_contract_address( + generate_salt(&dependency_contract.diff.name), + dependency_contract.diff.base_class_hash, + &[], + world_address, + ); + *field = contract_address.to_string(); + } else if let Some(dependency) = field.strip_prefix("$class_hash:") { + let dependency_contract = + contracts_clone.iter().find(|c| c.diff.name == dependency).unwrap(); + *field = dependency_contract.diff.local_class_hash.to_string(); + } + } + } + + Ok(()) + } } /// construct migration strategy diff --git a/crates/dojo-world/src/migration/world.rs b/crates/dojo-world/src/migration/world.rs index 7fdad6e43d..27adf6c69a 100644 --- a/crates/dojo-world/src/migration/world.rs +++ b/crates/dojo-world/src/migration/world.rs @@ -1,7 +1,11 @@ use std::fmt::Display; +use std::mem; +use std::str::FromStr; +use anyhow::{bail, Result}; use convert_case::{Case, Casing}; use starknet_crypto::FieldElement; +use topological_sort::TopologicalSort; use super::class::ClassDiff; use super::contract::ContractDiff; @@ -74,6 +78,7 @@ impl WorldDiff { .find(|r| r.inner.class_hash() == contract.inner.class_hash()) .map(|r| *r.inner.class_hash()) }), + init_calldata: contract.inner.init_calldata.clone(), } }) .collect::>(); @@ -91,6 +96,7 @@ impl WorldDiff { original_class_hash: *local.world.inner.original_class_hash(), base_class_hash: *local.base.inner.class_hash(), remote_class_hash: remote.map(|m| *m.world.inner.class_hash()), + init_calldata: vec![], }; WorldDiff { world, base, contracts, models } @@ -107,6 +113,63 @@ impl WorldDiff { count += self.contracts.iter().filter(|s| !s.is_same()).count(); count } + + pub fn update_order(&mut self) -> Result<()> { + let mut ts = TopologicalSort::<&str>::new(); + + // make the dependency graph by reading the constructor_calldata + for contract in self.contracts.iter() { + let curr_name: &str = &contract.name; + ts.insert(curr_name); + + for field in &contract.init_calldata { + if let Some(dependency) = field.strip_prefix("$contract_address:") { + ts.add_dependency(dependency, curr_name); + } else if let Some(dependency) = field.strip_prefix("$class_hash:") { + ts.add_dependency(dependency, curr_name); + } else { + // verify its a field element + match FieldElement::from_str(field) { + Ok(_) => continue, + Err(e) => bail!(format!( + "Expected init_calldata element to be a special variable (i.e. \ + starting with $contract_address or $class_hash) or be a \ + FieldElement. Failed with error: {e:?}" + )), + } + } + } + } + + let mut calculated_order = vec![]; + + while !ts.is_empty() { + let mut values = ts.pop_all(); + // if `ts` is not empty and `pop_all` returns an empty vector it means there is a cyclic + // dependency see: https://docs.rs/topological-sort/latest/topological_sort/struct.TopologicalSort.html#method.pop_all + if values.is_empty() { + bail!("Cyclic dependency detected in `init_calldata`"); + } + + values.sort(); + calculated_order.extend(values); + } + + let mut new_contracts = vec![]; + + for c_name in calculated_order { + let contract = match self.contracts.iter().find(|c| c.name == c_name) { + Some(c) => c, + None => bail!("Unidentified contract found in `init_calldata`"), + }; + + new_contracts.push(contract.clone()); + } + + mem::swap(&mut self.contracts, &mut new_contracts); + + Ok(()) + } } impl Display for WorldDiff { diff --git a/crates/dojo-world/src/migration/world_test.rs b/crates/dojo-world/src/migration/world_test.rs index be50a4044c..e84e1b2cec 100644 --- a/crates/dojo-world/src/migration/world_test.rs +++ b/crates/dojo-world/src/migration/world_test.rs @@ -105,3 +105,70 @@ fn diff_when_local_and_remote_are_different() { assert!(diff.models.iter().any(|m| m.name == "dojo_mock::models::model_2")); assert!(diff.contracts.iter().any(|c| c.name == "dojo_mock::contracts::my_contract")); } + +#[test] +fn updating_order_as_expected() { + let init_calldata = vec![ + ("c4", vec!["$contract_address:c1", "0x0"]), + ("c3", vec!["0x0"]), + ("c5", vec!["$contract_address:c4", "0x0"]), + ("c7", vec!["$contract_address:c4", "0x0"]), + ("c2", vec!["0x0"]), + ("c6", vec!["$contract_address:c4", "$contract_address:c3", "0x0"]), + ("c1", vec!["0x0"]), + ]; + + let mut contracts = vec![]; + for calldata in init_calldata { + contracts.push(ContractDiff { + init_calldata: calldata.1.iter().map(|c| c.to_string()).collect(), + name: calldata.0.to_string(), + ..Default::default() + }); + } + + let mut diff = WorldDiff { + world: ContractDiff::default(), + base: ClassDiff::default(), + contracts, + models: vec![], + }; + + diff.update_order().unwrap(); + + let expected_order = ["c1", "c2", "c3", "c4", "c5", "c6", "c7"]; + for (i, contract) in diff.contracts.iter().enumerate() { + assert_eq!(contract.name, expected_order[i]); + } +} + +#[test] +fn updating_order_when_cyclic_dependency_fail() { + let init_calldata = vec![ + ("c4", vec!["$contract_address:c1", "$contract_address:c6", "0x0"]), + ("c3", vec!["0x0"]), + ("c5", vec!["$contract_address:c4", "0x0"]), + ("c7", vec!["$contract_address:c4", "0x0"]), + ("c2", vec!["0x0"]), + ("c6", vec!["$contract_address:c4", "$contract_address:c3", "0x0"]), + ("c1", vec!["0x0"]), + ]; + + let mut contracts = vec![]; + for calldata in init_calldata { + contracts.push(ContractDiff { + init_calldata: calldata.1.iter().map(|c| c.to_string()).collect(), + name: calldata.0.to_string(), + ..Default::default() + }); + } + + let mut diff = WorldDiff { + world: ContractDiff::default(), + base: ClassDiff::default(), + contracts, + models: vec![], + }; + + assert!(diff.update_order().is_err_and(|e| e.to_string().contains("Cyclic"))); +} diff --git a/crates/sozo/ops/src/migration/migrate.rs b/crates/sozo/ops/src/migration/migrate.rs index 70a9eb1c74..044479a5d6 100644 --- a/crates/sozo/ops/src/migration/migrate.rs +++ b/crates/sozo/ops/src/migration/migrate.rs @@ -494,6 +494,7 @@ where contract.diff.base_class_hash, migrator, txn_config, + &contract.diff.init_calldata, ) .await { @@ -541,7 +542,10 @@ where } Err(e) => { ui.verbose(format!("{e:?}")); - return Err(anyhow!("Failed to migrate {name}: {e}")); + return Err(anyhow!( + "Failed to migrate {name}: {e}. Please also verify init calldata is valid, if \ + any." + )); } } } diff --git a/crates/sozo/ops/src/migration/mod.rs b/crates/sozo/ops/src/migration/mod.rs index e998b0fa36..85f58dfa44 100644 --- a/crates/sozo/ops/src/migration/mod.rs +++ b/crates/sozo/ops/src/migration/mod.rs @@ -83,7 +83,9 @@ where // Calculate diff between local and remote World manifests. ui.print_step(2, "🧰", "Evaluating Worlds diff..."); - let diff = WorldDiff::compute(local_manifest.clone(), remote_manifest.clone()); + let mut diff = WorldDiff::compute(local_manifest.clone(), remote_manifest.clone()); + diff.update_order()?; + let total_diffs = diff.count_diffs(); ui.print_sub(format!("Total diffs found: {total_diffs}")); @@ -94,6 +96,7 @@ where let mut strategy = prepare_migration(&target_dir, diff, name, world_address, &ui)?; let world_address = strategy.world_address().expect("world address must exist"); + strategy.resolve_variable(world_address)?; if dry_run { print_strategy(&ui, account.provider(), &strategy, world_address).await; diff --git a/crates/sozo/ops/src/tests/migration.rs b/crates/sozo/ops/src/tests/migration.rs index 45047fe345..708724a4c8 100644 --- a/crates/sozo/ops/src/tests/migration.rs +++ b/crates/sozo/ops/src/tests/migration.rs @@ -217,7 +217,8 @@ async fn migrate_with_auto_authorize() { let config = setup::load_config(); let ws = setup::setup_ws(&config); - let migration = setup::setup_migration(&config).unwrap(); + let mut migration = setup::setup_migration(&config).unwrap(); + migration.resolve_variable(migration.world_address().unwrap()).unwrap(); let manifest_base = config.manifest_path().parent().unwrap(); let mut manifest = diff --git a/crates/torii/core/src/sql_test.rs b/crates/torii/core/src/sql_test.rs index 1b9d0ea9f6..7cc52b506f 100644 --- a/crates/torii/core/src/sql_test.rs +++ b/crates/torii/core/src/sql_test.rs @@ -68,7 +68,8 @@ async fn test_load_from_remote() { let base_dir = manifest_path.parent().unwrap(); let target_dir = format!("{}/target/dev", base_dir); - let migration = prepare_migration(base_dir.into(), target_dir.into()).unwrap(); + let mut migration = prepare_migration(base_dir.into(), target_dir.into()).unwrap(); + migration.resolve_variable(migration.world_address().unwrap()).unwrap(); let sequencer = TestSequencer::start(SequencerConfig::default(), get_default_test_starknet_config()).await; @@ -114,7 +115,7 @@ async fn test_load_from_remote() { let _block_timestamp = 1710754478_u64; let models = sqlx::query("SELECT * FROM models").fetch_all(&pool).await.unwrap(); - assert_eq!(models.len(), 5); + assert_eq!(models.len(), 6); let (id, name, packed_size, unpacked_size): (String, String, u8, u8) = sqlx::query_as( "SELECT id, name, packed_size, unpacked_size FROM models WHERE name = 'Position'", diff --git a/crates/torii/grpc/src/server/tests/entities_test.rs b/crates/torii/grpc/src/server/tests/entities_test.rs index 9c9a871280..4776659558 100644 --- a/crates/torii/grpc/src/server/tests/entities_test.rs +++ b/crates/torii/grpc/src/server/tests/entities_test.rs @@ -36,7 +36,12 @@ async fn test_entities_queries() { sqlx::migrate!("../migrations").run(&pool).await.unwrap(); let base_path = "../../../examples/spawn-and-move"; let target_path = format!("{}/target/dev", base_path); - let migration = prepare_migration(base_path.into(), target_path.into()).unwrap(); + + let mut migration = prepare_migration(base_path.into(), target_path.into()).unwrap(); + migration.resolve_variable(migration.world_address().unwrap()).unwrap(); + + dbg!(&migration); + let sequencer = TestSequencer::start(SequencerConfig::default(), get_default_test_starknet_config()).await; let provider = Arc::new(JsonRpcClient::new(HttpTransport::new(sequencer.url()))); diff --git a/crates/torii/types-test/manifests/dev/base/dojo_world_world.toml b/crates/torii/types-test/manifests/dev/base/dojo_world_world.toml index 5a021e2793..efc6f0ca39 100644 --- a/crates/torii/types-test/manifests/dev/base/dojo_world_world.toml +++ b/crates/torii/types-test/manifests/dev/base/dojo_world_world.toml @@ -1,5 +1,5 @@ kind = "Class" -class_hash = "0x64728e0c0713811c751930f8d3292d683c23f107c89b0a101425d9e80adb1c0" -original_class_hash = "0x64728e0c0713811c751930f8d3292d683c23f107c89b0a101425d9e80adb1c0" +class_hash = "0x34aafe3ca8fd1aec61deea58541aefd0ec6647299939ad96e4cd3a79c47bb8e" +original_class_hash = "0x34aafe3ca8fd1aec61deea58541aefd0ec6647299939ad96e4cd3a79c47bb8e" abi = "manifests/dev/abis/base/dojo_world_world.json" name = "dojo::world::world" diff --git a/examples/spawn-and-move/Scarb.toml b/examples/spawn-and-move/Scarb.toml index 87e2185eb9..93a78fbbd3 100644 --- a/examples/spawn-and-move/Scarb.toml +++ b/examples/spawn-and-move/Scarb.toml @@ -25,4 +25,4 @@ rpc_url = "http://localhost:5050/" # Default account for katana with seed = 0 account_address = "0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03" private_key = "0x1800000000300000180000000000030000000000003006001800006600" -world_address = "0x1c958955aedbc7b8e2f051767d3369168e88bc5074b0f39e5f8cd2539138281" +world_address = "0x29aea29955b6b0c0aabf92e265cd0bca14069575511ec9b6819ca2917277962" diff --git a/examples/spawn-and-move/manifests/dev/abis/base/contracts/dojo_examples_actions_actions.json b/examples/spawn-and-move/manifests/dev/abis/base/contracts/dojo_examples_actions_actions.json index 1e068262bb..21aed968a7 100644 --- a/examples/spawn-and-move/manifests/dev/abis/base/contracts/dojo_examples_actions_actions.json +++ b/examples/spawn-and-move/manifests/dev/abis/base/contracts/dojo_examples_actions_actions.json @@ -210,6 +210,24 @@ } ] }, + { + "type": "impl", + "name": "IDojoInitImpl", + "interface_name": "dojo_examples::actions::actions::IDojoInit" + }, + { + "type": "interface", + "name": "dojo_examples::actions::actions::IDojoInit", + "items": [ + { + "type": "function", + "name": "dojo_init", + "inputs": [], + "outputs": [], + "state_mutability": "view" + } + ] + }, { "type": "impl", "name": "UpgradableImpl", diff --git a/examples/spawn-and-move/manifests/dev/abis/base/contracts/dojo_examples_others_others.json b/examples/spawn-and-move/manifests/dev/abis/base/contracts/dojo_examples_others_others.json new file mode 100644 index 0000000000..36d8c3ef78 --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/abis/base/contracts/dojo_examples_others_others.json @@ -0,0 +1,146 @@ +[ + { + "type": "impl", + "name": "DojoResourceProviderImpl", + "interface_name": "dojo::world::IDojoResourceProvider" + }, + { + "type": "interface", + "name": "dojo::world::IDojoResourceProvider", + "items": [ + { + "type": "function", + "name": "dojo_resource", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "WorldProviderImpl", + "interface_name": "dojo::world::IWorldProvider" + }, + { + "type": "struct", + "name": "dojo::world::IWorldDispatcher", + "members": [ + { + "name": "contract_address", + "type": "core::starknet::contract_address::ContractAddress" + } + ] + }, + { + "type": "interface", + "name": "dojo::world::IWorldProvider", + "items": [ + { + "type": "function", + "name": "world", + "inputs": [], + "outputs": [ + { + "type": "dojo::world::IWorldDispatcher" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "IDojoInitImpl", + "interface_name": "dojo_examples::others::others::IDojoInit" + }, + { + "type": "interface", + "name": "dojo_examples::others::others::IDojoInit", + "items": [ + { + "type": "function", + "name": "dojo_init", + "inputs": [ + { + "name": "actions_address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "actions_class", + "type": "core::starknet::class_hash::ClassHash" + }, + { + "name": "value", + "type": "core::integer::u8" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "UpgradableImpl", + "interface_name": "dojo::components::upgradeable::IUpgradeable" + }, + { + "type": "interface", + "name": "dojo::components::upgradeable::IUpgradeable", + "items": [ + { + "type": "function", + "name": "upgrade", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "event", + "name": "dojo::components::upgradeable::upgradeable::Upgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::components::upgradeable::upgradeable::Event", + "kind": "enum", + "variants": [ + { + "name": "Upgraded", + "type": "dojo::components::upgradeable::upgradeable::Upgraded", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "dojo_examples::others::others::Event", + "kind": "enum", + "variants": [ + { + "name": "UpgradeableEvent", + "type": "dojo::components::upgradeable::upgradeable::Event", + "kind": "nested" + } + ] + } +] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/abis/base/dojo_world_world.json b/examples/spawn-and-move/manifests/dev/abis/base/dojo_world_world.json index d800e7d191..63207ddec9 100644 --- a/examples/spawn-and-move/manifests/dev/abis/base/dojo_world_world.json +++ b/examples/spawn-and-move/manifests/dev/abis/base/dojo_world_world.json @@ -205,6 +205,10 @@ { "name": "class_hash", "type": "core::starknet::class_hash::ClassHash" + }, + { + "name": "init_calldata", + "type": "core::array::Span::" } ], "outputs": [ diff --git a/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_others_others_contract_initialized.json b/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_others_others_contract_initialized.json new file mode 100644 index 0000000000..1dbbd313d8 --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_others_others_contract_initialized.json @@ -0,0 +1,367 @@ +[ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::IModel" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::database::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::database::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::database::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::IModel", + "items": [ + { + "type": "function", + "name": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "version", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u8" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "contract_initializedImpl", + "interface_name": "dojo_examples::others::others::Icontract_initialized" + }, + { + "type": "struct", + "name": "dojo_examples::others::others::ContractInitialized", + "members": [ + { + "name": "contract_address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "contract_class", + "type": "core::starknet::class_hash::ClassHash" + }, + { + "name": "value", + "type": "core::integer::u8" + } + ] + }, + { + "type": "interface", + "name": "dojo_examples::others::others::Icontract_initialized", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "dojo_examples::others::others::ContractInitialized" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "dojo_examples::others::others::contract_initialized::Event", + "kind": "enum", + "variants": [] + } +] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples_actions_actions.json b/examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples_actions_actions.json index 1e068262bb..21aed968a7 100644 --- a/examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples_actions_actions.json +++ b/examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples_actions_actions.json @@ -210,6 +210,24 @@ } ] }, + { + "type": "impl", + "name": "IDojoInitImpl", + "interface_name": "dojo_examples::actions::actions::IDojoInit" + }, + { + "type": "interface", + "name": "dojo_examples::actions::actions::IDojoInit", + "items": [ + { + "type": "function", + "name": "dojo_init", + "inputs": [], + "outputs": [], + "state_mutability": "view" + } + ] + }, { "type": "impl", "name": "UpgradableImpl", diff --git a/examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples_others_others.json b/examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples_others_others.json new file mode 100644 index 0000000000..36d8c3ef78 --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples_others_others.json @@ -0,0 +1,146 @@ +[ + { + "type": "impl", + "name": "DojoResourceProviderImpl", + "interface_name": "dojo::world::IDojoResourceProvider" + }, + { + "type": "interface", + "name": "dojo::world::IDojoResourceProvider", + "items": [ + { + "type": "function", + "name": "dojo_resource", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "WorldProviderImpl", + "interface_name": "dojo::world::IWorldProvider" + }, + { + "type": "struct", + "name": "dojo::world::IWorldDispatcher", + "members": [ + { + "name": "contract_address", + "type": "core::starknet::contract_address::ContractAddress" + } + ] + }, + { + "type": "interface", + "name": "dojo::world::IWorldProvider", + "items": [ + { + "type": "function", + "name": "world", + "inputs": [], + "outputs": [ + { + "type": "dojo::world::IWorldDispatcher" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "IDojoInitImpl", + "interface_name": "dojo_examples::others::others::IDojoInit" + }, + { + "type": "interface", + "name": "dojo_examples::others::others::IDojoInit", + "items": [ + { + "type": "function", + "name": "dojo_init", + "inputs": [ + { + "name": "actions_address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "actions_class", + "type": "core::starknet::class_hash::ClassHash" + }, + { + "name": "value", + "type": "core::integer::u8" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "UpgradableImpl", + "interface_name": "dojo::components::upgradeable::IUpgradeable" + }, + { + "type": "interface", + "name": "dojo::components::upgradeable::IUpgradeable", + "items": [ + { + "type": "function", + "name": "upgrade", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "event", + "name": "dojo::components::upgradeable::upgradeable::Upgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::components::upgradeable::upgradeable::Event", + "kind": "enum", + "variants": [ + { + "name": "Upgraded", + "type": "dojo::components::upgradeable::upgradeable::Upgraded", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "dojo_examples::others::others::Event", + "kind": "enum", + "variants": [ + { + "name": "UpgradeableEvent", + "type": "dojo::components::upgradeable::upgradeable::Event", + "kind": "nested" + } + ] + } +] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/abis/deployments/dojo_world_world.json b/examples/spawn-and-move/manifests/dev/abis/deployments/dojo_world_world.json index d800e7d191..63207ddec9 100644 --- a/examples/spawn-and-move/manifests/dev/abis/deployments/dojo_world_world.json +++ b/examples/spawn-and-move/manifests/dev/abis/deployments/dojo_world_world.json @@ -205,6 +205,10 @@ { "name": "class_hash", "type": "core::starknet::class_hash::ClassHash" + }, + { + "name": "init_calldata", + "type": "core::array::Span::" } ], "outputs": [ diff --git a/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_others_others_contract_initialized.json b/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_others_others_contract_initialized.json new file mode 100644 index 0000000000..1dbbd313d8 --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_others_others_contract_initialized.json @@ -0,0 +1,367 @@ +[ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::IModel" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::database::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::database::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::database::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::IModel", + "items": [ + { + "type": "function", + "name": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "version", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u8" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "contract_initializedImpl", + "interface_name": "dojo_examples::others::others::Icontract_initialized" + }, + { + "type": "struct", + "name": "dojo_examples::others::others::ContractInitialized", + "members": [ + { + "name": "contract_address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "contract_class", + "type": "core::starknet::class_hash::ClassHash" + }, + { + "name": "value", + "type": "core::integer::u8" + } + ] + }, + { + "type": "interface", + "name": "dojo_examples::others::others::Icontract_initialized", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "dojo_examples::others::others::ContractInitialized" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "dojo_examples::others::others::contract_initialized::Event", + "kind": "enum", + "variants": [] + } +] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples_actions_actions.toml b/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples_actions_actions.toml index 1d97364950..17294cff0a 100644 --- a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples_actions_actions.toml +++ b/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples_actions_actions.toml @@ -1,9 +1,10 @@ kind = "DojoContract" -class_hash = "0x5b617d120767e91d40621dd939b092f48975a8fa1c5236ac68f97a4ffaf45b" -original_class_hash = "0x5b617d120767e91d40621dd939b092f48975a8fa1c5236ac68f97a4ffaf45b" +class_hash = "0x44838b88a31f6cf954408395e5d4256d53640ca48a46658d08400ddf11790f5" +original_class_hash = "0x44838b88a31f6cf954408395e5d4256d53640ca48a46658d08400ddf11790f5" base_class_hash = "0x0" abi = "manifests/dev/abis/base/contracts/dojo_examples_actions_actions.json" reads = [] writes = [] computed = [] +init_calldata = [] name = "dojo_examples::actions::actions" diff --git a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples_others_others.toml b/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples_others_others.toml new file mode 100644 index 0000000000..0526bc5473 --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples_others_others.toml @@ -0,0 +1,10 @@ +kind = "DojoContract" +class_hash = "0x3ee016157303a7ce35a9fecdb5b8519159df620c5780527d61443636aaa3c3a" +original_class_hash = "0x3ee016157303a7ce35a9fecdb5b8519159df620c5780527d61443636aaa3c3a" +base_class_hash = "0x0" +abi = "manifests/dev/abis/base/contracts/dojo_examples_others_others.json" +reads = [] +writes = [] +computed = [] +init_calldata = [] +name = "dojo_examples::others::others" diff --git a/examples/spawn-and-move/manifests/dev/base/dojo_world_world.toml b/examples/spawn-and-move/manifests/dev/base/dojo_world_world.toml index 5a021e2793..efc6f0ca39 100644 --- a/examples/spawn-and-move/manifests/dev/base/dojo_world_world.toml +++ b/examples/spawn-and-move/manifests/dev/base/dojo_world_world.toml @@ -1,5 +1,5 @@ kind = "Class" -class_hash = "0x64728e0c0713811c751930f8d3292d683c23f107c89b0a101425d9e80adb1c0" -original_class_hash = "0x64728e0c0713811c751930f8d3292d683c23f107c89b0a101425d9e80adb1c0" +class_hash = "0x34aafe3ca8fd1aec61deea58541aefd0ec6647299939ad96e4cd3a79c47bb8e" +original_class_hash = "0x34aafe3ca8fd1aec61deea58541aefd0ec6647299939ad96e4cd3a79c47bb8e" abi = "manifests/dev/abis/base/dojo_world_world.json" name = "dojo::world::world" diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_others_others_contract_initialized.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_others_others_contract_initialized.toml new file mode 100644 index 0000000000..f267d02139 --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_others_others_contract_initialized.toml @@ -0,0 +1,20 @@ +kind = "DojoModel" +class_hash = "0x6b54d690f4f43e3011fe05fabf3e5f1807b3a026430eb175534336e9a90d5a5" +original_class_hash = "0x6b54d690f4f43e3011fe05fabf3e5f1807b3a026430eb175534336e9a90d5a5" +abi = "manifests/dev/abis/base/models/dojo_examples_others_others_contract_initialized.json" +name = "dojo_examples::others::others::contract_initialized" + +[[members]] +name = "contract_address" +type = "ContractAddress" +key = true + +[[members]] +name = "contract_class" +type = "ClassHash" +key = false + +[[members]] +name = "value" +type = "u8" +key = false diff --git a/examples/spawn-and-move/manifests/dev/manifest.json b/examples/spawn-and-move/manifests/dev/manifest.json index 727658b2bc..90c10bfbc0 100644 --- a/examples/spawn-and-move/manifests/dev/manifest.json +++ b/examples/spawn-and-move/manifests/dev/manifest.json @@ -1,8 +1,8 @@ { "world": { "kind": "WorldContract", - "class_hash": "0x64728e0c0713811c751930f8d3292d683c23f107c89b0a101425d9e80adb1c0", - "original_class_hash": "0x64728e0c0713811c751930f8d3292d683c23f107c89b0a101425d9e80adb1c0", + "class_hash": "0x34aafe3ca8fd1aec61deea58541aefd0ec6647299939ad96e4cd3a79c47bb8e", + "original_class_hash": "0x34aafe3ca8fd1aec61deea58541aefd0ec6647299939ad96e4cd3a79c47bb8e", "abi": [ { "type": "impl", @@ -210,6 +210,10 @@ { "name": "class_hash", "type": "core::starknet::class_hash::ClassHash" + }, + { + "name": "init_calldata", + "type": "core::array::Span::" } ], "outputs": [ @@ -951,8 +955,8 @@ ] } ], - "address": "0x1c958955aedbc7b8e2f051767d3369168e88bc5074b0f39e5f8cd2539138281", - "transaction_hash": "0x703e38b6957635cccc0f9ddddd43356025f260de7f3593523157838e4443281", + "address": "0x29aea29955b6b0c0aabf92e265cd0bca14069575511ec9b6819ca2917277962", + "transaction_hash": "0xa32990a5203fc3c67ba905f65a0161fa5435d8c28aa1e889cc09b551f431d3", "block_number": 3, "seed": "dojo_examples", "metadata": { @@ -971,9 +975,9 @@ "contracts": [ { "kind": "DojoContract", - "address": "0x21d87b58131a6879752e3b658d658fe3a80a42d85228ba8aec5220c4a5c364c", - "class_hash": "0x5b617d120767e91d40621dd939b092f48975a8fa1c5236ac68f97a4ffaf45b", - "original_class_hash": "0x5b617d120767e91d40621dd939b092f48975a8fa1c5236ac68f97a4ffaf45b", + "address": "0xa0db53af8c89cbaab909bb34635262ffe36bbd414184e830eabfa6b592a17d", + "class_hash": "0x44838b88a31f6cf954408395e5d4256d53640ca48a46658d08400ddf11790f5", + "original_class_hash": "0x44838b88a31f6cf954408395e5d4256d53640ca48a46658d08400ddf11790f5", "base_class_hash": "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46", "abi": [ { @@ -1187,6 +1191,24 @@ } ] }, + { + "type": "impl", + "name": "IDojoInitImpl", + "interface_name": "dojo_examples::actions::actions::IDojoInit" + }, + { + "type": "interface", + "name": "dojo_examples::actions::actions::IDojoInit", + "items": [ + { + "type": "function", + "name": "dojo_init", + "inputs": [], + "outputs": [], + "state_mutability": "view" + } + ] + }, { "type": "impl", "name": "UpgradableImpl", @@ -1253,7 +1275,170 @@ "Position" ], "computed": [], + "init_calldata": [], "name": "dojo_examples::actions::actions" + }, + { + "kind": "DojoContract", + "address": "0x482b931a82a26a4d8501ff051b1c8e2c125b79c954dc5d5106988749129c9d3", + "class_hash": "0x3ee016157303a7ce35a9fecdb5b8519159df620c5780527d61443636aaa3c3a", + "original_class_hash": "0x3ee016157303a7ce35a9fecdb5b8519159df620c5780527d61443636aaa3c3a", + "base_class_hash": "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46", + "abi": [ + { + "type": "impl", + "name": "DojoResourceProviderImpl", + "interface_name": "dojo::world::IDojoResourceProvider" + }, + { + "type": "interface", + "name": "dojo::world::IDojoResourceProvider", + "items": [ + { + "type": "function", + "name": "dojo_resource", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "WorldProviderImpl", + "interface_name": "dojo::world::IWorldProvider" + }, + { + "type": "struct", + "name": "dojo::world::IWorldDispatcher", + "members": [ + { + "name": "contract_address", + "type": "core::starknet::contract_address::ContractAddress" + } + ] + }, + { + "type": "interface", + "name": "dojo::world::IWorldProvider", + "items": [ + { + "type": "function", + "name": "world", + "inputs": [], + "outputs": [ + { + "type": "dojo::world::IWorldDispatcher" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "IDojoInitImpl", + "interface_name": "dojo_examples::others::others::IDojoInit" + }, + { + "type": "interface", + "name": "dojo_examples::others::others::IDojoInit", + "items": [ + { + "type": "function", + "name": "dojo_init", + "inputs": [ + { + "name": "actions_address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "actions_class", + "type": "core::starknet::class_hash::ClassHash" + }, + { + "name": "value", + "type": "core::integer::u8" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "UpgradableImpl", + "interface_name": "dojo::components::upgradeable::IUpgradeable" + }, + { + "type": "interface", + "name": "dojo::components::upgradeable::IUpgradeable", + "items": [ + { + "type": "function", + "name": "upgrade", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "event", + "name": "dojo::components::upgradeable::upgradeable::Upgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::components::upgradeable::upgradeable::Event", + "kind": "enum", + "variants": [ + { + "name": "Upgraded", + "type": "dojo::components::upgradeable::upgradeable::Upgraded", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "dojo_examples::others::others::Event", + "kind": "enum", + "variants": [ + { + "name": "UpgradeableEvent", + "type": "dojo::components::upgradeable::upgradeable::Event", + "kind": "nested" + } + ] + } + ], + "reads": [], + "writes": [], + "computed": [], + "init_calldata": [ + "$contract_address:dojo_examples::actions::actions", + "$class_hash:dojo_examples::actions::actions", + "10" + ], + "name": "dojo_examples::others::others" } ], "models": [ @@ -3294,6 +3479,396 @@ } ], "name": "dojo_examples::models::position" + }, + { + "kind": "DojoModel", + "members": [ + { + "name": "contract_address", + "type": "ContractAddress", + "key": true + }, + { + "name": "contract_class", + "type": "ClassHash", + "key": false + }, + { + "name": "value", + "type": "u8", + "key": false + } + ], + "class_hash": "0x6b54d690f4f43e3011fe05fabf3e5f1807b3a026430eb175534336e9a90d5a5", + "original_class_hash": "0x6b54d690f4f43e3011fe05fabf3e5f1807b3a026430eb175534336e9a90d5a5", + "abi": [ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::IModel" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::database::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::database::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::database::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::IModel", + "items": [ + { + "type": "function", + "name": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "version", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u8" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "contract_initializedImpl", + "interface_name": "dojo_examples::others::others::Icontract_initialized" + }, + { + "type": "struct", + "name": "dojo_examples::others::others::ContractInitialized", + "members": [ + { + "name": "contract_address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "contract_class", + "type": "core::starknet::class_hash::ClassHash" + }, + { + "name": "value", + "type": "core::integer::u8" + } + ] + }, + { + "type": "interface", + "name": "dojo_examples::others::others::Icontract_initialized", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "dojo_examples::others::others::ContractInitialized" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "dojo_examples::others::others::contract_initialized::Event", + "kind": "enum", + "variants": [] + } + ], + "name": "dojo_examples::others::others::contract_initialized" } ] } \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/manifest.toml b/examples/spawn-and-move/manifests/dev/manifest.toml index e3324ca12e..330a9fac1d 100644 --- a/examples/spawn-and-move/manifests/dev/manifest.toml +++ b/examples/spawn-and-move/manifests/dev/manifest.toml @@ -1,10 +1,10 @@ [world] kind = "WorldContract" -class_hash = "0x64728e0c0713811c751930f8d3292d683c23f107c89b0a101425d9e80adb1c0" -original_class_hash = "0x64728e0c0713811c751930f8d3292d683c23f107c89b0a101425d9e80adb1c0" +class_hash = "0x34aafe3ca8fd1aec61deea58541aefd0ec6647299939ad96e4cd3a79c47bb8e" +original_class_hash = "0x34aafe3ca8fd1aec61deea58541aefd0ec6647299939ad96e4cd3a79c47bb8e" abi = "manifests/dev/abis/deployments/dojo_world_world.json" -address = "0x1c958955aedbc7b8e2f051767d3369168e88bc5074b0f39e5f8cd2539138281" -transaction_hash = "0x703e38b6957635cccc0f9ddddd43356025f260de7f3593523157838e4443281" +address = "0x29aea29955b6b0c0aabf92e265cd0bca14069575511ec9b6819ca2917277962" +transaction_hash = "0xa32990a5203fc3c67ba905f65a0161fa5435d8c28aa1e889cc09b551f431d3" block_number = 3 seed = "dojo_examples" name = "dojo::world::world" @@ -21,9 +21,9 @@ name = "dojo::base::base" [[contracts]] kind = "DojoContract" -address = "0x21d87b58131a6879752e3b658d658fe3a80a42d85228ba8aec5220c4a5c364c" -class_hash = "0x5b617d120767e91d40621dd939b092f48975a8fa1c5236ac68f97a4ffaf45b" -original_class_hash = "0x5b617d120767e91d40621dd939b092f48975a8fa1c5236ac68f97a4ffaf45b" +address = "0xa0db53af8c89cbaab909bb34635262ffe36bbd414184e830eabfa6b592a17d" +class_hash = "0x44838b88a31f6cf954408395e5d4256d53640ca48a46658d08400ddf11790f5" +original_class_hash = "0x44838b88a31f6cf954408395e5d4256d53640ca48a46658d08400ddf11790f5" base_class_hash = "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46" abi = "manifests/dev/abis/deployments/contracts/dojo_examples_actions_actions.json" reads = [] @@ -32,8 +32,26 @@ writes = [ "Position", ] computed = [] +init_calldata = [] name = "dojo_examples::actions::actions" +[[contracts]] +kind = "DojoContract" +address = "0x482b931a82a26a4d8501ff051b1c8e2c125b79c954dc5d5106988749129c9d3" +class_hash = "0x3ee016157303a7ce35a9fecdb5b8519159df620c5780527d61443636aaa3c3a" +original_class_hash = "0x3ee016157303a7ce35a9fecdb5b8519159df620c5780527d61443636aaa3c3a" +base_class_hash = "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46" +abi = "manifests/dev/abis/deployments/contracts/dojo_examples_others_others.json" +reads = [] +writes = [] +computed = [] +init_calldata = [ + "$contract_address:dojo_examples::actions::actions", + "$class_hash:dojo_examples::actions::actions", + "10", +] +name = "dojo_examples::others::others" + [[models]] kind = "DojoModel" class_hash = "0x5508ab47983d4842a780fe483cb9ba5d24ad4b8d0196f767cd5983398b9f4c4" @@ -133,3 +151,25 @@ key = true name = "vec" type = "Vec2" key = false + +[[models]] +kind = "DojoModel" +class_hash = "0x6b54d690f4f43e3011fe05fabf3e5f1807b3a026430eb175534336e9a90d5a5" +original_class_hash = "0x6b54d690f4f43e3011fe05fabf3e5f1807b3a026430eb175534336e9a90d5a5" +abi = "manifests/dev/abis/deployments/models/dojo_examples_others_others_contract_initialized.json" +name = "dojo_examples::others::others::contract_initialized" + +[[models.members]] +name = "contract_address" +type = "ContractAddress" +key = true + +[[models.members]] +name = "contract_class" +type = "ClassHash" +key = false + +[[models.members]] +name = "value" +type = "u8" +key = false diff --git a/examples/spawn-and-move/manifests/dev/overlays/contracts/dojo_examples_actions_actions.toml b/examples/spawn-and-move/manifests/dev/overlays/contracts/dojo_examples_actions_actions.toml index b18cfcaedb..a8e2fd4c2d 100644 --- a/examples/spawn-and-move/manifests/dev/overlays/contracts/dojo_examples_actions_actions.toml +++ b/examples/spawn-and-move/manifests/dev/overlays/contracts/dojo_examples_actions_actions.toml @@ -2,3 +2,5 @@ computed = [ ] name = "dojo_examples::actions::actions" reads = [ ] writes = [ "Moves", "Position" ] +init_calldata = [] + diff --git a/examples/spawn-and-move/manifests/dev/overlays/contracts/dojo_examples_others_others.toml b/examples/spawn-and-move/manifests/dev/overlays/contracts/dojo_examples_others_others.toml new file mode 100644 index 0000000000..b74df0c8fe --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/overlays/contracts/dojo_examples_others_others.toml @@ -0,0 +1,5 @@ +reads = [] +writes = [] +computed = [] +init_calldata = ["$contract_address:dojo_examples::actions::actions", "$class_hash:dojo_examples::actions::actions", "10"] +name = "dojo_examples::others::others" diff --git a/examples/spawn-and-move/src/actions.cairo b/examples/spawn-and-move/src/actions.cairo index 6b9156343b..65dc16c55c 100644 --- a/examples/spawn-and-move/src/actions.cairo +++ b/examples/spawn-and-move/src/actions.cairo @@ -123,7 +123,7 @@ mod tests { // deploy systems contract let contract_address = world - .deploy_contract('salt', actions::TEST_CLASS_HASH.try_into().unwrap()); + .deploy_contract('salt', actions::TEST_CLASS_HASH.try_into().unwrap(), array![].span()); let actions_system = IActionsDispatcher { contract_address }; // System calls diff --git a/examples/spawn-and-move/src/lib.cairo b/examples/spawn-and-move/src/lib.cairo index e3149f1627..44309e5fca 100644 --- a/examples/spawn-and-move/src/lib.cairo +++ b/examples/spawn-and-move/src/lib.cairo @@ -1,3 +1,4 @@ mod actions; mod models; mod utils; +mod others; diff --git a/examples/spawn-and-move/src/others.cairo b/examples/spawn-and-move/src/others.cairo new file mode 100644 index 0000000000..0f27d036a8 --- /dev/null +++ b/examples/spawn-and-move/src/others.cairo @@ -0,0 +1,31 @@ +#[dojo::contract] +mod others { + use starknet::{ContractAddress, ClassHash, get_caller_address}; + use dojo_examples::models::{Position, Moves, Direction, Vec2}; + use dojo_examples::utils::next_position; + + #[derive(Copy, Drop, Serde)] + #[dojo::event] + #[dojo::model] + struct ContractInitialized { + #[key] + contract_address: ContractAddress, + contract_class: ClassHash, + value: u8, + } + + + fn dojo_init( + world: IWorldDispatcher, + actions_address: ContractAddress, + actions_class: ClassHash, + value: u8 + ) { + emit!( + world, + ContractInitialized { + contract_address: actions_address, contract_class: actions_class, value + } + ); + } +} From 6153192f2388013d17433aa1a5dc8dabab26a357 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Baranx?= Date: Wed, 29 May 2024 19:05:38 +0800 Subject: [PATCH 09/16] Sozo model layout and commands (#2002) --- .github/workflows/ci.yml | 4 +- Cargo.lock | 1 + bin/sozo/src/commands/model.rs | 36 ++ crates/dojo-core/src/base_test.cairo | 2 +- .../dojo-core/src/database/introspect.cairo | 18 +- .../src/database/introspect_test.cairo | 154 ++++- crates/dojo-core/src/world.cairo | 35 +- crates/dojo-lang/src/introspect/layout.rs | 137 ++-- crates/dojo-lang/src/introspect/mod.rs | 31 +- crates/dojo-lang/src/introspect/size.rs | 98 ++- crates/dojo-lang/src/introspect/utils.rs | 14 - .../manifests/dev/base/dojo_world_world.toml | 4 +- .../dojo-lang/src/plugin_test_data/introspect | 563 ++++++++--------- crates/dojo-lang/src/plugin_test_data/model | 32 +- crates/dojo-types/src/schema.rs | 2 +- crates/dojo-world/src/contracts/model_test.rs | 2 +- crates/dojo-world/src/metadata_test.rs | 7 +- crates/sozo/ops/src/model.rs | 585 +++++++++++++++++- crates/torii/core/Cargo.toml | 1 + crates/torii/core/src/sql_test.rs | 13 +- .../manifests/dev/base/dojo_world_world.toml | 4 +- dojoup/dojoup | 2 +- examples/spawn-and-move/Scarb.toml | 2 +- .../dojo_examples_actions_actions.toml | 4 +- .../manifests/dev/base/dojo_world_world.toml | 4 +- .../dojo_examples_actions_actions_moved.toml | 4 +- .../dojo_examples_models_emote_message.toml | 4 +- .../models/dojo_examples_models_moves.toml | 4 +- .../dojo_examples_models_player_config.toml | 4 +- .../models/dojo_examples_models_position.toml | 4 +- .../manifests/dev/manifest.json | 36 +- .../manifests/dev/manifest.toml | 36 +- examples/spawn-and-move/src/models.cairo | 10 +- 33 files changed, 1286 insertions(+), 571 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 25b08d52fd..93377d7076 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ env: jobs: test: - runs-on: ubuntu-latest-16-cores + runs-on: ubuntu-latest-32-cores container: image: ghcr.io/dojoengine/dojo-dev:v0.7.0-alpha.4 steps: @@ -20,7 +20,7 @@ jobs: - uses: Swatinem/rust-cache@v2 - run: | cargo build -r --bin katana - KATANA_RUNNER_BIN=$(pwd)/target/release/katana cargo llvm-cov nextest --no-report --all-features --workspace --exclude katana --build-jobs 10 + KATANA_RUNNER_BIN=$(pwd)/target/release/katana cargo llvm-cov nextest --no-report --all-features --workspace --exclude katana --build-jobs 20 cargo llvm-cov nextest --no-report -p katana # TODO(kariy): uncomment this line when `sir` feature support Cairo 2.6.3 # cargo llvm-cov nextest --no-report -p katana --no-default-features --features sir diff --git a/Cargo.lock b/Cargo.lock index e021fa153f..094618803f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13436,6 +13436,7 @@ dependencies = [ "futures-channel", "futures-util", "hex", + "katana-runner", "lazy_static", "log", "once_cell", diff --git a/bin/sozo/src/commands/model.rs b/bin/sozo/src/commands/model.rs index d927b24578..c14297034a 100644 --- a/bin/sozo/src/commands/model.rs +++ b/bin/sozo/src/commands/model.rs @@ -41,6 +41,37 @@ pub enum ModelCommand { starknet: StarknetOptions, }, + #[command(about = "Displays the model's layout into dojo storage.\n +The Dojo storage system uses the poseidon_hash function to compute +hashes, called 'hash' in the following documentation. + + How storage locations are computed ? + + model key = hash(model_keys) + + fixed layout key = parent_key + struct layout field key = hash(parent_key, field_selector) + tuple layout item key = hash(parent_key, item_index) + enum layout + variant key = parent_key + data key = hash(parent_key, variant_index) + array layout + length key = parent_key + item key = hash(parent_key, item_index) + byte array layout = parent_key + + final storage location = hash('dojo_storage', model_selector, record_key)")] + Layout { + #[arg(help = "The name of the model")] + name: String, + + #[command(flatten)] + world: WorldOptions, + + #[command(flatten)] + starknet: StarknetOptions, + }, + #[command(about = "Retrieve the schema for a model")] Schema { #[arg(help = "The name of the model")] @@ -92,6 +123,11 @@ impl ModelArgs { let provider = starknet.provider(env_metadata.as_ref()).unwrap(); model::model_contract_address(name, world_address, provider).await } + ModelCommand::Layout { name, starknet, world } => { + let world_address = world.address(env_metadata.as_ref()).unwrap(); + let provider = starknet.provider(env_metadata.as_ref()).unwrap(); + model::model_layout(name, world_address, provider).await + } ModelCommand::Schema { name, to_json, starknet, world } => { let world_address = world.address(env_metadata.as_ref()).unwrap(); let provider = starknet.provider(env_metadata.as_ref()).unwrap(); diff --git a/crates/dojo-core/src/base_test.cairo b/crates/dojo-core/src/base_test.cairo index f52aea79f4..1e3f533b08 100644 --- a/crates/dojo-core/src/base_test.cairo +++ b/crates/dojo-core/src/base_test.cairo @@ -160,7 +160,7 @@ mod invalid_model { fn selector(self: @ContractState) -> felt252 { // NOTE: Need to update this value if address changes // Pre-computed address of a contract deployed through the world. - 0x3dc3b5d2f73350ccda67b655bfae01e747c5db6e6f570743ee2867649da2a73 + 0x15f0ffa36184d74ead97aa501b09aed53ee7236e364997a0c21879194340ab6 } fn name(self: @ContractState) -> ByteArray { diff --git a/crates/dojo-core/src/database/introspect.cairo b/crates/dojo-core/src/database/introspect.cairo index a7d2fed3a4..d3ad4e6962 100644 --- a/crates/dojo-core/src/database/introspect.cairo +++ b/crates/dojo-core/src/database/introspect.cairo @@ -16,7 +16,7 @@ enum Layout { ByteArray, // there is one layout per variant. // the `selector` field identifies the variant - // the `layout` field defines the full variant layout (variant value + optional variant data) + // the `layout` defines the variant data (could be empty for variant without data). Enum: Span, } @@ -203,18 +203,10 @@ impl Introspect_option> of Introspect> { fn layout() -> Layout { Layout::Enum( array![ - FieldLayout { - // Some - selector: 0, - layout: Layout::Tuple( - array![Layout::Fixed(array![8].span()), Introspect::::layout()].span() - ) - }, - FieldLayout { - // None - selector: 1, - layout: Layout::Tuple(array![Layout::Fixed(array![8].span())].span()) - }, + FieldLayout { // Some + selector: 0, layout: Introspect::::layout() }, + FieldLayout { // None + selector: 1, layout: Layout::Fixed(array![].span()) }, ] .span() ) diff --git a/crates/dojo-core/src/database/introspect_test.cairo b/crates/dojo-core/src/database/introspect_test.cairo index 95a993e770..c62d9561bc 100644 --- a/crates/dojo-core/src/database/introspect_test.cairo +++ b/crates/dojo-core/src/database/introspect_test.cairo @@ -35,6 +35,24 @@ struct WithNestedArrayInTuple { arr: (u8, (u16, Array, u256), u32) } +#[derive(Drop, IntrospectPacked)] +struct Vec3 { + x: u32, + y: u32, + z: u32 +} + +#[derive(IntrospectPacked)] +struct Translation { + from: Vec3, + to: Vec3 +} + +#[derive(Drop, IntrospectPacked)] +struct StructInnerNotPacked { + x: Base +} + #[derive(Drop, Introspect)] enum EnumNoData { One, @@ -43,12 +61,45 @@ enum EnumNoData { } #[derive(Drop, Introspect)] -enum EnumWithData { +enum EnumWithSameData { + One: u256, + Two: u256, + Three: u256 +} + +#[derive(Drop, Introspect)] +enum EnumWithSameTupleData { + One: (u256, u32), + Two: (u256, u32), + Three: (u256, u32) +} + +#[derive(Drop, Introspect)] +enum EnumWithVariousData { One: u32, Two: (u8, u16), Three: Array, } + +#[derive(Drop, IntrospectPacked)] +enum EnumPacked { + A: u32, + B: u32, +} + +#[derive(Drop, IntrospectPacked)] +enum EnumInnerPacked { + A: (EnumPacked, Vec3), + B: (EnumPacked, Vec3), +} + +#[derive(Drop, IntrospectPacked)] +enum EnumInnerNotPacked { + A: (EnumPacked, Base), + B: (EnumPacked, Base), +} + #[derive(Drop, Introspect)] struct StructWithOption { x: Option @@ -82,10 +133,8 @@ fn _enum(values: Array>) -> Layout { let v = *values.at(i); match v { - Option::Some(v) => { - items.append(field(i.into(), tuple(array![fixed(array![8]), v]))); - }, - Option::None => { items.append(field(i.into(), fixed(array![8]))) } + Option::Some(v) => { items.append(field(i.into(), v)); }, + Option::None => { items.append(field(i.into(), fixed(array![]))) } } i += 1; @@ -144,9 +193,25 @@ fn test_size_with_nested_array_in_tuple() { #[test] fn test_size_of_enum_without_variant_data() { let size = Introspect::::size(); - assert!(size.is_none()); + assert!(size.is_some()); + assert!(size.unwrap() == 1); +} + +#[test] +fn test_size_of_enum_with_same_variant_data() { + let size = Introspect::::size(); + assert!(size.is_some()); + assert!(size.unwrap() == 3); } +#[test] +fn test_size_of_enum_with_same_tuple_variant_data() { + let size = Introspect::::size(); + assert!(size.is_some()); + assert!(size.unwrap() == 4); +} + + #[test] fn test_size_of_struct_with_option() { let size = Introspect::::size(); @@ -155,49 +220,39 @@ fn test_size_of_struct_with_option() { #[test] fn test_size_of_enum_with_variant_data() { - let size = Introspect::::size(); + let size = Introspect::::size(); assert!(size.is_none()); } #[test] fn test_layout_of_enum_without_variant_data() { let layout = Introspect::::layout(); - let expected = Layout::Enum( - array![ - // One - field(0, tuple(array![fixed(array![8])])), - // Two - field(1, tuple(array![fixed(array![8])])), - // Three - field(2, tuple(array![fixed(array![8])])), - ] - .span() - ); + let expected = _enum(array![ // One + Option::None, // Two + Option::None, // Three + Option::None,]); assert!(layout == expected); } #[test] fn test_layout_of_enum_with_variant_data() { - let layout = Introspect::::layout(); - let expected = Layout::Enum( + let layout = Introspect::::layout(); + let expected = _enum( array![ // One - field(0, tuple(array![fixed(array![8]), fixed(array![32]),])), + Option::Some(fixed(array![32])), // Two - field( - 1, - tuple(array![fixed(array![8]), tuple(array![fixed(array![8]), fixed(array![16]),])]) - ), + Option::Some(tuple(array![fixed(array![8]), fixed(array![16])])), // Three - field(2, tuple(array![fixed(array![8]), arr(fixed(array![128])),])), + Option::Some(arr(fixed(array![128]))), ] - .span() ); assert!(layout == expected); } +#[test] fn test_layout_of_struct_with_option() { let layout = Introspect::::layout(); let expected = Layout::Struct( @@ -207,3 +262,48 @@ fn test_layout_of_struct_with_option() { assert!(layout == expected); } + +#[test] +fn test_layout_of_packed_struct() { + let layout = Introspect::::layout(); + let expected = Layout::Fixed(array![32, 32, 32].span()); + + assert!(layout == expected); +} + +#[test] +fn test_layout_of_inner_packed_struct() { + let layout = Introspect::::layout(); + let expected = Layout::Fixed(array![32, 32, 32, 32, 32, 32].span()); + + assert!(layout == expected); +} + +#[test] +#[should_panic(expected: ("A packed model layout must contain Fixed layouts only.",))] +fn test_layout_of_not_packed_inner_struct() { + let _ = Introspect::::layout(); +} + + +#[test] +fn test_layout_of_packed_enum() { + let layout = Introspect::::layout(); + let expected = Layout::Fixed(array![8, 32].span()); + + assert!(layout == expected); +} + +#[test] +fn test_layout_of_inner_packed_enum() { + let layout = Introspect::::layout(); + let expected = Layout::Fixed(array![8, 8, 32, 32, 32, 32].span()); + + assert!(layout == expected); +} + +#[test] +#[should_panic(expected: ("A packed model layout must contain Fixed layouts only.",))] +fn test_layout_of_not_packed_inner_enum() { + let _ = Introspect::::layout(); +} diff --git a/crates/dojo-core/src/world.cairo b/crates/dojo-core/src/world.cairo index 6517a21d21..b01adc0d36 100644 --- a/crates/dojo-core/src/world.cairo +++ b/crates/dojo-core/src/world.cairo @@ -1001,9 +1001,17 @@ mod world { let variant = *values.at(offset); assert(variant.into() < 256_u256, 'invalid variant value'); + // and write it + database::set(model, key, values, offset, array![251].span()); + offset += 1; + // find the corresponding layout and then write the full variant + let variant_data_key = Self::_field_key(key, variant); + match Self::_find_variant_layout(variant, variant_layouts) { - Option::Some(layout) => Self::_write_layout(model, key, values, ref offset, layout), + Option::Some(layout) => Self::_write_layout( + model, variant_data_key, values, ref offset, layout + ), Option::None => panic!("Unable to find the variant layout") }; } @@ -1104,16 +1112,21 @@ mod world { } fn _delete_enum_layout(model: felt252, key: felt252, variant_layouts: Span) { - // read the variant value first which is the first stored felt252 + // read the variant value let res = database::get(model, key, array![251].span()); assert(res.len() == 1, 'internal database error'); let variant = *res.at(0); assert(variant.into() < 256_u256, 'invalid variant value'); + // reset the variant value + database::delete(model, key, array![251].span()); + // find the corresponding layout and the delete the full variant + let variant_data_key = Self::_field_key(key, variant); + match Self::_find_variant_layout(variant, variant_layouts) { - Option::Some(layout) => Self::_delete_layout(model, key, layout), + Option::Some(layout) => Self::_delete_layout(model, variant_data_key, layout), Option::None => panic!("Unable to find the variant layout") }; } @@ -1277,18 +1290,22 @@ mod world { ref read_data: Array, variant_layouts: Span ) { - // read the variant value first, which is the first element of the tuple - // (because an enum is stored as a tuple). - let variant_key = Self::_field_key(key, 0); - let res = database::get(model, variant_key, array![8].span()); + // read the variant value first + let res = database::get(model, key, array![8].span()); assert(res.len() == 1, 'internal database error'); let variant = *res.at(0); assert(variant.into() < 256_u256, 'invalid variant value'); - // find the corresponding layout and the read the full variant + read_data.append(variant); + + // find the corresponding layout and the read the variant data + let variant_data_key = Self::_field_key(key, variant); + match Self::_find_variant_layout(variant, variant_layouts) { - Option::Some(layout) => Self::_read_layout(model, key, ref read_data, layout), + Option::Some(layout) => Self::_read_layout( + model, variant_data_key, ref read_data, layout + ), Option::None => panic!("Unable to find the variant layout") }; } diff --git a/crates/dojo-lang/src/introspect/layout.rs b/crates/dojo-lang/src/introspect/layout.rs index 0b7e43386d..216b00678c 100644 --- a/crates/dojo-lang/src/introspect/layout.rs +++ b/crates/dojo-lang/src/introspect/layout.rs @@ -56,7 +56,9 @@ pub fn build_variant_layouts( let selector = format!("{i}"); let variant_layout = match v.type_clause(db) { - OptionTypeClause::Empty(_) => "".to_string(), + OptionTypeClause::Empty(_) => { + "dojo::database::introspect::Layout::Fixed(array![].span())".to_string() + } OptionTypeClause::TypeClause(type_clause) => { get_layout_from_type_clause(db, diagnostics, &type_clause) } @@ -65,12 +67,7 @@ pub fn build_variant_layouts( format!( "dojo::database::introspect::FieldLayout {{ selector: {selector}, - layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Layout::Fixed(array![8].span()), - {variant_layout} - ].span() - ) + layout: {variant_layout} }}" ) }) @@ -183,12 +180,16 @@ pub fn build_item_layout_from_type( } } +pub fn is_custom_layout(layout: &str) -> bool { + layout.starts_with("dojo::database::introspect::Introspect::") +} + pub fn build_packed_struct_layout( db: &dyn SyntaxGroup, diagnostics: &mut Vec, struct_ast: &ItemStruct, ) -> String { - struct_ast + let layouts = struct_ast .members(db) .elements(db) .iter() @@ -199,8 +200,64 @@ pub fn build_packed_struct_layout( Some(get_packed_field_layout_from_type_clause(db, diagnostics, &m.type_clause(db))) }) + .flatten() + .collect::>(); + + if layouts.iter().any(|v| is_custom_layout(v.as_str())) { + generate_cairo_code_for_fixed_layout_with_custom_types(&layouts) + } else { + format!( + "dojo::database::introspect::Layout::Fixed( + array![ + {} + ].span() + )", + layouts.join(",") + ) + } +} + +pub fn generate_cairo_code_for_fixed_layout_with_custom_types(layouts: &[String]) -> String { + let layouts_repr = layouts + .iter() + .map(|l| { + if is_custom_layout(l) { + l.to_string() + } else { + format!("dojo::database::introspect::Layout::Fixed(array![{l}].span())") + } + }) .collect::>() - .join(",") + .join(",\n"); + + format!( + "let mut layouts = array![ + {layouts_repr} + ]; + let mut merged_layout = ArrayTrait::::new(); + + loop {{ + match ArrayTrait::pop_front(ref layouts) {{ + Option::Some(mut layout) => {{ + match layout {{ + dojo::database::introspect::Layout::Fixed(mut l) => {{ + loop {{ + match SpanTrait::pop_front(ref l) {{ + Option::Some(x) => merged_layout.append(*x), + Option::None(_) => {{ break; }} + }}; + }}; + }}, + _ => panic!(\"A packed model layout must contain Fixed layouts only.\"), + }}; + }}, + Option::None(_) => {{ break; }} + }}; + }}; + + dojo::database::introspect::Layout::Fixed(merged_layout.span()) + ", + ) } // @@ -209,23 +266,36 @@ pub fn build_packed_enum_layout( diagnostics: &mut Vec, enum_ast: &ItemEnum, ) -> String { - let variant_layouts = enum_ast - .variants(db) - .elements(db) - .iter() - .map(|v| match v.type_clause(db) { - OptionTypeClause::Empty(_) => "".to_string(), + // to be packable, all variants data must have the same size. + // as this point has already been checked before calling `build_packed_enum_layout`, + // just use the first variant to generate the fixed layout. + let elements = enum_ast.variants(db).elements(db); + let mut variant_layout = if elements.is_empty() { + vec![] + } else { + match elements.first().unwrap().type_clause(db) { + OptionTypeClause::Empty(_) => vec![], OptionTypeClause::TypeClause(type_clause) => { get_packed_field_layout_from_type_clause(db, diagnostics, &type_clause) } - }) - .collect::>(); + } + }; - if variant_layouts.is_empty() { - return "8".to_string(); - } + // don't forget the store the variant value + variant_layout.insert(0, "8".to_string()); - format!("8,{}", variant_layouts[0]) + if variant_layout.iter().any(|v| is_custom_layout(v.as_str())) { + generate_cairo_code_for_fixed_layout_with_custom_types(&variant_layout) + } else { + format!( + "dojo::database::introspect::Layout::Fixed( + array![ + {} + ].span() + )", + variant_layout.join(",") + ) + } } // @@ -233,7 +303,7 @@ pub fn get_packed_field_layout_from_type_clause( db: &dyn SyntaxGroup, diagnostics: &mut Vec, type_clause: &TypeClause, -) -> String { +) -> Vec { match type_clause.ty(db) { Expr::Path(path) => { let path_type = path.as_syntax_node().get_text(db); @@ -253,7 +323,7 @@ pub fn get_packed_field_layout_from_type_clause( message: "Unexpected expression for variant data type.".to_string(), severity: Severity::Error, }); - "ERROR".to_string() + vec!["ERROR".to_string()] } } } @@ -263,28 +333,26 @@ pub fn get_packed_item_layout_from_type( diagnostics: &mut Vec, diagnostic_item: ids::SyntaxStablePtrId, item_type: &str, -) -> String { +) -> Vec { if is_array(item_type) || is_byte_array(item_type) { diagnostics.push(PluginDiagnostic { stable_ptr: diagnostic_item, message: "Array field cannot be packed.".into(), severity: Severity::Error, }); - "ERROR".to_string() + vec!["ERROR".to_string()] } else if is_tuple(item_type) { get_packed_tuple_layout_from_type(diagnostics, diagnostic_item, item_type) } else { let primitives = primitive_type_introspection(); if let Some(p) = primitives.get(item_type) { - p.1.iter().map(|x| x.to_string()).collect::>().join(",") + vec![p.1.iter().map(|x| x.to_string()).collect::>().join(",")] } else { - diagnostics.push(PluginDiagnostic { - stable_ptr: diagnostic_item, - message: "For now, field with custom type cannot be packed".into(), - severity: Severity::Error, - }); - "ERROR".to_string() + // as we cannot verify that an enum/struct custom type is packable, + // we suppose it is and let the user verify this. + // If it's not the case, the Dojo model layout function will panic. + vec![format!("dojo::database::introspect::Introspect::<{}>::layout()", item_type)] } } } @@ -294,10 +362,9 @@ pub fn get_packed_tuple_layout_from_type( diagnostics: &mut Vec, diagnostic_item: ids::SyntaxStablePtrId, item_type: &str, -) -> String { +) -> Vec { get_tuple_item_types(item_type) .iter() - .map(|x| get_packed_item_layout_from_type(diagnostics, diagnostic_item, x)) + .flat_map(|x| get_packed_item_layout_from_type(diagnostics, diagnostic_item, x)) .collect::>() - .join(",") } diff --git a/crates/dojo-lang/src/introspect/mod.rs b/crates/dojo-lang/src/introspect/mod.rs index fb788af004..856c3477e0 100644 --- a/crates/dojo-lang/src/introspect/mod.rs +++ b/crates/dojo-lang/src/introspect/mod.rs @@ -21,18 +21,11 @@ pub fn handle_introspect_struct( packed: bool, ) -> RewriteNode { let struct_name = struct_ast.name(db).text(db).into(); - let struct_size = size::compute_struct_layout_size(db, &struct_ast); + let struct_size = size::compute_struct_layout_size(db, &struct_ast, packed); let ty = ty::build_struct_ty(db, &struct_name, &struct_ast); let layout = if packed { - format!( - "dojo::database::introspect::Layout::Fixed( - array![ - {} - ].span() - )", - layout::build_packed_struct_layout(db, diagnostics, &struct_ast) - ) + layout::build_packed_struct_layout(db, diagnostics, &struct_ast) } else { format!( "dojo::database::introspect::Layout::Struct( @@ -57,24 +50,15 @@ pub fn handle_introspect_enum( packed: bool, ) -> RewriteNode { let enum_name = enum_ast.name(db).text(db).into(); - let identical_variants = utils::are_enum_variants_identical(db, &enum_ast); - let enum_size = size::compute_enum_layout_size(db, &enum_ast, identical_variants); - let ty = ty::build_enum_ty(db, &enum_name, &enum_ast); + let variant_sizes = size::compute_enum_variant_sizes(db, &enum_ast); let layout = if packed { - if identical_variants { - format!( - "dojo::database::introspect::Layout::Fixed( - array![ - {} - ].span() - )", - layout::build_packed_enum_layout(db, diagnostics, &enum_ast) - ) + if size::is_enum_packable(&variant_sizes) { + layout::build_packed_enum_layout(db, diagnostics, &enum_ast) } else { diagnostics.push(PluginDiagnostic { stable_ptr: enum_ast.name(db).stable_ptr().0, - message: "To be packed, all variants must have exactly the same layout." + message: "To be packed, all variants must have fixed layout of same size." .to_string(), severity: Severity::Error, }); @@ -92,6 +76,8 @@ pub fn handle_introspect_enum( }; let (gen_types, gen_impls) = build_generic_types_and_impls(db, enum_ast.generic_params(db)); + let enum_size = size::compute_enum_layout_size(&variant_sizes, packed); + let ty = ty::build_enum_ty(db, &enum_name, &enum_ast); generate_introspect(&enum_name, &enum_size, &gen_types, gen_impls, &layout, &ty) } @@ -115,7 +101,6 @@ impl $name$Introspect<$generics$> of \ $size$ } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { $layout$ } diff --git a/crates/dojo-lang/src/introspect/size.rs b/crates/dojo-lang/src/introspect/size.rs index d2bd078eee..9c056897bf 100644 --- a/crates/dojo-lang/src/introspect/size.rs +++ b/crates/dojo-lang/src/introspect/size.rs @@ -7,7 +7,11 @@ use super::utils::{ get_tuple_item_types, is_array, is_byte_array, is_tuple, primitive_type_introspection, }; -pub fn compute_struct_layout_size(db: &dyn SyntaxGroup, struct_ast: &ItemStruct) -> String { +pub fn compute_struct_layout_size( + db: &dyn SyntaxGroup, + struct_ast: &ItemStruct, + is_packed: bool, +) -> String { let mut cumulated_sizes = 0; let mut is_dynamic_size = false; @@ -29,32 +33,61 @@ pub fn compute_struct_layout_size(db: &dyn SyntaxGroup, struct_ast: &ItemStruct) }) .flatten() .collect::>(); - build_size_function_body(&mut sizes, cumulated_sizes, is_dynamic_size) + build_size_function_body(&mut sizes, cumulated_sizes, is_dynamic_size, is_packed) } -pub fn compute_enum_layout_size( +pub fn compute_enum_variant_sizes( db: &dyn SyntaxGroup, enum_ast: &ItemEnum, - identical_variants: bool, +) -> Vec<(Vec, u32, bool)> { + enum_ast + .variants(db) + .elements(db) + .iter() + .map(|v| match v.type_clause(db) { + OptionTypeClause::Empty(_) => (vec![], 0, false), + OptionTypeClause::TypeClause(type_clause) => { + get_field_size_from_type_clause(db, &type_clause) + } + }) + .collect::>() +} + +pub fn is_enum_packable(variant_sizes: &[(Vec, u32, bool)]) -> bool { + if variant_sizes.is_empty() { + return true; + } + + let v0_sizes = variant_sizes[0].0.clone(); + let v0_fixed_size = variant_sizes[0].1; + + variant_sizes.iter().all(|vs| { + vs.0.len() == v0_sizes.len() + && vs.0.iter().zip(v0_sizes.iter()).all(|(a, b)| a == b) + && vs.1 == v0_fixed_size + && !vs.2 + }) +} + +pub fn compute_enum_layout_size( + variant_sizes: &[(Vec, u32, bool)], + is_packed: bool, ) -> String { + if variant_sizes.is_empty() { + return "Option::None".to_string(); + } + + let v0 = variant_sizes[0].clone(); + let identical_variants = + variant_sizes.iter().all(|vs| vs.0 == v0.0 && vs.1 == v0.1 && vs.2 == v0.2); + if identical_variants { - match enum_ast.variants(db).elements(db).first() { - Some(first_variant) => { - let (mut sizes, cumulated_sizes, is_dynamic_size) = - match first_variant.type_clause(db) { - OptionTypeClause::Empty(_) => (vec![], 0, false), - OptionTypeClause::TypeClause(type_clause) => { - get_field_size_from_type_clause(db, &type_clause) - } - }; - - // add 8 bits to store the variant identifier - sizes.insert(0, "8".to_string()); - - build_size_function_body(&mut sizes, cumulated_sizes, is_dynamic_size) - } - None => "Option::None".to_string(), - } + let (mut sizes, mut cumulated_sizes, is_dynamic_size) = v0; + + // add one felt252 to store the variant identifier + cumulated_sizes += 1; + + build_size_function_body(&mut sizes, cumulated_sizes, is_dynamic_size, is_packed) } else { "Option::None".to_string() } @@ -64,6 +97,7 @@ pub fn build_size_function_body( sizes: &mut Vec, cumulated_sizes: u32, is_dynamic_size: bool, + is_packed: bool, ) -> String { if is_dynamic_size { return "Option::None".to_string(); @@ -77,16 +111,22 @@ pub fn build_size_function_body( 0 => "Option::None".to_string(), 1 => sizes[0].clone(), _ => { + let none_check = if is_packed { + "" + } else { + "if dojo::database::utils::any_none(@sizes) { + return Option::None; + }" + }; + format!( "let sizes : Array> = array![ - {} - ]; - - if dojo::database::utils::any_none(@sizes) {{ - return Option::None; - }} - Option::Some(dojo::database::utils::sum(sizes)) - ", + {} + ]; + + {none_check} + Option::Some(dojo::database::utils::sum(sizes)) + ", sizes.join(",\n") ) } diff --git a/crates/dojo-lang/src/introspect/utils.rs b/crates/dojo-lang/src/introspect/utils.rs index 6494e9f0fe..bf7be9964c 100644 --- a/crates/dojo-lang/src/introspect/utils.rs +++ b/crates/dojo-lang/src/introspect/utils.rs @@ -1,9 +1,5 @@ use std::collections::HashMap; -use cairo_lang_syntax::node::ast::ItemEnum; -use cairo_lang_syntax::node::db::SyntaxGroup; -use cairo_lang_syntax::node::TypedSyntaxNode; - #[derive(Clone, Default)] pub struct TypeIntrospection(pub usize, pub Vec); @@ -94,16 +90,6 @@ pub fn get_tuple_item_types(ty: &str) -> Vec { items } -pub fn are_enum_variants_identical(db: &dyn SyntaxGroup, enum_ast: &ItemEnum) -> bool { - let variants = enum_ast - .variants(db) - .elements(db) - .iter() - .map(|v| v.as_syntax_node().get_text(db)) - .collect::>(); - variants.iter().all(|item| item == &variants[0]) -} - #[test] pub fn test_get_tuple_item_types() { pub fn assert_array(got: Vec, expected: Vec) { diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo_world_world.toml b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo_world_world.toml index efc6f0ca39..2daf97b5e5 100644 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo_world_world.toml +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo_world_world.toml @@ -1,5 +1,5 @@ kind = "Class" -class_hash = "0x34aafe3ca8fd1aec61deea58541aefd0ec6647299939ad96e4cd3a79c47bb8e" -original_class_hash = "0x34aafe3ca8fd1aec61deea58541aefd0ec6647299939ad96e4cd3a79c47bb8e" +class_hash = "0x1fafbe78a4676c8998d2de2053bc2fba24aebbd4fb86f03ff6af87ad3314092" +original_class_hash = "0x1fafbe78a4676c8998d2de2053bc2fba24aebbd4fb86f03ff6af87ad3314092" abi = "manifests/dev/abis/base/dojo_world_world.json" name = "dojo::world::world" diff --git a/crates/dojo-lang/src/plugin_test_data/introspect b/crates/dojo-lang/src/plugin_test_data/introspect index c10b97e019..3582f86aad 100644 --- a/crates/dojo-lang/src/plugin_test_data/introspect +++ b/crates/dojo-lang/src/plugin_test_data/introspect @@ -14,8 +14,8 @@ struct Vec2 { #[derive(Serde, Copy, Drop, Introspect)] enum PlainEnum { - Left: (), - Right: (), + Left, + Right, } #[derive(Serde, Copy, Drop, Introspect)] @@ -55,9 +55,9 @@ enum EnumWithComplexTuple { } #[derive(Serde, Copy, Drop, Introspect)] -enum EnumTupleOnePrimitive { - Left: (u16,), - Right: (u16,), +enum EnumWithPrimitive { + Left: u32, + Right: u32, } #[derive(Serde, Copy, Drop, Introspect)] @@ -220,7 +220,7 @@ struct StructNotPackable1 { } #[derive(IntrospectPacked)] -struct StructNotPackable2 { +struct StructPackableWithInnerPacked { x: u8, y: StructPacked1 } @@ -245,6 +245,13 @@ enum EnumPacked3 { b: u256, } + +#[derive(IntrospectPacked)] +enum EnumPackableWithInnerPacked { + a: StructPacked1, + b: StructPacked1, +} + #[derive(IntrospectPacked)] enum EnumNotPackable1 { a: u8, @@ -262,8 +269,8 @@ struct Vec2 { #[derive(Serde, Copy, Drop, Introspect)] enum PlainEnum { - Left: (), - Right: (), + Left, + Right, } #[derive(Serde, Copy, Drop, Introspect)] @@ -303,9 +310,9 @@ enum EnumWithComplexTuple { } #[derive(Serde, Copy, Drop, Introspect)] -enum EnumTupleOnePrimitive { - Left: (u16,), - Right: (u16,), +enum EnumWithPrimitive { + Left: u32, + Right: u32, } #[derive(Serde, Copy, Drop, Introspect)] @@ -468,7 +475,7 @@ struct StructNotPackable1 { } #[derive(IntrospectPacked)] -struct StructNotPackable2 { +struct StructPackableWithInnerPacked { x: u8, y: StructPacked1 } @@ -493,6 +500,13 @@ enum EnumPacked3 { b: u256, } + +#[derive(IntrospectPacked)] +enum EnumPackableWithInnerPacked { + a: StructPacked1, + b: StructPacked1, +} + #[derive(IntrospectPacked)] enum EnumNotPackable1 { a: u8, @@ -519,7 +533,6 @@ impl Vec2Introspect<> of dojo::database::introspect::Introspect> { Option::Some(2) } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -583,38 +596,19 @@ impl PlainEnumDrop of core::traits::Drop::; impl PlainEnumIntrospect<> of dojo::database::introspect::Introspect> { #[inline(always)] fn size() -> Option { - Option::None + Option::Some(1) } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Enum( array![ dojo::database::introspect::FieldLayout { selector: 0, - layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Layout::Fixed(array![8].span()), - dojo::database::introspect::Layout::Tuple( - array![ - - ].span() - ) - ].span() - ) + layout: dojo::database::introspect::Layout::Fixed(array![].span()) }, dojo::database::introspect::FieldLayout { selector: 1, - layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Layout::Fixed(array![8].span()), - dojo::database::introspect::Layout::Tuple( - array![ - - ].span() - ) - ].span() - ) + layout: dojo::database::introspect::Layout::Fixed(array![].span()) } ].span() ) @@ -627,16 +621,8 @@ dojo::database::introspect::FieldLayout { name: 'PlainEnum', attrs: array![].span(), children: array![ - ('Left', dojo::database::introspect::Ty::Tuple( - array![ - - ].span() - )), -('Right', dojo::database::introspect::Ty::Tuple( - array![ - - ].span() - )) + ('Left', dojo::database::introspect::Ty::Tuple(array![].span())), +('Right', dojo::database::introspect::Ty::Tuple(array![].span())) ].span() } @@ -667,30 +653,19 @@ impl EnumWithPrimitiveDrop of core::traits::Drop::; impl EnumWithPrimitiveIntrospect<> of dojo::database::introspect::Introspect> { #[inline(always)] fn size() -> Option { - Option::None + Option::Some(2) } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Enum( array![ dojo::database::introspect::FieldLayout { selector: 0, - layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Layout::Fixed(array![8].span()), - dojo::database::introspect::Introspect::::layout() - ].span() - ) + layout: dojo::database::introspect::Introspect::::layout() }, dojo::database::introspect::FieldLayout { selector: 1, - layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Layout::Fixed(array![8].span()), - dojo::database::introspect::Introspect::::layout() - ].span() - ) + layout: dojo::database::introspect::Introspect::::layout() } ].span() ) @@ -735,30 +710,28 @@ impl EnumWithStructDrop of core::traits::Drop::; impl EnumWithStructIntrospect<> of dojo::database::introspect::Introspect> { #[inline(always)] fn size() -> Option { - Option::None + let sizes : Array> = array![ + dojo::database::introspect::Introspect::::size(), +Option::Some(1) + ]; + + if dojo::database::utils::any_none(@sizes) { + return Option::None; + } + Option::Some(dojo::database::utils::sum(sizes)) + } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Enum( array![ dojo::database::introspect::FieldLayout { selector: 0, - layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Layout::Fixed(array![8].span()), - dojo::database::introspect::Introspect::::layout() - ].span() - ) + layout: dojo::database::introspect::Introspect::::layout() }, dojo::database::introspect::FieldLayout { selector: 1, - layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Layout::Fixed(array![8].span()), - dojo::database::introspect::Introspect::::layout() - ].span() - ) + layout: dojo::database::introspect::Introspect::::layout() } ].span() ) @@ -806,27 +779,16 @@ impl EnumWithSimpleArrayIntrospect<> of dojo::database::introspect::Introspect dojo::database::introspect::Layout { dojo::database::introspect::Layout::Enum( array![ dojo::database::introspect::FieldLayout { selector: 0, - layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Layout::Fixed(array![8].span()), - dojo::database::introspect::Introspect::>::layout() - ].span() - ) + layout: dojo::database::introspect::Introspect::>::layout() }, dojo::database::introspect::FieldLayout { selector: 1, - layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Layout::Fixed(array![8].span()), - dojo::database::introspect::Introspect::>::layout() - ].span() - ) + layout: dojo::database::introspect::Introspect::>::layout() } ].span() ) @@ -882,27 +844,16 @@ impl EnumWithByteArrayIntrospect<> of dojo::database::introspect::Introspect dojo::database::introspect::Layout { dojo::database::introspect::Layout::Enum( array![ dojo::database::introspect::FieldLayout { selector: 0, - layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Layout::Fixed(array![8].span()), - dojo::database::introspect::Introspect::::layout() - ].span() - ) + layout: dojo::database::introspect::Introspect::::layout() }, dojo::database::introspect::FieldLayout { selector: 1, - layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Layout::Fixed(array![8].span()), - dojo::database::introspect::Introspect::::layout() - ].span() - ) + layout: dojo::database::introspect::Introspect::::layout() } ].span() ) @@ -947,40 +898,29 @@ impl EnumWithSimpleTupleDrop of core::traits::Drop::; impl EnumWithSimpleTupleIntrospect<> of dojo::database::introspect::Introspect> { #[inline(always)] fn size() -> Option { - Option::None + Option::Some(4) } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Enum( array![ dojo::database::introspect::FieldLayout { selector: 0, layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Layout::Fixed(array![8].span()), - dojo::database::introspect::Layout::Tuple( array![ dojo::database::introspect::Introspect::::layout(), dojo::database::introspect::Introspect::::layout() ].span() ) - ].span() - ) }, dojo::database::introspect::FieldLayout { selector: 1, layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Layout::Fixed(array![8].span()), - dojo::database::introspect::Layout::Tuple( array![ dojo::database::introspect::Introspect::::layout(), dojo::database::introspect::Introspect::::layout() ].span() ) - ].span() - ) } ].span() ) @@ -1035,40 +975,38 @@ impl EnumWithComplexTupleDrop of core::traits::Drop::; impl EnumWithComplexTupleIntrospect<> of dojo::database::introspect::Introspect> { #[inline(always)] fn size() -> Option { - Option::None + let sizes : Array> = array![ + dojo::database::introspect::Introspect::::size(), +Option::Some(2) + ]; + + if dojo::database::utils::any_none(@sizes) { + return Option::None; + } + Option::Some(dojo::database::utils::sum(sizes)) + } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Enum( array![ dojo::database::introspect::FieldLayout { selector: 0, layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Layout::Fixed(array![8].span()), - dojo::database::introspect::Layout::Tuple( array![ dojo::database::introspect::Introspect::::layout(), dojo::database::introspect::Introspect::::layout() ].span() ) - ].span() - ) }, dojo::database::introspect::FieldLayout { selector: 1, layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Layout::Fixed(array![8].span()), - dojo::database::introspect::Layout::Tuple( array![ dojo::database::introspect::Introspect::::layout(), dojo::database::introspect::Introspect::::layout() ].span() ) - ].span() - ) } ].span() ) @@ -1099,62 +1037,43 @@ dojo::database::introspect::Introspect::::ty() ) } } -impl EnumTupleOnePrimitiveSerde of core::serde::Serde:: { - fn serialize(self: @EnumTupleOnePrimitive, ref output: core::array::Array) { +impl EnumWithPrimitiveSerde of core::serde::Serde:: { + fn serialize(self: @EnumWithPrimitive, ref output: core::array::Array) { match self { - EnumTupleOnePrimitive::Left(x) => { core::serde::Serde::serialize(@0, ref output); core::serde::Serde::serialize(x, ref output); }, - EnumTupleOnePrimitive::Right(x) => { core::serde::Serde::serialize(@1, ref output); core::serde::Serde::serialize(x, ref output); }, + EnumWithPrimitive::Left(x) => { core::serde::Serde::serialize(@0, ref output); core::serde::Serde::serialize(x, ref output); }, + EnumWithPrimitive::Right(x) => { core::serde::Serde::serialize(@1, ref output); core::serde::Serde::serialize(x, ref output); }, } } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { let idx: felt252 = core::serde::Serde::deserialize(ref serialized)?; core::option::Option::Some( match idx { - 0 => EnumTupleOnePrimitive::Left(core::serde::Serde::deserialize(ref serialized)?), - 1 => EnumTupleOnePrimitive::Right(core::serde::Serde::deserialize(ref serialized)?), + 0 => EnumWithPrimitive::Left(core::serde::Serde::deserialize(ref serialized)?), + 1 => EnumWithPrimitive::Right(core::serde::Serde::deserialize(ref serialized)?), _ => { return core::option::Option::None; } } ) } } -impl EnumTupleOnePrimitiveCopy of core::traits::Copy::; -impl EnumTupleOnePrimitiveDrop of core::traits::Drop::; +impl EnumWithPrimitiveCopy of core::traits::Copy::; +impl EnumWithPrimitiveDrop of core::traits::Drop::; -impl EnumTupleOnePrimitiveIntrospect<> of dojo::database::introspect::Introspect> { +impl EnumWithPrimitiveIntrospect<> of dojo::database::introspect::Introspect> { #[inline(always)] fn size() -> Option { - Option::None + Option::Some(2) } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Enum( array![ dojo::database::introspect::FieldLayout { selector: 0, - layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Layout::Fixed(array![8].span()), - dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Introspect::::layout() - ].span() - ) - ].span() - ) + layout: dojo::database::introspect::Introspect::::layout() }, dojo::database::introspect::FieldLayout { selector: 1, - layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Layout::Fixed(array![8].span()), - dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Introspect::::layout() - ].span() - ) - ].span() - ) + layout: dojo::database::introspect::Introspect::::layout() } ].span() ) @@ -1164,19 +1083,11 @@ dojo::database::introspect::FieldLayout { fn ty() -> dojo::database::introspect::Ty { dojo::database::introspect::Ty::Enum( dojo::database::introspect::Enum { - name: 'EnumTupleOnePrimitive', + name: 'EnumWithPrimitive', attrs: array![].span(), children: array![ - ('Left', dojo::database::introspect::Ty::Tuple( - array![ - dojo::database::introspect::Introspect::::ty() - ].span() - )), -('Right', dojo::database::introspect::Ty::Tuple( - array![ - dojo::database::introspect::Introspect::::ty() - ].span() - )) + ('Left', dojo::database::introspect::Introspect::::ty()), +('Right', dojo::database::introspect::Introspect::::ty()) ].span() } @@ -1207,30 +1118,28 @@ impl EnumCustomDrop of core::traits::Drop::; impl EnumCustomIntrospect<> of dojo::database::introspect::Introspect> { #[inline(always)] fn size() -> Option { - Option::None + let sizes : Array> = array![ + dojo::database::introspect::Introspect::::size(), +Option::Some(1) + ]; + + if dojo::database::utils::any_none(@sizes) { + return Option::None; + } + Option::Some(dojo::database::utils::sum(sizes)) + } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Enum( array![ dojo::database::introspect::FieldLayout { selector: 0, - layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Layout::Fixed(array![8].span()), - dojo::database::introspect::Introspect::::layout() - ].span() - ) + layout: dojo::database::introspect::Introspect::::layout() }, dojo::database::introspect::FieldLayout { selector: 1, - layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Layout::Fixed(array![8].span()), - dojo::database::introspect::Introspect::::layout() - ].span() - ) + layout: dojo::database::introspect::Introspect::::layout() } ].span() ) @@ -1275,42 +1184,41 @@ impl EnumTupleMixDrop of core::traits::Drop::; impl EnumTupleMixIntrospect<> of dojo::database::introspect::Introspect> { #[inline(always)] fn size() -> Option { - Option::None + let sizes : Array> = array![ + dojo::database::introspect::Introspect::::size(), +dojo::database::introspect::Introspect::::size(), +Option::Some(2) + ]; + + if dojo::database::utils::any_none(@sizes) { + return Option::None; + } + Option::Some(dojo::database::utils::sum(sizes)) + } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Enum( array![ dojo::database::introspect::FieldLayout { selector: 0, layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Layout::Fixed(array![8].span()), - dojo::database::introspect::Layout::Tuple( array![ dojo::database::introspect::Introspect::::layout(), dojo::database::introspect::Introspect::::layout(), dojo::database::introspect::Introspect::::layout() ].span() ) - ].span() - ) }, dojo::database::introspect::FieldLayout { selector: 1, layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Layout::Fixed(array![8].span()), - dojo::database::introspect::Layout::Tuple( array![ dojo::database::introspect::Introspect::::layout(), dojo::database::introspect::Introspect::::layout(), dojo::database::introspect::Introspect::::layout() ].span() ) - ].span() - ) } ].span() ) @@ -1372,41 +1280,25 @@ impl EnumWithDifferentVariantDataIntrospect<> of dojo::database::introspect::Int Option::None } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Enum( array![ dojo::database::introspect::FieldLayout { selector: 0, - layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Layout::Fixed(array![8].span()), - - ].span() - ) + layout: dojo::database::introspect::Layout::Fixed(array![].span()) }, dojo::database::introspect::FieldLayout { selector: 1, - layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Layout::Fixed(array![8].span()), - dojo::database::introspect::Introspect::::layout() - ].span() - ) + layout: dojo::database::introspect::Introspect::::layout() }, dojo::database::introspect::FieldLayout { selector: 2, layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Layout::Fixed(array![8].span()), - dojo::database::introspect::Layout::Tuple( array![ dojo::database::introspect::Introspect::::layout(), dojo::database::introspect::Introspect::::layout() ].span() ) - ].span() - ) } ].span() ) @@ -1442,7 +1334,6 @@ impl StructWithPrimitivesIntrospect<> of dojo::database::introspect::Introspect< Option::Some(2) } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -1493,18 +1384,17 @@ impl StructWithStructIntrospect<> of dojo::database::introspect::Introspect Option { let sizes : Array> = array![ - dojo::database::introspect::Introspect::::size(), + dojo::database::introspect::Introspect::::size(), Option::Some(1) - ]; + ]; - if dojo::database::utils::any_none(@sizes) { - return Option::None; - } - Option::Some(dojo::database::utils::sum(sizes)) - + if dojo::database::utils::any_none(@sizes) { + return Option::None; + } + Option::Some(dojo::database::utils::sum(sizes)) + } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -1557,7 +1447,6 @@ impl StructWithSimpleArrayIntrospect<> of dojo::database::introspect::Introspect Option::None } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -1614,7 +1503,6 @@ impl StructWithByteArrayIntrospect<> of dojo::database::introspect::Introspect dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -1667,7 +1555,6 @@ impl StructWithComplexArrayIntrospect<> of dojo::database::introspect::Introspec Option::None } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -1724,7 +1611,6 @@ impl StructWithSimpleTupleIntrospect<> of dojo::database::introspect::Introspect Option::Some(4) } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -1785,19 +1671,18 @@ impl StructWithComplexTupleIntrospect<> of dojo::database::introspect::Introspec #[inline(always)] fn size() -> Option { let sizes : Array> = array![ - dojo::database::introspect::Introspect::::size(), + dojo::database::introspect::Introspect::::size(), dojo::database::introspect::Introspect::::size(), Option::Some(2) - ]; + ]; - if dojo::database::utils::any_none(@sizes) { - return Option::None; - } - Option::Some(dojo::database::utils::sum(sizes)) - + if dojo::database::utils::any_none(@sizes) { + return Option::None; + } + Option::Some(dojo::database::utils::sum(sizes)) + } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -1862,7 +1747,6 @@ impl StructWithNestedArraysIntrospect<> of dojo::database::introspect::Introspec Option::None } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -1933,19 +1817,18 @@ impl StructWithNestedTuplesIntrospect<> of dojo::database::introspect::Introspec #[inline(always)] fn size() -> Option { let sizes : Array> = array![ - dojo::database::introspect::Introspect::::size(), + dojo::database::introspect::Introspect::::size(), dojo::database::introspect::Introspect::::size(), Option::Some(3) - ]; + ]; - if dojo::database::utils::any_none(@sizes) { - return Option::None; - } - Option::Some(dojo::database::utils::sum(sizes)) - + if dojo::database::utils::any_none(@sizes) { + return Option::None; + } + Option::Some(dojo::database::utils::sum(sizes)) + } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -2028,7 +1911,6 @@ impl StructWithNestedTuplesAndByteArrayIntrospect<> of dojo::database::introspec Option::None } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -2111,7 +1993,6 @@ impl StructWithNestedEverythingIntrospect<> of dojo::database::introspect::Intro Option::None } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -2244,7 +2125,6 @@ impl GenericStructIntrospect::size() } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -2293,7 +2173,6 @@ impl StructWithBadOptionIntrospect<> of dojo::database::introspect::Introspect>::size() } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -2347,29 +2226,23 @@ impl EnumWithBadOptionIntrospect<> of dojo::database::introspect::Introspect Option { let sizes : Array> = array![ - 8, -dojo::database::introspect::Introspect::>::size() - ]; + dojo::database::introspect::Introspect::>::size(), +Option::Some(1) + ]; - if dojo::database::utils::any_none(@sizes) { - return Option::None; - } - Option::Some(dojo::database::utils::sum(sizes)) - + if dojo::database::utils::any_none(@sizes) { + return Option::None; + } + Option::Some(dojo::database::utils::sum(sizes)) + } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Enum( array![ dojo::database::introspect::FieldLayout { selector: 0, - layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Layout::Fixed(array![8].span()), - dojo::database::introspect::Introspect::>::layout() - ].span() - ) + layout: dojo::database::introspect::Introspect::>::layout() } ].span() ) @@ -2396,7 +2269,6 @@ impl EnumIncompatibleAttrsIntrospect<> of dojo::database::introspect::Introspect Option::None } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Enum( array![ @@ -2426,7 +2298,6 @@ impl EnumIncompatibleAttrsIntrospect<> of dojo::database::introspect::Introspect Option::None } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Fixed( array![ @@ -2456,7 +2327,6 @@ impl StructIncompatibleAttrsIntrospect<> of dojo::database::introspect::Introspe Option::None } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -2486,7 +2356,6 @@ impl StructIncompatibleAttrsIntrospect<> of dojo::database::introspect::Introspe Option::None } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Fixed( array![ @@ -2516,7 +2385,6 @@ impl StructIncompatibleAttrs2Introspect<> of dojo::database::introspect::Introsp Option::None } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -2546,7 +2414,6 @@ impl StructIncompatibleAttrs2Introspect<> of dojo::database::introspect::Introsp Option::None } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Fixed( array![ @@ -2576,7 +2443,6 @@ impl EnumIncompatibleAttrs2Introspect<> of dojo::database::introspect::Introspec Option::None } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Enum( array![ @@ -2606,7 +2472,6 @@ impl EnumIncompatibleAttrs2Introspect<> of dojo::database::introspect::Introspec Option::None } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Fixed( array![ @@ -2636,7 +2501,6 @@ impl StructPacked1Introspect<> of dojo::database::introspect::Introspect dojo::database::introspect::Layout { dojo::database::introspect::Layout::Fixed( array![ @@ -2670,7 +2534,6 @@ impl StructPacked2Introspect<> of dojo::database::introspect::Introspect dojo::database::introspect::Layout { dojo::database::introspect::Layout::Fixed( array![ @@ -2709,7 +2572,6 @@ impl StructPacked3Introspect<> of dojo::database::introspect::Introspect dojo::database::introspect::Layout { dojo::database::introspect::Layout::Fixed( array![ @@ -2753,7 +2615,6 @@ impl StructNotPackable1Introspect<> of dojo::database::introspect::Introspect dojo::database::introspect::Layout { dojo::database::introspect::Layout::Fixed( array![ @@ -2790,35 +2651,54 @@ dojo::database::introspect::Member { } } -impl StructNotPackable2Introspect<> of dojo::database::introspect::Introspect> { +impl StructPackableWithInnerPackedIntrospect<> of dojo::database::introspect::Introspect> { #[inline(always)] fn size() -> Option { let sizes : Array> = array![ - dojo::database::introspect::Introspect::::size(), + dojo::database::introspect::Introspect::::size(), Option::Some(1) - ]; + ]; - if dojo::database::utils::any_none(@sizes) { - return Option::None; - } - Option::Some(dojo::database::utils::sum(sizes)) - + + Option::Some(dojo::database::utils::sum(sizes)) + } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Fixed( - array![ - 8,ERROR - ].span() - ) + let mut layouts = array![ + dojo::database::introspect::Layout::Fixed(array![8].span()), +dojo::database::introspect::Introspect::::layout() + ]; + let mut merged_layout = ArrayTrait::::new(); + + loop { + match ArrayTrait::pop_front(ref layouts) { + Option::Some(mut layout) => { + match layout { + dojo::database::introspect::Layout::Fixed(mut l) => { + loop { + match SpanTrait::pop_front(ref l) { + Option::Some(x) => merged_layout.append(*x), + Option::None(_) => { break; } + }; + }; + }, + _ => panic!("A packed model layout must contain Fixed layouts only."), + }; + }, + Option::None(_) => { break; } + }; + }; + + dojo::database::introspect::Layout::Fixed(merged_layout.span()) + } #[inline(always)] fn ty() -> dojo::database::introspect::Ty { dojo::database::introspect::Ty::Struct( dojo::database::introspect::Struct { - name: 'StructNotPackable2', + name: 'StructPackableWithInnerPacked', attrs: array![].span(), children: array![ dojo::database::introspect::Member { @@ -2841,12 +2721,15 @@ dojo::database::introspect::Member { impl EnumPacked1Introspect<> of dojo::database::introspect::Introspect> { #[inline(always)] fn size() -> Option { - Option::None + Option::Some(1) } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { - ERROR + dojo::database::introspect::Layout::Fixed( + array![ + 8 + ].span() + ) } #[inline(always)] @@ -2869,12 +2752,15 @@ impl EnumPacked1Introspect<> of dojo::database::introspect::Introspect of dojo::database::introspect::Introspect> { #[inline(always)] fn size() -> Option { - Option::None + Option::Some(2) } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { - ERROR + dojo::database::introspect::Layout::Fixed( + array![ + 8,8 + ].span() + ) } #[inline(always)] @@ -2897,12 +2783,15 @@ impl EnumPacked2Introspect<> of dojo::database::introspect::Introspect of dojo::database::introspect::Introspect> { #[inline(always)] fn size() -> Option { - Option::None + Option::Some(3) } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { - ERROR + dojo::database::introspect::Layout::Fixed( + array![ + 8,128,128 + ].span() + ) } #[inline(always)] @@ -2926,13 +2815,71 @@ dojo::database::introspect::Introspect::::ty() } } +impl EnumPackableWithInnerPackedIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + let sizes : Array> = array![ + dojo::database::introspect::Introspect::::size(), +Option::Some(1) + ]; + + + Option::Some(dojo::database::utils::sum(sizes)) + + } + + fn layout() -> dojo::database::introspect::Layout { + let mut layouts = array![ + dojo::database::introspect::Layout::Fixed(array![8].span()), +dojo::database::introspect::Introspect::::layout() + ]; + let mut merged_layout = ArrayTrait::::new(); + + loop { + match ArrayTrait::pop_front(ref layouts) { + Option::Some(mut layout) => { + match layout { + dojo::database::introspect::Layout::Fixed(mut l) => { + loop { + match SpanTrait::pop_front(ref l) { + Option::Some(x) => merged_layout.append(*x), + Option::None(_) => { break; } + }; + }; + }, + _ => panic!("A packed model layout must contain Fixed layouts only."), + }; + }, + Option::None(_) => { break; } + }; + }; + + dojo::database::introspect::Layout::Fixed(merged_layout.span()) + + } + + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Enum( + dojo::database::introspect::Enum { + name: 'EnumPackableWithInnerPacked', + attrs: array![].span(), + children: array![ + ('a', dojo::database::introspect::Introspect::::ty()), +('b', dojo::database::introspect::Introspect::::ty()) + + ].span() + } + ) + } +} + impl EnumNotPackable1Introspect<> of dojo::database::introspect::Introspect> { #[inline(always)] fn size() -> Option { Option::None } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { ERROR } @@ -2989,27 +2936,7 @@ error: Array field cannot be packed. y: Array ^**********^ -error: For now, field with custom type cannot be packed - --> test_src/lib.cairo:219:6 - y: StructPacked1 - ^*************^ - -error: To be packed, all variants must have exactly the same layout. - --> test_src/lib.cairo:223:6 -enum EnumPacked1 { - ^*********^ - -error: To be packed, all variants must have exactly the same layout. - --> test_src/lib.cairo:230:6 -enum EnumPacked2 { - ^*********^ - -error: To be packed, all variants must have exactly the same layout. - --> test_src/lib.cairo:237:6 -enum EnumPacked3 { - ^*********^ - -error: To be packed, all variants must have exactly the same layout. - --> test_src/lib.cairo:243:6 +error: To be packed, all variants must have fixed layout of same size. + --> test_src/lib.cairo:250:6 enum EnumNotPackable1 { ^**************^ diff --git a/crates/dojo-lang/src/plugin_test_data/model b/crates/dojo-lang/src/plugin_test_data/model index f644db0710..092bee2438 100644 --- a/crates/dojo-lang/src/plugin_test_data/model +++ b/crates/dojo-lang/src/plugin_test_data/model @@ -277,7 +277,6 @@ impl BadModelMultipleAttrIntrospect<> of dojo::database::introspect::Introspect< dojo::database::introspect::Introspect::::size() } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -319,7 +318,6 @@ impl BadModelMultipleVersionsIntrospect<> of dojo::database::introspect::Introsp dojo::database::introspect::Introspect::::size() } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -496,7 +494,6 @@ impl BadModelBadVersionTypeIntrospect<> of dojo::database::introspect::Introspec dojo::database::introspect::Introspect::::size() } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -673,7 +670,6 @@ impl BadModelNoVersionValueIntrospect<> of dojo::database::introspect::Introspec dojo::database::introspect::Introspect::::size() } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -850,7 +846,6 @@ impl BadModelUnexpectedArgWithValueIntrospect<> of dojo::database::introspect::I dojo::database::introspect::Introspect::::size() } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -1027,7 +1022,6 @@ impl BadModelUnexpectedArgIntrospect<> of dojo::database::introspect::Introspect dojo::database::introspect::Introspect::::size() } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -1204,7 +1198,6 @@ impl BadModelNotSupportedVersionIntrospect<> of dojo::database::introspect::Intr dojo::database::introspect::Introspect::::size() } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -1381,7 +1374,6 @@ impl Modelv0Introspect<> of dojo::database::introspect::Introspect> { dojo::database::introspect::Introspect::::size() } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -1558,7 +1550,6 @@ impl PositionIntrospect<> of dojo::database::introspect::Introspect> dojo::database::introspect::Introspect::::size() } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -1735,7 +1726,6 @@ impl RolesIntrospect<> of dojo::database::introspect::Introspect> { Option::None } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -1912,7 +1902,6 @@ impl OnlyKeyModelIntrospect<> of dojo::database::introspect::Introspect dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -2081,7 +2070,6 @@ impl U256KeyModelIntrospect<> of dojo::database::introspect::Introspect dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -2250,7 +2238,6 @@ impl PlayerIntrospect<> of dojo::database::introspect::Introspect> { Option::Some(1) } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -2432,7 +2419,6 @@ impl ModelWithSimpleArrayIntrospect<> of dojo::database::introspect::Introspect< Option::None } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -2623,7 +2609,6 @@ impl ModelWithByteArrayIntrospect<> of dojo::database::introspect::Introspect dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -2810,7 +2795,6 @@ impl ModelWithComplexArrayIntrospect<> of dojo::database::introspect::Introspect Option::None } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -3001,7 +2985,6 @@ impl ModelWithTupleIntrospect<> of dojo::database::introspect::Introspect dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ @@ -3197,18 +3180,17 @@ impl ModelWithTupleNoPrimitivesIntrospect<> of dojo::database::introspect::Intro #[inline(always)] fn size() -> Option { let sizes : Array> = array![ - dojo::database::introspect::Introspect::::size(), + dojo::database::introspect::Introspect::::size(), Option::Some(3) - ]; + ]; - if dojo::database::utils::any_none(@sizes) { - return Option::None; - } - Option::Some(dojo::database::utils::sum(sizes)) - + if dojo::database::utils::any_none(@sizes) { + return Option::None; + } + Option::Some(dojo::database::utils::sum(sizes)) + } - #[inline(always)] fn layout() -> dojo::database::introspect::Layout { dojo::database::introspect::Layout::Struct( array![ diff --git a/crates/dojo-types/src/schema.rs b/crates/dojo-types/src/schema.rs index e461dd8dfc..5b7a2615f3 100644 --- a/crates/dojo-types/src/schema.rs +++ b/crates/dojo-types/src/schema.rs @@ -250,7 +250,6 @@ impl std::fmt::Display for Ty { let str = self .iter() .filter_map(|ty| match ty { - Ty::Primitive(_) => None, Ty::Struct(s) => { let mut struct_str = format!("struct {} {{\n", s.name); for member in &s.children { @@ -272,6 +271,7 @@ impl std::fmt::Display for Ty { } Ty::Array(items_ty) => Some(format!("Array<{}>", items_ty[0].name())), Ty::ByteArray(_) => Some("ByteArray".to_string()), + _ => None, }) .collect::>() .join("\n\n"); diff --git a/crates/dojo-world/src/contracts/model_test.rs b/crates/dojo-world/src/contracts/model_test.rs index 1b581b0e5e..f32a7b5943 100644 --- a/crates/dojo-world/src/contracts/model_test.rs +++ b/crates/dojo-world/src/contracts/model_test.rs @@ -65,7 +65,7 @@ async fn test_model() { assert_eq!( position.class_hash(), - felt!("0x03c3632f38ab3ba550bd3c596e2af55002d43bc76b7b660a3a57b49795307c58") + felt!("0x03ab26e88be7885877f93964880ccb63a8acd8e58f941c48bef52f191fa79868") ); let moves = world.model_reader("Moves").await.unwrap(); diff --git a/crates/dojo-world/src/metadata_test.rs b/crates/dojo-world/src/metadata_test.rs index eeaf797188..8da0b1af36 100644 --- a/crates/dojo-world/src/metadata_test.rs +++ b/crates/dojo-world/src/metadata_test.rs @@ -145,10 +145,9 @@ async fn get_full_dojo_metadata_from_workspace() { ); assert!(env.world_address.is_some()); - assert!( - env.world_address - .unwrap() - .eq("0x29aea29955b6b0c0aabf92e265cd0bca14069575511ec9b6819ca2917277962") + assert_eq!( + env.world_address.unwrap(), + "0x26a8d9f2ac0348182bea206d913908ef77e439416713592ebc85941a69048d6" ); assert!(env.keystore_path.is_none()); diff --git a/crates/sozo/ops/src/model.rs b/crates/sozo/ops/src/model.rs index 21d206ab19..fd11cec2dd 100644 --- a/crates/sozo/ops/src/model.rs +++ b/crates/sozo/ops/src/model.rs @@ -1,10 +1,15 @@ use anyhow::Result; +use cainome::cairo_serde::{ByteArray, CairoSerde}; +use dojo_types::schema::Ty; use dojo_world::contracts::model::ModelReader; use dojo_world::contracts::world::WorldContractReader; use starknet::core::types::{BlockId, BlockTag, FieldElement}; +use starknet::core::utils::get_selector_from_name; use starknet::providers::jsonrpc::HttpTransport; use starknet::providers::JsonRpcClient; +const INDENT: &str = " "; + pub async fn model_class_hash( name: String, world_address: FieldElement, @@ -35,6 +40,29 @@ pub async fn model_contract_address( Ok(()) } +pub async fn model_layout( + name: String, + world_address: FieldElement, + provider: JsonRpcClient, +) -> Result<()> { + let mut world_reader = WorldContractReader::new(world_address, &provider); + world_reader.set_block(BlockId::Tag(BlockTag::Pending)); + + let model = world_reader.model_reader(&name).await?; + let layout = match model.layout().await { + Ok(x) => x, + Err(_) => anyhow::bail!( + "[Incorrect layout]\nThe model is packed but contains at least one custom type field \ + which is not packed.\nPlease check your model to fix this." + ), + }; + let schema = model.schema().await?; + + deep_print_layout(&name, &layout, &schema); + + Ok(()) +} + pub async fn model_schema( name: String, world_address: FieldElement, @@ -50,7 +78,7 @@ pub async fn model_schema( if to_json { println!("{}", serde_json::to_string_pretty(&schema)?) } else { - println!("{schema}"); + deep_print_ty(schema); } Ok(()) @@ -66,9 +94,560 @@ pub async fn model_get( world_reader.set_block(BlockId::Tag(BlockTag::Pending)); let model = world_reader.model_reader(&name).await?; - let entity = model.entity(&keys).await?; + let schema = model.schema().await?; + let values = model.entity_storage(&keys).await?; - println!("{entity}"); + deep_print_record(&schema, &keys, &values); Ok(()) } + +#[derive(Clone, Debug)] +struct LayoutInfo { + layout_type: LayoutInfoType, + name: String, + fields: Vec, +} + +#[derive(Clone, Debug)] +enum LayoutInfoType { + Struct, + Enum, + Tuple, + Array, +} + +#[derive(Clone, Debug)] +struct FieldLayoutInfo { + selector: String, + name: String, + layout: String, +} + +fn format_fixed(layout: &[u8]) -> String { + format!("[{}]", layout.iter().map(|x| x.to_string()).collect::>().join(", ")) +} + +fn format_layout_ref(type_name: &str) -> String { + format!("layout({type_name})") +} + +fn format_selector(selector: String) -> String { + if selector.starts_with("0x") { format!("[{}]", selector) } else { selector } +} + +fn format_name(name: String) -> String { + if !name.is_empty() { format!(" {} ", name) } else { name } +} + +fn format_field(selector: String, name: String, layout: String) -> String { + let layout = if layout.eq("[]") { "".to_string() } else { format!(": {layout}") }; + + format!("{INDENT}{:<20}{:<18}{}", format_selector(selector), format_name(name), layout) +} + +fn format_field_layout( + layout: &dojo_world::contracts::model::abigen::model::Layout, + schema: &dojo_types::schema::Ty, +) -> String { + match layout { + dojo_world::contracts::model::abigen::model::Layout::Fixed(x) => format_fixed(x), + dojo_world::contracts::model::abigen::model::Layout::ByteArray => { + "layout(ByteArray)".to_string() + } + _ => format_layout_ref(&get_name_from_schema(schema)), + } +} + +fn is_layout_in_list(list: &[LayoutInfo], name: &String) -> bool { + list.iter().any(|x| x.name.eq(name)) +} + +fn get_name_from_schema(schema: &dojo_types::schema::Ty) -> String { + match schema { + dojo_types::schema::Ty::Struct(s) => s.name.clone(), + dojo_types::schema::Ty::Enum(e) => e.name.clone(), + dojo_types::schema::Ty::Primitive(p) => match p { + dojo_types::primitive::Primitive::U8(_) => "u8".to_string(), + dojo_types::primitive::Primitive::U16(_) => "u16".to_string(), + dojo_types::primitive::Primitive::U32(_) => "u32".to_string(), + dojo_types::primitive::Primitive::U64(_) => "u64".to_string(), + dojo_types::primitive::Primitive::U128(_) => "u128".to_string(), + dojo_types::primitive::Primitive::U256(_) => "u256".to_string(), + dojo_types::primitive::Primitive::USize(_) => "usize".to_string(), + dojo_types::primitive::Primitive::Bool(_) => "bool".to_string(), + dojo_types::primitive::Primitive::Felt252(_) => "felt252".to_string(), + dojo_types::primitive::Primitive::ClassHash(_) => "ClassHash".to_string(), + dojo_types::primitive::Primitive::ContractAddress(_) => "ContractAddress".to_string(), + }, + dojo_types::schema::Ty::Tuple(t) => { + format!("({})", t.iter().map(get_name_from_schema).collect::>().join(", ")) + } + dojo_types::schema::Ty::Array(a) => format!("Array<{}>", get_name_from_schema(&a[0])), + _ => "".to_string(), + } +} + +fn get_printable_layout_list_from_struct( + field_layouts: &[dojo_world::contracts::model::abigen::model::FieldLayout], + schema: &dojo_types::schema::Ty, + layout_list: &mut Vec, +) { + if let dojo_types::schema::Ty::Struct(ss) = schema { + let name = get_name_from_schema(schema); + + // process main struct + if !is_layout_in_list(layout_list, &name) { + layout_list.push(LayoutInfo { + layout_type: LayoutInfoType::Struct, + name, + fields: field_layouts + .iter() + .zip(ss.children.iter().filter(|x| !x.key)) + .map(|(l, m)| FieldLayoutInfo { + selector: format!("{:#x}", l.selector), + name: m.name.clone(), + layout: format_field_layout(&l.layout, &m.ty), + }) + .collect::>(), + }); + } + + // process members + for (member_layout, member) in + field_layouts.iter().zip(ss.children.iter().filter(|x| !x.key)) + { + get_printable_layout_list(&member_layout.layout, &member.ty, layout_list); + } + }; +} + +fn get_printable_layout_list_from_enum( + field_layouts: &[dojo_world::contracts::model::abigen::model::FieldLayout], + schema: &dojo_types::schema::Ty, + layout_list: &mut Vec, +) { + if let dojo_types::schema::Ty::Enum(se) = schema { + let name = get_name_from_schema(schema); + + // proces main enum + if !is_layout_in_list(layout_list, &name) { + layout_list.push(LayoutInfo { + layout_type: LayoutInfoType::Enum, + name, + fields: field_layouts + .iter() + .zip(se.options.iter()) + .map(|(l, o)| FieldLayoutInfo { + selector: format!("{:#x}", l.selector), + name: o.name.to_string(), + layout: format_field_layout(&l.layout, &o.ty), + }) + .collect::>(), + }); + } + + // process variants + for (variant_layout, variant) in field_layouts.iter().zip(se.options.iter()) { + get_printable_layout_list(&variant_layout.layout, &variant.ty, layout_list); + } + } +} + +fn get_printable_layout_list_from_tuple( + item_layouts: &[dojo_world::contracts::model::abigen::model::Layout], + schema: &dojo_types::schema::Ty, + layout_list: &mut Vec, +) { + if let dojo_types::schema::Ty::Tuple(st) = schema { + let name = get_name_from_schema(schema); + + // process tuple + if !is_layout_in_list(layout_list, &name) { + layout_list.push(LayoutInfo { + layout_type: LayoutInfoType::Tuple, + name, + fields: item_layouts + .iter() + .enumerate() + .zip(st.iter()) + .map(|((i, l), s)| FieldLayoutInfo { + selector: format!("{:#x}", i), + name: "".to_string(), + layout: format_field_layout(l, s), + }) + .collect::>(), + }); + } + + // process tuple items + for (item_layout, item_schema) in item_layouts.iter().zip(st.iter()) { + get_printable_layout_list(item_layout, item_schema, layout_list); + } + } +} + +fn get_printable_layout_list_from_array( + item_layout: &dojo_world::contracts::model::abigen::model::Layout, + schema: &dojo_types::schema::Ty, + layout_list: &mut Vec, +) { + if let dojo_types::schema::Ty::Array(sa) = schema { + let name = get_name_from_schema(schema); + + // process array + if !is_layout_in_list(layout_list, &name) { + layout_list.push(LayoutInfo { + layout_type: LayoutInfoType::Array, + name, + fields: vec![FieldLayoutInfo { + selector: "[ItemIndex]".to_string(), + name: "".to_string(), + layout: format_field_layout(item_layout, &sa[0]), + }], + }); + } + + // process array item + get_printable_layout_list(item_layout, &sa[0], layout_list); + } +} + +fn get_printable_layout_list( + root_layout: &dojo_world::contracts::model::abigen::model::Layout, + schema: &dojo_types::schema::Ty, + layout_list: &mut Vec, +) { + match root_layout { + dojo_world::contracts::model::abigen::model::Layout::Struct(ls) => { + get_printable_layout_list_from_struct(ls, schema, layout_list); + } + dojo_world::contracts::model::abigen::model::Layout::Enum(le) => { + get_printable_layout_list_from_enum(le, schema, layout_list); + } + dojo_world::contracts::model::abigen::model::Layout::Tuple(lt) => { + get_printable_layout_list_from_tuple(lt, schema, layout_list); + } + dojo_world::contracts::model::abigen::model::Layout::Array(la) => { + get_printable_layout_list_from_array(&la[0], schema, layout_list); + } + _ => {} + }; +} + +fn print_layout_info(layout_info: LayoutInfo) { + let fields = layout_info + .fields + .into_iter() + .map(|f| format_field(f.selector, f.name, f.layout)) + .collect::>(); + let layout_title = match layout_info.layout_type { + LayoutInfoType::Struct => format!("Struct {} {{", layout_info.name), + + LayoutInfoType::Enum => { + format!("{:<42}: [251] (variant id)", format!("Enum {} {{", layout_info.name)) + } + LayoutInfoType::Tuple => format!("{} (", layout_info.name), + LayoutInfoType::Array => { + format!("{:<42}: [32] (length)", format!("{} (", layout_info.name)) + } + }; + let end_token = match layout_info.layout_type { + LayoutInfoType::Struct => '}', + LayoutInfoType::Enum => '}', + LayoutInfoType::Tuple => ')', + LayoutInfoType::Array => ')', + }; + + println!( + "{layout_title} +{} +{end_token}\n", + fields.join("\n") + ); +} + +// print the full Layout tree +fn deep_print_layout( + name: &String, + layout: &dojo_world::contracts::model::abigen::model::Layout, + schema: &dojo_types::schema::Ty, +) { + if let dojo_world::contracts::model::abigen::model::Layout::Fixed(lf) = layout { + println!("\n{} (packed)", name); + println!(" selector : {:#x}", get_selector_from_name(name).unwrap()); + println!(" layout : {}", format_fixed(lf)); + } else { + let mut layout_list = vec![]; + get_printable_layout_list(layout, schema, &mut layout_list); + + println!("\n{} selector: {:#x}\n", name, get_selector_from_name(name).unwrap()); + + for l in layout_list { + print_layout_info(l); + } + } +} + +fn _start_indent(level: usize, start_indent: bool) -> String { + if start_indent { INDENT.repeat(level) } else { "".to_string() } +} + +fn format_primitive( + p: &dojo_types::primitive::Primitive, + values: &mut Vec, + level: usize, + start_indent: bool, +) -> String { + let mut _p = *p; + let _ = _p.deserialize(values); + + format!("{}{}", _start_indent(level, start_indent), _p.to_sql_value().unwrap()) +} + +fn format_byte_array(values: &mut Vec, level: usize, start_indent: bool) -> String { + let bytearray = ByteArray::cairo_deserialize(values, 0).unwrap(); + values.drain(0..ByteArray::cairo_serialized_size(&bytearray)); + + format!("{}{}", _start_indent(level, start_indent), ByteArray::to_string(&bytearray).unwrap()) +} + +fn format_field_value( + member: &dojo_types::schema::Member, + values: &mut Vec, + level: usize, +) -> String { + let field_repr = format_record_value(&member.ty, values, level, false); + format!("{}{:<16}: {field_repr}", INDENT.repeat(level), member.name) +} + +fn format_array( + item: &dojo_types::schema::Ty, + values: &mut Vec, + level: usize, + start_indent: bool, +) -> String { + let length: u32 = values.remove(0).try_into().unwrap(); + let mut items = vec![]; + + for _ in 0..length { + items.push(format_record_value(item, values, level + 1, true)); + } + + format!( + "{}[\n{}\n{}]", + _start_indent(level, start_indent), + items.join(",\n"), + INDENT.repeat(level) + ) +} + +fn format_tuple( + items: &[dojo_types::schema::Ty], + values: &mut Vec, + level: usize, + start_indent: bool, +) -> String { + if items.is_empty() { + return "".to_string(); + } + + let items_repr = items + .iter() + .map(|x| format_record_value(x, values, level + 1, true)) + .collect::>() + .join(",\n"); + + format!("{}(\n{}\n{})", _start_indent(level, start_indent), items_repr, INDENT.repeat(level)) +} + +fn format_struct( + schema: &dojo_types::schema::Struct, + values: &mut Vec, + level: usize, + start_indent: bool, +) -> String { + let fields = schema + .children + .iter() + .map(|m| format_field_value(m, values, level + 1)) + .collect::>(); + + format!( + "{}{{\n{}\n{}}}", + _start_indent(level, start_indent), + fields.join(",\n"), + INDENT.repeat(level) + ) +} + +fn format_enum( + schema: &dojo_types::schema::Enum, + values: &mut Vec, + level: usize, + start_indent: bool, +) -> String { + let variant_index: u8 = values.remove(0).try_into().unwrap(); + let variant_index: usize = variant_index.into(); + let variant_name = format!("{}::{}", schema.name, schema.options[variant_index].name); + let variant_data = + format_record_value(&schema.options[variant_index].ty, values, level + 1, true); + + if variant_data.is_empty() { + format!("{}{variant_name}", _start_indent(level, start_indent),) + } else { + format!( + "{}{variant_name}(\n{}\n{})", + _start_indent(level, start_indent), + variant_data, + INDENT.repeat(level) + ) + } +} + +fn format_record_value( + schema: &dojo_types::schema::Ty, + values: &mut Vec, + level: usize, + start_indent: bool, +) -> String { + match schema { + dojo_types::schema::Ty::Primitive(p) => format_primitive(p, values, level, start_indent), + dojo_types::schema::Ty::ByteArray(_) => format_byte_array(values, level, start_indent), + dojo_types::schema::Ty::Struct(s) => format_struct(s, values, level, start_indent), + dojo_types::schema::Ty::Enum(e) => format_enum(e, values, level, start_indent), + dojo_types::schema::Ty::Array(a) => format_array(&a[0], values, level, start_indent), + dojo_types::schema::Ty::Tuple(t) => format_tuple(t, values, level, start_indent), + } +} + +// print the structured record values +fn deep_print_record( + schema: &dojo_types::schema::Ty, + keys: &[FieldElement], + values: &[FieldElement], +) { + let mut model_values = vec![]; + model_values.extend(keys); + model_values.extend(values); + + println!("{}", format_record_value(schema, &mut model_values, 0, true)); +} + +fn get_ty_repr(ty: &Ty) -> String { + match ty { + Ty::Primitive(p) => p.to_string(), + Ty::Struct(s) => s.name.clone(), + Ty::Enum(e) => e.name.clone(), + Ty::Tuple(items) => { + if items.is_empty() { + "".to_string() + } else { + format!("({},)", items.iter().map(get_ty_repr).collect::>().join(", ")) + } + } + Ty::Array(items) => format!("Array<{}>", get_ty_repr(&items[0])), + Ty::ByteArray(_) => "ByteArray".to_string(), + } +} + +// to verify if a Ty has already been processed (i.e is in the list), +// just compare their type representation. +fn is_ty_already_in_list(ty_list: &[Ty], ty: &Ty) -> bool { + let ty_repr = get_ty_repr(ty); + ty_list.iter().any(|t| get_ty_repr(t).eq(&ty_repr)) +} + +// parse the Ty tree from its root and extract Ty to print. +// (basically, structs and enums) +fn get_printable_ty_list(root_ty: &Ty, ty_list: &mut Vec) { + match root_ty { + Ty::Primitive(_) => {} + Ty::ByteArray(_) => {} + Ty::Struct(s) => { + if !is_ty_already_in_list(ty_list, root_ty) { + ty_list.push(root_ty.clone()); + } + + for member in &s.children { + if !is_ty_already_in_list(ty_list, &member.ty) { + get_printable_ty_list(&member.ty, ty_list); + } + } + } + Ty::Enum(e) => { + if !ty_list.contains(root_ty) { + ty_list.push(root_ty.clone()); + } + + for child in &e.options { + if !is_ty_already_in_list(ty_list, &child.ty) { + get_printable_ty_list(&child.ty, ty_list); + } + } + } + Ty::Tuple(tuple) => { + for item_ty in tuple { + if !is_ty_already_in_list(ty_list, item_ty) { + get_printable_ty_list(item_ty, ty_list); + } + } + } + Ty::Array(items_ty) => { + if !is_ty_already_in_list(ty_list, &items_ty[0]) { + get_printable_ty_list(&items_ty[0], ty_list) + } + } + }; +} + +pub fn format_ty_field(name: &String, ty: &Ty, is_key: bool) -> String { + let ty_repr = get_ty_repr(ty); + let ty_repr = if ty_repr.is_empty() { "".to_string() } else { format!(": {ty_repr}") }; + let key_repr = if is_key { " #[key]\n".to_string() } else { "".to_string() }; + + format! {"{key_repr} {name}{ty_repr}"} +} + +// print Ty representation if required. +// For example, there is no need to print any information about arrays or tuples +// as they are members of struct and their items will be printed. +pub fn print_ty(ty: &Ty) { + let ty_repr = match ty { + Ty::Struct(s) => { + let mut struct_str = format!("struct {} {{\n", s.name); + for member in &s.children { + struct_str.push_str(&format!( + "{},\n", + format_ty_field(&member.name, &member.ty, member.key) + )); + } + struct_str.push('}'); + Some(struct_str) + } + Ty::Enum(e) => { + let mut enum_str = format!("enum {} {{\n", e.name); + for child in &e.options { + enum_str + .push_str(&format!("{},\n", format_ty_field(&child.name, &child.ty, false))); + } + enum_str.push('}'); + Some(enum_str) + } + _ => None, + }; + + if let Some(ty_repr) = ty_repr { + println!("{}\n\n", ty_repr); + } +} + +// print the full Ty tree +pub fn deep_print_ty(root: Ty) { + let mut ty_list = vec![]; + get_printable_ty_list(&root, &mut ty_list); + + for ty in ty_list { + print_ty(&ty); + } +} diff --git a/crates/torii/core/Cargo.toml b/crates/torii/core/Cargo.toml index 6f99f9e213..cf1cb8cdd3 100644 --- a/crates/torii/core/Cargo.toml +++ b/crates/torii/core/Cargo.toml @@ -43,3 +43,4 @@ camino.workspace = true dojo-test-utils = { path = "../../dojo-test-utils" } scarb.workspace = true sozo = { path = "../../../bin/sozo" } +katana-runner.workspace = true diff --git a/crates/torii/core/src/sql_test.rs b/crates/torii/core/src/sql_test.rs index 7cc52b506f..360e0a988c 100644 --- a/crates/torii/core/src/sql_test.rs +++ b/crates/torii/core/src/sql_test.rs @@ -3,12 +3,10 @@ use std::str::FromStr; use camino::Utf8PathBuf; use dojo_test_utils::compiler; use dojo_test_utils::migration::prepare_migration; -use dojo_test_utils::sequencer::{ - get_default_test_starknet_config, SequencerConfig, TestSequencer, -}; use dojo_world::contracts::world::WorldContractReader; use dojo_world::migration::TxnConfig; use dojo_world::utils::TransactionWaiter; +use katana_runner::KatanaRunner; use scarb::ops; use sozo_ops::migration::execute_strategy; use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions}; @@ -71,14 +69,13 @@ async fn test_load_from_remote() { let mut migration = prepare_migration(base_dir.into(), target_dir.into()).unwrap(); migration.resolve_variable(migration.world_address().unwrap()).unwrap(); - let sequencer = - TestSequencer::start(SequencerConfig::default(), get_default_test_starknet_config()).await; + let sequencer = KatanaRunner::new().expect("Failed to start runner."); let provider = JsonRpcClient::new(HttpTransport::new(sequencer.url())); let world = WorldContractReader::new(migration.world_address().unwrap(), &provider); - let mut account = sequencer.account(); + let mut account = sequencer.account(0); account.set_block_id(BlockId::Tag(BlockTag::Pending)); let ws = ops::read_workspace(config.manifest_path(), &config) @@ -126,7 +123,7 @@ async fn test_load_from_remote() { assert_eq!(id, format!("{:#x}", get_selector_from_name("Position").unwrap())); assert_eq!(name, "Position"); - assert_eq!(packed_size, 0); + assert_eq!(packed_size, 1); assert_eq!(unpacked_size, 2); let (id, name, packed_size, unpacked_size): (String, String, u8, u8) = sqlx::query_as( @@ -139,7 +136,7 @@ async fn test_load_from_remote() { assert_eq!(id, format!("{:#x}", get_selector_from_name("Moves").unwrap())); assert_eq!(name, "Moves"); assert_eq!(packed_size, 0); - assert_eq!(unpacked_size, 0); + assert_eq!(unpacked_size, 2); let (id, name, packed_size, unpacked_size): (String, String, u8, u8) = sqlx::query_as( "SELECT id, name, packed_size, unpacked_size FROM models WHERE name = 'PlayerConfig'", diff --git a/crates/torii/types-test/manifests/dev/base/dojo_world_world.toml b/crates/torii/types-test/manifests/dev/base/dojo_world_world.toml index efc6f0ca39..2daf97b5e5 100644 --- a/crates/torii/types-test/manifests/dev/base/dojo_world_world.toml +++ b/crates/torii/types-test/manifests/dev/base/dojo_world_world.toml @@ -1,5 +1,5 @@ kind = "Class" -class_hash = "0x34aafe3ca8fd1aec61deea58541aefd0ec6647299939ad96e4cd3a79c47bb8e" -original_class_hash = "0x34aafe3ca8fd1aec61deea58541aefd0ec6647299939ad96e4cd3a79c47bb8e" +class_hash = "0x1fafbe78a4676c8998d2de2053bc2fba24aebbd4fb86f03ff6af87ad3314092" +original_class_hash = "0x1fafbe78a4676c8998d2de2053bc2fba24aebbd4fb86f03ff6af87ad3314092" abi = "manifests/dev/abis/base/dojo_world_world.json" name = "dojo::world::world" diff --git a/dojoup/dojoup b/dojoup/dojoup index 494a288576..bf9c0d999f 100755 --- a/dojoup/dojoup +++ b/dojoup/dojoup @@ -254,7 +254,7 @@ EOF } usage() { - cat 1>&2 <&2 <<'EOF' The installer for Dojo. Update or revert to a specific Dojo version with ease. diff --git a/examples/spawn-and-move/Scarb.toml b/examples/spawn-and-move/Scarb.toml index 93a78fbbd3..99366ce45b 100644 --- a/examples/spawn-and-move/Scarb.toml +++ b/examples/spawn-and-move/Scarb.toml @@ -25,4 +25,4 @@ rpc_url = "http://localhost:5050/" # Default account for katana with seed = 0 account_address = "0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03" private_key = "0x1800000000300000180000000000030000000000003006001800006600" -world_address = "0x29aea29955b6b0c0aabf92e265cd0bca14069575511ec9b6819ca2917277962" +world_address = "0x26a8d9f2ac0348182bea206d913908ef77e439416713592ebc85941a69048d6" diff --git a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples_actions_actions.toml b/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples_actions_actions.toml index 17294cff0a..5f84fa6760 100644 --- a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples_actions_actions.toml +++ b/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples_actions_actions.toml @@ -1,6 +1,6 @@ kind = "DojoContract" -class_hash = "0x44838b88a31f6cf954408395e5d4256d53640ca48a46658d08400ddf11790f5" -original_class_hash = "0x44838b88a31f6cf954408395e5d4256d53640ca48a46658d08400ddf11790f5" +class_hash = "0xfe09a42928890d712af285559b4452ebbc448428dfa91179bfee66715a2add" +original_class_hash = "0xfe09a42928890d712af285559b4452ebbc448428dfa91179bfee66715a2add" base_class_hash = "0x0" abi = "manifests/dev/abis/base/contracts/dojo_examples_actions_actions.json" reads = [] diff --git a/examples/spawn-and-move/manifests/dev/base/dojo_world_world.toml b/examples/spawn-and-move/manifests/dev/base/dojo_world_world.toml index efc6f0ca39..2daf97b5e5 100644 --- a/examples/spawn-and-move/manifests/dev/base/dojo_world_world.toml +++ b/examples/spawn-and-move/manifests/dev/base/dojo_world_world.toml @@ -1,5 +1,5 @@ kind = "Class" -class_hash = "0x34aafe3ca8fd1aec61deea58541aefd0ec6647299939ad96e4cd3a79c47bb8e" -original_class_hash = "0x34aafe3ca8fd1aec61deea58541aefd0ec6647299939ad96e4cd3a79c47bb8e" +class_hash = "0x1fafbe78a4676c8998d2de2053bc2fba24aebbd4fb86f03ff6af87ad3314092" +original_class_hash = "0x1fafbe78a4676c8998d2de2053bc2fba24aebbd4fb86f03ff6af87ad3314092" abi = "manifests/dev/abis/base/dojo_world_world.json" name = "dojo::world::world" diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_actions_actions_moved.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_actions_actions_moved.toml index 1c55c2930f..a9e0f20f78 100644 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_actions_actions_moved.toml +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_actions_actions_moved.toml @@ -1,6 +1,6 @@ kind = "DojoModel" -class_hash = "0x5508ab47983d4842a780fe483cb9ba5d24ad4b8d0196f767cd5983398b9f4c4" -original_class_hash = "0x5508ab47983d4842a780fe483cb9ba5d24ad4b8d0196f767cd5983398b9f4c4" +class_hash = "0x6f85952ceeb7783fb265a4b2d235db48e7a36357bbce7a56997ca5798c95187" +original_class_hash = "0x6f85952ceeb7783fb265a4b2d235db48e7a36357bbce7a56997ca5798c95187" abi = "manifests/dev/abis/base/models/dojo_examples_actions_actions_moved.json" name = "dojo_examples::actions::actions::moved" diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_emote_message.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_emote_message.toml index c408805a96..668a594127 100644 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_emote_message.toml +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_emote_message.toml @@ -1,6 +1,6 @@ kind = "DojoModel" -class_hash = "0x3c690e6a69960642e2e276299c04ee4eb57f8dabb0f59dc96b09faf39c82a9" -original_class_hash = "0x3c690e6a69960642e2e276299c04ee4eb57f8dabb0f59dc96b09faf39c82a9" +class_hash = "0x3e8f99f02409b7bc3dfffba58ee3807e3fb3513a2dcac1b0bd1f1118ea79ecc" +original_class_hash = "0x3e8f99f02409b7bc3dfffba58ee3807e3fb3513a2dcac1b0bd1f1118ea79ecc" abi = "manifests/dev/abis/base/models/dojo_examples_models_emote_message.json" name = "dojo_examples::models::emote_message" diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_moves.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_moves.toml index 4b5c015a39..db94e2ff11 100644 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_moves.toml +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_moves.toml @@ -1,6 +1,6 @@ kind = "DojoModel" -class_hash = "0x6eeffc6c72945b6ef419d3c67ed377408437782fdc41fa7a52339cd30d6c563" -original_class_hash = "0x6eeffc6c72945b6ef419d3c67ed377408437782fdc41fa7a52339cd30d6c563" +class_hash = "0x402d1ee5171aac681d16fa8c248a0498678082152e0f4c416776a71fc270684" +original_class_hash = "0x402d1ee5171aac681d16fa8c248a0498678082152e0f4c416776a71fc270684" abi = "manifests/dev/abis/base/models/dojo_examples_models_moves.json" name = "dojo_examples::models::moves" diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_player_config.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_player_config.toml index a285a51830..bbaa577a1c 100644 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_player_config.toml +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_player_config.toml @@ -1,6 +1,6 @@ kind = "DojoModel" -class_hash = "0x74e835af876c9f95977537b91d60d656f6ff2a4a8b2bb8d47448f345980f612" -original_class_hash = "0x74e835af876c9f95977537b91d60d656f6ff2a4a8b2bb8d47448f345980f612" +class_hash = "0x596f2ea7f78e3828f6daa798a271ef0a98741967afa40e680c2d80879be7d09" +original_class_hash = "0x596f2ea7f78e3828f6daa798a271ef0a98741967afa40e680c2d80879be7d09" abi = "manifests/dev/abis/base/models/dojo_examples_models_player_config.json" name = "dojo_examples::models::player_config" diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_position.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_position.toml index 88609b7a59..5bcac0ef22 100644 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_position.toml +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_position.toml @@ -1,6 +1,6 @@ kind = "DojoModel" -class_hash = "0x3c3632f38ab3ba550bd3c596e2af55002d43bc76b7b660a3a57b49795307c58" -original_class_hash = "0x3c3632f38ab3ba550bd3c596e2af55002d43bc76b7b660a3a57b49795307c58" +class_hash = "0x3ab26e88be7885877f93964880ccb63a8acd8e58f941c48bef52f191fa79868" +original_class_hash = "0x3ab26e88be7885877f93964880ccb63a8acd8e58f941c48bef52f191fa79868" abi = "manifests/dev/abis/base/models/dojo_examples_models_position.json" name = "dojo_examples::models::position" diff --git a/examples/spawn-and-move/manifests/dev/manifest.json b/examples/spawn-and-move/manifests/dev/manifest.json index 90c10bfbc0..00db8977b0 100644 --- a/examples/spawn-and-move/manifests/dev/manifest.json +++ b/examples/spawn-and-move/manifests/dev/manifest.json @@ -1,8 +1,8 @@ { "world": { "kind": "WorldContract", - "class_hash": "0x34aafe3ca8fd1aec61deea58541aefd0ec6647299939ad96e4cd3a79c47bb8e", - "original_class_hash": "0x34aafe3ca8fd1aec61deea58541aefd0ec6647299939ad96e4cd3a79c47bb8e", + "class_hash": "0x1fafbe78a4676c8998d2de2053bc2fba24aebbd4fb86f03ff6af87ad3314092", + "original_class_hash": "0x1fafbe78a4676c8998d2de2053bc2fba24aebbd4fb86f03ff6af87ad3314092", "abi": [ { "type": "impl", @@ -955,8 +955,8 @@ ] } ], - "address": "0x29aea29955b6b0c0aabf92e265cd0bca14069575511ec9b6819ca2917277962", - "transaction_hash": "0xa32990a5203fc3c67ba905f65a0161fa5435d8c28aa1e889cc09b551f431d3", + "address": "0x26a8d9f2ac0348182bea206d913908ef77e439416713592ebc85941a69048d6", + "transaction_hash": "0x4fb663d83b07373bf2844ef51acfb10d1e957a2fd6d573b7360ad64710df6cc", "block_number": 3, "seed": "dojo_examples", "metadata": { @@ -975,9 +975,9 @@ "contracts": [ { "kind": "DojoContract", - "address": "0xa0db53af8c89cbaab909bb34635262ffe36bbd414184e830eabfa6b592a17d", - "class_hash": "0x44838b88a31f6cf954408395e5d4256d53640ca48a46658d08400ddf11790f5", - "original_class_hash": "0x44838b88a31f6cf954408395e5d4256d53640ca48a46658d08400ddf11790f5", + "address": "0x43ec1c3a2195bc6adaa4134b7183cec4bae46f1388cb41c0fc808aba7e04b0", + "class_hash": "0xfe09a42928890d712af285559b4452ebbc448428dfa91179bfee66715a2add", + "original_class_hash": "0xfe09a42928890d712af285559b4452ebbc448428dfa91179bfee66715a2add", "base_class_hash": "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46", "abi": [ { @@ -1280,7 +1280,7 @@ }, { "kind": "DojoContract", - "address": "0x482b931a82a26a4d8501ff051b1c8e2c125b79c954dc5d5106988749129c9d3", + "address": "0x55d1b3b80ddfd912e33a6cb331665dfc0b8f1738fcbe8d4c4191e27cd12f9c4", "class_hash": "0x3ee016157303a7ce35a9fecdb5b8519159df620c5780527d61443636aaa3c3a", "original_class_hash": "0x3ee016157303a7ce35a9fecdb5b8519159df620c5780527d61443636aaa3c3a", "base_class_hash": "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46", @@ -1456,8 +1456,8 @@ "key": false } ], - "class_hash": "0x5508ab47983d4842a780fe483cb9ba5d24ad4b8d0196f767cd5983398b9f4c4", - "original_class_hash": "0x5508ab47983d4842a780fe483cb9ba5d24ad4b8d0196f767cd5983398b9f4c4", + "class_hash": "0x6f85952ceeb7783fb265a4b2d235db48e7a36357bbce7a56997ca5798c95187", + "original_class_hash": "0x6f85952ceeb7783fb265a4b2d235db48e7a36357bbce7a56997ca5798c95187", "abi": [ { "type": "impl", @@ -1863,8 +1863,8 @@ "key": false } ], - "class_hash": "0x3c690e6a69960642e2e276299c04ee4eb57f8dabb0f59dc96b09faf39c82a9", - "original_class_hash": "0x3c690e6a69960642e2e276299c04ee4eb57f8dabb0f59dc96b09faf39c82a9", + "class_hash": "0x3e8f99f02409b7bc3dfffba58ee3807e3fb3513a2dcac1b0bd1f1118ea79ecc", + "original_class_hash": "0x3e8f99f02409b7bc3dfffba58ee3807e3fb3513a2dcac1b0bd1f1118ea79ecc", "abi": [ { "type": "impl", @@ -2275,8 +2275,8 @@ "key": false } ], - "class_hash": "0x6eeffc6c72945b6ef419d3c67ed377408437782fdc41fa7a52339cd30d6c563", - "original_class_hash": "0x6eeffc6c72945b6ef419d3c67ed377408437782fdc41fa7a52339cd30d6c563", + "class_hash": "0x402d1ee5171aac681d16fa8c248a0498678082152e0f4c416776a71fc270684", + "original_class_hash": "0x402d1ee5171aac681d16fa8c248a0498678082152e0f4c416776a71fc270684", "abi": [ { "type": "impl", @@ -2696,8 +2696,8 @@ "key": false } ], - "class_hash": "0x74e835af876c9f95977537b91d60d656f6ff2a4a8b2bb8d47448f345980f612", - "original_class_hash": "0x74e835af876c9f95977537b91d60d656f6ff2a4a8b2bb8d47448f345980f612", + "class_hash": "0x596f2ea7f78e3828f6daa798a271ef0a98741967afa40e680c2d80879be7d09", + "original_class_hash": "0x596f2ea7f78e3828f6daa798a271ef0a98741967afa40e680c2d80879be7d09", "abi": [ { "type": "impl", @@ -3099,8 +3099,8 @@ "key": false } ], - "class_hash": "0x3c3632f38ab3ba550bd3c596e2af55002d43bc76b7b660a3a57b49795307c58", - "original_class_hash": "0x3c3632f38ab3ba550bd3c596e2af55002d43bc76b7b660a3a57b49795307c58", + "class_hash": "0x3ab26e88be7885877f93964880ccb63a8acd8e58f941c48bef52f191fa79868", + "original_class_hash": "0x3ab26e88be7885877f93964880ccb63a8acd8e58f941c48bef52f191fa79868", "abi": [ { "type": "impl", diff --git a/examples/spawn-and-move/manifests/dev/manifest.toml b/examples/spawn-and-move/manifests/dev/manifest.toml index 330a9fac1d..66680bf397 100644 --- a/examples/spawn-and-move/manifests/dev/manifest.toml +++ b/examples/spawn-and-move/manifests/dev/manifest.toml @@ -1,10 +1,10 @@ [world] kind = "WorldContract" -class_hash = "0x34aafe3ca8fd1aec61deea58541aefd0ec6647299939ad96e4cd3a79c47bb8e" -original_class_hash = "0x34aafe3ca8fd1aec61deea58541aefd0ec6647299939ad96e4cd3a79c47bb8e" +class_hash = "0x1fafbe78a4676c8998d2de2053bc2fba24aebbd4fb86f03ff6af87ad3314092" +original_class_hash = "0x1fafbe78a4676c8998d2de2053bc2fba24aebbd4fb86f03ff6af87ad3314092" abi = "manifests/dev/abis/deployments/dojo_world_world.json" -address = "0x29aea29955b6b0c0aabf92e265cd0bca14069575511ec9b6819ca2917277962" -transaction_hash = "0xa32990a5203fc3c67ba905f65a0161fa5435d8c28aa1e889cc09b551f431d3" +address = "0x26a8d9f2ac0348182bea206d913908ef77e439416713592ebc85941a69048d6" +transaction_hash = "0x4fb663d83b07373bf2844ef51acfb10d1e957a2fd6d573b7360ad64710df6cc" block_number = 3 seed = "dojo_examples" name = "dojo::world::world" @@ -21,9 +21,9 @@ name = "dojo::base::base" [[contracts]] kind = "DojoContract" -address = "0xa0db53af8c89cbaab909bb34635262ffe36bbd414184e830eabfa6b592a17d" -class_hash = "0x44838b88a31f6cf954408395e5d4256d53640ca48a46658d08400ddf11790f5" -original_class_hash = "0x44838b88a31f6cf954408395e5d4256d53640ca48a46658d08400ddf11790f5" +address = "0x43ec1c3a2195bc6adaa4134b7183cec4bae46f1388cb41c0fc808aba7e04b0" +class_hash = "0xfe09a42928890d712af285559b4452ebbc448428dfa91179bfee66715a2add" +original_class_hash = "0xfe09a42928890d712af285559b4452ebbc448428dfa91179bfee66715a2add" base_class_hash = "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46" abi = "manifests/dev/abis/deployments/contracts/dojo_examples_actions_actions.json" reads = [] @@ -37,7 +37,7 @@ name = "dojo_examples::actions::actions" [[contracts]] kind = "DojoContract" -address = "0x482b931a82a26a4d8501ff051b1c8e2c125b79c954dc5d5106988749129c9d3" +address = "0x55d1b3b80ddfd912e33a6cb331665dfc0b8f1738fcbe8d4c4191e27cd12f9c4" class_hash = "0x3ee016157303a7ce35a9fecdb5b8519159df620c5780527d61443636aaa3c3a" original_class_hash = "0x3ee016157303a7ce35a9fecdb5b8519159df620c5780527d61443636aaa3c3a" base_class_hash = "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46" @@ -54,8 +54,8 @@ name = "dojo_examples::others::others" [[models]] kind = "DojoModel" -class_hash = "0x5508ab47983d4842a780fe483cb9ba5d24ad4b8d0196f767cd5983398b9f4c4" -original_class_hash = "0x5508ab47983d4842a780fe483cb9ba5d24ad4b8d0196f767cd5983398b9f4c4" +class_hash = "0x6f85952ceeb7783fb265a4b2d235db48e7a36357bbce7a56997ca5798c95187" +original_class_hash = "0x6f85952ceeb7783fb265a4b2d235db48e7a36357bbce7a56997ca5798c95187" abi = "manifests/dev/abis/deployments/models/dojo_examples_actions_actions_moved.json" name = "dojo_examples::actions::actions::moved" @@ -71,8 +71,8 @@ key = false [[models]] kind = "DojoModel" -class_hash = "0x3c690e6a69960642e2e276299c04ee4eb57f8dabb0f59dc96b09faf39c82a9" -original_class_hash = "0x3c690e6a69960642e2e276299c04ee4eb57f8dabb0f59dc96b09faf39c82a9" +class_hash = "0x3e8f99f02409b7bc3dfffba58ee3807e3fb3513a2dcac1b0bd1f1118ea79ecc" +original_class_hash = "0x3e8f99f02409b7bc3dfffba58ee3807e3fb3513a2dcac1b0bd1f1118ea79ecc" abi = "manifests/dev/abis/deployments/models/dojo_examples_models_emote_message.json" name = "dojo_examples::models::emote_message" @@ -88,8 +88,8 @@ key = false [[models]] kind = "DojoModel" -class_hash = "0x6eeffc6c72945b6ef419d3c67ed377408437782fdc41fa7a52339cd30d6c563" -original_class_hash = "0x6eeffc6c72945b6ef419d3c67ed377408437782fdc41fa7a52339cd30d6c563" +class_hash = "0x402d1ee5171aac681d16fa8c248a0498678082152e0f4c416776a71fc270684" +original_class_hash = "0x402d1ee5171aac681d16fa8c248a0498678082152e0f4c416776a71fc270684" abi = "manifests/dev/abis/deployments/models/dojo_examples_models_moves.json" name = "dojo_examples::models::moves" @@ -110,8 +110,8 @@ key = false [[models]] kind = "DojoModel" -class_hash = "0x74e835af876c9f95977537b91d60d656f6ff2a4a8b2bb8d47448f345980f612" -original_class_hash = "0x74e835af876c9f95977537b91d60d656f6ff2a4a8b2bb8d47448f345980f612" +class_hash = "0x596f2ea7f78e3828f6daa798a271ef0a98741967afa40e680c2d80879be7d09" +original_class_hash = "0x596f2ea7f78e3828f6daa798a271ef0a98741967afa40e680c2d80879be7d09" abi = "manifests/dev/abis/deployments/models/dojo_examples_models_player_config.json" name = "dojo_examples::models::player_config" @@ -137,8 +137,8 @@ key = false [[models]] kind = "DojoModel" -class_hash = "0x3c3632f38ab3ba550bd3c596e2af55002d43bc76b7b660a3a57b49795307c58" -original_class_hash = "0x3c3632f38ab3ba550bd3c596e2af55002d43bc76b7b660a3a57b49795307c58" +class_hash = "0x3ab26e88be7885877f93964880ccb63a8acd8e58f941c48bef52f191fa79868" +original_class_hash = "0x3ab26e88be7885877f93964880ccb63a8acd8e58f941c48bef52f191fa79868" abi = "manifests/dev/abis/deployments/models/dojo_examples_models_position.json" name = "dojo_examples::models::position" diff --git a/examples/spawn-and-move/src/models.cairo b/examples/spawn-and-move/src/models.cairo index 635b9c312f..e04859bdf4 100644 --- a/examples/spawn-and-move/src/models.cairo +++ b/examples/spawn-and-move/src/models.cairo @@ -47,13 +47,17 @@ struct Moves { last_direction: Direction } -#[derive(Copy, Drop, Serde, Introspect)] +#[derive(Copy, Drop, Serde, IntrospectPacked)] struct Vec2 { x: u32, y: u32 } -#[derive(Copy, Drop, Serde)] +// If `Vec2` wasn't packed, the `Position` would be invalid, +// and a runtime error would be thrown. +// Any field that is a custom type into a `IntrospectPacked` type +// must be packed. +#[derive(Copy, Drop, Serde, IntrospectPacked)] #[dojo::model] struct Position { #[key] @@ -61,6 +65,8 @@ struct Position { vec: Vec2, } +// Every field inside a model must derive `Introspect` or `IntrospectPacked`. +// `IntrospectPacked` can also be used into models that are only using `Introspect`. #[derive(Copy, Drop, Serde, Introspect)] struct PlayerItem { item_id: u32, From 61c6f399447d2bd01073f9e2a8b1d50f658b0d97 Mon Sep 17 00:00:00 2001 From: Larko <59736843+Larkooo@users.noreply.github.com> Date: Wed, 29 May 2024 08:41:31 -0400 Subject: [PATCH 10/16] feat(torii-core): multi dimensional array support (#1994) * feat(torii-core): multi dimensional array support * refactor: model data objects construction * feat: handle 2d+ arrays in graphql * fmt * clippy * fix: clippy * fmt --------- Co-authored-by: glihm --- crates/torii/core/src/sql.rs | 112 ++++++++++-------- crates/torii/graphql/src/object/entity.rs | 43 +++++-- crates/torii/graphql/src/object/model_data.rs | 86 ++++---------- crates/torii/graphql/src/query/mod.rs | 3 +- 4 files changed, 118 insertions(+), 126 deletions(-) diff --git a/crates/torii/core/src/sql.rs b/crates/torii/core/src/sql.rs index 5060bc7e07..efe9190150 100644 --- a/crates/torii/core/src/sql.rs +++ b/crates/torii/core/src/sql.rs @@ -130,8 +130,8 @@ impl Sql { vec![model.name()], &mut model_idx, block_timestamp, - false, - false, + &mut 0, + &mut 0, ); self.query_queue.execute_all().await?; @@ -186,7 +186,7 @@ impl Sql { (&entity_id, false), &entity, block_timestamp, - None, + &vec![], ); self.query_queue.execute_all().await?; @@ -241,7 +241,7 @@ impl Sql { (&entity_id, true), &entity, block_timestamp, - None, + &vec![], ); self.query_queue.execute_all().await?; @@ -413,8 +413,8 @@ impl Sql { path: Vec, model_idx: &mut i64, block_timestamp: u64, - is_array: bool, - is_parent_array: bool, + array_idx: &mut usize, + parent_array_idx: &mut usize, ) { if let Ty::Enum(e) = model { if e.options.iter().all(|o| if let Ty::Tuple(t) = &o.ty { t.is_empty() } else { false }) @@ -428,8 +428,8 @@ impl Sql { model, *model_idx, block_timestamp, - is_array, - is_parent_array, + *array_idx, + *parent_array_idx, ); let mut build_member = |pathname: &str, member: &Ty| { @@ -447,9 +447,8 @@ impl Sql { path_clone, &mut (*model_idx + 1), block_timestamp, - // If the parent is an array, all children are also represented as table arrays - if let Ty::Array(_) = member { true } else { is_array }, - if let Ty::Array(_) = model { true } else { is_parent_array }, + &mut (*array_idx + if let Ty::Array(_) = member { 1 } else { 0 }), + &mut (*parent_array_idx + if let Ty::Array(_) = model { 1 } else { 0 }), ); }; @@ -486,12 +485,12 @@ impl Sql { entity_id: (&str, bool), entity: &Ty, block_timestamp: u64, - index: Option, + indexes: &Vec, ) { let (entity_id, is_event_message) = entity_id; let update_members = - |members: &[Member], query_queue: &mut QueryQueue, index: Option| { + |members: &[Member], query_queue: &mut QueryQueue, indexes: &Vec| { let table_id = path.join("$"); let mut columns = vec![ "id".to_string(), @@ -517,9 +516,9 @@ impl Sql { Argument::String(entity_id.to_string()), ]; - if let Some(idx) = index { - columns.push("idx".to_string()); - arguments.push(Argument::Int(idx)); + for (column_idx, idx) in indexes.iter().enumerate() { + columns.push(format!("idx_{}", column_idx)); + arguments.push(Argument::Int(*idx)); } for member in members.iter() { @@ -552,7 +551,7 @@ impl Sql { match entity { Ty::Struct(s) => { - update_members(&s.children, &mut self.query_queue, index); + update_members(&s.children, &mut self.query_queue, indexes); for member in s.children.iter() { let mut path_clone = path.clone(); @@ -563,7 +562,7 @@ impl Sql { (entity_id, is_event_message), &member.ty, block_timestamp, - index, + indexes, ); } } @@ -584,7 +583,7 @@ impl Sql { Member { name: option.name.clone(), ty: option.ty.clone(), key: false }, ], &mut self.query_queue, - index, + indexes, ); match &option.ty { @@ -599,7 +598,7 @@ impl Sql { (entity_id, is_event_message), &option.ty, block_timestamp, - index, + indexes, ); } } @@ -616,7 +615,7 @@ impl Sql { .collect::>() .as_slice(), &mut self.query_queue, - index, + indexes, ); for (idx, member) in t.iter().enumerate() { @@ -628,25 +627,34 @@ impl Sql { (entity_id, is_event_message), member, block_timestamp, - index, + indexes, ); } } Ty::Array(array) => { - // delete all previous array elements - self.query_queue.enqueue( - format!( - "DELETE FROM [{table_id}] WHERE entity_id = ?", - table_id = path.join("$") - ), - vec![Argument::String(entity_id.to_string())], - ); + // delete all previous array elements with the array indexes + let table_id = path.join("$"); + let mut query = + format!("DELETE FROM [{table_id}] WHERE entity_id = ? ", table_id = table_id); + for idx in 0..indexes.len() { + query.push_str(&format!("AND idx_{} = ? ", idx)); + } + + // flatten indexes with entity id + let mut arguments = vec![Argument::String(entity_id.to_string())]; + arguments.extend(indexes.iter().map(|idx| Argument::Int(*idx))); + self.query_queue.enqueue(query, arguments); + + // insert the new array elements for (idx, member) in array.iter().enumerate() { + let mut indexes = indexes.clone(); + indexes.push(idx as i64); + update_members( &[Member { name: "data".to_string(), ty: member.clone(), key: false }], &mut self.query_queue, - Some(idx as i64), + &indexes, ); let mut path_clone = path.clone(); @@ -657,7 +665,7 @@ impl Sql { (entity_id, is_event_message), member, block_timestamp, - Some(idx as i64), + &indexes, ); } } @@ -704,8 +712,8 @@ impl Sql { model: &Ty, model_idx: i64, block_timestamp: u64, - is_array: bool, - is_parent_array: bool, + array_idx: usize, + parent_array_idx: usize, ) { let table_id = path.join("$"); let mut indices = Vec::new(); @@ -715,8 +723,10 @@ impl Sql { entity_id TEXT, event_message_id TEXT, " ); - if is_array { - create_table_query.push_str("idx INTEGER NOT NULL, "); + if array_idx > 0 { + for i in 0..array_idx { + create_table_query.push_str(&format!("idx_{i} INTEGER NOT NULL, ", i = i)); + } } let mut build_member = |name: &str, ty: &Ty, options: &mut Option| { @@ -907,24 +917,26 @@ impl Sql { if path.len() > 1 { let parent_table_id = path[..path.len() - 1].join("$"); - if is_parent_array && path.len() > 2 { - create_table_query.push_str(&format!( - "FOREIGN KEY (id, idx) REFERENCES {parent_table_id} (id, idx) ON DELETE \ - CASCADE, " - )); - } else { - create_table_query.push_str(&format!( - "FOREIGN KEY (id) REFERENCES {parent_table_id} (id), ", - parent_table_id = parent_table_id - )); + create_table_query.push_str("FOREIGN KEY (id"); + for i in 0..parent_array_idx { + create_table_query.push_str(&format!(", idx_{i}", i = i)); } + create_table_query.push_str(&format!( + ") REFERENCES {parent_table_id} (id", + parent_table_id = parent_table_id + )); + for i in 0..parent_array_idx { + create_table_query.push_str(&format!(", idx_{i}", i = i)); + } + create_table_query.push_str(") ON DELETE CASCADE, "); }; - if is_array { - create_table_query.push_str("PRIMARY KEY (id, idx), "); - } else { - create_table_query.push_str("PRIMARY KEY (id), "); + create_table_query.push_str("PRIMARY KEY (id"); + for i in 0..array_idx { + create_table_query.push_str(&format!(", idx_{i}", i = i)); } + create_table_query.push_str("), "); + create_table_query.push_str("FOREIGN KEY (entity_id) REFERENCES entities(id), "); // create_table_query.push_str("FOREIGN KEY (event_id) REFERENCES events(id), "); create_table_query diff --git a/crates/torii/graphql/src/object/entity.rs b/crates/torii/graphql/src/object/entity.rs index c098f7b4d4..281f6bb356 100644 --- a/crates/torii/graphql/src/object/entity.rs +++ b/crates/torii/graphql/src/object/entity.rs @@ -143,8 +143,9 @@ fn model_union_field() -> Field { &mut conn, vec![name.clone()], &entity_id, - None, + &[], &type_mapping, + false, ) .await? { @@ -169,15 +170,16 @@ pub async fn model_data_recursive_query( conn: &mut PoolConnection, path_array: Vec, entity_id: &str, - idx: Option, + indexes: &[i64], type_mapping: &TypeMapping, + is_list: bool, ) -> sqlx::Result { // For nested types, we need to remove prefix in path array let namespace = format!("{}_", path_array[0]); let table_name = &path_array.join("$").replace(&namespace, ""); let mut query = format!("SELECT * FROM {} WHERE entity_id = '{}' ", table_name, entity_id); - if let Some(idx) = idx { - query.push_str(&format!("AND idx = {}", idx)); + for (column_idx, index) in indexes.iter().enumerate() { + query.push_str(&format!("AND idx_{} = {} ", column_idx, index)); } let rows = sqlx::query(&query).fetch_all(conn.as_mut()).await?; @@ -200,8 +202,15 @@ pub async fn model_data_recursive_query( conn, nested_path, entity_id, - if rows.len() > 1 { Some(idx as i64) } else { None }, + &if is_list { + let mut indexes = indexes.to_vec(); + indexes.push(idx as i64); + indexes + } else { + indexes.to_vec() + }, nested_mapping, + false, ) .await?; @@ -215,8 +224,15 @@ pub async fn model_data_recursive_query( nested_path, entity_id, // this might need to be changed to support 2d+ arrays - None, + &if is_list { + let mut indexes = indexes.to_vec(); + indexes.push(idx as i64); + indexes + } else { + indexes.to_vec() + }, &IndexMap::from([(Name::new("data"), *inner.clone())]), + true, ) .await? { @@ -226,10 +242,19 @@ pub async fn model_data_recursive_query( .iter() .map(|v| match v { Value::Object(map) => map.get(&Name::new("data")).unwrap().clone(), - _ => unreachable!(), + _ => unreachable!( + "Expected Value::Object for list \"data\" field, got {:?}", + v + ), }) .collect(), - _ => unreachable!(), + Value::Object(map) => map.get(&Name::new("data")).unwrap().clone(), + ty => { + unreachable!( + "Expected Value::List or Value::Object for list, got {:?}", + ty + ); + } }; nested_value_mapping.insert(Name::new(field_name), data); @@ -239,7 +264,7 @@ pub async fn model_data_recursive_query( nested_value_mappings.push(Value::Object(nested_value_mapping)); } - if nested_value_mappings.len() > 1 { + if is_list { value_mapping = Value::List(nested_value_mappings); } else { value_mapping = nested_value_mappings.pop().unwrap(); diff --git a/crates/torii/graphql/src/object/model_data.rs b/crates/torii/graphql/src/object/model_data.rs index 2f05d6e592..4b221f9146 100644 --- a/crates/torii/graphql/src/object/model_data.rs +++ b/crates/torii/graphql/src/object/model_data.rs @@ -1,5 +1,3 @@ -use std::ops::Deref; - use async_graphql::dynamic::{Enum, Field, FieldFuture, InputObject, Object, TypeRef}; use async_graphql::Value; use chrono::{DateTime, Utc}; @@ -67,9 +65,8 @@ impl BasicObject for ModelDataObject { fn objects(&self) -> Vec { let mut objects = data_objects_recursion( - self.type_name(), - self.type_mapping(), - vec![self.type_name().to_string()], + &TypeData::Nested((TypeRef::named(self.type_name()), self.type_mapping.clone())), + &vec![self.type_name().to_string()], ); // root object requires entity_field association @@ -142,71 +139,28 @@ impl ResolvableObject for ModelDataObject { } } -// fn data_objects_recursion(type_data: &TypeData, path_array: Vec) -> Vec { -// let mut objects: Vec = vec![]; -// match type_data { -// TypeData::Nested((nested_type, nested_mapping)) => { -// let mut nested_path = path_array.clone(); -// nested_path.push(nested_type.to_string()); -// let nested_objects = nested_mapping.iter().flat_map(|(field_name, type_data)| { -// let mut nested_path = nested_path.clone(); -// nested_path.push(field_name.to_string()); -// data_objects_recursion(type_data, nested_path) -// }); - -// objects.extend(nested_objects); -// objects.push(object(&nested_type.to_string(), nested_mapping, path_array)); -// } -// TypeData::List(inner) => { -// let mut nested_path = path_array.clone(); -// nested_path.push(inner.type_ref().to_string()); -// let nested_objects = data_objects_recursion(inner, nested_path); - -// objects.extend(nested_objects); -// } -// _ => {} -// } - -// objects -// } - -fn data_objects_recursion( - type_name: &str, - type_mapping: &TypeMapping, - path_array: Vec, -) -> Vec { - let mut objects: Vec = type_mapping - .iter() - .filter_map(|(field_name, type_data)| { - if let TypeData::Nested((nested_type, nested_mapping)) = type_data { +fn data_objects_recursion(type_data: &TypeData, path_array: &Vec) -> Vec { + let mut objects: Vec = vec![]; + + match type_data { + TypeData::Nested((nested_type, nested_mapping)) => { + let nested_objects = nested_mapping.iter().flat_map(|(field_name, type_data)| { let mut nested_path = path_array.clone(); nested_path.push(field_name.to_string()); - let nested_objects = - data_objects_recursion(&nested_type.to_string(), nested_mapping, nested_path); - - Some(nested_objects) - } else if let TypeData::List(inner) = type_data { - if let TypeData::Nested((nested_type, nested_mapping)) = inner.deref() { - let mut nested_path = path_array.clone(); - nested_path.push(inner.type_ref().to_string()); - let nested_objects = data_objects_recursion( - &nested_type.to_string(), - nested_mapping, - nested_path, - ); - - return Some(nested_objects); - } + data_objects_recursion(type_data, &nested_path) + }); - None - } else { - None - } - }) - .flatten() - .collect(); + objects.extend(nested_objects); + objects.push(object(&nested_type.to_string(), nested_mapping, path_array.clone())); + } + TypeData::List(inner) => { + let nested_objects = data_objects_recursion(inner, path_array); + + objects.extend(nested_objects); + } + _ => {} + } - objects.push(object(type_name, type_mapping, path_array)); objects } diff --git a/crates/torii/graphql/src/query/mod.rs b/crates/torii/graphql/src/query/mod.rs index b2f8f8a005..8a3f2f8a73 100644 --- a/crates/torii/graphql/src/query/mod.rs +++ b/crates/torii/graphql/src/query/mod.rs @@ -114,8 +114,9 @@ fn parse_nested_type(member: &ModelMember, nested_members: &[&ModelMember]) -> T && nested_member .id .split('$') + .take(nested_member.id.split('$').count() - 1) .collect::>() - .starts_with(&member.id.split('$').collect::>()) + .eq(&member.id.split('$').collect::>()) { // if the nested member is an Enum and the member is an Enum, we need to inject the // Enum type in order to have a "option" field in the nested Enum From d14bc1ca323cec101af09c3e4e804165d01047f9 Mon Sep 17 00:00:00 2001 From: lambda-0x <0xlambda@protonmail.com> Date: Wed, 29 May 2024 18:57:29 +0530 Subject: [PATCH 11/16] feat(sozo): in build stats add bytecode and class size of casm class (#2004) * feat(sozo): in build stats add bytecode and class size of casm class * skip non-dojo build files * sort by contract_name * fix lints * clean up types * consider file size of minified json not pretty printed json * make table compact * add message before table for context --- Cargo.lock | 1 + bin/sozo/src/commands/build.rs | 92 ++++++++++++++----- crates/sozo/ops/Cargo.toml | 1 + crates/sozo/ops/src/statistics.rs | 146 +++++++++++++++++++++--------- 4 files changed, 173 insertions(+), 67 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 094618803f..c06643dc96 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12052,6 +12052,7 @@ dependencies = [ "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "cairo-lang-sierra-to-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-starknet-classes 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "cairo-lang-test-plugin", "cairo-lang-test-runner", "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", diff --git a/bin/sozo/src/commands/build.rs b/bin/sozo/src/commands/build.rs index 06e7967ccc..d8112bb51f 100644 --- a/bin/sozo/src/commands/build.rs +++ b/bin/sozo/src/commands/build.rs @@ -9,6 +9,11 @@ use scarb::ops::{CompileOpts, FeaturesOpts, FeaturesSelector}; use sozo_ops::statistics::{get_contract_statistics_for_dir, ContractStatistics}; use tracing::trace; +const BYTECODE_SIZE_LABEL: &str = "Bytecode size [in felts]\n(Sierra, Casm)"; +const CONTRACT_CLASS_SIZE_LABEL: &str = "Contract Class size [in bytes]\n(Sierra, Casm)"; + +const CONTRACT_NAME_LABEL: &str = "Contract"; + #[derive(Debug, Args)] pub struct BuildArgs { #[arg(long)] @@ -61,7 +66,7 @@ impl BuildArgs { if self.stats { let target_dir = &compile_info.target_dir; - let contracts_statistics = get_contract_statistics_for_dir(target_dir) + let contracts_statistics = get_contract_statistics_for_dir(config.ui(), target_dir) .context("Error getting contracts stats")?; trace!( ?contracts_statistics, @@ -69,6 +74,22 @@ impl BuildArgs { "Read contract statistics for target directory." ); + let ui = config.ui(); + + ui.print( + "Bytecode: It is low-level code that constitutes smart contracts and is \ + represented by an array of felts.", + ); + ui.print("Bytecode size: It is number of felts in Bytecode."); + ui.print( + "Contract Class: It serve as the fundamental building blocks of smart contracts.", + ); + ui.print( + "Contract Class size: It denotes the file size of the minified JSON \ + representation of the contract class.", + ); + ui.print(" "); + let table = create_stats_table(contracts_statistics); table.printstd() } @@ -95,26 +116,40 @@ impl BuildArgs { } } -fn create_stats_table(contracts_statistics: Vec) -> Table { +fn create_stats_table(mut contracts_statistics: Vec) -> Table { let mut table = Table::new(); table.set_format(*FORMAT_NO_LINESEP_WITH_TITLE); // Add table headers table.set_titles(Row::new(vec![ - Cell::new_align("Contract", format::Alignment::CENTER), - Cell::new_align("Bytecode size (felts)", format::Alignment::CENTER), - Cell::new_align("Class size (bytes)", format::Alignment::CENTER), + Cell::new_align(CONTRACT_NAME_LABEL, format::Alignment::CENTER), + Cell::new_align(BYTECODE_SIZE_LABEL, format::Alignment::CENTER), + Cell::new_align(CONTRACT_CLASS_SIZE_LABEL, format::Alignment::CENTER), ])); + // sort contracts in alphabetical order + contracts_statistics.sort_by(|a, b| a.contract_name.cmp(&b.contract_name)); + for contract_stats in contracts_statistics { // Add table rows let contract_name = contract_stats.contract_name; - let number_felts = contract_stats.number_felts; - let file_size = contract_stats.file_size; + + let sierra_bytecode_size = contract_stats.sierra_bytecode_size; + let sierra_contract_class_size = contract_stats.sierra_contract_class_size; + + let casm_bytecode_size = contract_stats.casm_bytecode_size; + let casm_contract_class_size = contract_stats.casm_contract_class_size; + table.add_row(Row::new(vec![ Cell::new_align(&contract_name, format::Alignment::LEFT), - Cell::new_align(format!("{}", number_felts).as_str(), format::Alignment::RIGHT), - Cell::new_align(format!("{}", file_size).as_str(), format::Alignment::RIGHT), + Cell::new_align( + format!("{}, {}", sierra_bytecode_size, casm_bytecode_size).as_str(), + format::Alignment::CENTER, + ), + Cell::new_align( + format!("{}, {}", sierra_contract_class_size, casm_contract_class_size).as_str(), + format::Alignment::CENTER, + ), ])); } @@ -129,7 +164,8 @@ mod tests { use prettytable::{format, Cell, Row, Table}; use sozo_ops::statistics::ContractStatistics; - use super::{create_stats_table, BuildArgs}; + use super::{create_stats_table, BuildArgs, *}; + use crate::commands::build::CONTRACT_NAME_LABEL; // Uncomment once bindings support arrays. #[test] @@ -156,42 +192,48 @@ mod tests { let contracts_statistics = vec![ ContractStatistics { contract_name: "Test1".to_string(), - number_felts: 33, - file_size: 33, + sierra_bytecode_size: 33, + sierra_contract_class_size: 33, + casm_bytecode_size: 66, + casm_contract_class_size: 66, }, ContractStatistics { contract_name: "Test2".to_string(), - number_felts: 43, - file_size: 24, + sierra_bytecode_size: 43, + sierra_contract_class_size: 24, + casm_bytecode_size: 86, + casm_contract_class_size: 48, }, ContractStatistics { contract_name: "Test3".to_string(), - number_felts: 36, - file_size: 12, + sierra_bytecode_size: 36, + sierra_contract_class_size: 12, + casm_bytecode_size: 72, + casm_contract_class_size: 24, }, ]; let mut expected_table = Table::new(); expected_table.set_format(*FORMAT_NO_LINESEP_WITH_TITLE); expected_table.set_titles(Row::new(vec![ - Cell::new_align("Contract", format::Alignment::CENTER), - Cell::new_align("Bytecode size (felts)", format::Alignment::CENTER), - Cell::new_align("Class size (bytes)", format::Alignment::CENTER), + Cell::new_align(CONTRACT_NAME_LABEL, format::Alignment::CENTER), + Cell::new_align(BYTECODE_SIZE_LABEL, format::Alignment::CENTER), + Cell::new_align(CONTRACT_CLASS_SIZE_LABEL, format::Alignment::CENTER), ])); expected_table.add_row(Row::new(vec![ Cell::new_align("Test1", format::Alignment::LEFT), - Cell::new_align(format!("{}", 33).as_str(), format::Alignment::RIGHT), - Cell::new_align(format!("{}", 33).as_str(), format::Alignment::RIGHT), + Cell::new_align(format!("{}, {}", 33, 66).as_str(), format::Alignment::CENTER), + Cell::new_align(format!("{}, {}", 33, 66).as_str(), format::Alignment::CENTER), ])); expected_table.add_row(Row::new(vec![ Cell::new_align("Test2", format::Alignment::LEFT), - Cell::new_align(format!("{}", 43).as_str(), format::Alignment::RIGHT), - Cell::new_align(format!("{}", 24).as_str(), format::Alignment::RIGHT), + Cell::new_align(format!("{}, {}", 43, 86).as_str(), format::Alignment::CENTER), + Cell::new_align(format!("{}, {}", 24, 48).as_str(), format::Alignment::CENTER), ])); expected_table.add_row(Row::new(vec![ Cell::new_align("Test3", format::Alignment::LEFT), - Cell::new_align(format!("{}", 36).as_str(), format::Alignment::RIGHT), - Cell::new_align(format!("{}", 12).as_str(), format::Alignment::RIGHT), + Cell::new_align(format!("{}, {}", 36, 72).as_str(), format::Alignment::CENTER), + Cell::new_align(format!("{}, {}", 12, 24).as_str(), format::Alignment::CENTER), ])); // Act diff --git a/crates/sozo/ops/Cargo.toml b/crates/sozo/ops/Cargo.toml index 78c10e0dd5..e4eded4705 100644 --- a/crates/sozo/ops/Cargo.toml +++ b/crates/sozo/ops/Cargo.toml @@ -16,6 +16,7 @@ cairo-lang-plugins.workspace = true cairo-lang-project.workspace = true cairo-lang-sierra-to-casm.workspace = true cairo-lang-sierra.workspace = true +cairo-lang-starknet-classes.workspace = true cairo-lang-starknet.workspace = true cairo-lang-test-plugin.workspace = true cairo-lang-test-runner.workspace = true diff --git a/crates/sozo/ops/src/statistics.rs b/crates/sozo/ops/src/statistics.rs index 81b77a15b7..b02a0dcbf8 100644 --- a/crates/sozo/ops/src/statistics.rs +++ b/crates/sozo/ops/src/statistics.rs @@ -1,45 +1,70 @@ use std::fs::{self, File}; -use std::io::{self, BufReader}; +use std::io::BufReader; use std::path::PathBuf; use anyhow::{Context, Result}; +use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; +use cairo_lang_starknet_classes::contract_class::ContractClass; use camino::Utf8PathBuf; -use starknet::core::types::contract::SierraClass; -use starknet::core::types::FlattenedSierraClass; +use scarb_ui::Ui; +use serde::Serialize; #[derive(Debug, PartialEq)] pub struct ContractStatistics { pub contract_name: String, - pub number_felts: u64, - pub file_size: u64, + + pub sierra_bytecode_size: u64, + pub sierra_contract_class_size: u64, + + pub casm_bytecode_size: u64, + pub casm_contract_class_size: u64, } -fn read_sierra_json_program(file: &File) -> Result { - let contract_artifact: SierraClass = serde_json::from_reader(BufReader::new(file))?; - let contract_artifact: FlattenedSierraClass = contract_artifact.flatten()?; +fn get_sierra_and_casm_class_from_file(file: &File) -> Result<(ContractClass, CasmContractClass)> { + let sierra_contract_class: ContractClass = serde_json::from_reader(BufReader::new(file))?; + let casm_contract_class: CasmContractClass = + CasmContractClass::from_contract_class(sierra_contract_class.clone(), false, usize::MAX)?; - Ok(contract_artifact) + Ok((sierra_contract_class, casm_contract_class)) } -fn get_sierra_byte_code_size(contract_artifact: FlattenedSierraClass) -> u64 { +fn get_sierra_byte_code_size(contract_artifact: ContractClass) -> u64 { contract_artifact.sierra_program.len() as u64 } -fn get_file_size(file: &File) -> Result { - file.metadata().map(|metadata| metadata.len()) +fn get_casm_byte_code_size(contract_artifact: CasmContractClass) -> u64 { + contract_artifact.bytecode.len() as u64 +} + +fn get_file_size_from_struct(t: &T) -> u64 +where + T: Serialize, +{ + serde_json::to_string(t).context("should be valid json").unwrap().len().try_into().unwrap() } fn get_contract_statistics_for_file( contract_name: String, - sierra_json_file: File, - contract_artifact: FlattenedSierraClass, + sierra_class: ContractClass, + casm_class: CasmContractClass, ) -> Result { - let file_size = get_file_size(&sierra_json_file).context("Error getting file size")?; - let number_felts = get_sierra_byte_code_size(contract_artifact); - Ok(ContractStatistics { file_size, contract_name, number_felts }) + let sierra_contract_class_size = get_file_size_from_struct(&sierra_class); + let sierra_bytecode_size = get_sierra_byte_code_size(sierra_class); + + let casm_contract_class_size = get_file_size_from_struct(&casm_class); + let casm_bytecode_size = get_casm_byte_code_size(casm_class); + + Ok(ContractStatistics { + contract_name, + sierra_bytecode_size, + sierra_contract_class_size, + casm_bytecode_size, + casm_contract_class_size, + }) } pub fn get_contract_statistics_for_dir( + ui: Ui, target_directory: &Utf8PathBuf, ) -> Result> { let mut contract_statistics = Vec::new(); @@ -55,19 +80,31 @@ pub fn get_contract_statistics_for_dir( let contract_name: String = path.file_stem().context("Error getting file name")?.to_string_lossy().to_string(); + // To ignore files like `contract.contract_class.json` or + // `contract.compiled_contract_class.json` + if contract_name.contains('.') { + continue; + } + let sierra_json_file: File = File::open(&path).context(format!("Error opening file: {}", path.to_string_lossy()))?; - let contract_artifact: FlattenedSierraClass = read_sierra_json_program(&sierra_json_file) - .context(format!( - "Error parsing Sierra class artifact: {}", - path.to_string_lossy() - ))?; + let (sierra_class, casm_class) = + match get_sierra_and_casm_class_from_file(&sierra_json_file) { + Ok(s) => s, + Err(e) => { + ui.verbose(format!("Unable to process file: {:?}\nWith error: {e:?}", &path)); + // skip any file which cannot be processed properly since there can be other + // file types in target folder for example casm contract + // class. + continue; + } + }; contract_statistics.push(get_contract_statistics_for_file( contract_name, - sierra_json_file, - contract_artifact, + sierra_class, + casm_class, )?); } Ok(contract_statistics) @@ -76,14 +113,18 @@ pub fn get_contract_statistics_for_dir( #[cfg(test)] mod tests { use std::fs::File; + use std::io::BufReader; use std::path::Path; + use cairo_lang_starknet_classes::contract_class::ContractClass; use camino::Utf8PathBuf; + use scarb_ui::Ui; use super::{ - get_contract_statistics_for_dir, get_contract_statistics_for_file, get_file_size, - get_sierra_byte_code_size, read_sierra_json_program, ContractStatistics, + get_contract_statistics_for_dir, get_contract_statistics_for_file, + get_sierra_and_casm_class_from_file, get_sierra_byte_code_size, ContractStatistics, }; + use crate::statistics::get_casm_byte_code_size; const TEST_SIERRA_JSON_CONTRACT: &str = "../../../bin/sozo/tests/test_data/compiled_contracts/test_contract.json"; @@ -94,16 +135,27 @@ mod tests { fn get_sierra_byte_code_size_returns_correct_size() { let sierra_json_file = File::open(TEST_SIERRA_JSON_CONTRACT) .unwrap_or_else(|err| panic!("Failed to open file: {}", err)); - let flattened_sierra_class = read_sierra_json_program(&sierra_json_file) - .unwrap_or_else(|err| panic!("Failed to read JSON program: {}", err)); - const EXPECTED_NUMBER_OF_FELTS: u64 = 2175; + let (flattened_sierra_class, casm_class) = + get_sierra_and_casm_class_from_file(&sierra_json_file) + .unwrap_or_else(|err| panic!("Failed to read JSON program: {}", err)); + + const SIERRA_EXPECTED_NUMBER_OF_FELTS: u64 = 2175; - let number_of_felts = get_sierra_byte_code_size(flattened_sierra_class); + let sierra_bytecode_size = get_sierra_byte_code_size(flattened_sierra_class); + let casm_bytecode_size = get_casm_byte_code_size(casm_class); + + const CASM_EXPECTED_NUMBER_OF_FELTS: u64 = 4412; + + assert_eq!( + sierra_bytecode_size, SIERRA_EXPECTED_NUMBER_OF_FELTS, + "[Sierra] Number of felts mismatch. Expected {}, got {}", + SIERRA_EXPECTED_NUMBER_OF_FELTS, sierra_bytecode_size + ); assert_eq!( - number_of_felts, EXPECTED_NUMBER_OF_FELTS, - "Number of felts mismatch. Expected {}, got {}", - EXPECTED_NUMBER_OF_FELTS, number_of_felts + casm_bytecode_size, CASM_EXPECTED_NUMBER_OF_FELTS, + "[Casm] Number of felts mismatch. Expected {}, got {}", + CASM_EXPECTED_NUMBER_OF_FELTS, casm_bytecode_size ); } @@ -111,21 +163,27 @@ mod tests { fn get_contract_statistics_for_file_returns_correct_statistics() { let sierra_json_file = File::open(TEST_SIERRA_JSON_CONTRACT) .unwrap_or_else(|err| panic!("Failed to open file: {}", err)); - let contract_artifact = read_sierra_json_program(&sierra_json_file) + + let (sierra_class, casm_class) = get_sierra_and_casm_class_from_file(&sierra_json_file) .unwrap_or_else(|err| panic!("Failed to read JSON program: {}", err)); + let filename = Path::new(TEST_SIERRA_JSON_CONTRACT) .file_stem() .expect("Error getting file name") .to_string_lossy() .to_string(); + let expected_contract_statistics: ContractStatistics = ContractStatistics { contract_name: String::from("test_contract"), - number_felts: 2175, - file_size: 114925, + sierra_bytecode_size: 2175, + sierra_contract_class_size: 106559, + + casm_bytecode_size: 4412, + casm_contract_class_size: 95806, }; let statistics = - get_contract_statistics_for_file(filename.clone(), sierra_json_file, contract_artifact) + get_contract_statistics_for_file(filename.clone(), sierra_class, casm_class) .expect("Error getting contract statistics for file"); assert_eq!(statistics, expected_contract_statistics); @@ -134,8 +192,9 @@ mod tests { #[test] fn get_contract_statistics_for_dir_returns_correct_statistics() { let target_dir = Utf8PathBuf::from(TEST_SIERRA_FOLDER_CONTRACTS); + let ui = Ui::new(scarb_ui::Verbosity::Normal, scarb_ui::OutputFormat::Text); - let contract_statistics = get_contract_statistics_for_dir(&target_dir) + let contract_statistics = get_contract_statistics_for_dir(ui, &target_dir) .unwrap_or_else(|_| panic!("Error getting contracts in dir {target_dir}")); assert_eq!(contract_statistics.len(), 1, "Mismatch number of contract statistics"); @@ -145,10 +204,13 @@ mod tests { fn get_file_size_returns_correct_size() { let sierra_json_file = File::open(TEST_SIERRA_JSON_CONTRACT) .unwrap_or_else(|err| panic!("Failed to open test file: {}", err)); - const EXPECTED_SIZE: u64 = 114925; + // file size of minified json + const EXPECTED_SIZE: u64 = 106559; - let file_size = get_file_size(&sierra_json_file) - .unwrap_or_else(|_| panic!("Error getting file size for test file")); + let sierra_contract_class: ContractClass = + serde_json::from_reader(BufReader::new(sierra_json_file)).unwrap(); + let file_size: u64 = + serde_json::to_string(&sierra_contract_class).unwrap().len().try_into().unwrap(); assert_eq!(file_size, EXPECTED_SIZE, "File size mismatch"); } @@ -159,7 +221,7 @@ mod tests { let sierra_json_file = File::open(TEST_SIERRA_JSON_CONTRACT) .unwrap_or_else(|err| panic!("Failed to open test file: {}", err)); - let result = read_sierra_json_program(&sierra_json_file); + let result = get_sierra_and_casm_class_from_file(&sierra_json_file); assert!(result.is_ok(), "Expected Ok result"); } From 8cfb0ba6d1398c5f77a5ea2fb07a8cd06489f874 Mon Sep 17 00:00:00 2001 From: notV4l <122404722+notV4l@users.noreply.github.com> Date: Wed, 29 May 2024 16:31:22 +0200 Subject: [PATCH 12/16] [dojo-core] use const array for pow2 (#1878) * use const array for pow2 * fix: fix world address and tests * fix: run scarb fmt * fix: add tx waiter to avoid test race condition --------- Co-authored-by: glihm --- crates/dojo-core/.tool-versions | 1 - crates/dojo-core/src/packing.cairo | 269 +++++++++++++++++- crates/dojo-core/src/packing_test.cairo | 15 +- .../manifests/dev/base/dojo_world_world.toml | 4 +- crates/dojo-world/src/metadata_test.rs | 2 +- crates/katana/rpc/rpc/tests/torii.rs | 5 +- .../manifests/dev/base/dojo_world_world.toml | 4 +- examples/spawn-and-move/Scarb.toml | 2 +- .../manifests/dev/base/dojo_world_world.toml | 4 +- .../manifests/dev/manifest.json | 12 +- .../manifests/dev/manifest.toml | 12 +- 11 files changed, 305 insertions(+), 25 deletions(-) delete mode 100644 crates/dojo-core/.tool-versions diff --git a/crates/dojo-core/.tool-versions b/crates/dojo-core/.tool-versions deleted file mode 100644 index 21cfc80772..0000000000 --- a/crates/dojo-core/.tool-versions +++ /dev/null @@ -1 +0,0 @@ -scarb 2.4.0 diff --git a/crates/dojo-core/src/packing.cairo b/crates/dojo-core/src/packing.cairo index 759700428b..22676d53ed 100644 --- a/crates/dojo-core/src/packing.cairo +++ b/crates/dojo-core/src/packing.cairo @@ -156,9 +156,274 @@ fn fpow(x: u256, n: u8) -> u256 { } fn shl(x: u256, n: u8) -> u256 { - x * fpow(2, n) + x * pow2_const(n) } fn shr(x: u256, n: u8) -> u256 { - x / fpow(2, n) + x / pow2_const(n) } + +fn pow2_const(n: u8) -> u256 { + *POW_2.span().at(n.into()) +} + +const POW_2: [ + u256 + ; 256] = [ + 1, + 2, + 4, + 8, + 16, + 32, + 64, + 128, + 256, + 512, + 1024, + 2048, + 4096, + 8192, + 16384, + 32768, + 65536, + 131072, + 262144, + 524288, + 1048576, + 2097152, + 4194304, + 8388608, + 16777216, + 33554432, + 67108864, + 134217728, + 268435456, + 536870912, + 1073741824, + 2147483648, + 4294967296, + 8589934592, + 17179869184, + 34359738368, + 68719476736, + 137438953472, + 274877906944, + 549755813888, + 1099511627776, + 2199023255552, + 4398046511104, + 8796093022208, + 17592186044416, + 35184372088832, + 70368744177664, + 140737488355328, + 281474976710656, + 562949953421312, + 1125899906842624, + 2251799813685248, + 4503599627370496, + 9007199254740992, + 18014398509481984, + 36028797018963968, + 72057594037927936, + 144115188075855872, + 288230376151711744, + 576460752303423488, + 1152921504606846976, + 2305843009213693952, + 4611686018427387904, + 9223372036854775808, + 18446744073709551616, + 36893488147419103232, + 73786976294838206464, + 147573952589676412928, + 295147905179352825856, + 590295810358705651712, + 1180591620717411303424, + 2361183241434822606848, + 4722366482869645213696, + 9444732965739290427392, + 18889465931478580854784, + 37778931862957161709568, + 75557863725914323419136, + 151115727451828646838272, + 302231454903657293676544, + 604462909807314587353088, + 1208925819614629174706176, + 2417851639229258349412352, + 4835703278458516698824704, + 9671406556917033397649408, + 19342813113834066795298816, + 38685626227668133590597632, + 77371252455336267181195264, + 154742504910672534362390528, + 309485009821345068724781056, + 618970019642690137449562112, + 1237940039285380274899124224, + 2475880078570760549798248448, + 4951760157141521099596496896, + 9903520314283042199192993792, + 19807040628566084398385987584, + 39614081257132168796771975168, + 79228162514264337593543950336, + 158456325028528675187087900672, + 316912650057057350374175801344, + 633825300114114700748351602688, + 1267650600228229401496703205376, + 2535301200456458802993406410752, + 5070602400912917605986812821504, + 10141204801825835211973625643008, + 20282409603651670423947251286016, + 40564819207303340847894502572032, + 81129638414606681695789005144064, + 162259276829213363391578010288128, + 324518553658426726783156020576256, + 649037107316853453566312041152512, + 1298074214633706907132624082305024, + 2596148429267413814265248164610048, + 5192296858534827628530496329220096, + 10384593717069655257060992658440192, + 20769187434139310514121985316880384, + 41538374868278621028243970633760768, + 83076749736557242056487941267521536, + 166153499473114484112975882535043072, + 332306998946228968225951765070086144, + 664613997892457936451903530140172288, + 1329227995784915872903807060280344576, + 2658455991569831745807614120560689152, + 5316911983139663491615228241121378304, + 10633823966279326983230456482242756608, + 21267647932558653966460912964485513216, + 42535295865117307932921825928971026432, + 85070591730234615865843651857942052864, + 170141183460469231731687303715884105728, + 340282366920938463463374607431768211456, + 680564733841876926926749214863536422912, + 1361129467683753853853498429727072845824, + 2722258935367507707706996859454145691648, + 5444517870735015415413993718908291383296, + 10889035741470030830827987437816582766592, + 21778071482940061661655974875633165533184, + 43556142965880123323311949751266331066368, + 87112285931760246646623899502532662132736, + 174224571863520493293247799005065324265472, + 348449143727040986586495598010130648530944, + 696898287454081973172991196020261297061888, + 1393796574908163946345982392040522594123776, + 2787593149816327892691964784081045188247552, + 5575186299632655785383929568162090376495104, + 11150372599265311570767859136324180752990208, + 22300745198530623141535718272648361505980416, + 44601490397061246283071436545296723011960832, + 89202980794122492566142873090593446023921664, + 178405961588244985132285746181186892047843328, + 356811923176489970264571492362373784095686656, + 713623846352979940529142984724747568191373312, + 1427247692705959881058285969449495136382746624, + 2854495385411919762116571938898990272765493248, + 5708990770823839524233143877797980545530986496, + 11417981541647679048466287755595961091061972992, + 22835963083295358096932575511191922182123945984, + 45671926166590716193865151022383844364247891968, + 91343852333181432387730302044767688728495783936, + 182687704666362864775460604089535377456991567872, + 365375409332725729550921208179070754913983135744, + 730750818665451459101842416358141509827966271488, + 1461501637330902918203684832716283019655932542976, + 2923003274661805836407369665432566039311865085952, + 5846006549323611672814739330865132078623730171904, + 11692013098647223345629478661730264157247460343808, + 23384026197294446691258957323460528314494920687616, + 46768052394588893382517914646921056628989841375232, + 93536104789177786765035829293842113257979682750464, + 187072209578355573530071658587684226515959365500928, + 374144419156711147060143317175368453031918731001856, + 748288838313422294120286634350736906063837462003712, + 1496577676626844588240573268701473812127674924007424, + 2993155353253689176481146537402947624255349848014848, + 5986310706507378352962293074805895248510699696029696, + 11972621413014756705924586149611790497021399392059392, + 23945242826029513411849172299223580994042798784118784, + 47890485652059026823698344598447161988085597568237568, + 95780971304118053647396689196894323976171195136475136, + 191561942608236107294793378393788647952342390272950272, + 383123885216472214589586756787577295904684780545900544, + 766247770432944429179173513575154591809369561091801088, + 1532495540865888858358347027150309183618739122183602176, + 3064991081731777716716694054300618367237478244367204352, + 6129982163463555433433388108601236734474956488734408704, + 12259964326927110866866776217202473468949912977468817408, + 24519928653854221733733552434404946937899825954937634816, + 49039857307708443467467104868809893875799651909875269632, + 98079714615416886934934209737619787751599303819750539264, + 196159429230833773869868419475239575503198607639501078528, + 392318858461667547739736838950479151006397215279002157056, + 784637716923335095479473677900958302012794430558004314112, + 1569275433846670190958947355801916604025588861116008628224, + 3138550867693340381917894711603833208051177722232017256448, + 6277101735386680763835789423207666416102355444464034512896, + 12554203470773361527671578846415332832204710888928069025792, + 25108406941546723055343157692830665664409421777856138051584, + 50216813883093446110686315385661331328818843555712276103168, + 100433627766186892221372630771322662657637687111424552206336, + 200867255532373784442745261542645325315275374222849104412672, + 401734511064747568885490523085290650630550748445698208825344, + 803469022129495137770981046170581301261101496891396417650688, + 1606938044258990275541962092341162602522202993782792835301376, + 3213876088517980551083924184682325205044405987565585670602752, + 6427752177035961102167848369364650410088811975131171341205504, + 12855504354071922204335696738729300820177623950262342682411008, + 25711008708143844408671393477458601640355247900524685364822016, + 51422017416287688817342786954917203280710495801049370729644032, + 102844034832575377634685573909834406561420991602098741459288064, + 205688069665150755269371147819668813122841983204197482918576128, + 411376139330301510538742295639337626245683966408394965837152256, + 822752278660603021077484591278675252491367932816789931674304512, + 1645504557321206042154969182557350504982735865633579863348609024, + 3291009114642412084309938365114701009965471731267159726697218048, + 6582018229284824168619876730229402019930943462534319453394436096, + 13164036458569648337239753460458804039861886925068638906788872192, + 26328072917139296674479506920917608079723773850137277813577744384, + 52656145834278593348959013841835216159447547700274555627155488768, + 105312291668557186697918027683670432318895095400549111254310977536, + 210624583337114373395836055367340864637790190801098222508621955072, + 421249166674228746791672110734681729275580381602196445017243910144, + 842498333348457493583344221469363458551160763204392890034487820288, + 1684996666696914987166688442938726917102321526408785780068975640576, + 3369993333393829974333376885877453834204643052817571560137951281152, + 6739986666787659948666753771754907668409286105635143120275902562304, + 13479973333575319897333507543509815336818572211270286240551805124608, + 26959946667150639794667015087019630673637144422540572481103610249216, + 53919893334301279589334030174039261347274288845081144962207220498432, + 107839786668602559178668060348078522694548577690162289924414440996864, + 215679573337205118357336120696157045389097155380324579848828881993728, + 431359146674410236714672241392314090778194310760649159697657763987456, + 862718293348820473429344482784628181556388621521298319395315527974912, + 1725436586697640946858688965569256363112777243042596638790631055949824, + 3450873173395281893717377931138512726225554486085193277581262111899648, + 6901746346790563787434755862277025452451108972170386555162524223799296, + 13803492693581127574869511724554050904902217944340773110325048447598592, + 27606985387162255149739023449108101809804435888681546220650096895197184, + 55213970774324510299478046898216203619608871777363092441300193790394368, + 110427941548649020598956093796432407239217743554726184882600387580788736, + 220855883097298041197912187592864814478435487109452369765200775161577472, + 441711766194596082395824375185729628956870974218904739530401550323154944, + 883423532389192164791648750371459257913741948437809479060803100646309888, + 1766847064778384329583297500742918515827483896875618958121606201292619776, + 3533694129556768659166595001485837031654967793751237916243212402585239552, + 7067388259113537318333190002971674063309935587502475832486424805170479104, + 14134776518227074636666380005943348126619871175004951664972849610340958208, + 28269553036454149273332760011886696253239742350009903329945699220681916416, + 56539106072908298546665520023773392506479484700019806659891398441363832832, + 113078212145816597093331040047546785012958969400039613319782796882727665664, + 226156424291633194186662080095093570025917938800079226639565593765455331328, + 452312848583266388373324160190187140051835877600158453279131187530910662656, + 904625697166532776746648320380374280103671755200316906558262375061821325312, + 1809251394333065553493296640760748560207343510400633813116524750123642650624, + 3618502788666131106986593281521497120414687020801267626233049500247285301248, + 7237005577332262213973186563042994240829374041602535252466099000494570602496, + 14474011154664524427946373126085988481658748083205070504932198000989141204992, + 28948022309329048855892746252171976963317496166410141009864396001978282409984, + 57896044618658097711785492504343953926634992332820282019728792003956564819968, +]; diff --git a/crates/dojo-core/src/packing_test.cairo b/crates/dojo-core/src/packing_test.cairo index 49aad1f3e8..58d340aff6 100644 --- a/crates/dojo-core/src/packing_test.cairo +++ b/crates/dojo-core/src/packing_test.cairo @@ -1,6 +1,8 @@ use array::{ArrayTrait, SpanTrait}; use starknet::{ClassHash, ContractAddress, Felt252TryIntoContractAddress, Felt252TryIntoClassHash}; -use dojo::packing::{shl, shr, fpow, pack, unpack, pack_inner, unpack_inner, calculate_packed_size}; +use dojo::packing::{ + shl, shr, fpow, pack, unpack, pack_inner, unpack_inner, calculate_packed_size, pow2_const +}; use integer::U256BitAnd; use option::OptionTrait; use debug::PrintTrait; @@ -18,6 +20,17 @@ fn test_bit_fpow() { ) } + +#[test] +fn test_bit_pow2_const() { + assert( + pow2_const( + 250 + ) == 1809251394333065553493296640760748560207343510400633813116524750123642650624_u256, + '' + ) +} + #[test] #[available_gas(9000000)] fn test_bit_shift() { diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo_world_world.toml b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo_world_world.toml index 2daf97b5e5..b93ad67681 100644 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo_world_world.toml +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo_world_world.toml @@ -1,5 +1,5 @@ kind = "Class" -class_hash = "0x1fafbe78a4676c8998d2de2053bc2fba24aebbd4fb86f03ff6af87ad3314092" -original_class_hash = "0x1fafbe78a4676c8998d2de2053bc2fba24aebbd4fb86f03ff6af87ad3314092" +class_hash = "0x49f5416d0fb6e6ec76a4f55bfd0addad9ab8a3c864d882012a0a2060d8e8a28" +original_class_hash = "0x49f5416d0fb6e6ec76a4f55bfd0addad9ab8a3c864d882012a0a2060d8e8a28" abi = "manifests/dev/abis/base/dojo_world_world.json" name = "dojo::world::world" diff --git a/crates/dojo-world/src/metadata_test.rs b/crates/dojo-world/src/metadata_test.rs index 8da0b1af36..4eded54d96 100644 --- a/crates/dojo-world/src/metadata_test.rs +++ b/crates/dojo-world/src/metadata_test.rs @@ -147,7 +147,7 @@ async fn get_full_dojo_metadata_from_workspace() { assert!(env.world_address.is_some()); assert_eq!( env.world_address.unwrap(), - "0x26a8d9f2ac0348182bea206d913908ef77e439416713592ebc85941a69048d6" + "0x05134532e5d24c8264e61bb6bbe5c06031d462b8b7bdd15b5554e77e2a97c369" ); assert!(env.keystore_path.is_none()); diff --git a/crates/katana/rpc/rpc/tests/torii.rs b/crates/katana/rpc/rpc/tests/torii.rs index a1afc99780..64f57da019 100644 --- a/crates/katana/rpc/rpc/tests/torii.rs +++ b/crates/katana/rpc/rpc/tests/torii.rs @@ -3,13 +3,14 @@ use std::sync::Arc; use std::time::Duration; use dojo_test_utils::sequencer::{get_default_test_starknet_config, TestSequencer}; +use dojo_world::utils::TransactionWaiter; use jsonrpsee::http_client::HttpClientBuilder; use katana_core::sequencer::SequencerConfig; use katana_rpc_api::dev::DevApiClient; use katana_rpc_api::starknet::StarknetApiClient; use katana_rpc_api::torii::ToriiApiClient; use katana_rpc_types::transaction::{TransactionsPage, TransactionsPageCursor}; -use starknet::accounts::{Account, Call}; +use starknet::accounts::{Account, Call, ConnectedAccount}; use starknet::core::types::{FieldElement, TransactionStatus}; use starknet::core::utils::get_selector_from_name; use tokio::time::sleep; @@ -90,6 +91,8 @@ async fn test_get_transactions() { let deploy_txn = account.execute(vec![deploy_call]); let deploy_txn_future = deploy_txn.send().await.unwrap(); + TransactionWaiter::new(deploy_txn_future.transaction_hash, &account.provider()).await.unwrap(); + // Should properly increment to new pending block let response: TransactionsPage = client .get_transactions(TransactionsPageCursor { diff --git a/crates/torii/types-test/manifests/dev/base/dojo_world_world.toml b/crates/torii/types-test/manifests/dev/base/dojo_world_world.toml index 2daf97b5e5..b93ad67681 100644 --- a/crates/torii/types-test/manifests/dev/base/dojo_world_world.toml +++ b/crates/torii/types-test/manifests/dev/base/dojo_world_world.toml @@ -1,5 +1,5 @@ kind = "Class" -class_hash = "0x1fafbe78a4676c8998d2de2053bc2fba24aebbd4fb86f03ff6af87ad3314092" -original_class_hash = "0x1fafbe78a4676c8998d2de2053bc2fba24aebbd4fb86f03ff6af87ad3314092" +class_hash = "0x49f5416d0fb6e6ec76a4f55bfd0addad9ab8a3c864d882012a0a2060d8e8a28" +original_class_hash = "0x49f5416d0fb6e6ec76a4f55bfd0addad9ab8a3c864d882012a0a2060d8e8a28" abi = "manifests/dev/abis/base/dojo_world_world.json" name = "dojo::world::world" diff --git a/examples/spawn-and-move/Scarb.toml b/examples/spawn-and-move/Scarb.toml index 99366ce45b..3bb8955a18 100644 --- a/examples/spawn-and-move/Scarb.toml +++ b/examples/spawn-and-move/Scarb.toml @@ -25,4 +25,4 @@ rpc_url = "http://localhost:5050/" # Default account for katana with seed = 0 account_address = "0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03" private_key = "0x1800000000300000180000000000030000000000003006001800006600" -world_address = "0x26a8d9f2ac0348182bea206d913908ef77e439416713592ebc85941a69048d6" +world_address = "0x05134532e5d24c8264e61bb6bbe5c06031d462b8b7bdd15b5554e77e2a97c369" diff --git a/examples/spawn-and-move/manifests/dev/base/dojo_world_world.toml b/examples/spawn-and-move/manifests/dev/base/dojo_world_world.toml index 2daf97b5e5..b93ad67681 100644 --- a/examples/spawn-and-move/manifests/dev/base/dojo_world_world.toml +++ b/examples/spawn-and-move/manifests/dev/base/dojo_world_world.toml @@ -1,5 +1,5 @@ kind = "Class" -class_hash = "0x1fafbe78a4676c8998d2de2053bc2fba24aebbd4fb86f03ff6af87ad3314092" -original_class_hash = "0x1fafbe78a4676c8998d2de2053bc2fba24aebbd4fb86f03ff6af87ad3314092" +class_hash = "0x49f5416d0fb6e6ec76a4f55bfd0addad9ab8a3c864d882012a0a2060d8e8a28" +original_class_hash = "0x49f5416d0fb6e6ec76a4f55bfd0addad9ab8a3c864d882012a0a2060d8e8a28" abi = "manifests/dev/abis/base/dojo_world_world.json" name = "dojo::world::world" diff --git a/examples/spawn-and-move/manifests/dev/manifest.json b/examples/spawn-and-move/manifests/dev/manifest.json index 00db8977b0..f0c028b084 100644 --- a/examples/spawn-and-move/manifests/dev/manifest.json +++ b/examples/spawn-and-move/manifests/dev/manifest.json @@ -1,8 +1,8 @@ { "world": { "kind": "WorldContract", - "class_hash": "0x1fafbe78a4676c8998d2de2053bc2fba24aebbd4fb86f03ff6af87ad3314092", - "original_class_hash": "0x1fafbe78a4676c8998d2de2053bc2fba24aebbd4fb86f03ff6af87ad3314092", + "class_hash": "0x49f5416d0fb6e6ec76a4f55bfd0addad9ab8a3c864d882012a0a2060d8e8a28", + "original_class_hash": "0x49f5416d0fb6e6ec76a4f55bfd0addad9ab8a3c864d882012a0a2060d8e8a28", "abi": [ { "type": "impl", @@ -955,8 +955,8 @@ ] } ], - "address": "0x26a8d9f2ac0348182bea206d913908ef77e439416713592ebc85941a69048d6", - "transaction_hash": "0x4fb663d83b07373bf2844ef51acfb10d1e957a2fd6d573b7360ad64710df6cc", + "address": "0x5134532e5d24c8264e61bb6bbe5c06031d462b8b7bdd15b5554e77e2a97c369", + "transaction_hash": "0x35473957a0f251eb91420957dfcacfe52c6b00c4f5ab5512bcb678b500abf", "block_number": 3, "seed": "dojo_examples", "metadata": { @@ -975,7 +975,7 @@ "contracts": [ { "kind": "DojoContract", - "address": "0x43ec1c3a2195bc6adaa4134b7183cec4bae46f1388cb41c0fc808aba7e04b0", + "address": "0x6dee77ea677ba316b702ac7666b5f2eb7d12d3b93a450cf61371b1cb2b5a2a8", "class_hash": "0xfe09a42928890d712af285559b4452ebbc448428dfa91179bfee66715a2add", "original_class_hash": "0xfe09a42928890d712af285559b4452ebbc448428dfa91179bfee66715a2add", "base_class_hash": "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46", @@ -1280,7 +1280,7 @@ }, { "kind": "DojoContract", - "address": "0x55d1b3b80ddfd912e33a6cb331665dfc0b8f1738fcbe8d4c4191e27cd12f9c4", + "address": "0x47bad9d0cd66bb0184ca7ebbc3b3067564e65aa5a3d3ffbf19ecbe9fb8fa1b4", "class_hash": "0x3ee016157303a7ce35a9fecdb5b8519159df620c5780527d61443636aaa3c3a", "original_class_hash": "0x3ee016157303a7ce35a9fecdb5b8519159df620c5780527d61443636aaa3c3a", "base_class_hash": "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46", diff --git a/examples/spawn-and-move/manifests/dev/manifest.toml b/examples/spawn-and-move/manifests/dev/manifest.toml index 66680bf397..21a653ba34 100644 --- a/examples/spawn-and-move/manifests/dev/manifest.toml +++ b/examples/spawn-and-move/manifests/dev/manifest.toml @@ -1,10 +1,10 @@ [world] kind = "WorldContract" -class_hash = "0x1fafbe78a4676c8998d2de2053bc2fba24aebbd4fb86f03ff6af87ad3314092" -original_class_hash = "0x1fafbe78a4676c8998d2de2053bc2fba24aebbd4fb86f03ff6af87ad3314092" +class_hash = "0x49f5416d0fb6e6ec76a4f55bfd0addad9ab8a3c864d882012a0a2060d8e8a28" +original_class_hash = "0x49f5416d0fb6e6ec76a4f55bfd0addad9ab8a3c864d882012a0a2060d8e8a28" abi = "manifests/dev/abis/deployments/dojo_world_world.json" -address = "0x26a8d9f2ac0348182bea206d913908ef77e439416713592ebc85941a69048d6" -transaction_hash = "0x4fb663d83b07373bf2844ef51acfb10d1e957a2fd6d573b7360ad64710df6cc" +address = "0x5134532e5d24c8264e61bb6bbe5c06031d462b8b7bdd15b5554e77e2a97c369" +transaction_hash = "0x35473957a0f251eb91420957dfcacfe52c6b00c4f5ab5512bcb678b500abf" block_number = 3 seed = "dojo_examples" name = "dojo::world::world" @@ -21,7 +21,7 @@ name = "dojo::base::base" [[contracts]] kind = "DojoContract" -address = "0x43ec1c3a2195bc6adaa4134b7183cec4bae46f1388cb41c0fc808aba7e04b0" +address = "0x6dee77ea677ba316b702ac7666b5f2eb7d12d3b93a450cf61371b1cb2b5a2a8" class_hash = "0xfe09a42928890d712af285559b4452ebbc448428dfa91179bfee66715a2add" original_class_hash = "0xfe09a42928890d712af285559b4452ebbc448428dfa91179bfee66715a2add" base_class_hash = "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46" @@ -37,7 +37,7 @@ name = "dojo_examples::actions::actions" [[contracts]] kind = "DojoContract" -address = "0x55d1b3b80ddfd912e33a6cb331665dfc0b8f1738fcbe8d4c4191e27cd12f9c4" +address = "0x47bad9d0cd66bb0184ca7ebbc3b3067564e65aa5a3d3ffbf19ecbe9fb8fa1b4" class_hash = "0x3ee016157303a7ce35a9fecdb5b8519159df620c5780527d61443636aaa3c3a" original_class_hash = "0x3ee016157303a7ce35a9fecdb5b8519159df620c5780527d61443636aaa3c3a" base_class_hash = "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46" From 0ab7d21d16dd0223bf5eae993a15cea362b15599 Mon Sep 17 00:00:00 2001 From: 0xevolve Date: Wed, 29 May 2024 16:57:35 +0200 Subject: [PATCH 13/16] feat: katana runner log path option (#2015) * feat(katana-runner): add log path option * fix: fmt --- crates/katana/runner/src/lib.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/katana/runner/src/lib.rs b/crates/katana/runner/src/lib.rs index 13a19fe771..3ad87a63ef 100644 --- a/crates/katana/runner/src/lib.rs +++ b/crates/katana/runner/src/lib.rs @@ -45,6 +45,8 @@ pub struct KatanaRunnerConfig { pub block_time: Option, /// The port to run the katana runner on, if None, a random free port is chosen. pub port: Option, + /// The path where to log info, if None, logs are stored in a temp dir. + pub log_path: Option, } impl Default for KatanaRunnerConfig { @@ -56,6 +58,7 @@ impl Default for KatanaRunnerConfig { port: None, program_name: None, run_name: None, + log_path: None, } } } @@ -102,14 +105,18 @@ impl KatanaRunner { let stdout = child.stdout.take().context("failed to take subprocess stdout")?; - let log_dir = TempDir::new().unwrap(); - let log_filename = PathBuf::from(format!( "katana-{}.log", config.run_name.clone().unwrap_or_else(|| port.to_string()) )); - let log_file_path = log_dir.join(log_filename); + let log_file_path = if let Some(log_path) = config.log_path { + log_path + } else { + let log_dir = TempDir::new().unwrap(); + log_dir.join(log_filename) + }; + let log_file_path_sent = log_file_path.clone(); let (sender, receiver) = mpsc::channel(); From 532ed956617f896bdd5bde50082ccb9f0451cea3 Mon Sep 17 00:00:00 2001 From: glihm Date: Wed, 29 May 2024 17:34:49 +0200 Subject: [PATCH 14/16] fix: scarb bump for LS (#2012) * chore: bump scarb and cairo-lang * fix: adjust to new scarb API * fix: ensure test-utils is correctly detected in other projects * fix: fix fmt * fix: impl missing upcast for ParserGroup * chore: cleanup LS dependencies * fix: add back the clap version argument * fix: update tests * fix: fix tests * ci: test with larger runner * chore: bump scarb to include tracing fix * fix: add workaround for cairo inference regression --- Cargo.lock | 1122 ++++++++++++----- Cargo.toml | 76 +- bin/dojo-language-server/Cargo.toml | 13 - bin/dojo-language-server/src/main.rs | 8 + bin/sozo/src/commands/test.rs | 8 +- bin/sozo/tests/register_test.rs | 29 +- crates/dojo-core/src/base_test.cairo | 2 +- crates/dojo-core/src/lib.cairo | 11 +- crates/dojo-core/src/world.cairo | 4 +- crates/dojo-lang/src/compiler.rs | 2 +- .../manifests/dev/base/dojo_world_world.toml | 4 +- crates/dojo-lang/src/scarb_internal/mod.rs | 13 +- crates/dojo-lang/src/semantics/test_utils.rs | 7 +- crates/dojo-test-utils/src/compiler.rs | 4 +- crates/dojo-world/src/contracts/model_test.rs | 2 +- crates/dojo-world/src/contracts/world_test.rs | 7 +- crates/dojo-world/src/metadata_test.rs | 2 +- .../manifests/dev/base/dojo_world_world.toml | 4 +- examples/spawn-and-move/Scarb.toml | 2 +- .../dojo_examples_actions_actions.toml | 4 +- .../manifests/dev/base/dojo_world_world.toml | 4 +- .../dojo_examples_actions_actions_moved.toml | 4 +- .../dojo_examples_models_emote_message.toml | 4 +- .../models/dojo_examples_models_moves.toml | 4 +- .../dojo_examples_models_player_config.toml | 4 +- .../models/dojo_examples_models_position.toml | 4 +- ...es_others_others_contract_initialized.toml | 4 +- .../manifests/dev/manifest.json | 40 +- .../manifests/dev/manifest.toml | 40 +- 29 files changed, 986 insertions(+), 446 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c06643dc96..5ed743aa54 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -915,8 +915,8 @@ dependencies = [ "memchr", "pin-project-lite", "tokio", - "zstd", - "zstd-safe", + "zstd 0.13.1", + "zstd-safe 7.1.0", ] [[package]] @@ -1538,7 +1538,7 @@ dependencies = [ "cairo-lang-runner 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", "cairo-lang-starknet-classes 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", - "cairo-vm", + "cairo-vm 0.9.2", "derive_more", "indexmap 2.2.6", "itertools 0.10.5", @@ -1690,6 +1690,27 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3e368af43e418a04d52505cf3dbc23dda4e3407ae2fa99fd0e4f308ce546acc" +[[package]] +name = "bzip2" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdb116a6ef3f6c3698828873ad02c3014b3c85cadb88496095628e3ef1e347f8" +dependencies = [ + "bzip2-sys", + "libc", +] + +[[package]] +name = "bzip2-sys" +version = "0.1.11+1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "736a955f3fa7875102d57c82b8cac37ec45224a07fd32d58f9f7a186b6cd4cdc" +dependencies = [ + "cc", + "libc", + "pkg-config", +] + [[package]] name = "c-kzg" version = "1.0.2" @@ -1834,6 +1855,20 @@ dependencies = [ "serde", ] +[[package]] +name = "cairo-lang-casm" +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10d9c31baeb6b52586b5adc88f01e90f86389d63d94363c562de5c79352e545b" +dependencies = [ + "cairo-lang-utils 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "indoc 2.0.5", + "num-bigint", + "num-traits 0.2.19", + "parity-scale-codec", + "serde", +] + [[package]] name = "cairo-lang-casm" version = "2.6.3" @@ -1850,9 +1885,9 @@ dependencies = [ [[package]] name = "cairo-lang-casm" version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" +source = "git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632#d9984ef58e2f704909e271f2f01327f520ded632" dependencies = [ - "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "indoc 2.0.5", "num-bigint", "num-traits 0.2.19", @@ -1860,6 +1895,29 @@ dependencies = [ "serde", ] +[[package]] +name = "cairo-lang-compiler" +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7148cb2d72a3db24a6d2ef2b2602102cc5099cb9f6b913e5047fb009cb3a22a1" +dependencies = [ + "anyhow", + "cairo-lang-defs 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-diagnostics 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-filesystem 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-lowering 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-parser 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-project 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-semantic 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-sierra 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-sierra-generator 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-syntax 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-utils 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "salsa", + "smol_str", + "thiserror", +] + [[package]] name = "cairo-lang-compiler" version = "2.6.3" @@ -1885,26 +1943,35 @@ dependencies = [ [[package]] name = "cairo-lang-compiler" version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" +source = "git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632#d9984ef58e2f704909e271f2f01327f520ded632" dependencies = [ "anyhow", - "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-lowering 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-project 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-semantic 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-sierra-generator 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-lowering 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-project 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-semantic 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-sierra-generator 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "indoc 2.0.5", "salsa", "smol_str", "thiserror", ] +[[package]] +name = "cairo-lang-debug" +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a761eb8e31ea65a2dd45f729c74f1770315f97124dad93d1f6853a10d460c6b" +dependencies = [ + "cairo-lang-utils 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "cairo-lang-debug" version = "2.6.3" @@ -1916,9 +1983,26 @@ dependencies = [ [[package]] name = "cairo-lang-debug" version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" +source = "git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632#d9984ef58e2f704909e271f2f01327f520ded632" dependencies = [ - "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", +] + +[[package]] +name = "cairo-lang-defs" +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6d60bc5d72fe7a95ba34e041dcbdf1cf3bfccb87008a515514b74913fa8ff05" +dependencies = [ + "cairo-lang-debug 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-diagnostics 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-filesystem 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-parser 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-syntax 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-utils 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "itertools 0.11.0", + "salsa", + "smol_str", ] [[package]] @@ -1940,19 +2024,31 @@ dependencies = [ [[package]] name = "cairo-lang-defs" version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" -dependencies = [ - "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", +source = "git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632#d9984ef58e2f704909e271f2f01327f520ded632" +dependencies = [ + "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "itertools 0.12.1", "salsa", "smol_str", ] +[[package]] +name = "cairo-lang-diagnostics" +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "356089e1b0a0ba9e115566191745613b3806a20259ad76764df82ab534d5412a" +dependencies = [ + "cairo-lang-debug 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-filesystem 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-utils 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "itertools 0.11.0", +] + [[package]] name = "cairo-lang-diagnostics" version = "2.6.3" @@ -1967,14 +2063,24 @@ dependencies = [ [[package]] name = "cairo-lang-diagnostics" version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" +source = "git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632#d9984ef58e2f704909e271f2f01327f520ded632" dependencies = [ - "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "itertools 0.12.1", ] +[[package]] +name = "cairo-lang-eq-solver" +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc43246cc2e5afd5a028bcdd63876ac3f8b1f4fb3ff785daaa0f0fbb51c9d906" +dependencies = [ + "cairo-lang-utils 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "good_lp", +] + [[package]] name = "cairo-lang-eq-solver" version = "2.6.3" @@ -1987,12 +2093,26 @@ dependencies = [ [[package]] name = "cairo-lang-eq-solver" version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" +source = "git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632#d9984ef58e2f704909e271f2f01327f520ded632" dependencies = [ - "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "good_lp", ] +[[package]] +name = "cairo-lang-filesystem" +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bcb9a4a40e53fa099774bd08bbcc3430f51213cc7fb1b50c2e9d01155731798" +dependencies = [ + "cairo-lang-debug 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-utils 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "path-clean", + "salsa", + "serde", + "smol_str", +] + [[package]] name = "cairo-lang-filesystem" version = "2.6.3" @@ -2009,10 +2129,10 @@ dependencies = [ [[package]] name = "cairo-lang-filesystem" version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" +source = "git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632#d9984ef58e2f704909e271f2f01327f520ded632" dependencies = [ - "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "path-clean", "salsa", "serde", @@ -2022,14 +2142,14 @@ dependencies = [ [[package]] name = "cairo-lang-formatter" version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" +source = "git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632#d9984ef58e2f704909e271f2f01327f520ded632" dependencies = [ "anyhow", - "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "diffy", "ignore", "itertools 0.12.1", @@ -2042,22 +2162,22 @@ dependencies = [ [[package]] name = "cairo-lang-language-server" version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" +source = "git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632#d9984ef58e2f704909e271f2f01327f520ded632" dependencies = [ "anyhow", - "cairo-lang-compiler 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-compiler 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "cairo-lang-formatter", - "cairo-lang-lowering 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-project 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-semantic 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-lowering 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-project 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-semantic 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "cairo-lang-test-plugin", - "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "salsa", "scarb-metadata 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde", @@ -2069,6 +2189,31 @@ dependencies = [ "tracing-subscriber", ] +[[package]] +name = "cairo-lang-lowering" +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ba60e1e2477aa0f610ccf29189097d580464607c94b51741e1c18e64d6cee5f" +dependencies = [ + "cairo-lang-debug 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-defs 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-diagnostics 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-filesystem 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-parser 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-proc-macros 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-semantic 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-syntax 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-utils 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "id-arena", + "itertools 0.11.0", + "log", + "num-bigint", + "num-traits 0.2.19", + "once_cell", + "salsa", + "smol_str", +] + [[package]] name = "cairo-lang-lowering" version = "2.6.3" @@ -2096,17 +2241,17 @@ dependencies = [ [[package]] name = "cairo-lang-lowering" version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" -dependencies = [ - "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-proc-macros 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-semantic 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", +source = "git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632#d9984ef58e2f704909e271f2f01327f520ded632" +dependencies = [ + "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-proc-macros 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-semantic 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "id-arena", "itertools 0.12.1", "log", @@ -2120,7 +2265,7 @@ dependencies = [ [[package]] name = "cairo-lang-macro" version = "0.0.1" -source = "git+https://github.com/software-mansion/scarb?rev=e813dbab8f0ec606b5846827ad65951ef8bd6b92#e813dbab8f0ec606b5846827ad65951ef8bd6b92" +source = "git+https://github.com/software-mansion/scarb?rev=f1aa7b09507a84d209d83b2fa80472c82605cc43#f1aa7b09507a84d209d83b2fa80472c82605cc43" dependencies = [ "cairo-lang-macro-attributes", "cairo-lang-macro-stable", @@ -2130,7 +2275,7 @@ dependencies = [ [[package]] name = "cairo-lang-macro-attributes" version = "0.0.1" -source = "git+https://github.com/software-mansion/scarb?rev=e813dbab8f0ec606b5846827ad65951ef8bd6b92#e813dbab8f0ec606b5846827ad65951ef8bd6b92" +source = "git+https://github.com/software-mansion/scarb?rev=f1aa7b09507a84d209d83b2fa80472c82605cc43#f1aa7b09507a84d209d83b2fa80472c82605cc43" dependencies = [ "quote", "scarb-stable-hash", @@ -2140,7 +2285,27 @@ dependencies = [ [[package]] name = "cairo-lang-macro-stable" version = "1.0.0" -source = "git+https://github.com/software-mansion/scarb?rev=e813dbab8f0ec606b5846827ad65951ef8bd6b92#e813dbab8f0ec606b5846827ad65951ef8bd6b92" +source = "git+https://github.com/software-mansion/scarb?rev=f1aa7b09507a84d209d83b2fa80472c82605cc43#f1aa7b09507a84d209d83b2fa80472c82605cc43" + +[[package]] +name = "cairo-lang-parser" +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f16ba1535e0cc5e79c2eff6592859bbdac03dc53d4dcdd26dbdbc04a77c3f5c" +dependencies = [ + "cairo-lang-diagnostics 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-filesystem 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-syntax 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-syntax-codegen 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-utils 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "colored", + "itertools 0.11.0", + "num-bigint", + "num-traits 0.2.19", + "salsa", + "smol_str", + "unescaper", +] [[package]] name = "cairo-lang-parser" @@ -2164,13 +2329,13 @@ dependencies = [ [[package]] name = "cairo-lang-parser" version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" +source = "git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632#d9984ef58e2f704909e271f2f01327f520ded632" dependencies = [ - "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-syntax-codegen 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-syntax-codegen 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "colored", "itertools 0.12.1", "num-bigint", @@ -2180,6 +2345,25 @@ dependencies = [ "unescaper", ] +[[package]] +name = "cairo-lang-plugins" +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81c8cf6e0ee3d6b19429cc1663738b22f1ecea7d51bf7452e8e1086f08798baf" +dependencies = [ + "cairo-lang-defs 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-diagnostics 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-filesystem 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-parser 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-syntax 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-utils 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "indent", + "indoc 2.0.5", + "itertools 0.11.0", + "salsa", + "smol_str", +] + [[package]] name = "cairo-lang-plugins" version = "2.6.3" @@ -2201,14 +2385,14 @@ dependencies = [ [[package]] name = "cairo-lang-plugins" version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" -dependencies = [ - "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", +source = "git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632#d9984ef58e2f704909e271f2f01327f520ded632" +dependencies = [ + "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "indent", "indoc 2.0.5", "itertools 0.12.1", @@ -2216,6 +2400,17 @@ dependencies = [ "smol_str", ] +[[package]] +name = "cairo-lang-proc-macros" +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67f9da66325ce7ed6c002360f26106fe79deb9f8a2fca30abdbb8d388da7bb46" +dependencies = [ + "cairo-lang-debug 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "quote", + "syn 2.0.64", +] + [[package]] name = "cairo-lang-proc-macros" version = "2.6.3" @@ -2229,13 +2424,27 @@ dependencies = [ [[package]] name = "cairo-lang-proc-macros" version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" +source = "git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632#d9984ef58e2f704909e271f2f01327f520ded632" dependencies = [ - "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "quote", "syn 2.0.64", ] +[[package]] +name = "cairo-lang-project" +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e198af1ab3d05c7fb8b6a9a7a2e9bce245a6c855df5f770b751d29874a23b152" +dependencies = [ + "cairo-lang-filesystem 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-utils 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "serde", + "smol_str", + "thiserror", + "toml 0.8.13", +] + [[package]] name = "cairo-lang-project" version = "2.6.3" @@ -2252,10 +2461,10 @@ dependencies = [ [[package]] name = "cairo-lang-project" version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" +source = "git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632#d9984ef58e2f704909e271f2f01327f520ded632" dependencies = [ - "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "serde", "smol_str", "thiserror", @@ -2281,7 +2490,7 @@ dependencies = [ "cairo-lang-sierra-type-size 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", - "cairo-vm", + "cairo-vm 0.9.2", "itertools 0.11.0", "keccak", "num-bigint", @@ -2295,22 +2504,21 @@ dependencies = [ [[package]] name = "cairo-lang-runner" version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" +source = "git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632#d9984ef58e2f704909e271f2f01327f520ded632" dependencies = [ "ark-ff 0.4.2", "ark-secp256k1", "ark-secp256r1", - "cairo-felt", - "cairo-lang-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-lowering 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-sierra-ap-change 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-sierra-generator 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-sierra-to-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-sierra-type-size 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-vm", + "cairo-lang-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-lowering 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-sierra-ap-change 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-sierra-generator 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-sierra-to-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-sierra-type-size 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-vm 1.0.0-rc3", "itertools 0.12.1", "keccak", "num-bigint", @@ -2320,9 +2528,35 @@ dependencies = [ "sha2 0.10.8", "smol_str", "starknet-crypto 0.6.2", + "starknet-types-core 0.1.2", "thiserror", ] +[[package]] +name = "cairo-lang-semantic" +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d7df81521c2125e3e95b683cc99374db1aebd7ddb317c5ca3dd92a235a9eb13" +dependencies = [ + "cairo-lang-debug 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-defs 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-diagnostics 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-filesystem 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-parser 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-plugins 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-proc-macros 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-syntax 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-utils 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "id-arena", + "indoc 2.0.5", + "itertools 0.11.0", + "num-bigint", + "num-traits 0.2.19", + "once_cell", + "salsa", + "smol_str", +] + [[package]] name = "cairo-lang-semantic" version = "2.6.3" @@ -2350,18 +2584,18 @@ dependencies = [ [[package]] name = "cairo-lang-semantic" version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" -dependencies = [ - "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-plugins 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-proc-macros 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", +source = "git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632#d9984ef58e2f704909e271f2f01327f520ded632" +dependencies = [ + "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-plugins 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-proc-macros 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "cairo-lang-test-utils", - "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "id-arena", "indoc 2.0.5", "itertools 0.12.1", @@ -2373,6 +2607,32 @@ dependencies = [ "toml 0.8.13", ] +[[package]] +name = "cairo-lang-sierra" +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07da3ca1434c62a7cc7cd77d2941ef47a1c23b37325781b59407b78d8c61d863" +dependencies = [ + "anyhow", + "cairo-felt", + "cairo-lang-utils 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "const-fnv1a-hash", + "convert_case 0.6.0", + "derivative", + "itertools 0.11.0", + "lalrpop", + "lalrpop-util", + "num-bigint", + "num-traits 0.2.19", + "regex", + "salsa", + "serde", + "serde_json", + "sha3", + "smol_str", + "thiserror", +] + [[package]] name = "cairo-lang-sierra" version = "2.6.3" @@ -2401,11 +2661,10 @@ dependencies = [ [[package]] name = "cairo-lang-sierra" version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" +source = "git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632#d9984ef58e2f704909e271f2f01327f520ded632" dependencies = [ "anyhow", - "cairo-felt", - "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "const-fnv1a-hash", "convert_case 0.6.0", "derivative", @@ -2420,6 +2679,22 @@ dependencies = [ "serde_json", "sha3", "smol_str", + "starknet-types-core 0.1.2", + "thiserror", +] + +[[package]] +name = "cairo-lang-sierra-ap-change" +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "122c9055eb609a511178e3dce577de061819fd4c4c6b7452804557f76ca43bbf" +dependencies = [ + "cairo-lang-eq-solver 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-sierra 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-sierra-type-size 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-utils 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "itertools 0.11.0", + "num-traits 0.2.19", "thiserror", ] @@ -2440,18 +2715,33 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-ap-change" version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" +source = "git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632#d9984ef58e2f704909e271f2f01327f520ded632" dependencies = [ - "cairo-lang-eq-solver 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-sierra-type-size 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-eq-solver 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-sierra-type-size 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "itertools 0.12.1", "num-bigint", "num-traits 0.2.19", "thiserror", ] +[[package]] +name = "cairo-lang-sierra-gas" +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf049d9aea65c6e38da219a3700c72f78795d11449d9adcec28047ef8d63bd23" +dependencies = [ + "cairo-lang-eq-solver 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-sierra 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-sierra-type-size 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-utils 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "itertools 0.11.0", + "num-traits 0.2.19", + "thiserror", +] + [[package]] name = "cairo-lang-sierra-gas" version = "2.6.3" @@ -2469,18 +2759,41 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-gas" version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" +source = "git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632#d9984ef58e2f704909e271f2f01327f520ded632" dependencies = [ - "cairo-lang-eq-solver 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-sierra-type-size 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-eq-solver 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-sierra-type-size 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "itertools 0.12.1", "num-bigint", "num-traits 0.2.19", "thiserror", ] +[[package]] +name = "cairo-lang-sierra-generator" +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e1d75e0830279ca1bd0189e3326720d6e081225f7d81ed060bbd22c6b37e980" +dependencies = [ + "cairo-lang-debug 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-defs 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-diagnostics 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-filesystem 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-lowering 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-parser 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-semantic 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-sierra 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-syntax 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-utils 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "itertools 0.11.0", + "num-traits 0.2.19", + "once_cell", + "salsa", + "smol_str", +] + [[package]] name = "cairo-lang-sierra-generator" version = "2.6.3" @@ -2506,18 +2819,18 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-generator" version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" -dependencies = [ - "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-lowering 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-semantic 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", +source = "git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632#d9984ef58e2f704909e271f2f01327f520ded632" +dependencies = [ + "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-lowering 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-semantic 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "itertools 0.12.1", "num-traits 0.2.19", "once_cell", @@ -2527,6 +2840,27 @@ dependencies = [ "smol_str", ] +[[package]] +name = "cairo-lang-sierra-to-casm" +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a3c3be88c8562fbf93b0803c186e7282f6daad93576c07f61b04a591fde468f" +dependencies = [ + "assert_matches", + "cairo-felt", + "cairo-lang-casm 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-sierra 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-sierra-ap-change 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-sierra-gas 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-sierra-type-size 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-utils 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "indoc 2.0.5", + "itertools 0.11.0", + "num-bigint", + "num-traits 0.2.19", + "thiserror", +] + [[package]] name = "cairo-lang-sierra-to-casm" version = "2.6.3" @@ -2550,23 +2884,33 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-to-casm" version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" +source = "git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632#d9984ef58e2f704909e271f2f01327f520ded632" dependencies = [ "assert_matches", - "cairo-felt", - "cairo-lang-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-sierra-ap-change 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-sierra-gas 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-sierra-type-size 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-sierra-ap-change 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-sierra-gas 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-sierra-type-size 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "indoc 2.0.5", "itertools 0.12.1", "num-bigint", "num-traits 0.2.19", + "starknet-types-core 0.1.2", "thiserror", ] +[[package]] +name = "cairo-lang-sierra-type-size" +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a38da6f98c6b16945c89d2ae351c82d636ed38d3e6eb02f7c8679e3e03a63988" +dependencies = [ + "cairo-lang-sierra 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-utils 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "cairo-lang-sierra-type-size" version = "2.6.3" @@ -2579,10 +2923,41 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-type-size" version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" +source = "git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632#d9984ef58e2f704909e271f2f01327f520ded632" dependencies = [ - "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", +] + +[[package]] +name = "cairo-lang-starknet" +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9ffa8b3b8c47138c36b1907cebb5047dfc4de29ec10ece5bd6d6853243ec50" +dependencies = [ + "anyhow", + "cairo-felt", + "cairo-lang-compiler 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-defs 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-diagnostics 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-filesystem 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-lowering 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-plugins 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-semantic 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-sierra 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-sierra-generator 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-starknet-classes 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-syntax 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-utils 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "const_format", + "indent", + "indoc 2.0.5", + "itertools 0.11.0", + "once_cell", + "serde", + "serde_json", + "smol_str", + "thiserror", ] [[package]] @@ -2618,22 +2993,21 @@ dependencies = [ [[package]] name = "cairo-lang-starknet" version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" +source = "git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632#d9984ef58e2f704909e271f2f01327f520ded632" dependencies = [ "anyhow", - "cairo-felt", - "cairo-lang-compiler 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-lowering 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-plugins 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-semantic 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-sierra-generator 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-starknet-classes 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-compiler 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-lowering 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-plugins 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-semantic 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-sierra-generator 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-starknet-classes 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "const_format", "indent", "indoc 2.0.5", @@ -2642,6 +3016,32 @@ dependencies = [ "serde", "serde_json", "smol_str", + "starknet-types-core 0.1.2", + "thiserror", +] + +[[package]] +name = "cairo-lang-starknet-classes" +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47c64ae2bb00173e3a88760128bf72de356fa80eb19fa47602479063648b4003" +dependencies = [ + "cairo-felt", + "cairo-lang-casm 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-sierra 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-sierra-to-casm 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-utils 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "convert_case 0.6.0", + "itertools 0.11.0", + "num-bigint", + "num-integer", + "num-traits 0.2.19", + "once_cell", + "serde", + "serde_json", + "sha3", + "smol_str", + "starknet-crypto 0.6.2", "thiserror", ] @@ -2672,13 +3072,12 @@ dependencies = [ [[package]] name = "cairo-lang-starknet-classes" version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" +source = "git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632#d9984ef58e2f704909e271f2f01327f520ded632" dependencies = [ - "cairo-felt", - "cairo-lang-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-sierra-to-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-sierra-to-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "convert_case 0.6.0", "itertools 0.12.1", "num-bigint", @@ -2690,9 +3089,26 @@ dependencies = [ "sha3", "smol_str", "starknet-crypto 0.6.2", + "starknet-types-core 0.1.2", "thiserror", ] +[[package]] +name = "cairo-lang-syntax" +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8262c426a57e1e5ec297db24278464841500613445e2cb1c43d5f71ad91ee8d6" +dependencies = [ + "cairo-lang-debug 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-filesystem 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-utils 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "num-bigint", + "num-traits 0.2.19", + "salsa", + "smol_str", + "unescaper", +] + [[package]] name = "cairo-lang-syntax" version = "2.6.3" @@ -2711,11 +3127,11 @@ dependencies = [ [[package]] name = "cairo-lang-syntax" version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" +source = "git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632#d9984ef58e2f704909e271f2f01327f520ded632" dependencies = [ - "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "num-bigint", "num-traits 0.2.19", "salsa", @@ -2723,6 +3139,16 @@ dependencies = [ "unescaper", ] +[[package]] +name = "cairo-lang-syntax-codegen" +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70e2d692eae4bb4179a4a1148fd5eb738a91653d86750c813658ffad4a99fa97" +dependencies = [ + "genco", + "xshell", +] + [[package]] name = "cairo-lang-syntax-codegen" version = "2.6.3" @@ -2735,7 +3161,7 @@ dependencies = [ [[package]] name = "cairo-lang-syntax-codegen" version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" +source = "git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632#d9984ef58e2f704909e271f2f01327f520ded632" dependencies = [ "genco", "xshell", @@ -2744,64 +3170,79 @@ dependencies = [ [[package]] name = "cairo-lang-test-plugin" version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" +source = "git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632#d9984ef58e2f704909e271f2f01327f520ded632" dependencies = [ "anyhow", - "cairo-felt", - "cairo-lang-compiler 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-lowering 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-semantic 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-sierra-generator 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-starknet-classes 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-compiler 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-lowering 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-semantic 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-sierra-generator 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-starknet-classes 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "indoc 2.0.5", "itertools 0.12.1", "num-bigint", "num-traits 0.2.19", "serde", + "starknet-types-core 0.1.2", ] [[package]] name = "cairo-lang-test-runner" version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" +source = "git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632#d9984ef58e2f704909e271f2f01327f520ded632" dependencies = [ "anyhow", - "cairo-felt", - "cairo-lang-compiler 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-runner 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-sierra-generator 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-sierra-to-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-compiler 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-runner 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-sierra-generator 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-sierra-to-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "cairo-lang-test-plugin", - "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "colored", "itertools 0.12.1", "num-traits 0.2.19", "rayon", + "starknet-types-core 0.1.2", ] [[package]] name = "cairo-lang-test-utils" version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" +source = "git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632#d9984ef58e2f704909e271f2f01327f520ded632" dependencies = [ "cairo-lang-formatter", - "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "colored", "log", "pretty_assertions", ] +[[package]] +name = "cairo-lang-utils" +version = "2.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf733a7cdc4166d0baf0ed8a98d9ada827daee6653b37d9326e334e53481c6d3" +dependencies = [ + "hashbrown 0.14.5", + "indexmap 2.2.6", + "itertools 0.11.0", + "num-bigint", + "num-traits 0.2.19", + "schemars", + "serde", +] + [[package]] name = "cairo-lang-utils" version = "2.6.3" @@ -2820,7 +3261,7 @@ dependencies = [ [[package]] name = "cairo-lang-utils" version = "2.6.3" -source = "git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5#290f51f554c978180ca9d91177423305959cbed5" +source = "git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632#d9984ef58e2f704909e271f2f01327f520ded632" dependencies = [ "env_logger 0.11.3", "hashbrown 0.14.5", @@ -2882,6 +3323,36 @@ dependencies = [ "thiserror-no-std", ] +[[package]] +name = "cairo-vm" +version = "1.0.0-rc3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0fa4c74b86c0f17b58ced4fdab5c1da0a41fb12725ad7601e12bb27d8d90435" +dependencies = [ + "anyhow", + "bincode 2.0.0-rc.3", + "bitvec", + "generic-array", + "hashbrown 0.14.5", + "hex", + "keccak", + "lazy_static", + "nom", + "num-bigint", + "num-integer", + "num-prime", + "num-traits 0.2.19", + "rand", + "serde", + "serde_json", + "sha2 0.10.8", + "sha3", + "starknet-crypto 0.6.2", + "starknet-types-core 0.1.2", + "thiserror-no-std", + "zip", +] + [[package]] name = "camino" version = "1.1.7" @@ -3393,6 +3864,12 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "constant_time_eq" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" + [[package]] name = "convert_case" version = "0.4.0" @@ -3478,7 +3955,7 @@ dependencies = [ [[package]] name = "create-output-dir" version = "1.0.0" -source = "git+https://github.com/software-mansion/scarb?rev=e813dbab8f0ec606b5846827ad65951ef8bd6b92#e813dbab8f0ec606b5846827ad65951ef8bd6b92" +source = "git+https://github.com/software-mansion/scarb?rev=f1aa7b09507a84d209d83b2fa80472c82605cc43#f1aa7b09507a84d209d83b2fa80472c82605cc43" dependencies = [ "anyhow", "core-foundation", @@ -4087,24 +4564,24 @@ name = "dojo-lang" version = "0.7.0-alpha.4" dependencies = [ "anyhow", - "cairo-lang-compiler 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-compiler 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "cairo-lang-formatter", - "cairo-lang-lowering 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-plugins 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-project 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-semantic 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-sierra-generator 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-starknet-classes 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-lowering 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-parser 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-plugins 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-project 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-semantic 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-sierra-generator 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-starknet-classes 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "cairo-lang-test-plugin", "cairo-lang-test-utils", - "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "camino", "convert_case 0.6.0", "directories", @@ -4137,22 +4614,9 @@ dependencies = [ name = "dojo-language-server" version = "0.7.0-alpha.4" dependencies = [ - "anyhow", - "cairo-lang-compiler 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "cairo-lang-language-server", - "cairo-lang-plugins 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-semantic 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-test-plugin", - "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", "clap", "dojo-lang", - "log", - "salsa", - "smol_str", - "tokio", - "tower-lsp", ] [[package]] @@ -4180,10 +4644,10 @@ dependencies = [ "anyhow", "assert_fs", "async-trait", - "cairo-lang-compiler 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-project 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-compiler 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-project 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "camino", "dojo-lang", "dojo-world", @@ -4232,10 +4696,10 @@ dependencies = [ "assert_matches", "async-trait", "cainome", - "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-project 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-starknet-classes 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-project 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-starknet-classes 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "camino", "convert_case 0.6.0", "dojo-lang", @@ -4266,8 +4730,8 @@ dependencies = [ name = "dojo-world-abigen" version = "0.7.0-alpha.4" dependencies = [ - "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-starknet-classes 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-starknet-classes 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "camino", "scarb", "scarb-ui", @@ -7341,7 +7805,7 @@ dependencies = [ "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", "cairo-lang-starknet-classes 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", - "cairo-vm", + "cairo-vm 0.9.2", ] [[package]] @@ -7378,9 +7842,9 @@ dependencies = [ "anyhow", "assert_matches", "async-trait", - "cairo-lang-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-vm", + "cairo-lang-casm 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-lang-starknet 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", + "cairo-vm 0.9.2", "convert_case 0.6.0", "derive_more", "dojo-metrics", @@ -7415,8 +7879,8 @@ name = "katana-db" version = "0.7.0-alpha.4" dependencies = [ "anyhow", - "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-vm", + "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-vm 0.9.2", "criterion", "katana-primitives", "page_size", @@ -7516,8 +7980,8 @@ version = "0.7.0-alpha.4" dependencies = [ "anyhow", "assert_matches", - "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-starknet-classes 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-starknet-classes 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "dojo-metrics", "dojo-test-utils", "dojo-world", @@ -7709,12 +8173,34 @@ dependencies = [ "regex-automata 0.4.6", ] +[[package]] +name = "lambdaworks-crypto" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fb5d4f22241504f7c7b8d2c3a7d7835d7c07117f10bff2a7d96a9ef6ef217c3" +dependencies = [ + "lambdaworks-math 0.7.0", + "serde", + "sha2 0.10.8", + "sha3", +] + [[package]] name = "lambdaworks-math" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ee7dcab3968c71896b8ee4dc829147acc918cffe897af6265b1894527fe3add" +[[package]] +name = "lambdaworks-math" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "358e172628e713b80a530a59654154bfc45783a6ed70ea284839800cebdf8f97" +dependencies = [ + "serde", + "serde_json", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -9427,6 +9913,17 @@ dependencies = [ "windows-targets 0.52.5", ] +[[package]] +name = "password-hash" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7676374caaee8a325c9e7a2ae557f216c5563a171d6997b0ef8a65af35147700" +dependencies = [ + "base64ct", + "rand_core", + "subtle", +] + [[package]] name = "paste" version = "1.0.15" @@ -9464,6 +9961,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" dependencies = [ "digest 0.10.7", + "hmac", + "password-hash", + "sha2 0.10.8", ] [[package]] @@ -11181,7 +11681,7 @@ dependencies = [ "async-trait", "cairo-felt", "cairo-proof-parser", - "cairo-vm", + "cairo-vm 0.9.2", "celestia-rpc", "celestia-types", "convert_case 0.6.0", @@ -11205,7 +11705,7 @@ dependencies = [ "serde_with", "starknet", "starknet-crypto 0.6.2", - "starknet-types-core", + "starknet-types-core 0.0.9", "starknet_api", "thiserror", "tokio", @@ -11246,25 +11746,25 @@ dependencies = [ [[package]] name = "scarb" version = "2.6.3" -source = "git+https://github.com/software-mansion/scarb?rev=e813dbab8f0ec606b5846827ad65951ef8bd6b92#e813dbab8f0ec606b5846827ad65951ef8bd6b92" +source = "git+https://github.com/software-mansion/scarb?rev=f1aa7b09507a84d209d83b2fa80472c82605cc43#f1aa7b09507a84d209d83b2fa80472c82605cc43" dependencies = [ "anyhow", "async-trait", - "cairo-lang-compiler 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-compiler 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-diagnostics 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "cairo-lang-formatter", "cairo-lang-macro", "cairo-lang-macro-stable", - "cairo-lang-semantic 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-sierra-to-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-starknet-classes 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-semantic 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-sierra-to-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-starknet-classes 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-syntax 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "cairo-lang-test-plugin", - "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "camino", "clap", "create-output-dir", @@ -11289,7 +11789,7 @@ dependencies = [ "redb", "reqwest 0.11.27", "scarb-build-metadata", - "scarb-metadata 1.12.0 (git+https://github.com/software-mansion/scarb?rev=e813dbab8f0ec606b5846827ad65951ef8bd6b92)", + "scarb-metadata 1.12.0 (git+https://github.com/software-mansion/scarb?rev=f1aa7b09507a84d209d83b2fa80472c82605cc43)", "scarb-stable-hash", "scarb-ui", "semver 1.0.23", @@ -11314,13 +11814,13 @@ dependencies = [ "which 5.0.0", "windows-sys 0.52.0", "zip", - "zstd", + "zstd 0.13.1", ] [[package]] name = "scarb-build-metadata" version = "2.6.3" -source = "git+https://github.com/software-mansion/scarb?rev=e813dbab8f0ec606b5846827ad65951ef8bd6b92#e813dbab8f0ec606b5846827ad65951ef8bd6b92" +source = "git+https://github.com/software-mansion/scarb?rev=f1aa7b09507a84d209d83b2fa80472c82605cc43#f1aa7b09507a84d209d83b2fa80472c82605cc43" dependencies = [ "cargo_metadata", ] @@ -11341,7 +11841,7 @@ dependencies = [ [[package]] name = "scarb-metadata" version = "1.12.0" -source = "git+https://github.com/software-mansion/scarb?rev=e813dbab8f0ec606b5846827ad65951ef8bd6b92#e813dbab8f0ec606b5846827ad65951ef8bd6b92" +source = "git+https://github.com/software-mansion/scarb?rev=f1aa7b09507a84d209d83b2fa80472c82605cc43#f1aa7b09507a84d209d83b2fa80472c82605cc43" dependencies = [ "camino", "derive_builder", @@ -11354,7 +11854,7 @@ dependencies = [ [[package]] name = "scarb-stable-hash" version = "1.0.0" -source = "git+https://github.com/software-mansion/scarb?rev=e813dbab8f0ec606b5846827ad65951ef8bd6b92#e813dbab8f0ec606b5846827ad65951ef8bd6b92" +source = "git+https://github.com/software-mansion/scarb?rev=f1aa7b09507a84d209d83b2fa80472c82605cc43#f1aa7b09507a84d209d83b2fa80472c82605cc43" dependencies = [ "data-encoding", "xxhash-rust", @@ -11363,14 +11863,14 @@ dependencies = [ [[package]] name = "scarb-ui" version = "0.1.5" -source = "git+https://github.com/software-mansion/scarb?rev=e813dbab8f0ec606b5846827ad65951ef8bd6b92#e813dbab8f0ec606b5846827ad65951ef8bd6b92" +source = "git+https://github.com/software-mansion/scarb?rev=f1aa7b09507a84d209d83b2fa80472c82605cc43#f1aa7b09507a84d209d83b2fa80472c82605cc43" dependencies = [ "anyhow", "camino", "clap", "console", "indicatif", - "scarb-metadata 1.12.0 (git+https://github.com/software-mansion/scarb?rev=e813dbab8f0ec606b5846827ad65951ef8bd6b92)", + "scarb-metadata 1.12.0 (git+https://github.com/software-mansion/scarb?rev=f1aa7b09507a84d209d83b2fa80472c82605cc43)", "serde", "serde_json", "tracing-core", @@ -11986,17 +12486,17 @@ dependencies = [ "async-trait", "bigdecimal 0.4.3", "cainome", - "cairo-lang-compiler 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-plugins 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-project 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-sierra-to-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-compiler 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-plugins 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-project 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-sierra-to-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "cairo-lang-test-plugin", "cairo-lang-test-runner", - "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "camino", "clap", "clap-verbosity-flag", @@ -12044,18 +12544,18 @@ dependencies = [ "assert_fs", "async-trait", "cainome", - "cairo-lang-compiler 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-plugins 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-project 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-sierra-to-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", - "cairo-lang-starknet-classes 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-compiler 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-filesystem 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-plugins 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-project 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-sierra 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-sierra-to-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", + "cairo-lang-starknet-classes 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "cairo-lang-test-plugin", "cairo-lang-test-runner", - "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-utils 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "camino", "clap", "clap-verbosity-flag", @@ -12558,7 +13058,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d53160556d1f23425100f42b3230df747ea05763efee685a2cd939dfb640701" dependencies = [ "bitvec", - "lambdaworks-math", + "lambdaworks-math 0.5.0", + "lazy_static", + "num-bigint", + "num-integer", + "num-traits 0.2.19", + "serde", +] + +[[package]] +name = "starknet-types-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4098ac4ad57621cc7ec133b80fe72814d2cc4bee63ca8e7be4450ba6f42a07e8" +dependencies = [ + "lambdaworks-crypto", + "lambdaworks-math 0.7.0", "lazy_static", "num-bigint", "num-integer", @@ -12572,7 +13087,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "365ec5c0662466f299762bd012012da30e9a28319000cfade372b8787111f202" dependencies = [ - "cairo-lang-starknet-classes 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=290f51f554c978180ca9d91177423305959cbed5)", + "cairo-lang-starknet-classes 2.6.3 (registry+https://github.com/rust-lang/crates.io-index)", "derive_more", "hex", "indexmap 2.2.6", @@ -15151,10 +15666,27 @@ version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" dependencies = [ + "aes", "byteorder", + "bzip2", + "constant_time_eq", "crc32fast", "crossbeam-utils", "flate2", + "hmac", + "pbkdf2", + "sha1", + "time", + "zstd 0.11.2+zstd.1.5.2", +] + +[[package]] +name = "zstd" +version = "0.11.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" +dependencies = [ + "zstd-safe 5.0.2+zstd.1.5.2", ] [[package]] @@ -15163,7 +15695,17 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d789b1514203a1120ad2429eae43a7bd32b90976a7bb8a05f7ec02fa88cc23a" dependencies = [ - "zstd-safe", + "zstd-safe 7.1.0", +] + +[[package]] +name = "zstd-safe" +version = "5.0.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" +dependencies = [ + "libc", + "zstd-sys", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 3fefe8f63b..743d01ddd2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -110,28 +110,28 @@ async-trait = "0.1.77" auto_impl = "1.2.0" base64 = "0.21.2" bytes = "1.6" -cairo-lang-compiler = "=2.6.3" -cairo-lang-debug = "=2.6.3" -cairo-lang-defs = "=2.6.3" -cairo-lang-diagnostics = "=2.6.3" -cairo-lang-filesystem = "=2.6.3" -cairo-lang-formatter = "=2.6.3" -cairo-lang-language-server = "=2.6.3" -cairo-lang-lowering = "=2.6.3" -cairo-lang-parser = "=2.6.3" -cairo-lang-plugins = { version = "=2.6.3", features = [ "testing" ] } -cairo-lang-project = "=2.6.3" -cairo-lang-semantic = { version = "=2.6.3", features = [ "testing" ] } -cairo-lang-sierra = "=2.6.3" -cairo-lang-sierra-generator = "=2.6.3" -cairo-lang-sierra-to-casm = "=2.6.3" -cairo-lang-starknet = "=2.6.3" -cairo-lang-starknet-classes = "=2.6.3" -cairo-lang-syntax = "=2.6.3" -cairo-lang-test-plugin = "=2.6.3" -cairo-lang-test-runner = "=2.6.3" -cairo-lang-test-utils = "=2.6.3" -cairo-lang-utils = "=2.6.3" +cairo-lang-compiler = { git = "https://github.com/starkware-libs/cairo", rev = "d9984ef58e2f704909e271f2f01327f520ded632" } +cairo-lang-debug = { git = "https://github.com/starkware-libs/cairo", rev = "d9984ef58e2f704909e271f2f01327f520ded632" } +cairo-lang-defs = { git = "https://github.com/starkware-libs/cairo", rev = "d9984ef58e2f704909e271f2f01327f520ded632" } +cairo-lang-diagnostics = { git = "https://github.com/starkware-libs/cairo", rev = "d9984ef58e2f704909e271f2f01327f520ded632" } +cairo-lang-filesystem = { git = "https://github.com/starkware-libs/cairo", rev = "d9984ef58e2f704909e271f2f01327f520ded632" } +cairo-lang-formatter = { git = "https://github.com/starkware-libs/cairo", rev = "d9984ef58e2f704909e271f2f01327f520ded632" } +cairo-lang-language-server = { git = "https://github.com/starkware-libs/cairo", rev = "d9984ef58e2f704909e271f2f01327f520ded632" } +cairo-lang-lowering = { git = "https://github.com/starkware-libs/cairo", rev = "d9984ef58e2f704909e271f2f01327f520ded632" } +cairo-lang-parser = { git = "https://github.com/starkware-libs/cairo", rev = "d9984ef58e2f704909e271f2f01327f520ded632" } +cairo-lang-plugins = { git = "https://github.com/starkware-libs/cairo", rev = "d9984ef58e2f704909e271f2f01327f520ded632", features = [ "testing" ] } +cairo-lang-project = { git = "https://github.com/starkware-libs/cairo", rev = "d9984ef58e2f704909e271f2f01327f520ded632" } +cairo-lang-semantic = { git = "https://github.com/starkware-libs/cairo", rev = "d9984ef58e2f704909e271f2f01327f520ded632", features = [ "testing" ] } +cairo-lang-sierra = { git = "https://github.com/starkware-libs/cairo", rev = "d9984ef58e2f704909e271f2f01327f520ded632" } +cairo-lang-sierra-generator = { git = "https://github.com/starkware-libs/cairo", rev = "d9984ef58e2f704909e271f2f01327f520ded632" } +cairo-lang-sierra-to-casm = { git = "https://github.com/starkware-libs/cairo", rev = "d9984ef58e2f704909e271f2f01327f520ded632" } +cairo-lang-starknet = { git = "https://github.com/starkware-libs/cairo", rev = "d9984ef58e2f704909e271f2f01327f520ded632" } +cairo-lang-starknet-classes = { git = "https://github.com/starkware-libs/cairo", rev = "d9984ef58e2f704909e271f2f01327f520ded632" } +cairo-lang-syntax = { git = "https://github.com/starkware-libs/cairo", rev = "d9984ef58e2f704909e271f2f01327f520ded632" } +cairo-lang-test-plugin = { git = "https://github.com/starkware-libs/cairo", rev = "d9984ef58e2f704909e271f2f01327f520ded632" } +cairo-lang-test-runner = { git = "https://github.com/starkware-libs/cairo", rev = "d9984ef58e2f704909e271f2f01327f520ded632" } +cairo-lang-test-utils = { git = "https://github.com/starkware-libs/cairo", rev = "d9984ef58e2f704909e271f2f01327f520ded632" } +cairo-lang-utils = { git = "https://github.com/starkware-libs/cairo", rev = "d9984ef58e2f704909e271f2f01327f520ded632" } cairo-proof-parser = { git = "https://github.com/cartridge-gg/cairo-proof-parser", tag = "v0.3.0" } cairo-vm = "0.9.2" camino = { version = "1.1.2", features = [ "serde1" ] } @@ -165,8 +165,8 @@ regex = "1.10.3" reqwest = { version = "0.12", features = [ "blocking", "rustls-tls" ], default-features = false } rpassword = "7.2.0" salsa = "0.16.1" -scarb = { git = "https://github.com/software-mansion/scarb", rev = "e813dbab8f0ec606b5846827ad65951ef8bd6b92" } -scarb-ui = { git = "https://github.com/software-mansion/scarb", rev = "e813dbab8f0ec606b5846827ad65951ef8bd6b92" } +scarb = { git = "https://github.com/software-mansion/scarb", rev = "f1aa7b09507a84d209d83b2fa80472c82605cc43" } +scarb-ui = { git = "https://github.com/software-mansion/scarb", rev = "f1aa7b09507a84d209d83b2fa80472c82605cc43" } semver = "1.0.5" serde = { version = "1.0", features = [ "derive" ] } serde_json = { version = "1.0", features = [ "arbitrary_precision" ] } @@ -227,31 +227,3 @@ alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "4655f8e437 alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "4655f8e4372ecc0b056e83abbc60c3912902ee64" } alloy-signer-wallet = { git = "https://github.com/alloy-rs/alloy", rev = "4655f8e4372ecc0b056e83abbc60c3912902ee64" } alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "4655f8e4372ecc0b056e83abbc60c3912902ee64" } - -cairo-lang-compiler = { git = "https://github.com/starkware-libs/cairo", rev = "290f51f554c978180ca9d91177423305959cbed5" } -cairo-lang-debug = { git = "https://github.com/starkware-libs/cairo", rev = "290f51f554c978180ca9d91177423305959cbed5" } -cairo-lang-defs = { git = "https://github.com/starkware-libs/cairo", rev = "290f51f554c978180ca9d91177423305959cbed5" } -cairo-lang-diagnostics = { git = "https://github.com/starkware-libs/cairo", rev = "290f51f554c978180ca9d91177423305959cbed5" } -cairo-lang-filesystem = { git = "https://github.com/starkware-libs/cairo", rev = "290f51f554c978180ca9d91177423305959cbed5" } -cairo-lang-formatter = { git = "https://github.com/starkware-libs/cairo", rev = "290f51f554c978180ca9d91177423305959cbed5" } -cairo-lang-language-server = { git = "https://github.com/starkware-libs/cairo", rev = "290f51f554c978180ca9d91177423305959cbed5" } -cairo-lang-lowering = { git = "https://github.com/starkware-libs/cairo", rev = "290f51f554c978180ca9d91177423305959cbed5" } -cairo-lang-parser = { git = "https://github.com/starkware-libs/cairo", rev = "290f51f554c978180ca9d91177423305959cbed5" } -cairo-lang-plugins = { git = "https://github.com/starkware-libs/cairo", rev = "290f51f554c978180ca9d91177423305959cbed5" } -cairo-lang-project = { git = "https://github.com/starkware-libs/cairo", rev = "290f51f554c978180ca9d91177423305959cbed5" } -cairo-lang-semantic = { git = "https://github.com/starkware-libs/cairo", rev = "290f51f554c978180ca9d91177423305959cbed5" } -cairo-lang-sierra = { git = "https://github.com/starkware-libs/cairo", rev = "290f51f554c978180ca9d91177423305959cbed5" } -cairo-lang-sierra-generator = { git = "https://github.com/starkware-libs/cairo", rev = "290f51f554c978180ca9d91177423305959cbed5" } -cairo-lang-sierra-to-casm = { git = "https://github.com/starkware-libs/cairo", rev = "290f51f554c978180ca9d91177423305959cbed5" } -cairo-lang-starknet = { git = "https://github.com/starkware-libs/cairo", rev = "290f51f554c978180ca9d91177423305959cbed5" } -cairo-lang-starknet-classes = { git = "https://github.com/starkware-libs/cairo", rev = "290f51f554c978180ca9d91177423305959cbed5" } -cairo-lang-syntax = { git = "https://github.com/starkware-libs/cairo", rev = "290f51f554c978180ca9d91177423305959cbed5" } -cairo-lang-test-plugin = { git = "https://github.com/starkware-libs/cairo", rev = "290f51f554c978180ca9d91177423305959cbed5" } -cairo-lang-test-runner = { git = "https://github.com/starkware-libs/cairo", rev = "290f51f554c978180ca9d91177423305959cbed5" } -cairo-lang-test-utils = { git = "https://github.com/starkware-libs/cairo", rev = "290f51f554c978180ca9d91177423305959cbed5" } -cairo-lang-utils = { git = "https://github.com/starkware-libs/cairo", rev = "290f51f554c978180ca9d91177423305959cbed5" } - -# Runner -cairo-lang-casm = { git = "https://github.com/starkware-libs/cairo", rev = "290f51f554c978180ca9d91177423305959cbed5" } -cairo-lang-runner = { git = "https://github.com/starkware-libs/cairo", rev = "290f51f554c978180ca9d91177423305959cbed5" } - diff --git a/bin/dojo-language-server/Cargo.toml b/bin/dojo-language-server/Cargo.toml index 62e08a7c9b..8dc16e26b0 100644 --- a/bin/dojo-language-server/Cargo.toml +++ b/bin/dojo-language-server/Cargo.toml @@ -6,19 +6,6 @@ version.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -anyhow.workspace = true -cairo-lang-compiler.workspace = true -cairo-lang-filesystem.workspace = true cairo-lang-language-server.workspace = true -cairo-lang-plugins.workspace = true -cairo-lang-semantic.workspace = true -cairo-lang-starknet.workspace = true -cairo-lang-test-plugin.workspace = true -cairo-lang-utils.workspace = true clap.workspace = true dojo-lang.workspace = true -log.workspace = true -salsa.workspace = true -smol_str.workspace = true -tokio = { version = "1.18.2", features = [ "full", "sync" ] } -tower-lsp = "0.20.0" diff --git a/bin/dojo-language-server/src/main.rs b/bin/dojo-language-server/src/main.rs index 3c01cbc792..d6516351a2 100644 --- a/bin/dojo-language-server/src/main.rs +++ b/bin/dojo-language-server/src/main.rs @@ -1,7 +1,15 @@ use cairo_lang_language_server::Tricks; +use clap::Parser; use dojo_lang::plugin::dojo_plugin_suite; +/// Dojo Language Server +#[derive(Parser, Debug)] +#[command(author, version, about, long_about = None)] +struct Args {} + fn main() { + let _args = Args::parse(); + let mut tricks = Tricks::default(); tricks.extra_plugin_suites = Some(&|| vec![dojo_plugin_suite()]); cairo_lang_language_server::start_with_tricks(tricks); diff --git a/bin/sozo/src/commands/test.rs b/bin/sozo/src/commands/test.rs index d89b1461ad..19f8279f18 100644 --- a/bin/sozo/src/commands/test.rs +++ b/bin/sozo/src/commands/test.rs @@ -85,7 +85,7 @@ impl TestArgs { continue; }; - let props: Props = unit.target().props()?; + let props: Props = unit.main_component().target_props()?; let db = build_root_database(&unit)?; if DiagnosticsReporter::stderr().allow_warnings().check(&db) { @@ -145,11 +145,13 @@ fn build_project_config(unit: &CairoCompilationUnit) -> Result { .components .iter() .filter(|model| !model.package.id.is_core()) - .map(|model| (model.cairo_package_name(), model.target.source_root().into())) + // NOTE: We're taking the first target of each compilation unit, which should always be the + // main package source root due to the order maintained by scarb. + .map(|model| (model.cairo_package_name(), model.targets[0].source_root().into())) .collect(); let corelib = - unit.core_package_component().map(|c| Directory::Real(c.target.source_root().into())); + unit.core_package_component().map(|c| Directory::Real(c.targets[0].source_root().into())); let crates_config = crates_config_for_compilation_unit(unit); diff --git a/bin/sozo/tests/register_test.rs b/bin/sozo/tests/register_test.rs index 607b4634bd..11053bd38f 100644 --- a/bin/sozo/tests/register_test.rs +++ b/bin/sozo/tests/register_test.rs @@ -1,11 +1,10 @@ mod utils; -use dojo_test_utils::compiler::build_test_config; +use camino::Utf8PathBuf; +use dojo_test_utils::compiler; use dojo_test_utils::migration::prepare_migration; -use dojo_test_utils::sequencer::{ - get_default_test_starknet_config, SequencerConfig, TestSequencer, -}; use dojo_world::migration::TxnConfig; +use katana_runner::KatanaRunner; use scarb::ops; use sozo_ops::migration::execute_strategy; use starknet::accounts::Account; @@ -14,24 +13,28 @@ use utils::snapbox::get_snapbox; #[tokio::test(flavor = "multi_thread")] async fn reregister_models() { - let config = build_test_config("../../examples/spawn-and-move/Scarb.toml").unwrap(); + let source_project_dir = Utf8PathBuf::from("../../examples/spawn-and-move/"); + let dojo_core_path = Utf8PathBuf::from("../../crates/dojo-core"); + + let config = compiler::copy_tmp_config(&source_project_dir, &dojo_core_path); + let ws = ops::read_workspace(config.manifest_path(), &config) .unwrap_or_else(|op| panic!("Error building workspace: {op:?}")); - let base_dir = "../../examples/spawn-and-move"; - let target_dir = format!("{}/target/dev", base_dir); - let migration = prepare_migration(base_dir.into(), target_dir.into()).unwrap(); + let base = config.manifest_path().parent().unwrap(); + let target_dir = format!("{}/target/dev", base); + + let migration = prepare_migration(base.into(), target_dir.into()).unwrap(); - let sequencer = - TestSequencer::start(SequencerConfig::default(), get_default_test_starknet_config()).await; + let sequencer = KatanaRunner::new().expect("Failed to start runner."); - let mut account = sequencer.account(); + let mut account = sequencer.account(0); account.set_block_id(BlockId::Tag(BlockTag::Pending)); - execute_strategy(&ws, &migration, &account, TxnConfig::default()).await.unwrap(); + execute_strategy(&ws, &migration, &account, TxnConfig::init_wait()).await.unwrap(); let world_address = &format!("0x{:x}", &migration.world_address().unwrap()); let account_address = &format!("0x{:x}", account.address()); - let private_key = &format!("0x{:x}", sequencer.raw_account().private_key); + let private_key = &format!("0x{:x}", sequencer.account_data(0).1.private_key); let rpc_url = &sequencer.url().to_string(); let moves_model = diff --git a/crates/dojo-core/src/base_test.cairo b/crates/dojo-core/src/base_test.cairo index 1e3f533b08..d3c974abd3 100644 --- a/crates/dojo-core/src/base_test.cairo +++ b/crates/dojo-core/src/base_test.cairo @@ -160,7 +160,7 @@ mod invalid_model { fn selector(self: @ContractState) -> felt252 { // NOTE: Need to update this value if address changes // Pre-computed address of a contract deployed through the world. - 0x15f0ffa36184d74ead97aa501b09aed53ee7236e364997a0c21879194340ab6 + 0x42503befcd7ad05718645aca9c5ddd83b53dca440f9239ce2dcf63018fba16 } fn name(self: @ContractState) -> ByteArray { diff --git a/crates/dojo-core/src/lib.cairo b/crates/dojo-core/src/lib.cairo index 2e66a3ac03..adbe199c73 100644 --- a/crates/dojo-core/src/lib.cairo +++ b/crates/dojo-core/src/lib.cairo @@ -14,7 +14,16 @@ mod world; #[cfg(test)] mod world_test; -#[cfg(test)] +// Since Scarb 2.6.0 there's an optimization that does not +// build tests for dependencies and it's not configurable. +// +// To expose correctly the test utils for a package using dojo-core, +// we need to it in the `lib` target or using the `#[cfg(target: "test")]` +// attribute. +// +// Since `test_utils` is using `TEST_CLASS_HASH` to factorize some deployment +// core, we place it under the test target manually. +#[cfg(target: "test")] mod test_utils; #[cfg(test)] diff --git a/crates/dojo-core/src/world.cairo b/crates/dojo-core/src/world.cairo index b01adc0d36..083c7b6c2b 100644 --- a/crates/dojo-core/src/world.cairo +++ b/crates/dojo-core/src/world.cairo @@ -400,7 +400,9 @@ mod world { } // If model is already registered, validate permission to update. - let (current_class_hash, current_address) = self.models.read(selector); + let model_data: (ClassHash, ContractAddress) = self.models.read(selector); + let (current_class_hash, current_address) = model_data; + if current_class_hash.is_non_zero() { assert(self.is_owner(caller, selector), Errors::OWNER_ONLY_UPDATE); prev_class_hash = current_class_hash; diff --git a/crates/dojo-lang/src/compiler.rs b/crates/dojo-lang/src/compiler.rs index b9fcaab338..653aab250e 100644 --- a/crates/dojo-lang/src/compiler.rs +++ b/crates/dojo-lang/src/compiler.rs @@ -90,7 +90,7 @@ impl Compiler for DojoCompiler { db: &mut RootDatabase, ws: &Workspace<'_>, ) -> Result<()> { - let props: Props = unit.target().props()?; + let props: Props = unit.main_component().target_props()?; let target_dir = unit.target_dir(ws); let sources_dir = target_dir.child(Utf8Path::new(SOURCES_DIR)); diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo_world_world.toml b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo_world_world.toml index b93ad67681..f80ccef0d2 100644 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo_world_world.toml +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo_world_world.toml @@ -1,5 +1,5 @@ kind = "Class" -class_hash = "0x49f5416d0fb6e6ec76a4f55bfd0addad9ab8a3c864d882012a0a2060d8e8a28" -original_class_hash = "0x49f5416d0fb6e6ec76a4f55bfd0addad9ab8a3c864d882012a0a2060d8e8a28" +class_hash = "0xf6f44afb3cacbcc01a371aff62c86ca9a45feba065424c99f7cd8637514d8f" +original_class_hash = "0xf6f44afb3cacbcc01a371aff62c86ca9a45feba065424c99f7cd8637514d8f" abi = "manifests/dev/abis/base/dojo_world_world.json" name = "dojo::world::world" diff --git a/crates/dojo-lang/src/scarb_internal/mod.rs b/crates/dojo-lang/src/scarb_internal/mod.rs index 15c56c7174..638c7a0d74 100644 --- a/crates/dojo-lang/src/scarb_internal/mod.rs +++ b/crates/dojo-lang/src/scarb_internal/mod.rs @@ -93,9 +93,10 @@ pub fn compile_workspace(config: &Config, opts: CompileOpts) -> Result>(); @@ -143,11 +144,15 @@ fn build_project_config(unit: &CairoCompilationUnit) -> Result { .components() .iter() .filter(|model| !model.package.id.is_core()) - .map(|model| (model.cairo_package_name(), model.target.source_root().into())) + // NOTE: We're taking the first target of each compilation unit, which should always be the + // main package source root due to the order maintained by scarb. + .map(|model| (model.cairo_package_name(), model.targets[0].source_root().into())) .collect(); let corelib = - unit.core_package_component().map(|c| Directory::Real(c.target.source_root().into())); + // NOTE: We're taking the first target of the corelib, which should always be the + // main package source root due to the order maintained by scarb. + unit.core_package_component().map(|c| Directory::Real(c.targets[0].source_root().into())); let content = ProjectConfigContent { crate_roots, diff --git a/crates/dojo-lang/src/semantics/test_utils.rs b/crates/dojo-lang/src/semantics/test_utils.rs index dc9db9a166..00e34b9b9b 100644 --- a/crates/dojo-lang/src/semantics/test_utils.rs +++ b/crates/dojo-lang/src/semantics/test_utils.rs @@ -12,7 +12,7 @@ use cairo_lang_filesystem::db::{ use cairo_lang_filesystem::ids::{ CrateId, CrateLongId, Directory, FileKind, FileLongId, VirtualFile, }; -use cairo_lang_parser::db::ParserDatabase; +use cairo_lang_parser::db::{ParserDatabase, ParserGroup}; use cairo_lang_semantic::db::{SemanticDatabase, SemanticGroup}; use cairo_lang_semantic::inline_macros::get_default_plugin_suite; use cairo_lang_semantic::items::functions::GenericFunctionId; @@ -100,6 +100,11 @@ impl Upcast for DojoSemanticDatabase { self } } +impl Upcast for DojoSemanticDatabase { + fn upcast(&self) -> &(dyn ParserGroup + 'static) { + self + } +} pub struct WithStringDiagnostics { value: T, diff --git a/crates/dojo-test-utils/src/compiler.rs b/crates/dojo-test-utils/src/compiler.rs index b8d30c5775..a48ef13435 100644 --- a/crates/dojo-test-utils/src/compiler.rs +++ b/crates/dojo-test-utils/src/compiler.rs @@ -195,7 +195,9 @@ pub fn corelib() -> PathBuf { let compilation_units = ops::generate_compilation_units(&resolve, &features_opts, &ws).unwrap(); if let CompilationUnit::Cairo(unit) = &compilation_units[0] { - unit.core_package_component().expect("should have component").target.source_root().into() + unit.core_package_component().expect("should have component").targets[0] + .source_root() + .into() } else { panic!("should have cairo compilation unit") } diff --git a/crates/dojo-world/src/contracts/model_test.rs b/crates/dojo-world/src/contracts/model_test.rs index f32a7b5943..178e9b6495 100644 --- a/crates/dojo-world/src/contracts/model_test.rs +++ b/crates/dojo-world/src/contracts/model_test.rs @@ -65,7 +65,7 @@ async fn test_model() { assert_eq!( position.class_hash(), - felt!("0x03ab26e88be7885877f93964880ccb63a8acd8e58f941c48bef52f191fa79868") + felt!("0x027942375b09862291ece780c573e8c625df4ba41fd7524e0658ca75fff014ff") ); let moves = world.model_reader("Moves").await.unwrap(); diff --git a/crates/dojo-world/src/contracts/world_test.rs b/crates/dojo-world/src/contracts/world_test.rs index b96f25476b..3b856c1f46 100644 --- a/crates/dojo-world/src/contracts/world_test.rs +++ b/crates/dojo-world/src/contracts/world_test.rs @@ -5,7 +5,7 @@ use dojo_lang::compiler::{BASE_DIR, MANIFESTS_DIR, OVERLAYS_DIR}; use dojo_test_utils::compiler; use katana_runner::KatanaRunner; use starknet::accounts::{Account, ConnectedAccount}; -use starknet::core::types::FieldElement; +use starknet::core::types::{BlockId, BlockTag, FieldElement}; use super::{WorldContract, WorldContractReader}; use crate::manifest::{BaseManifest, OverlayManifest}; @@ -24,8 +24,11 @@ async fn test_world_contract_reader() { let manifest_dir = config.manifest_path().parent().unwrap(); let target_dir = manifest_dir.join("target").join("dev"); - let account = runner.account(0); + let mut account = runner.account(0); + account.set_block_id(BlockId::Tag(BlockTag::Pending)); + let provider = account.provider(); + let world_address = deploy_world(&runner, &manifest_dir.to_path_buf(), &target_dir.to_path_buf()).await; diff --git a/crates/dojo-world/src/metadata_test.rs b/crates/dojo-world/src/metadata_test.rs index 4eded54d96..6a5938d2f2 100644 --- a/crates/dojo-world/src/metadata_test.rs +++ b/crates/dojo-world/src/metadata_test.rs @@ -147,7 +147,7 @@ async fn get_full_dojo_metadata_from_workspace() { assert!(env.world_address.is_some()); assert_eq!( env.world_address.unwrap(), - "0x05134532e5d24c8264e61bb6bbe5c06031d462b8b7bdd15b5554e77e2a97c369" + "0x2e31cfde9f9990c7fe44b25043e3c6958a849c0a66ab535686d2b710e97f309" ); assert!(env.keystore_path.is_none()); diff --git a/crates/torii/types-test/manifests/dev/base/dojo_world_world.toml b/crates/torii/types-test/manifests/dev/base/dojo_world_world.toml index b93ad67681..f80ccef0d2 100644 --- a/crates/torii/types-test/manifests/dev/base/dojo_world_world.toml +++ b/crates/torii/types-test/manifests/dev/base/dojo_world_world.toml @@ -1,5 +1,5 @@ kind = "Class" -class_hash = "0x49f5416d0fb6e6ec76a4f55bfd0addad9ab8a3c864d882012a0a2060d8e8a28" -original_class_hash = "0x49f5416d0fb6e6ec76a4f55bfd0addad9ab8a3c864d882012a0a2060d8e8a28" +class_hash = "0xf6f44afb3cacbcc01a371aff62c86ca9a45feba065424c99f7cd8637514d8f" +original_class_hash = "0xf6f44afb3cacbcc01a371aff62c86ca9a45feba065424c99f7cd8637514d8f" abi = "manifests/dev/abis/base/dojo_world_world.json" name = "dojo::world::world" diff --git a/examples/spawn-and-move/Scarb.toml b/examples/spawn-and-move/Scarb.toml index 3bb8955a18..8a1e9613e9 100644 --- a/examples/spawn-and-move/Scarb.toml +++ b/examples/spawn-and-move/Scarb.toml @@ -25,4 +25,4 @@ rpc_url = "http://localhost:5050/" # Default account for katana with seed = 0 account_address = "0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03" private_key = "0x1800000000300000180000000000030000000000003006001800006600" -world_address = "0x05134532e5d24c8264e61bb6bbe5c06031d462b8b7bdd15b5554e77e2a97c369" +world_address = "0x2e31cfde9f9990c7fe44b25043e3c6958a849c0a66ab535686d2b710e97f309" diff --git a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples_actions_actions.toml b/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples_actions_actions.toml index 5f84fa6760..09f30e5dfa 100644 --- a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples_actions_actions.toml +++ b/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples_actions_actions.toml @@ -1,6 +1,6 @@ kind = "DojoContract" -class_hash = "0xfe09a42928890d712af285559b4452ebbc448428dfa91179bfee66715a2add" -original_class_hash = "0xfe09a42928890d712af285559b4452ebbc448428dfa91179bfee66715a2add" +class_hash = "0x6d905953360cf18e3393d128c6ced40b38fc83b033412c8541fd4aba59d2767" +original_class_hash = "0x6d905953360cf18e3393d128c6ced40b38fc83b033412c8541fd4aba59d2767" base_class_hash = "0x0" abi = "manifests/dev/abis/base/contracts/dojo_examples_actions_actions.json" reads = [] diff --git a/examples/spawn-and-move/manifests/dev/base/dojo_world_world.toml b/examples/spawn-and-move/manifests/dev/base/dojo_world_world.toml index b93ad67681..f80ccef0d2 100644 --- a/examples/spawn-and-move/manifests/dev/base/dojo_world_world.toml +++ b/examples/spawn-and-move/manifests/dev/base/dojo_world_world.toml @@ -1,5 +1,5 @@ kind = "Class" -class_hash = "0x49f5416d0fb6e6ec76a4f55bfd0addad9ab8a3c864d882012a0a2060d8e8a28" -original_class_hash = "0x49f5416d0fb6e6ec76a4f55bfd0addad9ab8a3c864d882012a0a2060d8e8a28" +class_hash = "0xf6f44afb3cacbcc01a371aff62c86ca9a45feba065424c99f7cd8637514d8f" +original_class_hash = "0xf6f44afb3cacbcc01a371aff62c86ca9a45feba065424c99f7cd8637514d8f" abi = "manifests/dev/abis/base/dojo_world_world.json" name = "dojo::world::world" diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_actions_actions_moved.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_actions_actions_moved.toml index a9e0f20f78..8b79f5c317 100644 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_actions_actions_moved.toml +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_actions_actions_moved.toml @@ -1,6 +1,6 @@ kind = "DojoModel" -class_hash = "0x6f85952ceeb7783fb265a4b2d235db48e7a36357bbce7a56997ca5798c95187" -original_class_hash = "0x6f85952ceeb7783fb265a4b2d235db48e7a36357bbce7a56997ca5798c95187" +class_hash = "0x4ef89963afe500337aaf757ad52394ea8e311077a825b3de5a5f32d3457997c" +original_class_hash = "0x4ef89963afe500337aaf757ad52394ea8e311077a825b3de5a5f32d3457997c" abi = "manifests/dev/abis/base/models/dojo_examples_actions_actions_moved.json" name = "dojo_examples::actions::actions::moved" diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_emote_message.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_emote_message.toml index 668a594127..3dfeddaf7b 100644 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_emote_message.toml +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_emote_message.toml @@ -1,6 +1,6 @@ kind = "DojoModel" -class_hash = "0x3e8f99f02409b7bc3dfffba58ee3807e3fb3513a2dcac1b0bd1f1118ea79ecc" -original_class_hash = "0x3e8f99f02409b7bc3dfffba58ee3807e3fb3513a2dcac1b0bd1f1118ea79ecc" +class_hash = "0x6ec8bf0a073e509e5b442ee5d4bee75aa85b87671a110dff2b9e6a58cc2aaa5" +original_class_hash = "0x6ec8bf0a073e509e5b442ee5d4bee75aa85b87671a110dff2b9e6a58cc2aaa5" abi = "manifests/dev/abis/base/models/dojo_examples_models_emote_message.json" name = "dojo_examples::models::emote_message" diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_moves.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_moves.toml index db94e2ff11..6241643aa4 100644 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_moves.toml +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_moves.toml @@ -1,6 +1,6 @@ kind = "DojoModel" -class_hash = "0x402d1ee5171aac681d16fa8c248a0498678082152e0f4c416776a71fc270684" -original_class_hash = "0x402d1ee5171aac681d16fa8c248a0498678082152e0f4c416776a71fc270684" +class_hash = "0x456d85286b34249fffa0a13d1ac490cc1f5b02eb1a1c92d820c59d6b0f2eaa8" +original_class_hash = "0x456d85286b34249fffa0a13d1ac490cc1f5b02eb1a1c92d820c59d6b0f2eaa8" abi = "manifests/dev/abis/base/models/dojo_examples_models_moves.json" name = "dojo_examples::models::moves" diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_player_config.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_player_config.toml index bbaa577a1c..459eb9ebdb 100644 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_player_config.toml +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_player_config.toml @@ -1,6 +1,6 @@ kind = "DojoModel" -class_hash = "0x596f2ea7f78e3828f6daa798a271ef0a98741967afa40e680c2d80879be7d09" -original_class_hash = "0x596f2ea7f78e3828f6daa798a271ef0a98741967afa40e680c2d80879be7d09" +class_hash = "0x584d016a91d077c86ff1c014e0c4d735946d1084dd0d4c0a80cee6d04629e55" +original_class_hash = "0x584d016a91d077c86ff1c014e0c4d735946d1084dd0d4c0a80cee6d04629e55" abi = "manifests/dev/abis/base/models/dojo_examples_models_player_config.json" name = "dojo_examples::models::player_config" diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_position.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_position.toml index 5bcac0ef22..d29abaa4e0 100644 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_position.toml +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_position.toml @@ -1,6 +1,6 @@ kind = "DojoModel" -class_hash = "0x3ab26e88be7885877f93964880ccb63a8acd8e58f941c48bef52f191fa79868" -original_class_hash = "0x3ab26e88be7885877f93964880ccb63a8acd8e58f941c48bef52f191fa79868" +class_hash = "0x27942375b09862291ece780c573e8c625df4ba41fd7524e0658ca75fff014ff" +original_class_hash = "0x27942375b09862291ece780c573e8c625df4ba41fd7524e0658ca75fff014ff" abi = "manifests/dev/abis/base/models/dojo_examples_models_position.json" name = "dojo_examples::models::position" diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_others_others_contract_initialized.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_others_others_contract_initialized.toml index f267d02139..e4b4f0fdc3 100644 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_others_others_contract_initialized.toml +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_others_others_contract_initialized.toml @@ -1,6 +1,6 @@ kind = "DojoModel" -class_hash = "0x6b54d690f4f43e3011fe05fabf3e5f1807b3a026430eb175534336e9a90d5a5" -original_class_hash = "0x6b54d690f4f43e3011fe05fabf3e5f1807b3a026430eb175534336e9a90d5a5" +class_hash = "0x4b29afc6db744bd87f7276869620348557c11b984e9f3fcb27c4d55efb0ab6c" +original_class_hash = "0x4b29afc6db744bd87f7276869620348557c11b984e9f3fcb27c4d55efb0ab6c" abi = "manifests/dev/abis/base/models/dojo_examples_others_others_contract_initialized.json" name = "dojo_examples::others::others::contract_initialized" diff --git a/examples/spawn-and-move/manifests/dev/manifest.json b/examples/spawn-and-move/manifests/dev/manifest.json index f0c028b084..404bf0f8b6 100644 --- a/examples/spawn-and-move/manifests/dev/manifest.json +++ b/examples/spawn-and-move/manifests/dev/manifest.json @@ -1,8 +1,8 @@ { "world": { "kind": "WorldContract", - "class_hash": "0x49f5416d0fb6e6ec76a4f55bfd0addad9ab8a3c864d882012a0a2060d8e8a28", - "original_class_hash": "0x49f5416d0fb6e6ec76a4f55bfd0addad9ab8a3c864d882012a0a2060d8e8a28", + "class_hash": "0xf6f44afb3cacbcc01a371aff62c86ca9a45feba065424c99f7cd8637514d8f", + "original_class_hash": "0xf6f44afb3cacbcc01a371aff62c86ca9a45feba065424c99f7cd8637514d8f", "abi": [ { "type": "impl", @@ -955,8 +955,8 @@ ] } ], - "address": "0x5134532e5d24c8264e61bb6bbe5c06031d462b8b7bdd15b5554e77e2a97c369", - "transaction_hash": "0x35473957a0f251eb91420957dfcacfe52c6b00c4f5ab5512bcb678b500abf", + "address": "0x2e31cfde9f9990c7fe44b25043e3c6958a849c0a66ab535686d2b710e97f309", + "transaction_hash": "0x7106054ad5c4ccfcd5e512d286ce7cadc5ddc21b8cf058e4daab09743bace76", "block_number": 3, "seed": "dojo_examples", "metadata": { @@ -975,9 +975,9 @@ "contracts": [ { "kind": "DojoContract", - "address": "0x6dee77ea677ba316b702ac7666b5f2eb7d12d3b93a450cf61371b1cb2b5a2a8", - "class_hash": "0xfe09a42928890d712af285559b4452ebbc448428dfa91179bfee66715a2add", - "original_class_hash": "0xfe09a42928890d712af285559b4452ebbc448428dfa91179bfee66715a2add", + "address": "0x263f89fc2bdf121a3bdcc9af35eb6b3d5c078f9bcc257e9f5627af81a7607fd", + "class_hash": "0x6d905953360cf18e3393d128c6ced40b38fc83b033412c8541fd4aba59d2767", + "original_class_hash": "0x6d905953360cf18e3393d128c6ced40b38fc83b033412c8541fd4aba59d2767", "base_class_hash": "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46", "abi": [ { @@ -1280,7 +1280,7 @@ }, { "kind": "DojoContract", - "address": "0x47bad9d0cd66bb0184ca7ebbc3b3067564e65aa5a3d3ffbf19ecbe9fb8fa1b4", + "address": "0x2dc27292cc94aa40e4d2d327e511ce02e96f40ca3c41d1f9938860a1a4aee9f", "class_hash": "0x3ee016157303a7ce35a9fecdb5b8519159df620c5780527d61443636aaa3c3a", "original_class_hash": "0x3ee016157303a7ce35a9fecdb5b8519159df620c5780527d61443636aaa3c3a", "base_class_hash": "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46", @@ -1456,8 +1456,8 @@ "key": false } ], - "class_hash": "0x6f85952ceeb7783fb265a4b2d235db48e7a36357bbce7a56997ca5798c95187", - "original_class_hash": "0x6f85952ceeb7783fb265a4b2d235db48e7a36357bbce7a56997ca5798c95187", + "class_hash": "0x4ef89963afe500337aaf757ad52394ea8e311077a825b3de5a5f32d3457997c", + "original_class_hash": "0x4ef89963afe500337aaf757ad52394ea8e311077a825b3de5a5f32d3457997c", "abi": [ { "type": "impl", @@ -1863,8 +1863,8 @@ "key": false } ], - "class_hash": "0x3e8f99f02409b7bc3dfffba58ee3807e3fb3513a2dcac1b0bd1f1118ea79ecc", - "original_class_hash": "0x3e8f99f02409b7bc3dfffba58ee3807e3fb3513a2dcac1b0bd1f1118ea79ecc", + "class_hash": "0x6ec8bf0a073e509e5b442ee5d4bee75aa85b87671a110dff2b9e6a58cc2aaa5", + "original_class_hash": "0x6ec8bf0a073e509e5b442ee5d4bee75aa85b87671a110dff2b9e6a58cc2aaa5", "abi": [ { "type": "impl", @@ -2275,8 +2275,8 @@ "key": false } ], - "class_hash": "0x402d1ee5171aac681d16fa8c248a0498678082152e0f4c416776a71fc270684", - "original_class_hash": "0x402d1ee5171aac681d16fa8c248a0498678082152e0f4c416776a71fc270684", + "class_hash": "0x456d85286b34249fffa0a13d1ac490cc1f5b02eb1a1c92d820c59d6b0f2eaa8", + "original_class_hash": "0x456d85286b34249fffa0a13d1ac490cc1f5b02eb1a1c92d820c59d6b0f2eaa8", "abi": [ { "type": "impl", @@ -2696,8 +2696,8 @@ "key": false } ], - "class_hash": "0x596f2ea7f78e3828f6daa798a271ef0a98741967afa40e680c2d80879be7d09", - "original_class_hash": "0x596f2ea7f78e3828f6daa798a271ef0a98741967afa40e680c2d80879be7d09", + "class_hash": "0x584d016a91d077c86ff1c014e0c4d735946d1084dd0d4c0a80cee6d04629e55", + "original_class_hash": "0x584d016a91d077c86ff1c014e0c4d735946d1084dd0d4c0a80cee6d04629e55", "abi": [ { "type": "impl", @@ -3099,8 +3099,8 @@ "key": false } ], - "class_hash": "0x3ab26e88be7885877f93964880ccb63a8acd8e58f941c48bef52f191fa79868", - "original_class_hash": "0x3ab26e88be7885877f93964880ccb63a8acd8e58f941c48bef52f191fa79868", + "class_hash": "0x27942375b09862291ece780c573e8c625df4ba41fd7524e0658ca75fff014ff", + "original_class_hash": "0x27942375b09862291ece780c573e8c625df4ba41fd7524e0658ca75fff014ff", "abi": [ { "type": "impl", @@ -3499,8 +3499,8 @@ "key": false } ], - "class_hash": "0x6b54d690f4f43e3011fe05fabf3e5f1807b3a026430eb175534336e9a90d5a5", - "original_class_hash": "0x6b54d690f4f43e3011fe05fabf3e5f1807b3a026430eb175534336e9a90d5a5", + "class_hash": "0x4b29afc6db744bd87f7276869620348557c11b984e9f3fcb27c4d55efb0ab6c", + "original_class_hash": "0x4b29afc6db744bd87f7276869620348557c11b984e9f3fcb27c4d55efb0ab6c", "abi": [ { "type": "impl", diff --git a/examples/spawn-and-move/manifests/dev/manifest.toml b/examples/spawn-and-move/manifests/dev/manifest.toml index 21a653ba34..ccc078a545 100644 --- a/examples/spawn-and-move/manifests/dev/manifest.toml +++ b/examples/spawn-and-move/manifests/dev/manifest.toml @@ -1,10 +1,10 @@ [world] kind = "WorldContract" -class_hash = "0x49f5416d0fb6e6ec76a4f55bfd0addad9ab8a3c864d882012a0a2060d8e8a28" -original_class_hash = "0x49f5416d0fb6e6ec76a4f55bfd0addad9ab8a3c864d882012a0a2060d8e8a28" +class_hash = "0xf6f44afb3cacbcc01a371aff62c86ca9a45feba065424c99f7cd8637514d8f" +original_class_hash = "0xf6f44afb3cacbcc01a371aff62c86ca9a45feba065424c99f7cd8637514d8f" abi = "manifests/dev/abis/deployments/dojo_world_world.json" -address = "0x5134532e5d24c8264e61bb6bbe5c06031d462b8b7bdd15b5554e77e2a97c369" -transaction_hash = "0x35473957a0f251eb91420957dfcacfe52c6b00c4f5ab5512bcb678b500abf" +address = "0x2e31cfde9f9990c7fe44b25043e3c6958a849c0a66ab535686d2b710e97f309" +transaction_hash = "0x7106054ad5c4ccfcd5e512d286ce7cadc5ddc21b8cf058e4daab09743bace76" block_number = 3 seed = "dojo_examples" name = "dojo::world::world" @@ -21,9 +21,9 @@ name = "dojo::base::base" [[contracts]] kind = "DojoContract" -address = "0x6dee77ea677ba316b702ac7666b5f2eb7d12d3b93a450cf61371b1cb2b5a2a8" -class_hash = "0xfe09a42928890d712af285559b4452ebbc448428dfa91179bfee66715a2add" -original_class_hash = "0xfe09a42928890d712af285559b4452ebbc448428dfa91179bfee66715a2add" +address = "0x263f89fc2bdf121a3bdcc9af35eb6b3d5c078f9bcc257e9f5627af81a7607fd" +class_hash = "0x6d905953360cf18e3393d128c6ced40b38fc83b033412c8541fd4aba59d2767" +original_class_hash = "0x6d905953360cf18e3393d128c6ced40b38fc83b033412c8541fd4aba59d2767" base_class_hash = "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46" abi = "manifests/dev/abis/deployments/contracts/dojo_examples_actions_actions.json" reads = [] @@ -37,7 +37,7 @@ name = "dojo_examples::actions::actions" [[contracts]] kind = "DojoContract" -address = "0x47bad9d0cd66bb0184ca7ebbc3b3067564e65aa5a3d3ffbf19ecbe9fb8fa1b4" +address = "0x2dc27292cc94aa40e4d2d327e511ce02e96f40ca3c41d1f9938860a1a4aee9f" class_hash = "0x3ee016157303a7ce35a9fecdb5b8519159df620c5780527d61443636aaa3c3a" original_class_hash = "0x3ee016157303a7ce35a9fecdb5b8519159df620c5780527d61443636aaa3c3a" base_class_hash = "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46" @@ -54,8 +54,8 @@ name = "dojo_examples::others::others" [[models]] kind = "DojoModel" -class_hash = "0x6f85952ceeb7783fb265a4b2d235db48e7a36357bbce7a56997ca5798c95187" -original_class_hash = "0x6f85952ceeb7783fb265a4b2d235db48e7a36357bbce7a56997ca5798c95187" +class_hash = "0x4ef89963afe500337aaf757ad52394ea8e311077a825b3de5a5f32d3457997c" +original_class_hash = "0x4ef89963afe500337aaf757ad52394ea8e311077a825b3de5a5f32d3457997c" abi = "manifests/dev/abis/deployments/models/dojo_examples_actions_actions_moved.json" name = "dojo_examples::actions::actions::moved" @@ -71,8 +71,8 @@ key = false [[models]] kind = "DojoModel" -class_hash = "0x3e8f99f02409b7bc3dfffba58ee3807e3fb3513a2dcac1b0bd1f1118ea79ecc" -original_class_hash = "0x3e8f99f02409b7bc3dfffba58ee3807e3fb3513a2dcac1b0bd1f1118ea79ecc" +class_hash = "0x6ec8bf0a073e509e5b442ee5d4bee75aa85b87671a110dff2b9e6a58cc2aaa5" +original_class_hash = "0x6ec8bf0a073e509e5b442ee5d4bee75aa85b87671a110dff2b9e6a58cc2aaa5" abi = "manifests/dev/abis/deployments/models/dojo_examples_models_emote_message.json" name = "dojo_examples::models::emote_message" @@ -88,8 +88,8 @@ key = false [[models]] kind = "DojoModel" -class_hash = "0x402d1ee5171aac681d16fa8c248a0498678082152e0f4c416776a71fc270684" -original_class_hash = "0x402d1ee5171aac681d16fa8c248a0498678082152e0f4c416776a71fc270684" +class_hash = "0x456d85286b34249fffa0a13d1ac490cc1f5b02eb1a1c92d820c59d6b0f2eaa8" +original_class_hash = "0x456d85286b34249fffa0a13d1ac490cc1f5b02eb1a1c92d820c59d6b0f2eaa8" abi = "manifests/dev/abis/deployments/models/dojo_examples_models_moves.json" name = "dojo_examples::models::moves" @@ -110,8 +110,8 @@ key = false [[models]] kind = "DojoModel" -class_hash = "0x596f2ea7f78e3828f6daa798a271ef0a98741967afa40e680c2d80879be7d09" -original_class_hash = "0x596f2ea7f78e3828f6daa798a271ef0a98741967afa40e680c2d80879be7d09" +class_hash = "0x584d016a91d077c86ff1c014e0c4d735946d1084dd0d4c0a80cee6d04629e55" +original_class_hash = "0x584d016a91d077c86ff1c014e0c4d735946d1084dd0d4c0a80cee6d04629e55" abi = "manifests/dev/abis/deployments/models/dojo_examples_models_player_config.json" name = "dojo_examples::models::player_config" @@ -137,8 +137,8 @@ key = false [[models]] kind = "DojoModel" -class_hash = "0x3ab26e88be7885877f93964880ccb63a8acd8e58f941c48bef52f191fa79868" -original_class_hash = "0x3ab26e88be7885877f93964880ccb63a8acd8e58f941c48bef52f191fa79868" +class_hash = "0x27942375b09862291ece780c573e8c625df4ba41fd7524e0658ca75fff014ff" +original_class_hash = "0x27942375b09862291ece780c573e8c625df4ba41fd7524e0658ca75fff014ff" abi = "manifests/dev/abis/deployments/models/dojo_examples_models_position.json" name = "dojo_examples::models::position" @@ -154,8 +154,8 @@ key = false [[models]] kind = "DojoModel" -class_hash = "0x6b54d690f4f43e3011fe05fabf3e5f1807b3a026430eb175534336e9a90d5a5" -original_class_hash = "0x6b54d690f4f43e3011fe05fabf3e5f1807b3a026430eb175534336e9a90d5a5" +class_hash = "0x4b29afc6db744bd87f7276869620348557c11b984e9f3fcb27c4d55efb0ab6c" +original_class_hash = "0x4b29afc6db744bd87f7276869620348557c11b984e9f3fcb27c4d55efb0ab6c" abi = "manifests/dev/abis/deployments/models/dojo_examples_others_others_contract_initialized.json" name = "dojo_examples::others::others::contract_initialized" From 5af2bc695be959b724e5bb386169d950cd2d3d7a Mon Sep 17 00:00:00 2001 From: Larko <59736843+Larkooo@users.noreply.github.com> Date: Wed, 29 May 2024 15:25:26 -0400 Subject: [PATCH 15/16] feat(dojo-bindgen): support new layout types (#1954) * feat: new types in unity bindgen * feat: add types support to typescript codegen too * feat: handle token directly to get type name * chore: correct type names * chore: update to correct tuple types * fmt * Update mod.rs * Update mod.rs * Update mod.rs * feat: add support for complex enums to unity bindgen * feat: support generic args in typescript * fmt * feat: newer tuple type for c# * feat: value type name in record field * feat: generic rust like enum for unity bindgen * refacotr: optional generic args for record * feat: add suppport for generic enums for typescript v2 * feat: update test & disable typescript * fix: update unity systsem bindgen to use new felt getter #2008 * chore: clippy * clean uop --- bin/sozo/src/commands/build.rs | 21 ++- .../src/plugins/typescript/mod.rs | 89 +++++++--- .../src/plugins/typescript_v2/mod.rs | 157 +++++++++++------- crates/dojo-bindgen/src/plugins/unity/mod.rs | 127 +++++++++----- .../src/test_data/mocks/dojo_examples.ts | 100 ++++++----- 5 files changed, 317 insertions(+), 177 deletions(-) diff --git a/bin/sozo/src/commands/build.rs b/bin/sozo/src/commands/build.rs index d8112bb51f..e278e693d0 100644 --- a/bin/sozo/src/commands/build.rs +++ b/bin/sozo/src/commands/build.rs @@ -16,10 +16,11 @@ const CONTRACT_NAME_LABEL: &str = "Contract"; #[derive(Debug, Args)] pub struct BuildArgs { - #[arg(long)] - #[arg(help = "Generate Typescript bindings.")] - pub typescript: bool, - + // Should we deprecate typescript bindings codegen? + // Disabled due to lack of support in dojo.js + // #[arg(long)] + // #[arg(help = "Generate Typescript bindings.")] + // pub typescript: bool, #[arg(long)] #[arg(help = "Generate Typescript bindings.")] pub typescript_v2: bool, @@ -52,9 +53,11 @@ impl BuildArgs { trace!(?compile_info, "Compiled workspace."); let mut builtin_plugins = vec![]; - if self.typescript { - builtin_plugins.push(BuiltinPlugins::Typescript); - } + + // Disable typescript for now. Due to lack of support and maintenance in dojo.js + // if self.typescript { + // builtin_plugins.push(BuiltinPlugins::Typescript); + // } if self.typescript_v2 { builtin_plugins.push(BuiltinPlugins::TypeScriptV2); @@ -177,9 +180,9 @@ mod tests { let build_args = BuildArgs { bindings_output: "generated".to_string(), - typescript: false, + // typescript: false, unity: true, - typescript_v2: false, + typescript_v2: true, stats: true, }; let result = build_args.run(&config); diff --git a/crates/dojo-bindgen/src/plugins/typescript/mod.rs b/crates/dojo-bindgen/src/plugins/typescript/mod.rs index de2f11bc91..9b00739fe8 100644 --- a/crates/dojo-bindgen/src/plugins/typescript/mod.rs +++ b/crates/dojo-bindgen/src/plugins/typescript/mod.rs @@ -16,8 +16,8 @@ impl TypescriptPlugin { } // Maps cairo types to C#/Unity SDK defined types - fn map_type(type_name: &str) -> String { - match type_name { + fn map_type(token: &Token, generic_args: &Vec<(String, Token)>) -> String { + match token.type_name().as_str() { "bool" => "RecsType.Boolean".to_string(), "u8" => "RecsType.Number".to_string(), "u16" => "RecsType.Number".to_string(), @@ -30,8 +30,44 @@ impl TypescriptPlugin { "bytes31" => "RecsType.String".to_string(), "ClassHash" => "RecsType.BigInt".to_string(), "ContractAddress" => "RecsType.BigInt".to_string(), + "ByteArray" => "RecsType.String".to_string(), + "array" => { + if let Token::Array(array) = token { + format!("{}[]", TypescriptPlugin::map_type(&array.inner, generic_args)) + } else { + panic!("Invalid array token: {:?}", token); + } + } + "tuple" => { + if let Token::Tuple(tuple) = token { + let inners = tuple + .inners + .iter() + .map(|inner| TypescriptPlugin::map_type(inner, generic_args)) + .collect::>() + .join(", "); - _ => type_name.to_string(), + format!("[{}]", inners) + } else { + panic!("Invalid tuple token: {:?}", token); + } + } + "generic_arg" => { + if let Token::GenericArg(arg) = &token { + let arg_type = generic_args + .iter() + .find(|(name, _)| name == arg) + .unwrap_or_else(|| panic!("Generic arg not found: {}", arg)) + .1 + .clone(); + + TypescriptPlugin::map_type(&arg_type, generic_args) + } else { + panic!("Invalid generic arg token: {:?}", token); + } + } + + _ => token.type_name().to_string(), } } @@ -50,7 +86,7 @@ impl TypescriptPlugin { let mut fields = String::new(); for field in &token.inners { - let mapped = TypescriptPlugin::map_type(field.token.type_name().as_str()); + let mapped = TypescriptPlugin::map_type(&field.token, &token.generic_args); if mapped == field.token.type_name() { let token = handled_tokens .iter() @@ -93,24 +129,35 @@ export const {name}Definition = {{ // This will be formatted into a C# enum // Enum is mapped using index of cairo enum fn format_enum(token: &Composite) -> String { - let fields = token - .inners - .iter() - .map(|field| format!("{},", field.name,)) - .collect::>() - .join("\n "); + let name = token.type_name(); - format!( + let mut result = format!( " // Type definition for `{}` enum -export enum {} {{ - {} -}} -", - token.type_path, - token.type_name(), - fields - ) +type {} = ", + token.type_path, name + ); + + let mut variants = Vec::new(); + + for field in &token.inners { + let field_type = + TypescriptPlugin::map_type(&field.token, &token.generic_args).replace("()", ""); + + let variant_definition = if field_type.is_empty() { + // No associated data + format!("{{ type: '{}'; }}", field.name) + } else { + // With associated data + format!("{{ type: '{}'; data: {}; }}", field.name, field_type) + }; + + variants.push(variant_definition); + } + + result += &variants.join(" | "); + + result } // Token should be a model @@ -123,7 +170,7 @@ export enum {} {{ .inners .iter() .map(|field| { - let mapped = TypescriptPlugin::map_type(field.token.type_name().as_str()); + let mapped = TypescriptPlugin::map_type(&field.token, &model.generic_args); if mapped == field.token.type_name() { custom_types.push(format!("\"{}\"", field.token.type_name())); @@ -258,7 +305,7 @@ export function defineContractComponents(world: World) { fn format_system(system: &Function, handled_tokens: &[Composite]) -> String { fn map_type(token: &Token) -> String { match token { - Token::CoreBasic(t) => TypescriptPlugin::map_type(&t.type_name()) + Token::CoreBasic(_) => TypescriptPlugin::map_type(token, &vec![]) .replace("RecsType.", "") // types should be lowercased .to_lowercase(), diff --git a/crates/dojo-bindgen/src/plugins/typescript_v2/mod.rs b/crates/dojo-bindgen/src/plugins/typescript_v2/mod.rs index d894a340ad..7ae5d5b2a6 100644 --- a/crates/dojo-bindgen/src/plugins/typescript_v2/mod.rs +++ b/crates/dojo-bindgen/src/plugins/typescript_v2/mod.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use std::path::{Path, PathBuf}; use async_trait::async_trait; -use cainome::parser::tokens::{Composite, CompositeType, Function}; +use cainome::parser::tokens::{Composite, CompositeType, Function, Token}; use convert_case::Casing; use crate::error::BindgenResult; @@ -17,8 +17,8 @@ impl TypeScriptV2Plugin { } // Maps cairo types to TypeScript defined types - fn map_type(type_name: &str) -> String { - match type_name { + fn map_type(token: &Token) -> String { + match token.type_name().as_str() { "bool" => "boolean".to_string(), "u8" => "number".to_string(), "u16" => "number".to_string(), @@ -28,10 +28,57 @@ impl TypeScriptV2Plugin { "u256" => "bigint".to_string(), "usize" => "number".to_string(), "felt252" => "string".to_string(), + "bytes31" => "string".to_string(), "ClassHash" => "string".to_string(), "ContractAddress" => "string".to_string(), + "ByteArray" => "string".to_string(), + "array" => { + if let Token::Array(array) = token { + format!("{}[]", TypeScriptV2Plugin::map_type(&array.inner)) + } else { + panic!("Invalid array token: {:?}", token); + } + } + "tuple" => { + if let Token::Tuple(tuple) = token { + let inners = tuple + .inners + .iter() + .map(TypeScriptV2Plugin::map_type) + .collect::>() + .join(", "); + format!("[{}]", inners) + } else { + panic!("Invalid tuple token: {:?}", token); + } + } + "generic_arg" => { + if let Token::GenericArg(generic_arg) = &token { + generic_arg.clone() + } else { + panic!("Invalid generic_arg token: {:?}", token); + } + } + + _ => { + let mut type_name = token.type_name(); - _ => type_name.to_string(), + if let Token::Composite(composite) = token { + if !composite.generic_args.is_empty() { + type_name += &format!( + "<{}>", + composite + .generic_args + .iter() + .map(|(_, t)| TypeScriptV2Plugin::map_type(t)) + .collect::>() + .join(", ") + ) + } + } + + type_name + } } } @@ -116,36 +163,21 @@ function convertQueryToToriiClause(query: Query): Clause | undefined {{ for model in models { let tokens = &model.tokens; - for token in &tokens.enums { - handled_tokens.push(token.to_composite().unwrap().to_owned()); - } for token in &tokens.structs { - handled_tokens.push(token.to_composite().unwrap().to_owned()); - } - - let mut structs = tokens.structs.to_owned(); - structs.sort_by(|a, b| { - if a.to_composite() - .unwrap() - .inners - .iter() - .any(|field| field.token.type_name() == b.type_name()) - { - std::cmp::Ordering::Greater - } else { - std::cmp::Ordering::Less + if handled_tokens.iter().any(|t| t.type_name() == token.type_name()) { + continue; } - }); - for token in &structs { - out += TypeScriptV2Plugin::format_struct( - token.to_composite().unwrap(), - handled_tokens, - ) - .as_str(); + handled_tokens.push(token.to_composite().unwrap().to_owned()); + out += TypeScriptV2Plugin::format_struct(token.to_composite().unwrap()).as_str(); } for token in &tokens.enums { + if handled_tokens.iter().any(|t| t.type_name() == token.type_name()) { + continue; + } + + handled_tokens.push(token.to_composite().unwrap().to_owned()); out += TypeScriptV2Plugin::format_enum(token.to_composite().unwrap()).as_str(); } @@ -417,24 +449,13 @@ function convertQueryToToriiClause(query: Query): Clause | undefined {{ // Token should be a struct // This will be formatted into a TypeScript interface // using TypeScript defined types - fn format_struct(token: &Composite, handled_tokens: &[Composite]) -> String { + fn format_struct(token: &Composite) -> String { let mut native_fields: Vec = Vec::new(); for field in &token.inners { - let mapped = TypeScriptV2Plugin::map_type(field.token.type_name().as_str()); - if mapped == field.token.type_name() { - let token = handled_tokens - .iter() - .find(|t| t.type_name() == field.token.type_name()) - .unwrap_or_else(|| panic!("Token not found: {}", field.token.type_name())); - if token.r#type == CompositeType::Enum { - native_fields.push(format!("{}: {};", field.name, mapped)); - } else { - native_fields.push(format!("{}: {};", field.name, field.token.type_name())); - } - } else { - native_fields.push(format!("{}: {};", field.name, mapped)); - } + let mapped = TypeScriptV2Plugin::map_type(&field.token); + format!("{}: {};", field.name, mapped); + native_fields.push(format!("{}: {};", field.name, mapped)); } format!( @@ -454,24 +475,40 @@ export interface {name} {{ // This will be formatted into a C# enum // Enum is mapped using index of cairo enum fn format_enum(token: &Composite) -> String { - let fields = token - .inners - .iter() - .map(|field| format!("{},", field.name,)) - .collect::>() - .join("\n "); + let mut name = token.type_name(); + if !token.generic_args.is_empty() { + name += &format!( + "<{}>", + token.generic_args.iter().map(|(n, _)| n.clone()).collect::>().join(", ") + ) + } - format!( + let mut result = format!( " // Type definition for `{}` enum -export enum {} {{ - {} -}} -", - token.type_path, - token.type_name(), - fields - ) +type {} = ", + token.type_path, name + ); + + let mut variants = Vec::new(); + + for field in &token.inners { + let field_type = TypeScriptV2Plugin::map_type(&field.token).replace("()", ""); + + let variant_definition = if field_type.is_empty() { + // No associated data + format!("{{ type: '{}'; }}", field.name) + } else { + // With associated data + format!("{{ type: '{}'; data: {}; }}", field.name, field_type) + }; + + variants.push(variant_definition); + } + + result += &variants.join(" | "); + + result } // Formats a system into a JS method used by the contract class @@ -485,10 +522,10 @@ export enum {} {{ format!( "{}: {}", arg.0, - if TypeScriptV2Plugin::map_type(&arg.1.type_name()) == arg.1.type_name() { + if TypeScriptV2Plugin::map_type(&arg.1) == arg.1.type_name() { arg.1.type_name() } else { - TypeScriptV2Plugin::map_type(&arg.1.type_name()) + TypeScriptV2Plugin::map_type(&arg.1) } ) }) diff --git a/crates/dojo-bindgen/src/plugins/unity/mod.rs b/crates/dojo-bindgen/src/plugins/unity/mod.rs index addee69930..2827519351 100644 --- a/crates/dojo-bindgen/src/plugins/unity/mod.rs +++ b/crates/dojo-bindgen/src/plugins/unity/mod.rs @@ -16,8 +16,8 @@ impl UnityPlugin { } // Maps cairo types to C#/Unity SDK defined types - fn map_type(type_name: &str) -> String { - match type_name { + fn map_type(token: &Token) -> String { + match token.type_name().as_str() { "u8" => "byte".to_string(), "u16" => "ushort".to_string(), "u32" => "uint".to_string(), @@ -29,8 +29,54 @@ impl UnityPlugin { "bytes31" => "string".to_string(), "ClassHash" => "FieldElement".to_string(), "ContractAddress" => "FieldElement".to_string(), + "ByteArray" => "string".to_string(), + "array" => { + if let Token::Array(array) = token { + format!("{}[]", UnityPlugin::map_type(&array.inner)) + } else { + panic!("Invalid array token: {:?}", token); + } + } + "tuple" => { + if let Token::Tuple(tuple) = token { + let inners = tuple + .inners + .iter() + .map(UnityPlugin::map_type) + .collect::>() + .join(", "); + format!("({})", inners) + } else { + panic!("Invalid tuple token: {:?}", token); + } + } + "generic_arg" => { + if let Token::GenericArg(g) = &token { + g.clone() + } else { + panic!("Invalid generic arg token: {:?}", token); + } + } + + _ => { + let mut type_name = token.type_name().to_string(); + + if let Token::Composite(composite) = token { + if !composite.generic_args.is_empty() { + type_name += &format!( + "<{}>", + composite + .generic_args + .iter() + .map(|(_, t)| UnityPlugin::map_type(t)) + .collect::>() + .join(", ") + ) + } + } - _ => type_name.to_string(), + type_name + } } } @@ -48,13 +94,7 @@ impl UnityPlugin { let fields = token .inners .iter() - .map(|field| { - format!( - "public {} {};", - UnityPlugin::map_type(field.token.clone().type_name().as_str()), - field.name - ) - }) + .map(|field| format!("public {} {};", UnityPlugin::map_type(&field.token), field.name)) .collect::>() .join("\n "); @@ -76,24 +116,35 @@ public struct {} {{ // This will be formatted into a C# enum // Enum is mapped using index of cairo enum fn format_enum(token: &Composite) -> String { - let fields = token - .inners - .iter() - .map(|field| format!("{},", field.name,)) - .collect::>() - .join("\n "); + let mut name_with_generics = token.type_name(); + if !token.generic_args.is_empty() { + name_with_generics += &format!( + "<{}>", + token.generic_args.iter().map(|(n, _)| n.clone()).collect::>().join(", ") + ); + } - format!( + let mut result = format!( " // Type definition for `{}` enum -public enum {} {{ - {} -}} -", - token.type_path, - token.type_name(), - fields - ) +public abstract record {}() {{", + token.type_path, name_with_generics + ); + + for field in &token.inners { + let type_name = UnityPlugin::map_type(&field.token).replace(['(', ')'], ""); + + result += format!( + "\n public record {}({}) : {name_with_generics};", + field.name, + if type_name.is_empty() { type_name } else { format!("{} value", type_name) } + ) + .as_str(); + } + + result += "\n}\n"; + + result } // Token should be a model @@ -107,7 +158,7 @@ public enum {} {{ format!( "[ModelField(\"{}\")]\n public {} {};", field.name, - UnityPlugin::map_type(field.token.type_name().as_str()), + UnityPlugin::map_type(&field.token), field.name, ) }) @@ -183,19 +234,10 @@ public class {} : ModelInstance {{ // Handled tokens should be a list of all structs and enums used by the contract // Such as a set of referenced tokens from a model fn format_system(system: &Function, handled_tokens: &[Composite]) -> String { - fn map_type(token: &Token) -> String { - match token { - Token::CoreBasic(t) => UnityPlugin::map_type(&t.type_name()), - Token::Composite(t) => t.type_name().to_string(), - Token::Array(t) => format!("{}[]", map_type(&t.inner)), - _ => panic!("Unsupported token type: {:?}", token), - } - } - let args = system .inputs .iter() - .map(|arg| format!("{} {}", map_type(&arg.1), &arg.0)) + .map(|arg| format!("{} {}", UnityPlugin::map_type(&arg.1), &arg.0)) .collect::>() .join(", "); @@ -214,21 +256,18 @@ public class {} : ModelInstance {{ .inners .iter() .map(|field| { - format!( - "new FieldElement({}.{}).Inner()", - type_name, field.name - ) + format!("new FieldElement({}.{}).Inner", type_name, field.name) }) .collect::>() .join(",\n "), _ => { - format!("new FieldElement({}).Inner()", type_name) + format!("new FieldElement({}).Inner", type_name) } } } - None => match UnityPlugin::map_type(type_name).as_str() { - "FieldElement" => format!("{}.Inner()", type_name), - _ => format!("new FieldElement({}).Inner()", type_name), + None => match UnityPlugin::map_type(token).as_str() { + "FieldElement" => format!("{}.Inner", type_name), + _ => format!("new FieldElement({}).Inner", type_name), }, } }) diff --git a/crates/dojo-bindgen/src/test_data/mocks/dojo_examples.ts b/crates/dojo-bindgen/src/test_data/mocks/dojo_examples.ts index 0e807cd262..1c1c19c7bb 100644 --- a/crates/dojo-bindgen/src/test_data/mocks/dojo_examples.ts +++ b/crates/dojo-bindgen/src/test_data/mocks/dojo_examples.ts @@ -1,4 +1,4 @@ -// Generated by dojo-bindgen on Wed, 17 Apr 2024 07:58:49 +0000. Do not modify this file manually. +// Generated by dojo-bindgen on Tue, 28 May 2024 15:30:47 +0000. Do not modify this file manually. import { Account } from "starknet"; import { Clause, @@ -14,22 +14,6 @@ import { createManifestFromJson, } from "@dojoengine/core"; -// Type definition for `dojo_examples::models::EmoteMessage` struct -export interface EmoteMessage { - identity: string; - emote: Emote; -} - -// Type definition for `dojo_examples::models::Emote` enum -export enum Emote { - None, - Happy, - Sad, - Angry, - Love, -} - - // Type definition for `dojo_examples::models::Vec2` struct export interface Vec2 { x: number; @@ -42,6 +26,15 @@ export interface Position { vec: Vec2; } +// Type definition for `core::byte_array::ByteArray` struct +export interface ByteArray { + data: string[]; + pending_word: string; + pending_word_len: number; +} + +// Type definition for `core::option::Option::` enum +type Option = { type: 'Some'; data: A; } | { type: 'None'; } // Type definition for `dojo_examples::actions::actions::Moved` struct export interface Moved { @@ -50,14 +43,7 @@ export interface Moved { } // Type definition for `dojo_examples::models::Direction` enum -export enum Direction { - None, - Left, - Right, - Up, - Down, -} - +type Direction = { type: 'None'; } | { type: 'Left'; } | { type: 'Right'; } | { type: 'Up'; } | { type: 'Down'; } // Type definition for `dojo_examples::models::Moves` struct export interface Moves { @@ -66,13 +52,28 @@ export interface Moves { last_direction: Direction; } -// Type definition for `dojo_examples::models::Direction` enum -export enum Direction { - None, - Left, - Right, - Up, - Down, + +// Type definition for `dojo_examples::models::EmoteMessage` struct +export interface EmoteMessage { + identity: string; + emote: Emote; +} + +// Type definition for `dojo_examples::models::Emote` enum +type Emote = { type: 'None'; } | { type: 'Happy'; } | { type: 'Sad'; } | { type: 'Angry'; } | { type: 'Love'; } + +// Type definition for `dojo_examples::models::PlayerItem` struct +export interface PlayerItem { + item_id: number; + quantity: number; +} + +// Type definition for `dojo_examples::models::PlayerConfig` struct +export interface PlayerConfig { + player: string; + name: string; + items: PlayerItem[]; + favorite_item: Option; } @@ -129,15 +130,6 @@ class ActionsCalls extends BaseCalls { } } - async dojoResource(): Promise { - try { - await this.execute("dojo_resource", []) - } catch (error) { - console.error("Error executing dojoResource:", error); - throw error; - } - } - async spawn(): Promise { try { await this.execute("spawn", []) @@ -155,20 +147,42 @@ class ActionsCalls extends BaseCalls { throw error; } } + + async setPlayerConfig(name: string): Promise { + try { + await this.execute("set_player_config", [props.name.data, + props.name.pending_word, + props.name.pending_word_len]) + } catch (error) { + console.error("Error executing setPlayerConfig:", error); + throw error; + } + } + + async dojoResource(): Promise { + try { + await this.execute("dojo_resource", []) + } catch (error) { + console.error("Error executing dojoResource:", error); + throw error; + } + } } type Query = Partial<{ - EmoteMessage: ModelClause; Position: ModelClause; Moved: ModelClause; Moves: ModelClause; + EmoteMessage: ModelClause; + PlayerConfig: ModelClause; }>; type ResultMapping = { - EmoteMessage: EmoteMessage; Position: Position; Moved: Moved; Moves: Moves; + EmoteMessage: EmoteMessage; + PlayerConfig: PlayerConfig; }; type QueryResult = { From 328004d65bbbf7692c26f030b75fa95b7947841d Mon Sep 17 00:00:00 2001 From: Tarrence van As Date: Wed, 29 May 2024 15:25:50 -0400 Subject: [PATCH 16/16] Prepare release: v0.7.0-alpha.5 (#2018) Co-authored-by: glihm --- Cargo.lock | 84 ++++++++++---------- Cargo.toml | 2 +- crates/katana/runner/runner-macro/Cargo.toml | 2 +- 3 files changed, 44 insertions(+), 44 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5ed743aa54..530db77742 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1338,7 +1338,7 @@ dependencies = [ [[package]] name = "benches" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "anyhow", "clap", @@ -3764,7 +3764,7 @@ dependencies = [ [[package]] name = "common" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "anyhow", "reqwest 0.12.4", @@ -4537,7 +4537,7 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" [[package]] name = "dojo-bindgen" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "async-trait", "cainome", @@ -4553,15 +4553,15 @@ dependencies = [ [[package]] name = "dojo-core" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" [[package]] name = "dojo-examples-spawn-and-move" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" [[package]] name = "dojo-lang" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "anyhow", "cairo-lang-compiler 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", @@ -4612,7 +4612,7 @@ dependencies = [ [[package]] name = "dojo-language-server" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "cairo-lang-language-server", "clap", @@ -4621,7 +4621,7 @@ dependencies = [ [[package]] name = "dojo-metrics" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "anyhow", "hyper 0.14.28", @@ -4639,7 +4639,7 @@ dependencies = [ [[package]] name = "dojo-test-utils" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "anyhow", "assert_fs", @@ -4673,7 +4673,7 @@ dependencies = [ [[package]] name = "dojo-types" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "cainome", "crypto-bigint", @@ -4689,7 +4689,7 @@ dependencies = [ [[package]] name = "dojo-world" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "anyhow", "assert_fs", @@ -4728,7 +4728,7 @@ dependencies = [ [[package]] name = "dojo-world-abigen" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "cairo-lang-starknet-classes 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", @@ -7770,7 +7770,7 @@ dependencies = [ [[package]] name = "katana" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "alloy-primitives", "anyhow", @@ -7797,7 +7797,7 @@ dependencies = [ [[package]] name = "katana-cairo" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "cairo-lang-casm 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", "cairo-lang-runner 2.6.3 (git+https://github.com/starkware-libs/cairo?tag=v2.6.3)", @@ -7810,7 +7810,7 @@ dependencies = [ [[package]] name = "katana-codecs" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "bytes", "katana-primitives", @@ -7818,7 +7818,7 @@ dependencies = [ [[package]] name = "katana-codecs-derive" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "proc-macro2", "quote", @@ -7828,7 +7828,7 @@ dependencies = [ [[package]] name = "katana-core" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "alloy-contract", "alloy-network", @@ -7876,7 +7876,7 @@ dependencies = [ [[package]] name = "katana-db" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "anyhow", "cairo-lang-starknet 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", @@ -7898,7 +7898,7 @@ dependencies = [ [[package]] name = "katana-executor" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "alloy-primitives", "anyhow", @@ -7925,7 +7925,7 @@ dependencies = [ [[package]] name = "katana-primitives" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "alloy-primitives", "anyhow", @@ -7950,7 +7950,7 @@ dependencies = [ [[package]] name = "katana-provider" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "alloy-primitives", "anyhow", @@ -7976,7 +7976,7 @@ dependencies = [ [[package]] name = "katana-rpc" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "anyhow", "assert_matches", @@ -8014,7 +8014,7 @@ dependencies = [ [[package]] name = "katana-rpc-api" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "jsonrpsee 0.16.3", "katana-core", @@ -8025,7 +8025,7 @@ dependencies = [ [[package]] name = "katana-rpc-types" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "alloy-primitives", "anyhow", @@ -8046,7 +8046,7 @@ dependencies = [ [[package]] name = "katana-rpc-types-builder" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "anyhow", "katana-executor", @@ -8058,7 +8058,7 @@ dependencies = [ [[package]] name = "katana-runner" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "anyhow", "assert_fs", @@ -8077,7 +8077,7 @@ dependencies = [ [[package]] name = "katana-tasks" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "futures", "rayon", @@ -11388,7 +11388,7 @@ checksum = "f86854cf50259291520509879a5c294c3c9a4c334e9ff65071c51e42ef1e2343" [[package]] name = "runner-macro" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "quote", "syn 2.0.64", @@ -11656,7 +11656,7 @@ dependencies = [ [[package]] name = "saya" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "anyhow", "clap", @@ -11675,7 +11675,7 @@ dependencies = [ [[package]] name = "saya-core" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "anyhow", "async-trait", @@ -11715,7 +11715,7 @@ dependencies = [ [[package]] name = "saya-provider" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "alloy-primitives", "anyhow", @@ -12479,7 +12479,7 @@ dependencies = [ [[package]] name = "sozo" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "anyhow", "assert_fs", @@ -12538,7 +12538,7 @@ dependencies = [ [[package]] name = "sozo-ops" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "anyhow", "assert_fs", @@ -12593,7 +12593,7 @@ dependencies = [ [[package]] name = "sozo-signers" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "anyhow", "starknet", @@ -13864,7 +13864,7 @@ checksum = "ea68304e134ecd095ac6c3574494fc62b909f416c4fca77e440530221e549d3d" [[package]] name = "torii" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "anyhow", "async-trait", @@ -13909,7 +13909,7 @@ dependencies = [ [[package]] name = "torii-client" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "async-trait", "camino", @@ -13937,7 +13937,7 @@ dependencies = [ [[package]] name = "torii-core" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "anyhow", "async-trait", @@ -13976,7 +13976,7 @@ dependencies = [ [[package]] name = "torii-graphql" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "anyhow", "async-graphql", @@ -14017,7 +14017,7 @@ dependencies = [ [[package]] name = "torii-grpc" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "bytes", "crypto-bigint", @@ -14060,7 +14060,7 @@ dependencies = [ [[package]] name = "torii-relay" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "anyhow", "async-trait", @@ -14095,7 +14095,7 @@ dependencies = [ [[package]] name = "torii-server" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" dependencies = [ "anyhow", "async-trait", @@ -14418,7 +14418,7 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "types-test" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" [[package]] name = "ucd-trie" diff --git a/Cargo.toml b/Cargo.toml index 743d01ddd2..0675d09c79 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,7 +45,7 @@ edition = "2021" license = "Apache-2.0" license-file = "LICENSE" repository = "https://github.com/dojoengine/dojo/" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" [profile.performance] codegen-units = 1 diff --git a/crates/katana/runner/runner-macro/Cargo.toml b/crates/katana/runner/runner-macro/Cargo.toml index 3388fce369..3b7767c142 100644 --- a/crates/katana/runner/runner-macro/Cargo.toml +++ b/crates/katana/runner/runner-macro/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "runner-macro" -version = "0.7.0-alpha.4" +version = "0.7.0-alpha.5" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html