diff --git a/Cargo.lock b/Cargo.lock index ddc2bfa042..700fe3f43d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -40,9 +40,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" dependencies = [ "getrandom", "once_cell", @@ -51,14 +51,15 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "cd7d5a2cecb58716e47d67d5703a249964b14c7be1ec3cad3affc295b2d1c35d" dependencies = [ "cfg-if", "getrandom", "once_cell", "version_check", + "zerocopy", ] [[package]] @@ -360,9 +361,9 @@ dependencies = [ [[package]] name = "async-graphql" -version = "6.0.7" +version = "6.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1addb0b551c59640e15de99e7566a4e3a1186cf42269e160c485ba6d8b43fe30" +checksum = "117113a7ff4a98f2a864fa7a5274033b0907fce65dc8464993c75033f8074f90" dependencies = [ "async-graphql-derive", "async-graphql-parser", @@ -394,9 +395,9 @@ dependencies = [ [[package]] name = "async-graphql-derive" -version = "6.0.7" +version = "6.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e1121ff0be2feea705c24f6940162c4f14a077e50a217b16e091e6534a8c08a" +checksum = "6e4bb7b7b2344d24af860776b7fe4e4ee4a67cd965f076048d023f555703b854" dependencies = [ "Inflector", "async-graphql-parser", @@ -411,9 +412,9 @@ dependencies = [ [[package]] name = "async-graphql-parser" -version = "6.0.7" +version = "6.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0b6713fd4ffd610b8b6f6e911bf31277cbb84b7c2a9cdeeb39d1b3eed3b88e4" +checksum = "c47e1c1ff6cb7cae62c9cd768d76475cc68f156d8234b024fd2499ad0e91da21" dependencies = [ "async-graphql-value", "pest", @@ -423,9 +424,9 @@ dependencies = [ [[package]] name = "async-graphql-value" -version = "6.0.7" +version = "6.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d74240f9daa8c1e8f73e9cfcc338d20a88d00bbeb83ded49ce8e5b4dcec0f5" +checksum = "2270df3a642efce860ed06fbcf61fc6db10f83c2ecb5613127fb453c82e012a4" dependencies = [ "bytes", "indexmap 2.0.2", @@ -435,9 +436,9 @@ dependencies = [ [[package]] name = "async-graphql-warp" -version = "6.0.7" +version = "6.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7943123dbcfa253fae634f6cc3d02295ce9d11ed4bf09f138ee99ecb88c1fbcf" +checksum = "5d54ac2c41da8f2bc2b5976227d585e787b55f696660d26fd6e1bee50e740f98" dependencies = [ "async-graphql", "futures-util", @@ -607,9 +608,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.4" +version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" [[package]] name = "base64ct" @@ -712,7 +713,7 @@ dependencies = [ [[package]] name = "blockifier" version = "0.1.0-rc0" -source = "git+https://github.com/dojoengine/blockifier?rev=f7df9ba#f7df9ba98a8e0549813fbde945741fd50930ff29" +source = "git+https://github.com/dojoengine/blockifier?rev=3357e69#3357e69d701e02d90766302b7d2315060ef0dbef" dependencies = [ "ark-ff", "ark-secp256k1", @@ -825,6 +826,12 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3e368af43e418a04d52505cf3dbc23dda4e3407ae2fa99fd0e4f308ce546acc" +[[package]] +name = "byteyarn" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7534301c0ea17abb4db06d75efc7b4b0fa360fce8e175a4330d721c71c942ff" + [[package]] name = "bzip2" version = "0.4.4" @@ -860,9 +867,9 @@ dependencies = [ [[package]] name = "cairo-lang-casm" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc7f7cb89bc3f52c2c738f3e87c8f8773bd3456cae1d322d100d4b0da584f3c" +checksum = "4b89fd5edce5c0b128fa25f76f07db322ae9b28c123619ddcd11df18a73d3217" dependencies = [ "cairo-lang-utils", "indoc 2.0.4", @@ -877,9 +884,9 @@ dependencies = [ [[package]] name = "cairo-lang-compiler" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4f2c54b065f7fd97bf8d5df76cbcbbd01d8a8c319d281796ee20ecc48e16ca8" +checksum = "7fc2689f520038019ddc8884ee36f6df04a66fe46906c9d1ac76e8e9675e55f0" dependencies = [ "anyhow", "cairo-lang-defs", @@ -895,26 +902,24 @@ dependencies = [ "cairo-lang-syntax", "cairo-lang-utils", "itertools 0.11.0", - "log", "salsa", - "smol_str", "thiserror", ] [[package]] name = "cairo-lang-debug" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "873ba77d4c3f780c727c7d6c738cded22b3f6d4023e30546dfe14f97a087887e" +checksum = "3544967c563b53066163794d3c400270faf4617cfdd33ba1f74296efdca14e9d" dependencies = [ "cairo-lang-utils", ] [[package]] name = "cairo-lang-defs" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5031fff038c27ed43769b73a6f5d41aeaea34df9af862e024c23fbb4f076249" +checksum = "a07a54c419c573bc2610c2b3d672420723ca38b79a4cae2f24e0287173524e18" dependencies = [ "cairo-lang-debug", "cairo-lang-diagnostics", @@ -922,7 +927,6 @@ dependencies = [ "cairo-lang-parser", "cairo-lang-syntax", "cairo-lang-utils", - "indexmap 2.0.2", "itertools 0.11.0", "salsa", "smol_str", @@ -930,34 +934,31 @@ dependencies = [ [[package]] name = "cairo-lang-diagnostics" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b6cb1492e5784e1076320a5018ce7584f391b2f3b414bc0a8ab7c289fa118ce" +checksum = "82dc3934a47960155812cc181e7e2a3d48f2df447c23fcdbecff966855244162" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", "cairo-lang-utils", "itertools 0.11.0", - "salsa", ] [[package]] name = "cairo-lang-eq-solver" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c35dddbc63b2a4870891cc74498726aa32bfaa518596352f9bb101411cc4c584" +checksum = "2f944eae57f6c31fa0157811117b584cba4556770e2e5db4fd856459b877680f" dependencies = [ "cairo-lang-utils", "good_lp", - "indexmap 2.0.2", - "itertools 0.11.0", ] [[package]] name = "cairo-lang-filesystem" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32ce0b8e66a6085ae157d43b5c162d60166f0027d6f125c50ee74e4dc7916ff6" +checksum = "79b9b4f02ee6da5526a58b054dae3dce8ff592ae5e740c1d028ebd7e8218e1dc" dependencies = [ "cairo-lang-debug", "cairo-lang-utils", @@ -969,9 +970,9 @@ dependencies = [ [[package]] name = "cairo-lang-formatter" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79535d235d17f3be2a2d7e82b92709ed4cb60978e8d96c92520178a795162969" +checksum = "f5d6a5c8875cd4ab64623b6bc8b15a48e27df1030377ba66751b7ad33299cf56" dependencies = [ "anyhow", "cairo-lang-diagnostics", @@ -979,53 +980,49 @@ dependencies = [ "cairo-lang-parser", "cairo-lang-syntax", "cairo-lang-utils", - "colored", "diffy", "ignore", "itertools 0.11.0", - "log", "salsa", + "serde", "smol_str", ] [[package]] name = "cairo-lang-language-server" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4793c9799857c94ddd8f7146220fd82b4a4402fa8597f49d48b705747f9ee05" +checksum = "abc9f0b7cd76e3ecd432fc23eee4b6dda277b6cdf64cf97be926c55286b52eb5" dependencies = [ "anyhow", "cairo-lang-compiler", - "cairo-lang-debug", "cairo-lang-defs", "cairo-lang-diagnostics", "cairo-lang-filesystem", "cairo-lang-formatter", "cairo-lang-lowering", "cairo-lang-parser", - "cairo-lang-plugins", "cairo-lang-project", "cairo-lang-semantic", "cairo-lang-starknet", "cairo-lang-syntax", + "cairo-lang-test-plugin", "cairo-lang-utils", - "indoc 2.0.4", "log", "lsp-types", "salsa", - "scarb-metadata 1.8.0", + "scarb-metadata 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde", "serde_json", - "smol_str", "tokio", "tower-lsp", ] [[package]] name = "cairo-lang-lowering" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29cc679f501725e03ee703559ed27d084c6f4031bd51ff86378cf845a85ee207" +checksum = "f5654b46630d3e8e740ebb058d344aa62ca92c5b1cbc5febbb993abe1ab622cb" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -1044,14 +1041,13 @@ dependencies = [ "num-traits 0.2.17", "once_cell", "salsa", - "smol_str", ] [[package]] name = "cairo-lang-parser" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdcadb046659134466bc7e11961ea8a56969dae8a54d8f985955ce0b95185c7f" +checksum = "1f42707f9db24a7c15b82b1d26615c3038323b6136c76739622ea3a3877a8ed7" dependencies = [ "cairo-lang-diagnostics", "cairo-lang-filesystem", @@ -1060,7 +1056,6 @@ dependencies = [ "cairo-lang-utils", "colored", "itertools 0.11.0", - "log", "num-bigint", "num-traits 0.2.17", "salsa", @@ -1070,9 +1065,9 @@ dependencies = [ [[package]] name = "cairo-lang-plugins" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4632790cd4ea11d4849934456a400eae7ed419f6d721f24a6b637df67b7e902f" +checksum = "11b58c906cfb2d64ab630c1417a9dac15dea0859978cc5b2b61dab7fa098a9b9" dependencies = [ "cairo-lang-defs", "cairo-lang-diagnostics", @@ -1083,16 +1078,15 @@ dependencies = [ "indent", "indoc 2.0.4", "itertools 0.11.0", - "num-bigint", "salsa", "smol_str", ] [[package]] name = "cairo-lang-proc-macros" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "170838817fc33ddb65e0a9480526df0b226b148a0fca0a5cd7071be4c6683157" +checksum = "178c68268a904eba03c07714b2c29d1f97d6754e74931f5d465961f901a88d59" dependencies = [ "cairo-lang-debug", "quote", @@ -1101,9 +1095,9 @@ dependencies = [ [[package]] name = "cairo-lang-project" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4162ee976c61fdeb3b621f4a76fd256e46a5c0890f750a3a9d2c9560a3bc1daf" +checksum = "f5eb369e0b51a8f03ad92dc2981387cb9b35cba6d117271ef307a14a14ff58b0" dependencies = [ "cairo-lang-filesystem", "cairo-lang-utils", @@ -1115,27 +1109,19 @@ dependencies = [ [[package]] name = "cairo-lang-runner" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d66ef01350e2e7f7e6b2b43b865da2513a42600082ee1a2975d3af3da7f0ca" +checksum = "b53180d68de6d6b1e48585ec783bc930b65486856d69adb6bd7277c2a064fc2b" dependencies = [ - "anyhow", "ark-ff", "ark-secp256k1", "ark-secp256r1", "ark-std", "cairo-felt", "cairo-lang-casm", - "cairo-lang-compiler", - "cairo-lang-defs", - "cairo-lang-diagnostics", - "cairo-lang-filesystem", - "cairo-lang-lowering", - "cairo-lang-semantic", "cairo-lang-sierra", "cairo-lang-sierra-ap-change", "cairo-lang-sierra-gas", - "cairo-lang-sierra-generator", "cairo-lang-sierra-to-casm", "cairo-lang-sierra-type-size", "cairo-lang-starknet", @@ -1146,15 +1132,14 @@ dependencies = [ "num-bigint", "num-integer", "num-traits 0.2.17", - "salsa", "thiserror", ] [[package]] name = "cairo-lang-semantic" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e544fa9a222bf2d007df2b5fc9b21c2a20ab7e17d6fefbcbc193de209451cd" +checksum = "7564b5ea75237c83b6b7e39d9177fcf13f34f035bf8bd5f659198ac8f6ee78b9" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -1164,10 +1149,10 @@ dependencies = [ "cairo-lang-plugins", "cairo-lang-proc-macros", "cairo-lang-syntax", + "cairo-lang-test-utils", "cairo-lang-utils", "id-arena", "itertools 0.11.0", - "log", "num-bigint", "num-traits 0.2.17", "once_cell", @@ -1177,10 +1162,11 @@ dependencies = [ [[package]] name = "cairo-lang-sierra" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5e136b79e95a14ef38a2be91a67ceb85317407d336a5b0d418c33b23c78596a" +checksum = "ada598c1f7a7c343cf5d604c0f028000fcc17d67c036d797d5cd3b7fd8777e1a" dependencies = [ + "anyhow", "cairo-lang-utils", "const-fnv1a-hash", "convert_case 0.6.0", @@ -1200,9 +1186,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-ap-change" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "511ca7708faa7ba8d14ae26e1d60ead2d02028c8f664baf5ecb0fd6a0d1e20f6" +checksum = "00cf99976ca90ceeb11895521feb34b1be8e0f98b6ca79e9a4018148d7ff7888" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -1214,9 +1200,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-gas" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "351a25bc010b910919c01d5c57e937b0c3d330fc30d92702c0cb4061819df8df" +checksum = "0f64f8d381ef4f97ecdbfae7f9f77fe6aa18191696e52b112e53c75a84af7e84" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -1228,9 +1214,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-generator" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "114091bb971c06fd072aca816af1c3f62566cd8a4b1453c786155161a36c7bce" +checksum = "dfee5967e7967c71cee15f545faf5288a9c6046c60ecff89748c65d9654a7be4" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -1238,14 +1224,10 @@ dependencies = [ "cairo-lang-filesystem", "cairo-lang-lowering", "cairo-lang-parser", - "cairo-lang-plugins", - "cairo-lang-proc-macros", "cairo-lang-semantic", "cairo-lang-sierra", "cairo-lang-syntax", "cairo-lang-utils", - "id-arena", - "indexmap 2.0.2", "itertools 0.11.0", "num-bigint", "once_cell", @@ -1255,9 +1237,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-to-casm" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa1c799de62972dfd7112d563000695be94305b6f7d9bedd29f347799bf03e1c" +checksum = "4af7d2812d283b63f074a1ab4135fe0db586bf1b5edaa7ef2129f3067c9e894a" dependencies = [ "assert_matches", "cairo-felt", @@ -1269,7 +1251,6 @@ dependencies = [ "cairo-lang-utils", "indoc 2.0.4", "itertools 0.11.0", - "log", "num-bigint", "num-traits 0.2.17", "thiserror", @@ -1277,9 +1258,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-type-size" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2fe73d9d58aaf9088f6ba802bcf43ce9ca4bd198190cf5bf91caa7d408dd11a" +checksum = "8b753a6569f903c3637dda7ef944455a91b2b004f5294262ab1e823914ea65e5" dependencies = [ "cairo-lang-sierra", "cairo-lang-utils", @@ -1287,9 +1268,9 @@ dependencies = [ [[package]] name = "cairo-lang-starknet" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75df624e71e33a31a924e799dd2a9a8284204b41d8db9c51803317bd9edff81f" +checksum = "6866e7599234986acb221cbc5a9720731e4b6d068e87ce07d6437e51f8fc8a24" dependencies = [ "anyhow", "cairo-felt", @@ -1299,22 +1280,17 @@ dependencies = [ "cairo-lang-diagnostics", "cairo-lang-filesystem", "cairo-lang-lowering", - "cairo-lang-parser", - "cairo-lang-plugins", "cairo-lang-semantic", "cairo-lang-sierra", - "cairo-lang-sierra-ap-change", - "cairo-lang-sierra-gas", "cairo-lang-sierra-generator", "cairo-lang-sierra-to-casm", "cairo-lang-syntax", "cairo-lang-utils", + "const_format", "convert_case 0.6.0", - "genco", "indent", "indoc 2.0.4", "itertools 0.11.0", - "log", "num-bigint", "num-integer", "num-traits 0.2.17", @@ -1328,9 +1304,9 @@ dependencies = [ [[package]] name = "cairo-lang-syntax" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b1af0ae21f9e539f97cfdf56f5ce0934dae5d87f568fd778c3d624a102f8dbb" +checksum = "b91c81cd720549131e80598172d6a9db3d62795ab6be1060b7efed463c793bd1" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -1339,60 +1315,71 @@ dependencies = [ "num-traits 0.2.17", "salsa", "smol_str", - "thiserror", "unescaper", ] [[package]] name = "cairo-lang-syntax-codegen" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "822ffabf24f6a5506262edcece315260a82d9dfba3abe6548791a6d654563ad0" +checksum = "04f2e93b768bf5fff62bcd445fda45c98cdb4e58a81b2095bda01cdbf00e2e6a" dependencies = [ "genco", "xshell", ] [[package]] -name = "cairo-lang-test-runner" -version = "2.2.0" +name = "cairo-lang-test-plugin" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43323524d8bcae023e66c9c6f3e857ae73cddc86bb2cc7ea6d739ef54beacb19" +checksum = "f67ac7f93f0894d72a0ee8ae94abc1c1bfc751b285d92422343888fe367deb2e" dependencies = [ "anyhow", "cairo-felt", - "cairo-lang-casm", "cairo-lang-compiler", "cairo-lang-debug", "cairo-lang-defs", "cairo-lang-diagnostics", "cairo-lang-filesystem", "cairo-lang-lowering", - "cairo-lang-plugins", - "cairo-lang-project", - "cairo-lang-runner", "cairo-lang-semantic", "cairo-lang-sierra", "cairo-lang-sierra-generator", - "cairo-lang-sierra-to-casm", "cairo-lang-starknet", "cairo-lang-syntax", "cairo-lang-utils", - "cairo-vm", + "itertools 0.11.0", + "num-traits 0.2.17", + "serde", +] + +[[package]] +name = "cairo-lang-test-runner" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d25f7daff159c006401ee2efc491ed8cdbacdab7c575471ea7a18e7894cdb814" +dependencies = [ + "anyhow", + "cairo-felt", + "cairo-lang-compiler", + "cairo-lang-filesystem", + "cairo-lang-runner", + "cairo-lang-sierra", + "cairo-lang-sierra-to-casm", + "cairo-lang-starknet", + "cairo-lang-test-plugin", + "cairo-lang-utils", "colored", "itertools 0.11.0", - "num-bigint", "num-traits 0.2.17", "rayon", - "salsa", - "thiserror", ] [[package]] name = "cairo-lang-test-utils" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81394b73748176c2485cc8e25be8163ab883f7076efb261a50b0d2fdf7d41fb8" +checksum = "8f010387fd80fe6fa681da9c88dc7ee3d78e02324d12e3b67dab7198d0d10f27" dependencies = [ "cairo-lang-utils", "colored", @@ -1402,16 +1389,15 @@ dependencies = [ [[package]] name = "cairo-lang-utils" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f974b6e859f0b09c0f13ec8188c96e9e8bbb5da04214f911dbb5bcda67cb812b" +checksum = "3a676a06f80da115e9ef2669e708ee3d2a495224ebc6e5464e8d6132d0e8266b" dependencies = [ "env_logger", "indexmap 2.0.2", "itertools 0.11.0", "log", "num-bigint", - "num-integer", "num-traits 0.2.17", "parity-scale-codec", "schemars", @@ -1480,6 +1466,20 @@ dependencies = [ "thiserror", ] +[[package]] +name = "cargo_metadata" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" +dependencies = [ + "camino", + "cargo-platform", + "semver", + "serde", + "serde_json", + "thiserror", +] + [[package]] name = "cc" version = "1.0.83" @@ -1533,9 +1533,9 @@ dependencies = [ [[package]] name = "clap-verbosity-flag" -version = "2.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1eef05769009513df2eb1c3b4613e7fad873a14c600ff025b08f250f59fee7de" +checksum = "e5fdbb015d790cfb378aca82caf9cc52a38be96a7eecdb92f31b4366a8afc019" dependencies = [ "clap", "log", @@ -1624,7 +1624,7 @@ version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5286a0843c21f8367f7be734f89df9b822e0321d8bcce8d6e735aadff7d74979" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", "bech32", "bs58", "digest 0.10.7", @@ -1708,6 +1708,26 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28c122c3980598d243d63d9a704629a2d748d101f278052ff068be5a4423ab6f" +[[package]] +name = "const_format" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a214c7af3d04997541b18d432afaff4c455e79e2029079647e72fc2bd27673" +dependencies = [ + "const_format_proc_macros", +] + +[[package]] +name = "const_format_proc_macros" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f6ff08fd20f4f299298a28e2dfa8a8ba1036e6cd2460ac1de7b425d76f2500" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + [[package]] name = "constant_time_eq" version = "0.1.5" @@ -1790,7 +1810,7 @@ dependencies = [ [[package]] name = "create-output-dir" version = "1.0.0" -source = "git+https://github.com/software-mansion/scarb?rev=7adb7fd#7adb7fd972e4ec95dc404650dec78099815392c9" +source = "git+https://github.com/software-mansion/scarb?rev=f306f9a#f306f9a91b15077d933a8b9a3e5e1b43d94542f0" dependencies = [ "anyhow", "core-foundation", @@ -2265,12 +2285,14 @@ dependencies = [ "cairo-lang-utils", "camino", "convert_case 0.6.0", + "directories", "dojo-test-utils", "dojo-types", "dojo-world", "env_logger", "indoc 1.0.9", "itertools 0.10.5", + "lazy_static", "once_cell", "pretty_assertions", "salsa", @@ -2298,6 +2320,7 @@ dependencies = [ "cairo-lang-plugins", "cairo-lang-semantic", "cairo-lang-starknet", + "cairo-lang-test-plugin", "cairo-lang-test-runner", "cairo-lang-utils", "clap", @@ -2486,7 +2509,7 @@ version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fe81b5c06ecfdbc71dd845216f225f53b62a10cb8a16c946836a3467f701d05b" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", "bytes", "hex", "k256", @@ -2517,6 +2540,15 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +[[package]] +name = "erased-serde" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c138974f9d5e7fe373eb04df7cae98833802ae4b11c24ac7039a21d5af4b26c" +dependencies = [ + "serde", +] + [[package]] name = "errno" version = "0.3.5" @@ -2692,7 +2724,7 @@ checksum = "c0a17f0708692024db9956b31d7a20163607d2745953f5ae8125ab368ba280ad" dependencies = [ "arrayvec", "bytes", - "cargo_metadata", + "cargo_metadata 0.17.0", "chrono", "const-hex", "elliptic-curve", @@ -2764,7 +2796,7 @@ checksum = "6838fa110e57d572336178b7c79e94ff88ef976306852d8cb87d9e5b1fc7c0b5" dependencies = [ "async-trait", "auto_impl", - "base64 0.21.4", + "base64 0.21.5", "bytes", "const-hex", "enr", @@ -2979,9 +3011,9 @@ dependencies = [ [[package]] name = "fs4" -version = "0.6.6" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eeb4ed9e12f43b7fa0baae3f9cdda28352770132ef2e09a23760c29cae8bd47" +checksum = "29f9df8a11882c4e3335eb2d18a0137c505d9ca927470b0cac9c6f0ae07d28f7" dependencies = [ "rustix", "windows-sys 0.48.0", @@ -3185,9 +3217,9 @@ checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" [[package]] name = "gix" -version = "0.50.1" +version = "0.54.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "275b1bfa0d6f6ed31a2e2e878a4539f4994eac8840546283ab3aebbd8fcaa42d" +checksum = "ad6d32e74454459690d57d18ea4ebec1629936e6b130b51d12cb4a81630ac953" dependencies = [ "gix-actor", "gix-archive", @@ -3207,17 +3239,22 @@ dependencies = [ "gix-ignore", "gix-index", "gix-lock", + "gix-macros", "gix-mailmap", "gix-negotiate", "gix-object", "gix-odb", "gix-pack", "gix-path", + "gix-pathspec", "gix-prompt", "gix-ref", "gix-refspec", "gix-revision", + "gix-revwalk", "gix-sec", + "gix-status", + "gix-submodule", "gix-tempfile", "gix-trace", "gix-traverse", @@ -3225,9 +3262,11 @@ dependencies = [ "gix-utils", "gix-validate", "gix-worktree", + "gix-worktree-state", "gix-worktree-stream", - "log", "once_cell", + "parking_lot 0.12.1", + "regex", "signal-hook", "smallvec", "thiserror", @@ -3236,23 +3275,23 @@ dependencies = [ [[package]] name = "gix-actor" -version = "0.24.2" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abd2566c12095a584716f2c16f051850bd8987f57556f1fef4a7cce0300b83d0" +checksum = "08c60e982c5290897122d4e2622447f014a2dadd5a18cb73d50bb91b31645e27" dependencies = [ "bstr", "btoi", "gix-date", "itoa", - "nom", "thiserror", + "winnow", ] [[package]] name = "gix-archive" -version = "0.2.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc89a798842b519048e947339a9c9f3cfd8fb9c2d9b66b6ebcb0c3cc8fe5874d" +checksum = "ab71635f7fb38ad4cc7da7e98af79e3010e35b05de5cb6eb79b2da68ab93eac7" dependencies = [ "bstr", "gix-date", @@ -3263,16 +3302,16 @@ dependencies = [ [[package]] name = "gix-attributes" -version = "0.16.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63a134a674e39e238bd273326a9815296cc71f867ad5466518da71392cff98ce" +checksum = "2451665e70709ba4753b623ef97511ee98c4a73816b2c5b5df25678d607ed820" dependencies = [ "bstr", + "byteyarn", "gix-glob", "gix-path", "gix-quote", - "kstring", - "log", + "gix-trace", "smallvec", "thiserror", "unicode-bom", @@ -3307,9 +3346,9 @@ dependencies = [ [[package]] name = "gix-commitgraph" -version = "0.18.2" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8219fe6f39588a29dbfb8d1c244b07ee653126edc5b6f3860752c3b5454fa10b" +checksum = "e75a975ee22cf0a002bfe9b5d5cb3d2a88e263a8a178cd7509133cff10f4df8a" dependencies = [ "bstr", "gix-chunk", @@ -3321,9 +3360,9 @@ dependencies = [ [[package]] name = "gix-config" -version = "0.26.2" +version = "0.30.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2135b921a699a4c36167148193bea23c653a16ef0686f6a280e383469709a773" +checksum = "c171514b40487d3f677ae37efc0f45ac980e3169f23c27eb30a70b47fdf88ab5" dependencies = [ "bstr", "gix-config-value", @@ -3332,7 +3371,6 @@ dependencies = [ "gix-path", "gix-ref", "gix-sec", - "log", "memchr", "once_cell", "smallvec", @@ -3343,9 +3381,9 @@ dependencies = [ [[package]] name = "gix-config-value" -version = "0.12.5" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e874f41437441c02991dcea76990b9058fadfc54b02ab4dd06ab2218af43897" +checksum = "ea7505b97f4d8e7933e29735a568ba2f86d8de466669d9f0e8321384f9972f47" dependencies = [ "bitflags 2.4.1", "bstr", @@ -3356,9 +3394,9 @@ dependencies = [ [[package]] name = "gix-credentials" -version = "0.17.1" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "307d91ec5f7c8e9bfaa217fe30c2e0099101cbe83dbed27a222dbb6def38725f" +checksum = "46900b884cc5af6a6c141ee741607c0c651a4e1d33614b8d888a1ba81cc0bc8a" dependencies = [ "bstr", "gix-command", @@ -3372,9 +3410,9 @@ dependencies = [ [[package]] name = "gix-date" -version = "0.7.4" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a825babda995d788e30d306a49dacd1e93d5f5d33d53c7682d0347cef40333c" +checksum = "fc7df669639582dc7c02737642f76890b03b5544e141caba68a7d6b4eb551e0d" dependencies = [ "bstr", "itoa", @@ -3384,9 +3422,9 @@ dependencies = [ [[package]] name = "gix-diff" -version = "0.33.1" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a49d7a9a9ed5ec3428c3061da45d0fc5f50b3c07b91ea4e7ec4959668f25f6c" +checksum = "788ddb152c388206e81f36bcbb574e7ed7827c27d8fa62227b34edc333d8928c" dependencies = [ "gix-hash", "gix-object", @@ -3396,9 +3434,9 @@ dependencies = [ [[package]] name = "gix-discover" -version = "0.22.1" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "041480eb03d8aa0894d9b73d25d182d51bc4d0ea8925a6ee0c971262bbc7715e" +checksum = "69507643d75a0ea9a402fcf73ced517d2b95cc95385904ac09d03e0b952fde33" dependencies = [ "bstr", "dunce", @@ -3411,9 +3449,9 @@ dependencies = [ [[package]] name = "gix-features" -version = "0.32.1" +version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "882695cccf38da4c3cc7ee687bdb412cf25e37932d7f8f2c306112ea712449f1" +checksum = "9b9ff423ae4983f762659040d13dd7a5defbd54b6a04ac3cc7347741cec828cd" dependencies = [ "bytes", "bytesize", @@ -3434,9 +3472,9 @@ dependencies = [ [[package]] name = "gix-filter" -version = "0.2.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef4d4d61f2ab07de4612f8e078d7f1a443c7ab5c40f382784c8eacdf0fd172b9" +checksum = "1be40d28cd41445bb6cd52c4d847d915900e5466f7433eaee6a9e0a3d1d88b08" dependencies = [ "bstr", "encoding_rs", @@ -3454,18 +3492,18 @@ dependencies = [ [[package]] name = "gix-fs" -version = "0.4.1" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d5b6e9d34a2c61ea4a02bbca94c409ab6dbbca1348cbb67298cd7fed8758761" +checksum = "09815faba62fe9b32d918b75a554686c98e43f7d48c43a80df58eb718e5c6635" dependencies = [ "gix-features", ] [[package]] name = "gix-glob" -version = "0.10.2" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7255c717f49a556fa5029f6d9f2b3c008b4dd016c87f23c2ab8ca9636d5fade" +checksum = "a9d76e85f11251dcf751d2c5e918a14f562db5be6f727fd24775245653e9b19d" dependencies = [ "bitflags 2.4.1", "bstr", @@ -3475,19 +3513,19 @@ dependencies = [ [[package]] name = "gix-hash" -version = "0.11.4" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b422ff2ad9a0628baaad6da468cf05385bf3f5ab495ad5a33cce99b9f41092f" +checksum = "1884c7b41ea0875217c1be9ce91322f90bde433e91d374d0e1276073a51ccc60" dependencies = [ - "hex", + "faster-hex", "thiserror", ] [[package]] name = "gix-hashtable" -version = "0.2.4" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "385f4ce6ecf3692d313ca3aa9bd3b3d8490de53368d6d94bedff3af8b6d9c58d" +checksum = "409268480841ad008e81c17ca5a293393fbf9f2b6c2f85b8ab9de1f0c5176a16" dependencies = [ "gix-hash", "hashbrown 0.14.2", @@ -3496,9 +3534,9 @@ dependencies = [ [[package]] name = "gix-ignore" -version = "0.5.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a88b95ceb3bc45abcab6eb55ef4e0053e58b4df0712d3f9aec7d0ca990952603" +checksum = "b048f443a1f6b02da4205c34d2e287e3fd45d75e8e2f06cfb216630ea9bff5e3" dependencies = [ "bstr", "gix-glob", @@ -3508,9 +3546,9 @@ dependencies = [ [[package]] name = "gix-index" -version = "0.21.1" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "732f61ec71576bd443a3c24f4716dc7eac180d8929e7bb8603c7310161507106" +checksum = "f54d63a9d13c13088f41f5a3accbec284e492ac8f4f707fcc307c139622e17b7" dependencies = [ "bitflags 2.4.1", "bstr", @@ -3531,20 +3569,31 @@ dependencies = [ [[package]] name = "gix-lock" -version = "7.0.2" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e82ec23c8a281f91044bf3ed126063b91b59f9c9340bf0ae746f385cc85a6fa" +checksum = "47fc96fa8b6b6d33555021907c81eb3b27635daecf6e630630bdad44f8feaa95" dependencies = [ "gix-tempfile", "gix-utils", "thiserror", ] +[[package]] +name = "gix-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d8acb5ee668d55f0f2d19a320a3f9ef67a6999ad483e11135abcc2464ed18b6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", +] + [[package]] name = "gix-mailmap" -version = "0.16.1" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fc0dbbf35d29639770af68d7ff55924d83786c8924b0e6a1766af1a98b7d58b" +checksum = "40f00fa96e29e066ef208f5d13e0f5f95fa70c3ae4bd4f0234272ed4d708a7db" dependencies = [ "bstr", "gix-actor", @@ -3554,9 +3603,9 @@ dependencies = [ [[package]] name = "gix-negotiate" -version = "0.5.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce0061b7ae867e830c77b1ecfc5875f0d042aebb3d7e6014d04fd86ca6c71d59" +checksum = "6f1697bf9911c6d1b8d709b9e6ef718cb5ea5821a1b7991520125a8134448004" dependencies = [ "bitflags 2.4.1", "gix-commitgraph", @@ -3570,9 +3619,9 @@ dependencies = [ [[package]] name = "gix-object" -version = "0.33.2" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfdd87520c71a19afecfa616863a4b761621074878f5a3999243b3e37e233943" +checksum = "1e7e19616c67967374137bae83e950e9b518a9ea8a605069bd6716ada357fd6f" dependencies = [ "bstr", "btoi", @@ -3581,18 +3630,17 @@ dependencies = [ "gix-features", "gix-hash", "gix-validate", - "hex", "itoa", - "nom", "smallvec", "thiserror", + "winnow", ] [[package]] name = "gix-odb" -version = "0.50.2" +version = "0.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e827dbda6d3dabadb94cd437d0e0fe8c314a60d136a3235fc6f5bf7b96b976ac" +checksum = "8d6a392c6ba3a2f133cdc63120e9bc7aec81eef763db372c817de31febfe64bf" dependencies = [ "arc-swap", "gix-date", @@ -3609,20 +3657,18 @@ dependencies = [ [[package]] name = "gix-pack" -version = "0.40.2" +version = "0.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46f029a4dce9ac91da35c968c3abdcae573b3e52c123be86cbab3011599de533" +checksum = "7536203a45b31e1bc5694bbf90ba8da1b736c77040dd6a520db369f371eb1ab3" dependencies = [ "clru", "gix-chunk", - "gix-diff", "gix-features", "gix-hash", "gix-hashtable", "gix-object", "gix-path", "gix-tempfile", - "gix-traverse", "memmap2", "parking_lot 0.12.1", "smallvec", @@ -3643,9 +3689,9 @@ dependencies = [ [[package]] name = "gix-path" -version = "0.8.4" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18609c8cbec8508ea97c64938c33cd305b75dfc04a78d0c3b78b8b3fd618a77c" +checksum = "6a1d370115171e3ae03c5c6d4f7d096f2981a40ddccb98dfd704c773530ba73b" dependencies = [ "bstr", "gix-trace", @@ -3654,11 +3700,26 @@ dependencies = [ "thiserror", ] +[[package]] +name = "gix-pathspec" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3e26c9b47c51be73f98d38c84494bd5fb99334c5d6fda14ef5d036d50a9e5fd" +dependencies = [ + "bitflags 2.4.1", + "bstr", + "gix-attributes", + "gix-config-value", + "gix-glob", + "gix-path", + "thiserror", +] + [[package]] name = "gix-prompt" -version = "0.5.5" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c22decaf4a063ccae2b2108820c8630c01bd6756656df3fe464b32b8958a5ea" +checksum = "5c9a913769516f5e9d937afac206fb76428e3d7238e538845842887fda584678" dependencies = [ "gix-command", "gix-config-value", @@ -3680,9 +3741,9 @@ dependencies = [ [[package]] name = "gix-ref" -version = "0.33.3" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25db11edd78bf33043d1969fff51c567a4b30edd77ab44f6f8eb460a4c14985d" +checksum = "22e6b749660b613641769edc1954132eb8071a13c32224891686091bef078de4" dependencies = [ "gix-actor", "gix-date", @@ -3695,15 +3756,15 @@ dependencies = [ "gix-tempfile", "gix-validate", "memmap2", - "nom", "thiserror", + "winnow", ] [[package]] name = "gix-refspec" -version = "0.14.1" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d19a02bf740b326d6c082a7d6f754ebe56eef900986c5e91be7cf000df9ea18d" +checksum = "0895cb7b1e70f3c3bd4550c329e9f5caf2975f97fcd4238e05754e72208ef61e" dependencies = [ "bstr", "gix-hash", @@ -3715,9 +3776,9 @@ dependencies = [ [[package]] name = "gix-revision" -version = "0.18.1" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38a13500890435e3b9e7746bceda248646bfc69e259210884c98e29bb7a1aa6f" +checksum = "c8c4b15cf2ab7a35f5bcb3ef146187c8d36df0177e171ca061913cbaaa890e89" dependencies = [ "bstr", "gix-date", @@ -3725,14 +3786,15 @@ dependencies = [ "gix-hashtable", "gix-object", "gix-revwalk", + "gix-trace", "thiserror", ] [[package]] name = "gix-revwalk" -version = "0.4.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71d4cbaf3cfbfde2b81b5ee8b469aff42c34693ce0fe17fc3c244d5085307f2c" +checksum = "e9870c6b1032f2084567710c3b2106ac603377f8d25766b8a6b7c33e6e3ca279" dependencies = [ "gix-commitgraph", "gix-date", @@ -3745,9 +3807,9 @@ dependencies = [ [[package]] name = "gix-sec" -version = "0.8.4" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9615cbd6b456898aeb942cd75e5810c382fbfc48dbbff2fa23ebd2d33dcbe9c7" +checksum = "92b9542ac025a8c02ed5d17b3fc031a111a384e859d0be3532ec4d58c40a0f28" dependencies = [ "bitflags 2.4.1", "gix-path", @@ -3755,11 +3817,44 @@ dependencies = [ "windows", ] +[[package]] +name = "gix-status" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "082801c42ba707f2407b5cce3d99b89cfa84f3794962946dc94cfdc00ae522fa" +dependencies = [ + "bstr", + "filetime", + "gix-features", + "gix-fs", + "gix-hash", + "gix-index", + "gix-object", + "gix-path", + "gix-pathspec", + "thiserror", +] + +[[package]] +name = "gix-submodule" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0150e82e9282d3f2ab2dd57a22f9f6c3447b9d9856e5321ac92d38e3e0e2b7" +dependencies = [ + "bstr", + "gix-config", + "gix-path", + "gix-pathspec", + "gix-refspec", + "gix-url", + "thiserror", +] + [[package]] name = "gix-tempfile" -version = "7.0.2" +version = "10.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa28d567848cec8fdd77d36ad4f5f78ecfaba7d78f647d4f63c8ae1a2cec7243" +checksum = "5ae0978f3e11dc57290ee75ac2477c815bca1ce2fa7ed5dc5f16db067410ac4d" dependencies = [ "gix-fs", "libc", @@ -3778,9 +3873,9 @@ checksum = "96b6d623a1152c3facb79067d6e2ecdae48130030cf27d6eb21109f13bd7b836" [[package]] name = "gix-traverse" -version = "0.30.1" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e12e0fe428394226c37dd686ad64b09a04b569fe157d638b125b4a4c1e7e2df0" +checksum = "22ef04ab3643acba289b5cedd25d6f53c0430770b1d689d1d654511e6fb81ba0" dependencies = [ "gix-commitgraph", "gix-date", @@ -3794,9 +3889,9 @@ dependencies = [ [[package]] name = "gix-url" -version = "0.21.1" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4411bdbd1d46b35ae50e84c191660d437f89974e4236627785024be0b577170a" +checksum = "6125ecf46e8c68bf7202da6cad239831daebf0247ffbab30210d72f3856e420f" dependencies = [ "bstr", "gix-features", @@ -3817,9 +3912,9 @@ dependencies = [ [[package]] name = "gix-validate" -version = "0.7.7" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba9b3737b2cef3dcd014633485f0034b0f1a931ee54aeb7d8f87f177f3c89040" +checksum = "e05cab2b03a45b866156e052aa38619f4ece4adcb2f79978bfc249bc3b21b8c5" dependencies = [ "bstr", "thiserror", @@ -3827,15 +3922,13 @@ dependencies = [ [[package]] name = "gix-worktree" -version = "0.23.1" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f8bb6dd57dc6c9dfa03cc2cf2cc0942edae405eb6dfd1c34dbd2be00a90cab2" +checksum = "9f5e32972801bd82d56609e6fc84efc358fa1f11f25c5e83b7807ee2280f14fe" dependencies = [ "bstr", - "filetime", "gix-attributes", "gix-features", - "gix-filter", "gix-fs", "gix-glob", "gix-hash", @@ -3843,15 +3936,33 @@ dependencies = [ "gix-index", "gix-object", "gix-path", +] + +[[package]] +name = "gix-worktree-state" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3aeb06960f2c5ac9e4cdb6b38eb3c2b99d5e525e68285fef21ed17dfbd597ad" +dependencies = [ + "bstr", + "gix-features", + "gix-filter", + "gix-fs", + "gix-glob", + "gix-hash", + "gix-index", + "gix-object", + "gix-path", + "gix-worktree", "io-close", "thiserror", ] [[package]] name = "gix-worktree-stream" -version = "0.2.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb2a0fa070db8f3c0f7e9d5e8f189df7f8fdbb0fed331c79dae4c3410d7106dd" +checksum = "c89fe93a12e45cc3ad6ba429a7dd7506b03d7d406374a65ad9998b5cb2627569" dependencies = [ "gix-attributes", "gix-features", @@ -3967,7 +4078,7 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash 0.7.6", + "ahash 0.7.7", ] [[package]] @@ -3976,7 +4087,7 @@ version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.5", ] [[package]] @@ -3985,7 +4096,7 @@ version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.5", "allocator-api2", "serde", ] @@ -4024,7 +4135,7 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06683b93020a07e3dbcf5f8c0f6d40080d725bea7936fc01ad345c01b97dc270" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", "bytes", "headers-core", "http", @@ -4203,7 +4314,7 @@ dependencies = [ "futures-util", "http", "hyper", - "rustls 0.21.7", + "rustls 0.21.8", "tokio", "tokio-rustls 0.24.1", ] @@ -4288,7 +4399,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e98c1d0ad70fc91b8b9654b1f33db55e59579d3b3de2bffdced0fdb810570cb8" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.5", "hashbrown 0.12.3", ] @@ -4499,9 +4610,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "iri-string" @@ -4660,7 +4771,7 @@ version = "8.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", "pem", "ring 0.16.20", "serde", @@ -4799,15 +4910,6 @@ dependencies = [ "libc", ] -[[package]] -name = "kstring" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec3066350882a1cd6d950d055997f379ac37fd39f81cd4d8ed186032eb3c5747" -dependencies = [ - "static_assertions", -] - [[package]] name = "lalrpop" version = "0.20.0" @@ -5030,9 +5132,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" dependencies = [ "libc", "log", @@ -5583,9 +5685,9 @@ checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pest" -version = "2.7.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c022f1e7b65d6a24c0dbbd5fb344c66881bc01f3e5ae74a1c8100f2f985d98a4" +checksum = "ae9cee2a55a544be8b89dc6848072af97a20f2422603c10865be2a42b580fff5" dependencies = [ "memchr", "thiserror", @@ -5594,9 +5696,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.7.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35513f630d46400a977c4cb58f78e1bfbe01434316e60c37d27b9ad6139c66d8" +checksum = "81d78524685f5ef2a3b3bd1cafbc9fcabb036253d9b1463e726a91cd16e2dfc2" dependencies = [ "pest", "pest_generator", @@ -5604,9 +5706,9 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.7.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc9fc1b9e7057baba189b5c626e2d6f40681ae5b6eb064dc7c7834101ec8123a" +checksum = "68bd1206e71118b5356dae5ddc61c8b11e28b09ef6a31acbd15ea48a28e0c227" dependencies = [ "pest", "pest_meta", @@ -5617,9 +5719,9 @@ dependencies = [ [[package]] name = "pest_meta" -version = "2.7.4" +version = "2.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1df74e9e7ec4053ceb980e7c0c8bd3594e977fde1af91daba9c928e8e8c6708d" +checksum = "7c747191d4ad9e4a4ab9c8798f1e82a39affe7ef9648390b7e5548d18e099de6" dependencies = [ "once_cell", "pest", @@ -5753,9 +5855,9 @@ checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" [[package]] name = "portable-atomic" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31114a898e107c51bb1609ffaf55a0e011cf6a4d7f1170d0015a165082c0338b" +checksum = "b559898e0b4931ed2d3b959ab0c2da4d99cc644c4b0b1a35b4d344027f474023" [[package]] name = "powerfmt" @@ -5892,9 +5994,9 @@ dependencies = [ [[package]] name = "prodash" -version = "25.0.2" +version = "26.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d67eb4220992a4a052a4bb03cf776e493ecb1a3a36bab551804153d63486af7" +checksum = "794b5bf8e2d19b53dcdcec3e4bba628e20f5b6062503ba89281fa7037dd7bbcf" dependencies = [ "bytesize", "human_format", @@ -6179,7 +6281,7 @@ version = "0.11.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", "bytes", "encoding_rs", "futures-core", @@ -6196,7 +6298,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls 0.21.7", + "rustls 0.21.8", "rustls-pemfile", "serde", "serde_json", @@ -6337,12 +6439,12 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.7" +version = "0.21.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" +checksum = "446e14c5cda4f3f30fe71863c34ec70f5ac79d6087097ad0bb433e1be5edf04c" dependencies = [ "log", - "ring 0.16.20", + "ring 0.17.5", "rustls-webpki", "sct", ] @@ -6365,17 +6467,17 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", ] [[package]] name = "rustls-webpki" -version = "0.101.6" +version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c7d5dece342910d9ba34d259310cae3e0154b873b35408b787b59bce53d34fe" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ - "ring 0.16.20", - "untrusted 0.7.1", + "ring 0.17.5", + "untrusted 0.9.0", ] [[package]] @@ -6463,8 +6565,8 @@ dependencies = [ [[package]] name = "scarb" -version = "0.7.0" -source = "git+https://github.com/software-mansion/scarb?rev=7adb7fd#7adb7fd972e4ec95dc404650dec78099815392c9" +version = "2.3.0" +source = "git+https://github.com/software-mansion/scarb?rev=f306f9a#f306f9a91b15077d933a8b9a3e5e1b43d94542f0" dependencies = [ "anyhow", "async-trait", @@ -6473,8 +6575,10 @@ dependencies = [ "cairo-lang-filesystem", "cairo-lang-formatter", "cairo-lang-semantic", + "cairo-lang-sierra", "cairo-lang-sierra-to-casm", "cairo-lang-starknet", + "cairo-lang-test-plugin", "cairo-lang-utils", "camino", "clap", @@ -6483,7 +6587,6 @@ dependencies = [ "data-encoding", "deno_task_shell", "derive_builder", - "diffy", "directories", "dunce", "fs4", @@ -6498,17 +6601,22 @@ dependencies = [ "pathdiff", "petgraph", "scarb-build-metadata", - "scarb-metadata 1.7.0", + "scarb-metadata 1.8.0 (git+https://github.com/software-mansion/scarb?rev=f306f9a)", "scarb-ui", "semver", "serde", + "serde-untagged", "serde-value", "serde_json", + "serde_repr", + "sha2", + "smallvec", "smol_str", + "tar", "thiserror", "tokio", - "toml 0.7.8", - "toml_edit", + "toml 0.8.4", + "toml_edit 0.20.4", "tracing", "tracing-log", "tracing-subscriber", @@ -6516,25 +6624,27 @@ dependencies = [ "url", "walkdir", "which", + "windows-sys 0.48.0", "xxhash-rust", "zip", + "zstd 0.12.4", ] [[package]] name = "scarb-build-metadata" -version = "0.7.0" -source = "git+https://github.com/software-mansion/scarb?rev=7adb7fd#7adb7fd972e4ec95dc404650dec78099815392c9" +version = "2.3.0" +source = "git+https://github.com/software-mansion/scarb?rev=f306f9a#f306f9a91b15077d933a8b9a3e5e1b43d94542f0" dependencies = [ - "cargo_metadata", + "cargo_metadata 0.18.1", ] [[package]] name = "scarb-metadata" -version = "1.7.0" -source = "git+https://github.com/software-mansion/scarb?rev=7adb7fd#7adb7fd972e4ec95dc404650dec78099815392c9" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a1939d4a36ba77bc4a23024f42e16e307b74fe451d8efa23aff8916fdde6a83" dependencies = [ "camino", - "derive_builder", "semver", "serde", "serde_json", @@ -6544,10 +6654,10 @@ dependencies = [ [[package]] name = "scarb-metadata" version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a1939d4a36ba77bc4a23024f42e16e307b74fe451d8efa23aff8916fdde6a83" +source = "git+https://github.com/software-mansion/scarb?rev=f306f9a#f306f9a91b15077d933a8b9a3e5e1b43d94542f0" dependencies = [ "camino", + "derive_builder", "semver", "serde", "serde_json", @@ -6556,16 +6666,15 @@ dependencies = [ [[package]] name = "scarb-ui" -version = "0.7.0" -source = "git+https://github.com/software-mansion/scarb?rev=7adb7fd#7adb7fd972e4ec95dc404650dec78099815392c9" +version = "0.1.0" +source = "git+https://github.com/software-mansion/scarb?rev=f306f9a#f306f9a91b15077d933a8b9a3e5e1b43d94542f0" dependencies = [ "anyhow", "camino", "clap", "console", "indicatif", - "indoc 2.0.4", - "scarb-metadata 1.7.0", + "scarb-metadata 1.8.0 (git+https://github.com/software-mansion/scarb?rev=f306f9a)", "serde", "serde_json", ] @@ -6705,6 +6814,16 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-untagged" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ba3ac59c62f51b75a6bfad8840b2ede4a81ff5cc23c200221ef479ae75a4aa3" +dependencies = [ + "erased-serde", + "serde", +] + [[package]] name = "serde-value" version = "0.7.0" @@ -6772,9 +6891,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" +checksum = "12022b835073e5b11e90a14f86838ceb1c8fb0325b72416845c487ac0fa95e80" dependencies = [ "serde", ] @@ -7053,6 +7172,7 @@ dependencies = [ "cairo-lang-sierra", "cairo-lang-sierra-to-casm", "cairo-lang-starknet", + "cairo-lang-test-plugin", "cairo-lang-test-runner", "camino", "clap", @@ -7143,7 +7263,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa8241483a83a3f33aa5fff7e7d9def398ff9990b2752b6c6112b83c6d246029" dependencies = [ - "ahash 0.7.6", + "ahash 0.7.7", "atoi", "bitflags 1.3.2", "byteorder", @@ -7270,7 +7390,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14139b1c39bdc2f1e663c12090ff5108fe50ebe62c09e15e32988dfaf445a7e4" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", "flate2", "hex", "serde", @@ -7599,6 +7719,17 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" +[[package]] +name = "tar" +version = "0.4.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b16afcea1f22891c49a00c751c7b63b2233284064f11a200fc624137c51e2ddb" +dependencies = [ + "filetime", + "libc", + "xattr", +] + [[package]] name = "tempfile" version = "3.8.0" @@ -7811,7 +7942,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.21.7", + "rustls 0.21.8", "tokio", ] @@ -7834,7 +7965,7 @@ checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" dependencies = [ "futures-util", "log", - "rustls 0.21.7", + "rustls 0.21.8", "tokio", "tokio-rustls 0.24.1", "tungstenite", @@ -7874,14 +8005,26 @@ dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit", + "toml_edit 0.19.15", +] + +[[package]] +name = "toml" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ef75d881185fd2df4a040793927c153d863651108a93c7e17a9e591baa95cc6" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit 0.20.4", ] [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" dependencies = [ "serde", ] @@ -7899,6 +8042,19 @@ dependencies = [ "winnow", ] +[[package]] +name = "toml_edit" +version = "0.20.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "380f9e8120405471f7c9ad1860a713ef5ece6a670c7eae39225e477340f32fc4" +dependencies = [ + "indexmap 2.0.2", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + [[package]] name = "tonic" version = "0.9.2" @@ -7906,7 +8062,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3082666a3a6433f7f511c7192923fa1fe07c69332d3c6a2e6bb040b569199d5a" dependencies = [ "async-trait", - "base64 0.21.4", + "base64 0.21.5", "bytes", "flate2", "futures-core", @@ -7931,7 +8087,7 @@ dependencies = [ "async-stream", "async-trait", "axum", - "base64 0.21.4", + "base64 0.21.5", "bytes", "h2", "http", @@ -7981,7 +8137,7 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fddb2a37b247e6adcb9f239f4e5cefdcc5ed526141a416b943929f13aea2cce" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", "bytes", "http", "http-body", @@ -8001,7 +8157,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac5987e92915a51a4b05e69a0ef903a7b76f16674f7ee66534f87fd3323e2d3a" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", "byteorder", "bytes", "futures-util", @@ -8087,7 +8243,7 @@ dependencies = [ "async-graphql-warp", "async-recursion", "async-trait", - "base64 0.21.4", + "base64 0.21.5", "camino", "chrono", "dojo-test-utils", @@ -8153,7 +8309,7 @@ version = "0.3.1" dependencies = [ "anyhow", "async-trait", - "base64 0.21.4", + "base64 0.21.5", "camino", "chrono", "clap", @@ -8214,7 +8370,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" dependencies = [ "async-compression", - "base64 0.21.4", + "base64 0.21.5", "bitflags 2.4.1", "bytes", "futures-core", @@ -8328,12 +8484,12 @@ dependencies = [ [[package]] name = "tracing-log" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +checksum = "f751112709b4e791d8ce53e32c4ed2d353565a795ce84da2285393f41557bdf2" dependencies = [ - "lazy_static", "log", + "once_cell", "tracing-core", ] @@ -8387,7 +8543,7 @@ dependencies = [ "httparse", "log", "rand", - "rustls 0.21.7", + "rustls 0.21.8", "sha1", "thiserror", "url", @@ -8396,18 +8552,18 @@ dependencies = [ [[package]] name = "typed-builder" -version = "0.15.2" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe83c85a85875e8c4cb9ce4a890f05b23d38cd0d47647db7895d3d2a79566d2" +checksum = "34085c17941e36627a879208083e25d357243812c30e7d7387c3b954f30ade16" dependencies = [ "typed-builder-macro", ] [[package]] name = "typed-builder-macro" -version = "0.15.2" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29a3151c41d0b13e3d011f98adc24434560ef06673a155a6c7f66b9879eecce2" +checksum = "f03ca4cb38206e2bef0700092660bb74d696f808514dae47fa1467cbfe26e96e" dependencies = [ "proc-macro2", "quote", @@ -9005,6 +9161,15 @@ dependencies = [ "tap", ] +[[package]] +name = "xattr" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4686009f71ff3e5c4dbcf1a282d0a44db3f021ba69350cd42086b3e5f1c6985" +dependencies = [ + "libc", +] + [[package]] name = "xshell" version = "0.2.5" @@ -9032,6 +9197,26 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" +[[package]] +name = "zerocopy" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c19fae0c8a9efc6a8281f2e623db8af1db9e57852e04cde3e754dd2dc29340f" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc56589e9ddd1f1c28d4b4b5c773ce232910a6bb67a70133d61c9e347585efe9" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", +] + [[package]] name = "zeroize" version = "1.6.0" @@ -9081,6 +9266,15 @@ dependencies = [ "zstd-safe 5.0.2+zstd.1.5.2", ] +[[package]] +name = "zstd" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a27595e173641171fc74a1232b7b1c7a7cb6e18222c11e9dfb9888fa424c53c" +dependencies = [ + "zstd-safe 6.0.6", +] + [[package]] name = "zstd" version = "0.13.0" @@ -9100,6 +9294,16 @@ dependencies = [ "zstd-sys", ] +[[package]] +name = "zstd-safe" +version = "6.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee98ffd0b48ee95e6c5168188e44a54550b1564d9d530ee21d5f0eaed1069581" +dependencies = [ + "libc", + "zstd-sys", +] + [[package]] name = "zstd-safe" version = "7.0.0" diff --git a/Cargo.toml b/Cargo.toml index 2264ace779..8e49f7b787 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,27 +34,28 @@ anyhow = "1.0.75" assert_matches = "1.5.0" async-trait = "0.1.68" blockifier = { git = "https://github.com/starkware-libs/blockifier" } -cairo-lang-casm = "2.2.0" -cairo-lang-compiler = "2.2.0" -cairo-lang-debug = "2.2.0" -cairo-lang-defs = "2.2.0" -cairo-lang-diagnostics = "2.2.0" -cairo-lang-filesystem = "2.2.0" -cairo-lang-formatter = "2.2.0" -cairo-lang-language-server = "2.2.0" -cairo-lang-lowering = "2.2.0" -cairo-lang-parser = "2.2.0" -cairo-lang-plugins = "2.2.0" -cairo-lang-project = "2.2.0" -cairo-lang-semantic = { version = "2.2.0", features = [ "testing" ] } -cairo-lang-sierra = "2.2.0" -cairo-lang-sierra-generator = "2.2.0" -cairo-lang-sierra-to-casm = "2.2.0" -cairo-lang-starknet = "2.2.0" -cairo-lang-syntax = "2.2.0" -cairo-lang-test-runner = "2.2.0" -cairo-lang-test-utils = "2.2.0" -cairo-lang-utils = "2.2.0" +cairo-lang-casm = "2.3.0" +cairo-lang-compiler = "2.3.0" +cairo-lang-debug = "2.3.0" +cairo-lang-defs = "2.3.0" +cairo-lang-diagnostics = "2.3.0" +cairo-lang-filesystem = "2.3.0" +cairo-lang-formatter = "2.3.0" +cairo-lang-language-server = "2.3.0" +cairo-lang-lowering = "2.3.0" +cairo-lang-parser = "2.3.0" +cairo-lang-plugins = "2.3.0" +cairo-lang-project = "2.3.0" +cairo-lang-semantic = { version = "2.3.0", features = [ "testing" ] } +cairo-lang-sierra = "2.3.0" +cairo-lang-sierra-generator = "2.3.0" +cairo-lang-sierra-to-casm = "2.3.0" +cairo-lang-starknet = "2.3.0" +cairo-lang-syntax = "2.3.0" +cairo-lang-test-plugin = "2.3.0" +cairo-lang-test-runner = "2.3.0" +cairo-lang-test-utils = "2.3.0" +cairo-lang-utils = "2.3.0" cairo-vm = "0.8.2" camino = { version = "1.1.2", features = [ "serde1" ] } chrono = { version = "0.4.24", features = [ "serde" ] } @@ -76,8 +77,8 @@ parking_lot = "0.12.1" pretty_assertions = "1.2.1" rayon = "1.8.0" salsa = "0.16.1" -scarb = { git = "https://github.com/software-mansion/scarb", rev = "7adb7fd" } -scarb-ui = { git = "https://github.com/software-mansion/scarb", rev = "7adb7fd" } +scarb = { git = "https://github.com/software-mansion/scarb", rev = "f306f9a" } +scarb-ui = { git = "https://github.com/software-mansion/scarb", rev = "f306f9a" } semver = "1.0.5" serde = { version = "1.0.156", features = [ "derive" ] } serde_json = "1.0" @@ -113,7 +114,7 @@ wasm-tonic = { version = "0.9.2", default-features = false, features = [ "codege wasm-tonic-build = { version = "0.9.2", default-features = false, features = [ "prost" ], package = "tonic-build" } [patch."https://github.com/starkware-libs/blockifier"] -blockifier = { git = "https://github.com/dojoengine/blockifier", rev = "f7df9ba" } +blockifier = { git = "https://github.com/dojoengine/blockifier", rev = "3357e69" } [patch.crates-io] cairo-felt = { git = "https://github.com/dojoengine/cairo-rs.git", rev = "262b7eb4b11ab165a2a936a5f914e78aa732d4a2" } diff --git a/crates/dojo-core/Scarb.lock b/crates/dojo-core/Scarb.lock new file mode 100644 index 0000000000..3abe8d53cb --- /dev/null +++ b/crates/dojo-core/Scarb.lock @@ -0,0 +1,13 @@ +# Code generated by scarb DO NOT EDIT. +version = 1 + +[[package]] +name = "dojo" +version = "0.3.1" +dependencies = [ + "dojo_plugin", +] + +[[package]] +name = "dojo_plugin" +version = "0.3.1" diff --git a/crates/dojo-core/Scarb.toml b/crates/dojo-core/Scarb.toml index 2d8a1d2e7f..78622aa0c1 100644 --- a/crates/dojo-core/Scarb.toml +++ b/crates/dojo-core/Scarb.toml @@ -1,9 +1,9 @@ [package] -cairo-version = "2.2.0" +cairo-version = "2.3.0" description = "The Dojo Core library for autonomous worlds." name = "dojo" version = "0.3.1" [dependencies] -dojo_plugin = { git = "https://github.com/dojoengine/dojo", tag = "v0.3.1" } -starknet = "2.2.0" +dojo_plugin = "0.3.1" +starknet = "2.3.0" diff --git a/crates/dojo-core/src/lib.cairo b/crates/dojo-core/src/lib.cairo index db7e2469c2..6e3301c6ee 100644 --- a/crates/dojo-core/src/lib.cairo +++ b/crates/dojo-core/src/lib.cairo @@ -19,4 +19,5 @@ mod upgradable; #[cfg(test)] mod test_utils; +#[cfg(test)] mod benchmarks; \ No newline at end of file diff --git a/crates/dojo-core/src/world.cairo b/crates/dojo-core/src/world.cairo index ece860a1f9..100a9a92d7 100644 --- a/crates/dojo-core/src/world.cairo +++ b/crates/dojo-core/src/world.cairo @@ -52,6 +52,7 @@ mod world { use traits::Into; use option::OptionTrait; use box::BoxTrait; + use starknet::event::EventEmitter; use serde::Serde; use core::hash::{HashStateExTrait, HashStateTrait}; use pedersen::{PedersenTrait, HashStateImpl, PedersenImpl}; diff --git a/crates/dojo-defi/Scarb.toml b/crates/dojo-defi/Scarb.toml index 495290ae1e..af3243388e 100644 --- a/crates/dojo-defi/Scarb.toml +++ b/crates/dojo-defi/Scarb.toml @@ -1,5 +1,5 @@ [package] -cairo-version = "2.2.0" +cairo-version = "2.3.0" description = "Implementations of a defi primitives for the Dojo framework" name = "dojo_defi" version = "0.3.1" diff --git a/crates/dojo-erc/Scarb.toml b/crates/dojo-erc/Scarb.toml index 562a3a65af..256add23f1 100644 --- a/crates/dojo-erc/Scarb.toml +++ b/crates/dojo-erc/Scarb.toml @@ -1,5 +1,5 @@ [package] -cairo-version = "2.2.0" +cairo-version = "2.3.0" description = "Implementations of ERC standards for the Dojo framework" name = "dojo_erc" version = "0.3.1" diff --git a/crates/dojo-lang/Cargo.toml b/crates/dojo-lang/Cargo.toml index 02ff743bd0..244e81a1ef 100644 --- a/crates/dojo-lang/Cargo.toml +++ b/crates/dojo-lang/Cargo.toml @@ -27,10 +27,12 @@ cairo-lang-syntax.workspace = true cairo-lang-utils.workspace = true camino.workspace = true convert_case.workspace = true +directories = "5" dojo-types = { path = "../dojo-types" } dojo-world = { path = "../dojo-world", features = [ "manifest" ] } indoc.workspace = true itertools.workspace = true +lazy_static.workspace = true once_cell.workspace = true salsa.workspace = true scarb.workspace = true diff --git a/crates/dojo-lang/src/compiler.rs b/crates/dojo-lang/src/compiler.rs index fb960a1b12..889cc00a22 100644 --- a/crates/dojo-lang/src/compiler.rs +++ b/crates/dojo-lang/src/compiler.rs @@ -1,30 +1,40 @@ -use std::collections::HashMap; +use std::collections::{BTreeMap, HashMap}; use std::iter::zip; -use std::ops::DerefMut; +use std::ops::{Deref, DerefMut}; use anyhow::{anyhow, Context, Result}; use cairo_lang_compiler::db::RootDatabase; +use cairo_lang_defs::ids::{ModuleId, ModuleItemId}; use cairo_lang_filesystem::db::FilesGroup; use cairo_lang_filesystem::ids::{CrateId, CrateLongId}; use cairo_lang_semantic::db::SemanticGroup; use cairo_lang_starknet::abi; use cairo_lang_starknet::contract::{find_contracts, ContractDeclaration}; use cairo_lang_starknet::contract_class::{compile_prepared_db, ContractClass}; +use cairo_lang_starknet::plugin::aux_data::StarkNetContractAuxData; use cairo_lang_utils::UpcastMut; +use convert_case::{Case, Casing}; +use dojo_world::manifest::{ + Class, Contract, BASE_CONTRACT_NAME, EXECUTOR_CONTRACT_NAME, WORLD_CONTRACT_NAME, +}; use itertools::Itertools; use scarb::compiler::helpers::{build_compiler_config, collect_main_crate_ids}; use scarb::compiler::{CompilationUnit, Compiler}; -use scarb::core::{PackageName, Workspace}; +use scarb::core::{PackageName, TargetKind, Workspace}; use serde::{Deserialize, Serialize}; use smol_str::SmolStr; use starknet::core::types::contract::SierraClass; use starknet::core::types::FieldElement; use tracing::{debug, trace, trace_span}; -use crate::manifest::Manifest; +use crate::plugin::DojoAuxData; const CAIRO_PATH_SEPARATOR: &str = "::"; +#[cfg(test)] +#[path = "compiler_test.rs"] +mod test; + pub struct DojoCompiler; #[derive(Debug, Default, Serialize, Deserialize)] @@ -48,8 +58,8 @@ impl ContractSelector { } impl Compiler for DojoCompiler { - fn target_kind(&self) -> &str { - "dojo" + fn target_kind(&self) -> TargetKind { + TargetKind::new("dojo") } fn compile( @@ -59,7 +69,7 @@ impl Compiler for DojoCompiler { ws: &Workspace<'_>, ) -> Result<()> { let props: Props = unit.target().props()?; - let target_dir = unit.target_dir(ws.config()); + let target_dir = unit.target_dir(ws); let compiler_config = build_compiler_config(&unit, ws); let mut main_crate_ids = collect_main_crate_ids(&unit, db); @@ -104,10 +114,16 @@ impl Compiler for DojoCompiler { compiled_classes.insert(contract_name, (class_hash, class.abi)); } - let mut file = target_dir.open_rw("manifest.json", "output file", ws.config())?; - let manifest = Manifest::new(db, &main_crate_ids, compiled_classes); - serde_json::to_writer_pretty(file.deref_mut(), &manifest) - .with_context(|| "failed to serialize manifest")?; + let mut manifest = target_dir + .open_ro("manifest.json", "output file", ws.config()) + .map(|file| dojo_world::manifest::Manifest::try_from(file.deref()).unwrap_or_default()) + .unwrap_or(dojo_world::manifest::Manifest::default()); + + update_manifest(&mut manifest, db, &main_crate_ids, compiled_classes)?; + + manifest.write_to_path( + target_dir.open_rw("manifest.json", "output file", ws.config())?.path(), + )?; Ok(()) } @@ -184,14 +200,177 @@ pub fn collect_external_crate_ids( .collect::>() } -#[test] -fn test_compiler() { - use dojo_test_utils::compiler::build_test_config; - use scarb::ops; +fn update_manifest( + manifest: &mut dojo_world::manifest::Manifest, + db: &dyn SemanticGroup, + crate_ids: &[CrateId], + compiled_artifacts: HashMap)>, +) -> anyhow::Result<()> { + fn get_compiled_artifact_from_map<'a>( + artifacts: &'a HashMap)>, + artifact_name: &str, + ) -> anyhow::Result<&'a (FieldElement, Option)> { + artifacts.get(artifact_name).context(format!( + "Contract `{artifact_name}` not found. Did you include `dojo` as a dependency?", + )) + } + + let world = { + let (hash, abi) = get_compiled_artifact_from_map(&compiled_artifacts, WORLD_CONTRACT_NAME)?; + Contract { + name: WORLD_CONTRACT_NAME.into(), + abi: abi.clone(), + class_hash: *hash, + ..Default::default() + } + }; + + let executor = { + let (hash, abi) = + get_compiled_artifact_from_map(&compiled_artifacts, EXECUTOR_CONTRACT_NAME)?; + Contract { + name: EXECUTOR_CONTRACT_NAME.into(), + abi: abi.clone(), + class_hash: *hash, + ..Default::default() + } + }; + + let base = { + let (hash, abi) = get_compiled_artifact_from_map(&compiled_artifacts, BASE_CONTRACT_NAME)?; + Class { name: BASE_CONTRACT_NAME.into(), abi: abi.clone(), class_hash: *hash } + }; + + let mut models = BTreeMap::new(); + let mut contracts = BTreeMap::new(); + + for crate_id in crate_ids { + for module_id in db.crate_modules(*crate_id).as_ref() { + let file_infos = db.module_generated_file_infos(*module_id).unwrap_or_default(); + for aux_data in file_infos + .iter() + .skip(1) + .filter_map(|info| info.as_ref().map(|i| &i.aux_data)) + .filter_map(|aux_data| aux_data.as_ref().map(|aux_data| aux_data.0.as_any())) + { + if let Some(aux_data) = aux_data.downcast_ref::() { + contracts.extend(get_dojo_contract_artifacts(aux_data, &compiled_artifacts)?); + } + + if let Some(dojo_aux_data) = aux_data.downcast_ref::() { + models.extend(get_dojo_model_artifacts( + db, + dojo_aux_data, + *module_id, + &compiled_artifacts, + )?); + } + } + } + } + + for model in &models { + contracts.remove(model.0.to_case(Case::Snake).as_str()); + } + + do_update_manifest(manifest, world, executor, base, models, contracts)?; + + Ok(()) +} + +/// Finds the inline modules annotated as models in the given crate_ids and +/// returns the corresponding Models. +fn get_dojo_model_artifacts( + db: &dyn SemanticGroup, + aux_data: &DojoAuxData, + module_id: ModuleId, + compiled_classes: &HashMap)>, +) -> anyhow::Result> { + let mut models = HashMap::with_capacity(aux_data.models.len()); + + for model in &aux_data.models { + if let Ok(Some(ModuleItemId::Struct(_))) = + db.module_item_by_name(module_id, model.name.clone().into()) + { + let model_contract_name = model.name.to_case(Case::Snake); + + let (class_hash, abi) = compiled_classes + .get(model_contract_name.as_str()) + .cloned() + .ok_or(anyhow!("Model {} not found in target.", model.name))?; + + models.insert( + model.name.clone(), + dojo_world::manifest::Model { + abi, + class_hash, + name: model.name.clone(), + members: model.members.clone(), + }, + ); + } + } + + Ok(models) +} + +fn get_dojo_contract_artifacts( + aux_data: &StarkNetContractAuxData, + compiled_classes: &HashMap)>, +) -> anyhow::Result> { + aux_data + .contracts + .iter() + .filter(|name| !matches!(name.as_ref(), "world" | "executor" | "base")) + .map(|name| { + let (class_hash, abi) = compiled_classes + .get(name) + .cloned() + .ok_or(anyhow!("Contract {name} not found in target."))?; + Ok((name.clone(), Contract { name: name.clone(), class_hash, abi, address: None })) + }) + .collect::>() +} + +fn do_update_manifest( + manifest: &mut dojo_world::manifest::Manifest, + world: dojo_world::manifest::Contract, + executor: dojo_world::manifest::Contract, + base: dojo_world::manifest::Class, + models: BTreeMap, + contracts: BTreeMap, +) -> anyhow::Result<()> { + if manifest.world.class_hash != world.class_hash { + manifest.world = world; + } + + if manifest.executor.class_hash != executor.class_hash { + manifest.executor = executor; + } + + if manifest.base.class_hash != base.class_hash { + manifest.base = base; + } + + for (name, model) in models { + if let Some(mm) = manifest.models.iter_mut().find(|m| m.name == name) { + if mm.class_hash != model.class_hash { + *mm = model; + } + } else { + manifest.models.push(model); + } + } + + for (name, contract) in contracts { + if let Some(mc) = manifest.contracts.iter_mut().find(|c| c.name == name) { + if mc.class_hash != contract.class_hash { + *mc = contract; + } + } else { + manifest.contracts.push(contract); + } + } - let config = build_test_config("../../examples/spawn-and-move/Scarb.toml").unwrap(); - let ws = ops::read_workspace(config.manifest_path(), &config) - .unwrap_or_else(|op| panic!("Error building workspace: {op:?}")); - let packages = ws.members().map(|p| p.id).collect(); - ops::compile(packages, &ws).unwrap_or_else(|op| panic!("Error compiling: {op:?}")) + Ok(()) } diff --git a/crates/dojo-lang/src/compiler_test.rs b/crates/dojo-lang/src/compiler_test.rs new file mode 100644 index 0000000000..479998d795 --- /dev/null +++ b/crates/dojo-lang/src/compiler_test.rs @@ -0,0 +1,61 @@ +use std::path::Path; +use std::{env, fs}; + +use cairo_lang_test_utils::parse_test_file::TestRunnerResult; +use cairo_lang_utils::ordered_hash_map::OrderedHashMap; +use dojo_test_utils::compiler::build_test_config; +use scarb::core::TargetKind; +use scarb::ops::{self, CompileOpts}; + +#[test] +fn test_compiler() { + let config = build_test_config("../../examples/spawn-and-move/Scarb.toml").unwrap(); + let ws = ops::read_workspace(config.manifest_path(), &config).unwrap(); + let packages = ws.members().map(|p| p.id).collect(); + assert!( + ops::compile( + packages, + CompileOpts { include_targets: vec![], exclude_targets: vec![TargetKind::TEST] }, + &ws + ) + .is_ok(), + "compilation failed" + ); +} + +cairo_lang_test_utils::test_file_test!( + manifest_file, + "src/manifest_test_data/", + { + manifest: "manifest", + }, + test_manifest_file +); + +pub fn test_manifest_file( + _inputs: &OrderedHashMap, + _args: &OrderedHashMap, +) -> TestRunnerResult { + let config = build_test_config("./src/manifest_test_data/spawn-and-move/Scarb.toml").unwrap(); + let ws = ops::read_workspace(config.manifest_path(), &config).unwrap(); + + let packages = ws.members().map(|p| p.id).collect(); + ops::compile( + packages, + CompileOpts { include_targets: vec![], exclude_targets: vec![TargetKind::TEST] }, + &ws, + ) + .unwrap_or_else(|op| panic!("Error compiling: {op:?}")); + + let target_dir = config.target_dir_override().unwrap(); + + let generated_manifest_path = + Path::new(target_dir).join(config.profile().as_str()).join("manifest.json"); + + let generated_file = fs::read_to_string(generated_manifest_path).unwrap(); + + TestRunnerResult::success(OrderedHashMap::from([( + "expected_manifest_file".into(), + generated_file, + )])) +} diff --git a/crates/dojo-lang/src/contract.rs b/crates/dojo-lang/src/contract.rs index 38c471a07c..6bb92b91c7 100644 --- a/crates/dojo-lang/src/contract.rs +++ b/crates/dojo-lang/src/contract.rs @@ -74,7 +74,7 @@ impl DojoContract { $body$ } ", - UnorderedHashMap::from([ + &UnorderedHashMap::from([ ("name".to_string(), RewriteNode::Text(name.to_string())), ("body".to_string(), RewriteNode::new_modified(body_nodes)), ]), @@ -143,7 +143,7 @@ impl DojoContract { #[external(v0)] fn execute(self: @ContractState, $params$) $ret_clause$ $body$ ", - UnorderedHashMap::from([ + &UnorderedHashMap::from([ ("params".to_string(), RewriteNode::Text(params)), ( "body".to_string(), diff --git a/crates/dojo-lang/src/introspect.rs b/crates/dojo-lang/src/introspect.rs index 3cdc602d9e..7300157623 100644 --- a/crates/dojo-lang/src/introspect.rs +++ b/crates/dojo-lang/src/introspect.rs @@ -272,7 +272,7 @@ fn handle_introspect_internal( } } ", - UnorderedHashMap::from([ + &UnorderedHashMap::from([ ("name".to_string(), RewriteNode::Text(name)), ("size".to_string(), RewriteNode::Text(size.join(" + "))), ("layout".to_string(), RewriteNode::new_modified(layout)), diff --git a/crates/dojo-lang/src/lib.rs b/crates/dojo-lang/src/lib.rs index ee8515d49c..218e499037 100644 --- a/crates/dojo-lang/src/lib.rs +++ b/crates/dojo-lang/src/lib.rs @@ -7,7 +7,6 @@ pub mod compiler; pub mod contract; pub mod inline_macros; pub mod introspect; -mod manifest; pub mod model; pub mod plugin; pub mod print; diff --git a/crates/dojo-lang/src/manifest.rs b/crates/dojo-lang/src/manifest.rs deleted file mode 100644 index b1098b142e..0000000000 --- a/crates/dojo-lang/src/manifest.rs +++ /dev/null @@ -1,166 +0,0 @@ -use std::collections::HashMap; - -use anyhow::Context; -use cairo_lang_defs::ids::{ModuleId, ModuleItemId}; -use cairo_lang_filesystem::ids::CrateId; -use cairo_lang_semantic::db::SemanticGroup; -use cairo_lang_starknet::abi; -use cairo_lang_starknet::plugin::aux_data::StarkNetContractAuxData; -use convert_case::{Case, Casing}; -use dojo_world::manifest::{ - Class, Contract, BASE_CONTRACT_NAME, EXECUTOR_CONTRACT_NAME, WORLD_CONTRACT_NAME, -}; -use serde::Serialize; -use smol_str::SmolStr; -use starknet::core::types::FieldElement; - -use crate::plugin::DojoAuxData; - -#[derive(Default, Debug, Serialize)] -pub(crate) struct Manifest(dojo_world::manifest::Manifest); - -impl Manifest { - pub fn new( - db: &dyn SemanticGroup, - crate_ids: &[CrateId], - compiled_classes: HashMap)>, - ) -> Self { - let mut manifest = Manifest(dojo_world::manifest::Manifest::default()); - let (world, world_abi) = compiled_classes.get(WORLD_CONTRACT_NAME).unwrap_or_else(|| { - panic!( - "{}", - format!( - "Contract `{}` not found. Did you include `dojo` as a dependency?", - WORLD_CONTRACT_NAME - ) - ); - }); - let (executor, executor_abi) = - compiled_classes.get(EXECUTOR_CONTRACT_NAME).unwrap_or_else(|| { - panic!( - "{}", - format!( - "Contract `{}` not found. Did you include `dojo` as a dependency?", - EXECUTOR_CONTRACT_NAME - ) - ); - }); - let (base, base_abi) = compiled_classes.get(BASE_CONTRACT_NAME).unwrap_or_else(|| { - panic!( - "{}", - format!( - "Contract `{}` not found. Did you include `dojo` as a dependency?", - BASE_CONTRACT_NAME - ) - ); - }); - - manifest.0.world = Contract { - name: WORLD_CONTRACT_NAME.into(), - address: None, - class_hash: *world, - abi: world_abi.clone(), - }; - manifest.0.base = - Class { name: BASE_CONTRACT_NAME.into(), class_hash: *base, abi: base_abi.clone() }; - manifest.0.executor = Contract { - name: EXECUTOR_CONTRACT_NAME.into(), - address: None, - class_hash: *executor, - abi: executor_abi.clone(), - }; - - for crate_id in crate_ids { - let modules = db.crate_modules(*crate_id); - for module_id in modules.iter() { - let generated_file_infos = - db.module_generated_file_infos(*module_id).unwrap_or_default(); - - for generated_file_info in generated_file_infos.iter().skip(1) { - let Some(generated_file_info) = generated_file_info else { - continue; - }; - let Some(aux_data) = &generated_file_info.aux_data else { - continue; - }; - let aux_data = aux_data.0.as_any(); - if let Some(contracts) = aux_data.downcast_ref::() { - manifest.find_contracts(contracts, &compiled_classes); - } else if let Some(dojo_aux_data) = aux_data.downcast_ref() { - manifest.find_models(db, dojo_aux_data, *module_id, &compiled_classes); - } - } - } - manifest.filter_contracts(); - } - - manifest - } - - /// Finds the inline modules annotated as models in the given crate_ids and - /// returns the corresponding Models. - fn find_models( - &mut self, - db: &dyn SemanticGroup, - aux_data: &DojoAuxData, - module_id: ModuleId, - compiled_classes: &HashMap)>, - ) { - for model in &aux_data.models { - let model = model.clone(); - let name: SmolStr = model.name.clone().into(); - if let Ok(Some(ModuleItemId::Struct(_))) = - db.module_item_by_name(module_id, name.clone()) - { - // It needs the `Model` suffix because we are - // searching from the compiled contracts. - let (class_hash, class_abi) = compiled_classes - .get(name.to_case(Case::Snake).as_str()) - .with_context(|| format!("Model {name} not found in target.")) - .unwrap(); - - self.0.models.push(dojo_world::manifest::Model { - name: model.name, - members: model.members, - class_hash: *class_hash, - abi: class_abi.clone(), - }); - } - } - } - - // removes contracts with DojoAuxType - fn filter_contracts(&mut self) { - let mut models = HashMap::new(); - - for model in &self.0.models { - models.insert(model.class_hash, true); - } - - for i in (0..self.0.contracts.len()).rev() { - if models.get(&self.0.contracts[i].class_hash).is_some() { - self.0.contracts.remove(i); - } - } - } - - fn find_contracts( - &mut self, - aux_data: &StarkNetContractAuxData, - compiled_classes: &HashMap)>, - ) { - for name in &aux_data.contracts { - if "world" == name.as_str() || "executor" == name.as_str() || "base" == name.as_str() { - return; - } - - let (class_hash, abi) = compiled_classes.get(name).unwrap().clone(); - - self.0.contracts.push(Contract { name: name.clone(), address: None, class_hash, abi }); - } - } -} - -#[cfg(test)] -#[path = "manifest_test.rs"] -mod test; diff --git a/crates/dojo-lang/src/manifest_test.rs b/crates/dojo-lang/src/manifest_test.rs deleted file mode 100644 index da5fc11c16..0000000000 --- a/crates/dojo-lang/src/manifest_test.rs +++ /dev/null @@ -1,35 +0,0 @@ -use std::path::Path; -use std::{env, fs}; - -use cairo_lang_utils::ordered_hash_map::OrderedHashMap; -use dojo_test_utils::compiler::build_test_config; -use scarb::ops; - -cairo_lang_test_utils::test_file_test!( - manifest_file, - "src/manifest_test_data/", - { - manifest: "manifest", - }, - test_manifest_file -); - -pub fn test_manifest_file( - _inputs: &OrderedHashMap, - _args: &OrderedHashMap, -) -> Result, String> { - let config = build_test_config("./src/manifest_test_data/spawn-and-move/Scarb.toml").unwrap(); - let ws = ops::read_workspace(config.manifest_path(), &config).unwrap(); - - let packages = ws.members().map(|p| p.id).collect(); - ops::compile(packages, &ws).unwrap_or_else(|op| panic!("Error compiling: {op:?}")); - - let target_dir = config.target_dir().path_existent().unwrap(); - - let generated_manifest_path = - Path::new(target_dir).join(config.profile().as_str()).join("manifest.json"); - - let generated_file = fs::read_to_string(generated_manifest_path).unwrap(); - - Ok(OrderedHashMap::from([("expected_manifest_file".into(), generated_file)])) -} diff --git a/crates/dojo-lang/src/manifest_test_data/manifest b/crates/dojo-lang/src/manifest_test_data/manifest index ea6e971778..a66ad52ff3 100644 --- a/crates/dojo-lang/src/manifest_test_data/manifest +++ b/crates/dojo-lang/src/manifest_test_data/manifest @@ -8,7 +8,7 @@ test_manifest_file "world": { "name": "world", "address": null, - "class_hash": "0x5179c281a8d3cca6cfb820201fa7a81150b56f9db492405a29e9564222370b8", + "class_hash": "0x25e33883f34b7b2ce1adc3e3cf0640d389ccfeca742c11d3d3cf55362153b19", "abi": [ { "type": "impl", @@ -744,7 +744,7 @@ test_manifest_file "executor": { "name": "executor", "address": null, - "class_hash": "0x2b35dd4816731188ed1ad16caa73bde76075c9d9cb8cbfa3e447d3ab9b1ab33", + "class_hash": "0xc56cfd3556105b87f396de49355cfe57a48b14f79197c680fda568ffb5dfdf", "abi": [ { "type": "impl", @@ -801,7 +801,7 @@ test_manifest_file }, "base": { "name": "base", - "class_hash": "0x7aec2b7d7064c1294a339cd90060331ff704ab573e4ee9a1b699be2215c11c9", + "class_hash": "0x515233234b830aa4c52a3b14acdf6413caa6a96967c5a55bba47337ba3d4406", "abi": [ { "type": "impl", @@ -864,7 +864,7 @@ test_manifest_file { "name": "actions", "address": null, - "class_hash": "0x879e001074687da51991333bd4c3f8121bfa77547dd6daa4ff9330d1cfcd7e", + "class_hash": "0x3446f6de79c5bd23b1fdd084d9aecf4216fd0efb6cae69cee847ac73530626c", "abi": [ { "type": "impl", @@ -1008,7 +1008,7 @@ test_manifest_file "key": false } ], - "class_hash": "0xb37482a660983dfbf65968caa26eab260d3e1077986454b52ac06e58ae20c4", + "class_hash": "0x2a20de0f38504e870c0ea88a2ac39e7d4e123ed1e024929638cf037a3e47396", "abi": [ { "type": "function", @@ -1185,7 +1185,7 @@ test_manifest_file "key": false } ], - "class_hash": "0x6ffc643cbc4b2fb9c424242b18175a5e142269b45f4463d1cd4dddb7a2e5095", + "class_hash": "0x6f8b85d1f68eab7612e3f4ea178c6386cedb30a6925c9f662a251c640b86d96", "abi": [ { "type": "function", diff --git a/crates/dojo-lang/src/manifest_test_data/simple_crate/Scarb.toml b/crates/dojo-lang/src/manifest_test_data/simple_crate/Scarb.toml index 8ee13b8171..e1b6872cdf 100644 --- a/crates/dojo-lang/src/manifest_test_data/simple_crate/Scarb.toml +++ b/crates/dojo-lang/src/manifest_test_data/simple_crate/Scarb.toml @@ -1,5 +1,5 @@ [package] -cairo-version = "2.2.0" +cairo-version = "2.3.0" name = "test_crate" version = "0.3.1" diff --git a/crates/dojo-lang/src/model.rs b/crates/dojo-lang/src/model.rs index fc62785b54..65a016b48e 100644 --- a/crates/dojo-lang/src/model.rs +++ b/crates/dojo-lang/src/model.rs @@ -152,7 +152,7 @@ pub fn handle_model_struct( } } ", - UnorderedHashMap::from([ + &UnorderedHashMap::from([ ("contract_name".to_string(), RewriteNode::Text(name.to_case(Case::Snake))), ( "type_name".to_string(), diff --git a/crates/dojo-lang/src/plugin.rs b/crates/dojo-lang/src/plugin.rs index 18a8b819a3..b2f1b51034 100644 --- a/crates/dojo-lang/src/plugin.rs +++ b/crates/dojo-lang/src/plugin.rs @@ -1,3 +1,6 @@ +use std::fs; +use std::fs::File; +use std::io::Write; use std::sync::Arc; use anyhow::Result; @@ -12,14 +15,16 @@ use cairo_lang_syntax::attribute::structured::{ use cairo_lang_syntax::node::db::SyntaxGroup; use cairo_lang_syntax::node::helpers::QueryAttrs; use cairo_lang_syntax::node::{ast, Terminal}; +use camino::{Utf8Path, Utf8PathBuf}; +use directories::ProjectDirs; use dojo_types::system::Dependency; use dojo_world::manifest::Member; +use lazy_static::lazy_static; use scarb::compiler::plugin::builtin::BuiltinStarkNetPlugin; use scarb::compiler::plugin::{CairoPlugin, CairoPluginInstance}; -use scarb::core::{PackageId, PackageName, SourceId}; +use scarb::core::{DependencyVersionReq, ManifestDependency, PackageId, PackageName, SourceId}; use semver::Version; use smol_str::SmolStr; -use url::Url; use crate::contract::DojoContract; use crate::inline_macros::emit::EmitMacro; @@ -64,9 +69,32 @@ impl GeneratedFileAuxData for DojoAuxData { #[path = "plugin_test.rs"] mod test; +pub const PACKAGE_NAME: &str = "dojo_plugin"; + #[derive(Debug, Default)] pub struct BuiltinDojoPlugin; +lazy_static! { + static ref MANIFEST_VERSION: Version = Version::parse(env!("CARGO_PKG_VERSION")).expect("Manifest version not defined"); + static ref MANIFEST_PATH: Utf8PathBuf = { + let pd = ProjectDirs::from("com", "dojoengine", "sozo") + .expect("no valid home directory path could be retrieved from the operating system"); + + let content = include_str!("../Scarb.toml"); + let path = pd.cache_dir().join(MANIFEST_VERSION.to_string()).join("Scarb.toml"); + + // Create the directory if it doesn't exist + if let Some(parent) = path.parent() { + fs::create_dir_all(parent).expect("Failed to create directory"); + } + + let mut file = File::create(&path).expect("unable to create file"); + write!(file, "{}", content).expect("unable to write to file"); + + Utf8Path::from_path(&path).expect("invalid UTF-8 path").to_path_buf() + }; +} + impl BuiltinDojoPlugin { fn handle_mod(&self, db: &dyn SyntaxGroup, module_ast: ast::ItemModule) -> PluginResult { if module_ast.has_attr(db, DOJO_CONTRACT_ATTR) { @@ -75,17 +103,23 @@ impl BuiltinDojoPlugin { PluginResult::default() } + + pub fn manifest_dependency() -> ManifestDependency { + let version_req = DependencyVersionReq::exact(&MANIFEST_VERSION); + ManifestDependency::builder() + .name(PackageName::new(PACKAGE_NAME)) + .source_id(SourceId::for_path(MANIFEST_PATH.as_path()).unwrap()) + .version_req(version_req) + .build() + } } impl CairoPlugin for BuiltinDojoPlugin { fn id(&self) -> PackageId { - let url = Url::parse("https://github.com/dojoengine/dojo").unwrap(); - let version = env!("CARGO_PKG_VERSION"); PackageId::new( - PackageName::new("dojo_plugin"), - Version::parse(version).unwrap(), - SourceId::for_git(&url, &scarb::core::GitReference::Tag(format!("v{version}").into())) - .unwrap(), + PackageName::new(PACKAGE_NAME), + MANIFEST_VERSION.to_owned(), + SourceId::for_path(MANIFEST_PATH.as_path()).unwrap(), ) } @@ -274,6 +308,10 @@ impl MacroPlugin for BuiltinDojoPlugin { _ => PluginResult::default(), } } + + fn declared_attributes(&self) -> Vec { + vec!["dojo::contract".to_string(), "key".to_string()] + } } pub struct CairoPluginRepository(scarb::compiler::plugin::CairoPluginRepository); diff --git a/crates/dojo-lang/src/plugin_test.rs b/crates/dojo-lang/src/plugin_test.rs index de55a7348f..338cbbc8eb 100644 --- a/crates/dojo-lang/src/plugin_test.rs +++ b/crates/dojo-lang/src/plugin_test.rs @@ -1,16 +1,26 @@ use std::sync::Arc; -use cairo_lang_defs::plugin::{MacroPlugin, PluginGeneratedFile}; +use cairo_lang_defs::db::{DefsDatabase, DefsGroup}; +use cairo_lang_defs::ids::{LanguageElementId, ModuleId, ModuleItemId}; +use cairo_lang_defs::plugin::MacroPlugin; use cairo_lang_diagnostics::{format_diagnostics, DiagnosticLocation}; use cairo_lang_filesystem::cfg::CfgSet; -use cairo_lang_filesystem::db::FilesGroup; -use cairo_lang_formatter::format_string; -use cairo_lang_parser::test_utils::create_virtual_file; -use cairo_lang_parser::utils::{get_syntax_file_and_diagnostics, SimpleParserDatabase}; -use cairo_lang_syntax::node::TypedSyntaxNode; +use cairo_lang_filesystem::db::{ + init_files_group, AsFilesGroupMut, FilesDatabase, FilesGroup, FilesGroupEx, +}; +use cairo_lang_filesystem::ids::{CrateLongId, Directory, FileLongId}; +use cairo_lang_parser::db::ParserDatabase; +use cairo_lang_plugins::get_default_plugins; +use cairo_lang_syntax::node::db::{SyntaxDatabase, SyntaxGroup}; +use cairo_lang_syntax::node::kind::SyntaxKind; +use cairo_lang_syntax::node::{ast, TypedSyntaxNode}; +use cairo_lang_test_utils::parse_test_file::TestRunnerResult; +use cairo_lang_test_utils::verify_diagnostics_expectation; use cairo_lang_utils::ordered_hash_map::OrderedHashMap; +use cairo_lang_utils::unordered_hash_set::UnorderedHashSet; +use cairo_lang_utils::Upcast; -use crate::plugin::BuiltinDojoPlugin; +use super::BuiltinDojoPlugin; cairo_lang_test_utils::test_file_test!( expand_plugin, @@ -26,9 +36,55 @@ cairo_lang_test_utils::test_file_test!( pub fn test_expand_plugin( inputs: &OrderedHashMap, - _args: &OrderedHashMap, -) -> Result, String> { - let db = &mut SimpleParserDatabase::default(); + args: &OrderedHashMap, +) -> TestRunnerResult { + test_expand_plugin_inner(inputs, args, &[Arc::new(BuiltinDojoPlugin)]) +} + +#[salsa::database(DefsDatabase, ParserDatabase, SyntaxDatabase, FilesDatabase)] +pub struct DatabaseForTesting { + storage: salsa::Storage, +} +impl salsa::Database for DatabaseForTesting {} +impl Default for DatabaseForTesting { + fn default() -> Self { + let mut res = Self { storage: Default::default() }; + init_files_group(&mut res); + res.set_macro_plugins(get_default_plugins()); + res + } +} +impl AsFilesGroupMut for DatabaseForTesting { + fn as_files_group_mut(&mut self) -> &mut (dyn FilesGroup + 'static) { + self + } +} +impl Upcast for DatabaseForTesting { + fn upcast(&self) -> &(dyn DefsGroup + 'static) { + self + } +} +impl Upcast for DatabaseForTesting { + fn upcast(&self) -> &(dyn FilesGroup + 'static) { + self + } +} +impl Upcast for DatabaseForTesting { + fn upcast(&self) -> &(dyn SyntaxGroup + 'static) { + self + } +} + +/// Tests expansion of given code, with the default plugins plus the given extra plugins. +pub fn test_expand_plugin_inner( + inputs: &OrderedHashMap, + args: &OrderedHashMap, + extra_plugins: &[Arc], +) -> TestRunnerResult { + let db = &mut DatabaseForTesting::default(); + let mut plugins = db.macro_plugins(); + plugins.extend_from_slice(extra_plugins); + db.set_macro_plugins(plugins); let cfg_set: Option = inputs.get("cfg").map(|s| serde_json::from_str(s.as_str()).unwrap()); @@ -37,52 +93,82 @@ pub fn test_expand_plugin( } let cairo_code = &inputs["cairo_code"]; - let file_id = create_virtual_file(db, "dummy_file.cairo", cairo_code); - - let (syntax_file, diagnostics) = get_syntax_file_and_diagnostics(db, file_id, cairo_code); - assert!(diagnostics.is_empty(), "Unexpected diagnostics:\n{}", diagnostics.format(db)); - - let plugins: Vec> = vec![Arc::new(BuiltinDojoPlugin)]; - let mut generated_items: Vec = Vec::new(); - let mut diagnostic_items: Vec = Vec::new(); - - for item in syntax_file.items(db).elements(db).into_iter() { - let mut remove_original_item = false; - let mut local_generated_items = Vec::::new(); - for plugin in &plugins { - let result = plugin.generate_code(db, item.clone()); - diagnostic_items.extend(result.diagnostics.iter().map(|diag| { - let syntax_node = diag.stable_ptr.lookup(db); - - let location = - DiagnosticLocation { file_id, span: syntax_node.span_without_trivia(db) }; - format_diagnostics(db, &diag.message, location) - })); + let crate_id = db.intern_crate(CrateLongId::Real("test".into())); + let root = Directory::Real("test_src".into()); + db.set_crate_root(crate_id, Some(root)); + + // Main module file. + let file_id = db.intern_file(FileLongId::OnDisk("test_src/lib.cairo".into())); + db.as_files_group_mut() + .override_file_content(file_id, Some(Arc::new(format!("{cairo_code}\n")))); + + let mut diagnostic_items = vec![]; + let expanded_module = + expand_module_text(db, ModuleId::CrateRoot(crate_id), &mut diagnostic_items); + let joined_diagnostics = diagnostic_items.join("\n"); + let error = verify_diagnostics_expectation(args, &joined_diagnostics); + + TestRunnerResult { + outputs: OrderedHashMap::from([ + ("expanded_cairo_code".into(), expanded_module), + ("expected_diagnostics".into(), joined_diagnostics), + ]), + error, + } +} - if result.remove_original_item { - remove_original_item = true; +pub fn expand_module_text( + db: &dyn DefsGroup, + module_id: ModuleId, + diagnostics: &mut Vec, +) -> String { + let mut output = String::new(); + // A collection of all the use statements in the module. + let mut uses_list = UnorderedHashSet::default(); + let syntax_db = db.upcast(); + // Collect the module diagnostics. + for (file_id, diag) in db.module_plugin_diagnostics(module_id).unwrap().iter() { + let syntax_node = diag.stable_ptr.lookup(syntax_db); + let location = DiagnosticLocation { + file_id: file_id.file_id(db.upcast()).unwrap(), + span: syntax_node.span_without_trivia(syntax_db), + }; + diagnostics.push(format_diagnostics(db.upcast(), &diag.message, location)); + } + for item_id in db.module_items(module_id).unwrap().iter() { + if let ModuleItemId::Submodule(item) = item_id { + let submodule_item = item.stable_ptr(db).lookup(syntax_db); + if let ast::MaybeModuleBody::Some(body) = submodule_item.body(syntax_db) { + // Recursively expand inline submodules. + output.extend([ + submodule_item.attributes(syntax_db).node.get_text(syntax_db), + submodule_item.module_kw(syntax_db).as_syntax_node().get_text(syntax_db), + submodule_item.name(syntax_db).as_syntax_node().get_text(syntax_db), + body.lbrace(syntax_db).as_syntax_node().get_text(syntax_db), + expand_module_text(db, ModuleId::Submodule(*item), diagnostics), + body.rbrace(syntax_db).as_syntax_node().get_text(syntax_db), + ]); + continue; } - - if let Some(PluginGeneratedFile { content, .. }) = result.code { - local_generated_items.push(format_string(db, content)); - break; + } else if let ModuleItemId::Use(use_id) = item_id { + let mut use_item = use_id.stable_ptr(db).lookup(syntax_db).as_syntax_node(); + // Climb up the AST until the syntax kind is ItemUse. This is needed since the use item + // points to the use leaf as one use statement can represent multiple use items. + while let Some(parent) = use_item.parent() { + use_item = parent; + if use_item.kind(syntax_db) == SyntaxKind::ItemUse { + break; + } } - - if remove_original_item { - break; + if uses_list.insert(use_item.clone()) { + output.push_str(&use_item.get_text(syntax_db)); } + continue; } - - if !remove_original_item { - generated_items.push(item.as_syntax_node().get_text(db)); - } - - generated_items.extend(local_generated_items); + let syntax_item = item_id.untyped_stable_ptr(db); + // Output other items as is. + output.push_str(&syntax_item.lookup(syntax_db).get_text(syntax_db)); } - - Ok(OrderedHashMap::from([ - ("generated_cairo_code".into(), generated_items.join("\n")), - ("expected_diagnostics".into(), diagnostic_items.join("\n")), - ])) + output } diff --git a/crates/dojo-lang/src/plugin_test_data/introspect b/crates/dojo-lang/src/plugin_test_data/introspect index 9f95b180bb..98e7f261d5 100644 --- a/crates/dojo-lang/src/plugin_test_data/introspect +++ b/crates/dojo-lang/src/plugin_test_data/introspect @@ -529,3 +529,568 @@ impl PositionSchemaIntrospection of dojo::database::schema::SchemaIntrospection< } //! > expected_diagnostics +error: Unsupported attribute. + --> test_src/lib.cairo[Position]:96:13 + #[starknet::contract] + ^*******************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[Position]:100:17 + #[storage] + ^********^ + +error: Unsupported attribute. + --> test_src/lib.cairo[Position]:103:17 + #[external(v0)] + ^*************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[Position]:108:17 + #[external(v0)] + ^*************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[Position]:113:17 + #[external(v0)] + ^*************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[Position]:121:17 + #[external(v0)] + ^*************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[Position]:128:17 + #[external(v0)] + ^*************^ + +//! > expanded_cairo_code +use serde::Serde; + +#[derive(Copy, Drop, Serde, Introspect)] +struct Vec2 { + x: u32, + y: u32 +} + +#[derive(Serde, Copy, Drop, Introspect)] +enum PlainEnum { + Left: (), + Right: (), +} + +#[derive(Serde, Copy, Drop, Introspect)] +enum EnumPrimitive { + Left: (u16,), + Right: (u16,), +} + +#[derive(Serde, Copy, Drop, Introspect)] +enum EnumTuple { + Left: (u8, u8), + Right: (u8, u8), +} + +#[derive(Serde, Copy, Drop, Introspect)] +enum EnumCustom { + Left: Vec2, + Right: Vec2, +} + +#[derive(Model, Copy, Drop, Introspect)] +struct Position { + #[key] + player: ContractAddress, + before: u8, + vec: Vec2, + after: u16, +} +impl Vec2Copy of Copy::; +impl Vec2Drop of Drop::; +impl Vec2Serde of Serde:: { + fn serialize(self: @Vec2, ref output: array::Array) { + serde::Serde::serialize(self.x, ref output); + serde::Serde::serialize(self.y, ref output) + } + fn deserialize(ref serialized: array::Span) -> Option { + Option::Some(Vec2 { + x: serde::Serde::deserialize(ref serialized)?, + y: serde::Serde::deserialize(ref serialized)?, + }) + } +} + + impl Vec2SchemaIntrospection of dojo::database::schema::SchemaIntrospection { + + #[inline(always)] + fn size() -> usize { + 2 + } + + #[inline(always)] + fn layout(ref layout: Array) { + layout.append(32); +layout.append(32); + + } + + #[inline(always)] + fn ty() -> dojo::database::schema::Ty { + + dojo::database::schema::Ty::Struct(dojo::database::schema::Struct { + name: 'Vec2', + attrs: array![].span(), + children: array![ + dojo::database::schema::serialize_member(@dojo::database::schema::Member { + name: 'x', + ty: dojo::database::schema::Ty::Primitive('u32'), + attrs: array![].span() + }) +, + + dojo::database::schema::serialize_member(@dojo::database::schema::Member { + name: 'y', + ty: dojo::database::schema::Ty::Primitive('u32'), + attrs: array![].span() + }) +].span() + }) + } + } +impl PlainEnumSerde of Serde:: { + fn serialize(self: @PlainEnum, ref output: array::Array) { + match self { + PlainEnum::Left(x) => { serde::Serde::serialize(@0, ref output); serde::Serde::serialize(x, ref output); }, + PlainEnum::Right(x) => { serde::Serde::serialize(@1, ref output); serde::Serde::serialize(x, ref output); }, + } + } + fn deserialize(ref serialized: array::Span) -> Option { + let idx: felt252 = serde::Serde::deserialize(ref serialized)?; + Option::Some( + if idx == 0 { PlainEnum::Left(serde::Serde::deserialize(ref serialized)?) } + else if idx == 1 { PlainEnum::Right(serde::Serde::deserialize(ref serialized)?) } + else { return Option::None; } + ) + } +} +impl PlainEnumCopy of Copy::; +impl PlainEnumDrop of Drop::; + + impl PlainEnumSchemaIntrospection of dojo::database::schema::SchemaIntrospection { + + #[inline(always)] + fn size() -> usize { + 1 + } + + #[inline(always)] + fn layout(ref layout: Array) { + layout.append(8); + + } + + #[inline(always)] + fn ty() -> dojo::database::schema::Ty { + + dojo::database::schema::Ty::Enum( + dojo::database::schema::Enum { + name: 'Direction', + attrs: array![].span(), + children: array![ + + ( + 'Left', + dojo::database::schema::serialize_member_type( + @dojo::database::schema::Ty::Tuple(array![].span())) + ), + + ( + 'Right', + dojo::database::schema::serialize_member_type( + @dojo::database::schema::Ty::Tuple(array![].span())) + ) + ].span() + } + ) + } + } +impl EnumPrimitiveSerde of Serde:: { + fn serialize(self: @EnumPrimitive, ref output: array::Array) { + match self { + EnumPrimitive::Left(x) => { serde::Serde::serialize(@0, ref output); serde::Serde::serialize(x, ref output); }, + EnumPrimitive::Right(x) => { serde::Serde::serialize(@1, ref output); serde::Serde::serialize(x, ref output); }, + } + } + fn deserialize(ref serialized: array::Span) -> Option { + let idx: felt252 = serde::Serde::deserialize(ref serialized)?; + Option::Some( + if idx == 0 { EnumPrimitive::Left(serde::Serde::deserialize(ref serialized)?) } + else if idx == 1 { EnumPrimitive::Right(serde::Serde::deserialize(ref serialized)?) } + else { return Option::None; } + ) + } +} +impl EnumPrimitiveCopy of Copy::; +impl EnumPrimitiveDrop of Drop::; + + impl EnumPrimitiveSchemaIntrospection of dojo::database::schema::SchemaIntrospection { + + #[inline(always)] + fn size() -> usize { + 2 + } + + #[inline(always)] + fn layout(ref layout: Array) { + layout.append(8); +layout.append(16); + + } + + #[inline(always)] + fn ty() -> dojo::database::schema::Ty { + + dojo::database::schema::Ty::Enum( + dojo::database::schema::Enum { + name: 'Direction', + attrs: array![].span(), + children: array![ + + ( + 'Left', + dojo::database::schema::serialize_member_type( + @dojo::database::schema::Ty::Tuple(array![dojo::database::schema::serialize_member_type( + @dojo::database::schema::Ty::Primitive('u16') + )].span())) + ), + + ( + 'Right', + dojo::database::schema::serialize_member_type( + @dojo::database::schema::Ty::Tuple(array![dojo::database::schema::serialize_member_type( + @dojo::database::schema::Ty::Primitive('u16') + )].span())) + ) + ].span() + } + ) + } + } +impl EnumTupleSerde of Serde:: { + fn serialize(self: @EnumTuple, ref output: array::Array) { + match self { + EnumTuple::Left(x) => { serde::Serde::serialize(@0, ref output); serde::Serde::serialize(x, ref output); }, + EnumTuple::Right(x) => { serde::Serde::serialize(@1, ref output); serde::Serde::serialize(x, ref output); }, + } + } + fn deserialize(ref serialized: array::Span) -> Option { + let idx: felt252 = serde::Serde::deserialize(ref serialized)?; + Option::Some( + if idx == 0 { EnumTuple::Left(serde::Serde::deserialize(ref serialized)?) } + else if idx == 1 { EnumTuple::Right(serde::Serde::deserialize(ref serialized)?) } + else { return Option::None; } + ) + } +} +impl EnumTupleCopy of Copy::; +impl EnumTupleDrop of Drop::; + + impl EnumTupleSchemaIntrospection of dojo::database::schema::SchemaIntrospection { + + #[inline(always)] + fn size() -> usize { + 3 + } + + #[inline(always)] + fn layout(ref layout: Array) { + layout.append(8); +layout.append(8); +layout.append(8); + + } + + #[inline(always)] + fn ty() -> dojo::database::schema::Ty { + + dojo::database::schema::Ty::Enum( + dojo::database::schema::Enum { + name: 'Direction', + attrs: array![].span(), + children: array![ + + ( + 'Left', + dojo::database::schema::serialize_member_type( + @dojo::database::schema::Ty::Tuple(array![dojo::database::schema::serialize_member_type( + @dojo::database::schema::Ty::Primitive('u8') + ), +dojo::database::schema::serialize_member_type( + @dojo::database::schema::Ty::Primitive('u8') + )].span())) + ), + + ( + 'Right', + dojo::database::schema::serialize_member_type( + @dojo::database::schema::Ty::Tuple(array![dojo::database::schema::serialize_member_type( + @dojo::database::schema::Ty::Primitive('u8') + ), +dojo::database::schema::serialize_member_type( + @dojo::database::schema::Ty::Primitive('u8') + )].span())) + ) + ].span() + } + ) + } + } +impl EnumCustomSerde of Serde:: { + fn serialize(self: @EnumCustom, ref output: array::Array) { + match self { + EnumCustom::Left(x) => { serde::Serde::serialize(@0, ref output); serde::Serde::serialize(x, ref output); }, + EnumCustom::Right(x) => { serde::Serde::serialize(@1, ref output); serde::Serde::serialize(x, ref output); }, + } + } + fn deserialize(ref serialized: array::Span) -> Option { + let idx: felt252 = serde::Serde::deserialize(ref serialized)?; + Option::Some( + if idx == 0 { EnumCustom::Left(serde::Serde::deserialize(ref serialized)?) } + else if idx == 1 { EnumCustom::Right(serde::Serde::deserialize(ref serialized)?) } + else { return Option::None; } + ) + } +} +impl EnumCustomCopy of Copy::; +impl EnumCustomDrop of Drop::; + + impl EnumCustomSchemaIntrospection of dojo::database::schema::SchemaIntrospection { + + #[inline(always)] + fn size() -> usize { + dojo::database::schema::SchemaIntrospection::::size() + 1 + } + + #[inline(always)] + fn layout(ref layout: Array) { + layout.append(8); +dojo::database::schema::SchemaIntrospection::::layout(ref layout); + + } + + #[inline(always)] + fn ty() -> dojo::database::schema::Ty { + + dojo::database::schema::Ty::Enum( + dojo::database::schema::Enum { + name: 'Direction', + attrs: array![].span(), + children: array![ + + ( + 'Left', + dojo::database::schema::serialize_member_type( + @dojo::database::schema::Ty::Tuple(array![dojo::database::schema::serialize_member_type( + @dojo::database::schema::SchemaIntrospection::::ty() + )].span())) + ), + + ( + 'Right', + dojo::database::schema::serialize_member_type( + @dojo::database::schema::Ty::Tuple(array![dojo::database::schema::serialize_member_type( + @dojo::database::schema::SchemaIntrospection::::ty() + )].span())) + ) + ].span() + } + ) + } + } +impl PositionCopy of Copy::; +impl PositionDrop of Drop::; + + impl PositionModel of dojo::model::Model { + #[inline(always)] + fn name(self: @Position) -> felt252 { + 'Position' + } + + #[inline(always)] + fn keys(self: @Position) -> Span { + let mut serialized = ArrayTrait::new(); + serde::Serde::serialize(self.player, ref serialized); + array::ArrayTrait::span(@serialized) + } + + #[inline(always)] + fn values(self: @Position) -> Span { + let mut serialized = ArrayTrait::new(); + serde::Serde::serialize(self.before, ref serialized);serde::Serde::serialize(self.vec, ref serialized);serde::Serde::serialize(self.after, ref serialized); + array::ArrayTrait::span(@serialized) + } + + #[inline(always)] + fn layout(self: @Position) -> Span { + let mut layout = ArrayTrait::new(); + dojo::database::schema::SchemaIntrospection::::layout(ref layout); + array::ArrayTrait::span(@layout) + } + + #[inline(always)] + fn packed_size(self: @Position) -> usize { + let mut layout = self.layout(); + dojo::packing::calculate_packed_size(ref layout) + } + } + + + impl PositionSchemaIntrospection of dojo::database::schema::SchemaIntrospection { + + #[inline(always)] + fn size() -> usize { + dojo::database::schema::SchemaIntrospection::::size() + 2 + } + + #[inline(always)] + fn layout(ref layout: Array) { + layout.append(8); +dojo::database::schema::SchemaIntrospection::::layout(ref layout); +layout.append(16); + + } + + #[inline(always)] + fn ty() -> dojo::database::schema::Ty { + + dojo::database::schema::Ty::Struct(dojo::database::schema::Struct { + name: 'Position', + attrs: array![].span(), + children: array![ + dojo::database::schema::serialize_member(@dojo::database::schema::Member { + name: 'player', + ty: dojo::database::schema::Ty::Primitive('ContractAddress'), + attrs: array!['key'].span() + }) +, + + dojo::database::schema::serialize_member(@dojo::database::schema::Member { + name: 'before', + ty: dojo::database::schema::Ty::Primitive('u8'), + attrs: array![].span() + }) +, + + dojo::database::schema::serialize_member(@dojo::database::schema::Member { + name: 'vec', + ty: dojo::database::schema::SchemaIntrospection::::ty(), + attrs: array![].span() + }) +, + + dojo::database::schema::serialize_member(@dojo::database::schema::Member { + name: 'after', + ty: dojo::database::schema::Ty::Primitive('u16'), + attrs: array![].span() + }) +].span() + }) + } + } + + + #[starknet::interface] + trait IPosition { + fn name(self: @T) -> felt252; + } + + #[starknet::contract] + mod position { + use super::Position; + + #[storage] + struct Storage {} + + #[external(v0)] + fn name(self: @ContractState) -> felt252 { + 'Position' + } + + #[external(v0)] + fn unpacked_size(self: @ContractState) -> usize { + dojo::database::schema::SchemaIntrospection::::size() + } + + #[external(v0)] + fn packed_size(self: @ContractState) -> usize { + let mut layout = ArrayTrait::new(); + dojo::database::schema::SchemaIntrospection::::layout(ref layout); + let mut layout_span = layout.span(); + dojo::packing::calculate_packed_size(ref layout_span) + } + + #[external(v0)] + fn layout(self: @ContractState) -> Span { + let mut layout = ArrayTrait::new(); + dojo::database::schema::SchemaIntrospection::::layout(ref layout); + array::ArrayTrait::span(@layout) + } + + #[external(v0)] + fn schema(self: @ContractState) -> dojo::database::schema::Ty { + dojo::database::schema::SchemaIntrospection::::ty() + } + } + + impl PositionSchemaIntrospection of dojo::database::schema::SchemaIntrospection { + + #[inline(always)] + fn size() -> usize { + dojo::database::schema::SchemaIntrospection::::size() + 2 + } + + #[inline(always)] + fn layout(ref layout: Array) { + layout.append(8); +dojo::database::schema::SchemaIntrospection::::layout(ref layout); +layout.append(16); + + } + + #[inline(always)] + fn ty() -> dojo::database::schema::Ty { + + dojo::database::schema::Ty::Struct(dojo::database::schema::Struct { + name: 'Position', + attrs: array![].span(), + children: array![ + dojo::database::schema::serialize_member(@dojo::database::schema::Member { + name: 'player', + ty: dojo::database::schema::Ty::Primitive('ContractAddress'), + attrs: array!['key'].span() + }) +, + + dojo::database::schema::serialize_member(@dojo::database::schema::Member { + name: 'before', + ty: dojo::database::schema::Ty::Primitive('u8'), + attrs: array![].span() + }) +, + + dojo::database::schema::serialize_member(@dojo::database::schema::Member { + name: 'vec', + ty: dojo::database::schema::SchemaIntrospection::::ty(), + attrs: array![].span() + }) +, + + dojo::database::schema::serialize_member(@dojo::database::schema::Member { + name: 'after', + ty: dojo::database::schema::Ty::Primitive('u16'), + attrs: array![].span() + }) +].span() + }) + } + } diff --git a/crates/dojo-lang/src/plugin_test_data/model b/crates/dojo-lang/src/plugin_test_data/model index 0d02d47141..c6fdecdb4f 100644 --- a/crates/dojo-lang/src/plugin_test_data/model +++ b/crates/dojo-lang/src/plugin_test_data/model @@ -521,6 +521,613 @@ mod player { //! > expected_diagnostics error: Model must define atleast one #[key] attribute - --> dummy_file.cairo:36:8 + --> test_src/lib.cairo:36:8 struct Roles { ^***^ + +error: Unsupported attribute. + --> test_src/lib.cairo[Position]:80:13 + #[starknet::contract] + ^*******************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[Roles]:73:13 + #[starknet::contract] + ^*******************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[Player]:87:13 + #[starknet::contract] + ^*******************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[Position]:84:17 + #[storage] + ^********^ + +error: Unsupported attribute. + --> test_src/lib.cairo[Position]:87:17 + #[external(v0)] + ^*************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[Position]:92:17 + #[external(v0)] + ^*************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[Position]:97:17 + #[external(v0)] + ^*************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[Position]:105:17 + #[external(v0)] + ^*************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[Position]:112:17 + #[external(v0)] + ^*************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[Roles]:77:17 + #[storage] + ^********^ + +error: Unsupported attribute. + --> test_src/lib.cairo[Roles]:80:17 + #[external(v0)] + ^*************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[Roles]:85:17 + #[external(v0)] + ^*************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[Roles]:90:17 + #[external(v0)] + ^*************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[Roles]:98:17 + #[external(v0)] + ^*************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[Roles]:105:17 + #[external(v0)] + ^*************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[Player]:91:17 + #[storage] + ^********^ + +error: Unsupported attribute. + --> test_src/lib.cairo[Player]:94:17 + #[external(v0)] + ^*************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[Player]:99:17 + #[external(v0)] + ^*************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[Player]:104:17 + #[external(v0)] + ^*************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[Player]:112:17 + #[external(v0)] + ^*************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[Player]:119:17 + #[external(v0)] + ^*************^ + +//! > expanded_cairo_code +use serde::Serde; + +#[derive(Introspect, Copy, Drop, Serde)] +struct Vec3 { + x: u32, + y: u32, + z: u8, +} + +#[derive(Model, Copy, Drop, Serde)] +struct Position { + #[key] + id: felt252, + v: Vec3, +} + +trait PositionTrait { + fn is_zero(self: Position) -> bool; + fn is_equal(self: Position, b: Position) -> bool; +} + +impl PositionImpl of PositionTrait { + fn is_zero(self: Position) -> bool { + match self.x - self.y { + 0 => bool::True(()), + _ => bool::False(()), + } + } + + fn is_equal(self: Position, b: Position) -> bool { + self.x == b.x && self.y == b.y + } +} + +#[derive(Model, Serde)] +struct Roles { + role_ids: Array +} + +use starknet::ContractAddress; + +#[derive(Model, Copy, Drop, Serde)] +struct Player { + #[key] + game: felt252, + #[key] + player: ContractAddress, + + name: felt252, +} +impl Vec3Copy of Copy::; +impl Vec3Drop of Drop::; +impl Vec3Serde of Serde:: { + fn serialize(self: @Vec3, ref output: array::Array) { + serde::Serde::serialize(self.x, ref output); + serde::Serde::serialize(self.y, ref output); + serde::Serde::serialize(self.z, ref output) + } + fn deserialize(ref serialized: array::Span) -> Option { + Option::Some(Vec3 { + x: serde::Serde::deserialize(ref serialized)?, + y: serde::Serde::deserialize(ref serialized)?, + z: serde::Serde::deserialize(ref serialized)?, + }) + } +} + + impl Vec3SchemaIntrospection of dojo::database::schema::SchemaIntrospection { + + #[inline(always)] + fn size() -> usize { + 3 + } + + #[inline(always)] + fn layout(ref layout: Array) { + layout.append(32); +layout.append(32); +layout.append(8); + + } + + #[inline(always)] + fn ty() -> dojo::database::schema::Ty { + + dojo::database::schema::Ty::Struct(dojo::database::schema::Struct { + name: 'Vec3', + attrs: array![].span(), + children: array![ + dojo::database::schema::serialize_member(@dojo::database::schema::Member { + name: 'x', + ty: dojo::database::schema::Ty::Primitive('u32'), + attrs: array![].span() + }) +, + + dojo::database::schema::serialize_member(@dojo::database::schema::Member { + name: 'y', + ty: dojo::database::schema::Ty::Primitive('u32'), + attrs: array![].span() + }) +, + + dojo::database::schema::serialize_member(@dojo::database::schema::Member { + name: 'z', + ty: dojo::database::schema::Ty::Primitive('u8'), + attrs: array![].span() + }) +].span() + }) + } + } +impl PositionCopy of Copy::; +impl PositionDrop of Drop::; +impl PositionSerde of Serde:: { + fn serialize(self: @Position, ref output: array::Array) { + serde::Serde::serialize(self.id, ref output); + serde::Serde::serialize(self.v, ref output) + } + fn deserialize(ref serialized: array::Span) -> Option { + Option::Some(Position { + id: serde::Serde::deserialize(ref serialized)?, + v: serde::Serde::deserialize(ref serialized)?, + }) + } +} + + impl PositionModel of dojo::model::Model { + #[inline(always)] + fn name(self: @Position) -> felt252 { + 'Position' + } + + #[inline(always)] + fn keys(self: @Position) -> Span { + let mut serialized = ArrayTrait::new(); + array::ArrayTrait::append(ref serialized, *self.id); + array::ArrayTrait::span(@serialized) + } + + #[inline(always)] + fn values(self: @Position) -> Span { + let mut serialized = ArrayTrait::new(); + serde::Serde::serialize(self.v, ref serialized); + array::ArrayTrait::span(@serialized) + } + + #[inline(always)] + fn layout(self: @Position) -> Span { + let mut layout = ArrayTrait::new(); + dojo::database::schema::SchemaIntrospection::::layout(ref layout); + array::ArrayTrait::span(@layout) + } + + #[inline(always)] + fn packed_size(self: @Position) -> usize { + let mut layout = self.layout(); + dojo::packing::calculate_packed_size(ref layout) + } + } + + + impl PositionSchemaIntrospection of dojo::database::schema::SchemaIntrospection { + + #[inline(always)] + fn size() -> usize { + dojo::database::schema::SchemaIntrospection::::size() + } + + #[inline(always)] + fn layout(ref layout: Array) { + dojo::database::schema::SchemaIntrospection::::layout(ref layout); + + } + + #[inline(always)] + fn ty() -> dojo::database::schema::Ty { + + dojo::database::schema::Ty::Struct(dojo::database::schema::Struct { + name: 'Position', + attrs: array![].span(), + children: array![ + dojo::database::schema::serialize_member(@dojo::database::schema::Member { + name: 'id', + ty: dojo::database::schema::Ty::Primitive('felt252'), + attrs: array!['key'].span() + }) +, + + dojo::database::schema::serialize_member(@dojo::database::schema::Member { + name: 'v', + ty: dojo::database::schema::SchemaIntrospection::::ty(), + attrs: array![].span() + }) +].span() + }) + } + } + + + #[starknet::interface] + trait IPosition { + fn name(self: @T) -> felt252; + } + + #[starknet::contract] + mod position { + use super::Position; + + #[storage] + struct Storage {} + + #[external(v0)] + fn name(self: @ContractState) -> felt252 { + 'Position' + } + + #[external(v0)] + fn unpacked_size(self: @ContractState) -> usize { + dojo::database::schema::SchemaIntrospection::::size() + } + + #[external(v0)] + fn packed_size(self: @ContractState) -> usize { + let mut layout = ArrayTrait::new(); + dojo::database::schema::SchemaIntrospection::::layout(ref layout); + let mut layout_span = layout.span(); + dojo::packing::calculate_packed_size(ref layout_span) + } + + #[external(v0)] + fn layout(self: @ContractState) -> Span { + let mut layout = ArrayTrait::new(); + dojo::database::schema::SchemaIntrospection::::layout(ref layout); + array::ArrayTrait::span(@layout) + } + + #[external(v0)] + fn schema(self: @ContractState) -> dojo::database::schema::Ty { + dojo::database::schema::SchemaIntrospection::::ty() + } + } +impl RolesSerde of Serde:: { + fn serialize(self: @Roles, ref output: array::Array) { + serde::Serde::serialize(self.role_ids, ref output) + } + fn deserialize(ref serialized: array::Span) -> Option { + Option::Some(Roles { + role_ids: serde::Serde::deserialize(ref serialized)?, + }) + } +} + + impl RolesModel of dojo::model::Model { + #[inline(always)] + fn name(self: @Roles) -> felt252 { + 'Roles' + } + + #[inline(always)] + fn keys(self: @Roles) -> Span { + let mut serialized = ArrayTrait::new(); + + array::ArrayTrait::span(@serialized) + } + + #[inline(always)] + fn values(self: @Roles) -> Span { + let mut serialized = ArrayTrait::new(); + serde::Serde::serialize(self.role_ids, ref serialized); + array::ArrayTrait::span(@serialized) + } + + #[inline(always)] + fn layout(self: @Roles) -> Span { + let mut layout = ArrayTrait::new(); + dojo::database::schema::SchemaIntrospection::::layout(ref layout); + array::ArrayTrait::span(@layout) + } + + #[inline(always)] + fn packed_size(self: @Roles) -> usize { + let mut layout = self.layout(); + dojo::packing::calculate_packed_size(ref layout) + } + } + + + impl RolesSchemaIntrospection of dojo::database::schema::SchemaIntrospection { + + #[inline(always)] + fn size() -> usize { + dojo::database::schema::SchemaIntrospection::>::size() + } + + #[inline(always)] + fn layout(ref layout: Array) { + dojo::database::schema::SchemaIntrospection::>::layout(ref layout); + + } + + #[inline(always)] + fn ty() -> dojo::database::schema::Ty { + + dojo::database::schema::Ty::Struct(dojo::database::schema::Struct { + name: 'Roles', + attrs: array![].span(), + children: array![ + dojo::database::schema::serialize_member(@dojo::database::schema::Member { + name: 'role_ids', + ty: dojo::database::schema::SchemaIntrospection::>::ty(), + attrs: array![].span() + }) +].span() + }) + } + } + + + #[starknet::interface] + trait IRoles { + fn name(self: @T) -> felt252; + } + + #[starknet::contract] + mod roles { + use super::Roles; + + #[storage] + struct Storage {} + + #[external(v0)] + fn name(self: @ContractState) -> felt252 { + 'Roles' + } + + #[external(v0)] + fn unpacked_size(self: @ContractState) -> usize { + dojo::database::schema::SchemaIntrospection::::size() + } + + #[external(v0)] + fn packed_size(self: @ContractState) -> usize { + let mut layout = ArrayTrait::new(); + dojo::database::schema::SchemaIntrospection::::layout(ref layout); + let mut layout_span = layout.span(); + dojo::packing::calculate_packed_size(ref layout_span) + } + + #[external(v0)] + fn layout(self: @ContractState) -> Span { + let mut layout = ArrayTrait::new(); + dojo::database::schema::SchemaIntrospection::::layout(ref layout); + array::ArrayTrait::span(@layout) + } + + #[external(v0)] + fn schema(self: @ContractState) -> dojo::database::schema::Ty { + dojo::database::schema::SchemaIntrospection::::ty() + } + } +impl PlayerCopy of Copy::; +impl PlayerDrop of Drop::; +impl PlayerSerde of Serde:: { + fn serialize(self: @Player, ref output: array::Array) { + serde::Serde::serialize(self.game, ref output); + serde::Serde::serialize(self.player, ref output); + serde::Serde::serialize(self.name, ref output) + } + fn deserialize(ref serialized: array::Span) -> Option { + Option::Some(Player { + game: serde::Serde::deserialize(ref serialized)?, + player: serde::Serde::deserialize(ref serialized)?, + name: serde::Serde::deserialize(ref serialized)?, + }) + } +} + + impl PlayerModel of dojo::model::Model { + #[inline(always)] + fn name(self: @Player) -> felt252 { + 'Player' + } + + #[inline(always)] + fn keys(self: @Player) -> Span { + let mut serialized = ArrayTrait::new(); + array::ArrayTrait::append(ref serialized, *self.game);serde::Serde::serialize(self.player, ref serialized); + array::ArrayTrait::span(@serialized) + } + + #[inline(always)] + fn values(self: @Player) -> Span { + let mut serialized = ArrayTrait::new(); + array::ArrayTrait::append(ref serialized, *self.name); + array::ArrayTrait::span(@serialized) + } + + #[inline(always)] + fn layout(self: @Player) -> Span { + let mut layout = ArrayTrait::new(); + dojo::database::schema::SchemaIntrospection::::layout(ref layout); + array::ArrayTrait::span(@layout) + } + + #[inline(always)] + fn packed_size(self: @Player) -> usize { + let mut layout = self.layout(); + dojo::packing::calculate_packed_size(ref layout) + } + } + + + impl PlayerSchemaIntrospection of dojo::database::schema::SchemaIntrospection { + + #[inline(always)] + fn size() -> usize { + 1 + } + + #[inline(always)] + fn layout(ref layout: Array) { + layout.append(251); + + } + + #[inline(always)] + fn ty() -> dojo::database::schema::Ty { + + dojo::database::schema::Ty::Struct(dojo::database::schema::Struct { + name: 'Player', + attrs: array![].span(), + children: array![ + dojo::database::schema::serialize_member(@dojo::database::schema::Member { + name: 'game', + ty: dojo::database::schema::Ty::Primitive('felt252'), + attrs: array!['key'].span() + }) +, + + dojo::database::schema::serialize_member(@dojo::database::schema::Member { + name: 'player', + ty: dojo::database::schema::Ty::Primitive('ContractAddress'), + attrs: array!['key'].span() + }) +, + + dojo::database::schema::serialize_member(@dojo::database::schema::Member { + name: 'name', + ty: dojo::database::schema::Ty::Primitive('felt252'), + attrs: array![].span() + }) +].span() + }) + } + } + + + #[starknet::interface] + trait IPlayer { + fn name(self: @T) -> felt252; + } + + #[starknet::contract] + mod player { + use super::Player; + + #[storage] + struct Storage {} + + #[external(v0)] + fn name(self: @ContractState) -> felt252 { + 'Player' + } + + #[external(v0)] + fn unpacked_size(self: @ContractState) -> usize { + dojo::database::schema::SchemaIntrospection::::size() + } + + #[external(v0)] + fn packed_size(self: @ContractState) -> usize { + let mut layout = ArrayTrait::new(); + dojo::database::schema::SchemaIntrospection::::layout(ref layout); + let mut layout_span = layout.span(); + dojo::packing::calculate_packed_size(ref layout_span) + } + + #[external(v0)] + fn layout(self: @ContractState) -> Span { + let mut layout = ArrayTrait::new(); + dojo::database::schema::SchemaIntrospection::::layout(ref layout); + array::ArrayTrait::span(@layout) + } + + #[external(v0)] + fn schema(self: @ContractState) -> dojo::database::schema::Ty { + dojo::database::schema::SchemaIntrospection::::ty() + } + } diff --git a/crates/dojo-lang/src/plugin_test_data/print b/crates/dojo-lang/src/plugin_test_data/print index cf138de450..f8611ec183 100644 --- a/crates/dojo-lang/src/plugin_test_data/print +++ b/crates/dojo-lang/src/plugin_test_data/print @@ -97,3 +97,74 @@ impl PlayerPrintImpl of debug::PrintTrait { } //! > expected_diagnostics + +//! > expanded_cairo_code +use serde::Serde; + +#[derive(Print, Copy, Drop, Serde)] +struct Position { + #[key] + id: felt252, + + x: felt252, + y: felt252 +} + +#[derive(Print, Serde)] +struct Roles { + role_ids: Array +} + +use starknet::ContractAddress; + +#[derive(Print, Copy, Drop, Serde)] +struct Player { + #[key] + game: felt252, + #[key] + player: ContractAddress, + + name: felt252, +} +impl PositionCopy of Copy::; +impl PositionDrop of Drop::; +impl PositionSerde of Serde:: { + fn serialize(self: @Position, ref output: array::Array) { + serde::Serde::serialize(self.id, ref output); + serde::Serde::serialize(self.x, ref output); + serde::Serde::serialize(self.y, ref output) + } + fn deserialize(ref serialized: array::Span) -> Option { + Option::Some(Position { + id: serde::Serde::deserialize(ref serialized)?, + x: serde::Serde::deserialize(ref serialized)?, + y: serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl RolesSerde of Serde:: { + fn serialize(self: @Roles, ref output: array::Array) { + serde::Serde::serialize(self.role_ids, ref output) + } + fn deserialize(ref serialized: array::Span) -> Option { + Option::Some(Roles { + role_ids: serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl PlayerCopy of Copy::; +impl PlayerDrop of Drop::; +impl PlayerSerde of Serde:: { + fn serialize(self: @Player, ref output: array::Array) { + serde::Serde::serialize(self.game, ref output); + serde::Serde::serialize(self.player, ref output); + serde::Serde::serialize(self.name, ref output) + } + fn deserialize(ref serialized: array::Span) -> Option { + Option::Some(Player { + game: serde::Serde::deserialize(ref serialized)?, + player: serde::Serde::deserialize(ref serialized)?, + name: serde::Serde::deserialize(ref serialized)?, + }) + } +} diff --git a/crates/dojo-lang/src/plugin_test_data/system b/crates/dojo-lang/src/plugin_test_data/system index ac7947b7aa..3527678e30 100644 --- a/crates/dojo-lang/src/plugin_test_data/system +++ b/crates/dojo-lang/src/plugin_test_data/system @@ -141,3 +141,187 @@ mod ctxnamed { } //! > expected_diagnostics +error: Unsupported attribute. + --> test_src/lib.cairo[spawn]:2:17 + #[starknet::contract] + ^*******************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[proxy]:2:17 + #[starknet::contract] + ^*******************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[ctxnamed]:2:17 + #[starknet::contract] + ^*******************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[spawn]:8:21 + #[storage] + ^********^ + +error: Unsupported attribute. + --> test_src/lib.cairo[spawn]:13:21 + #[external(v0)] + ^*************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[spawn]:18:21 + #[external(v0)] + ^*************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[spawn]:32:17 + #[external(v0)] + ^*************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[proxy]:8:21 + #[storage] + ^********^ + +error: Unsupported attribute. + --> test_src/lib.cairo[proxy]:13:21 + #[external(v0)] + ^*************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[proxy]:18:21 + #[external(v0)] + ^*************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[proxy]:30:17 + #[external(v0)] + ^*************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[ctxnamed]:8:21 + #[storage] + ^********^ + +error: Unsupported attribute. + --> test_src/lib.cairo[ctxnamed]:13:21 + #[external(v0)] + ^*************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[ctxnamed]:18:21 + #[external(v0)] + ^*************^ + +error: Unsupported attribute. + --> test_src/lib.cairo[ctxnamed]:32:17 + #[external(v0)] + ^*************^ + +//! > expanded_cairo_code +#[starknet::contract] + mod spawn { + use dojo::world; + use dojo::world::IWorldDispatcher; + use dojo::world::IWorldDispatcherTrait; + + #[storage] + struct Storage { + world_dispatcher: IWorldDispatcher, + } + + #[external(v0)] + fn name(self: @ContractState) -> felt252 { + 'spawn' + } + + #[external(v0)] + impl Upgradeable of dojo::upgradable::IUpgradeable { + fn upgrade(ref self: ContractState, new_class_hash: starknet::ClassHash) { + let caller = starknet::get_caller_address(); + assert( + self.world_dispatcher.read().contract_address == caller, 'only World can upgrade' + ); + dojo::upgradable::UpgradeableTrait::upgrade(new_class_hash); + } + } + + use traits::Into; + use dojo::world::Context; + + #[external(v0)] + fn execute(self: @ContractState, ctx: Context, name: felt252) { + return (); + } + + } + + #[starknet::contract] + mod proxy { + use dojo::world; + use dojo::world::IWorldDispatcher; + use dojo::world::IWorldDispatcherTrait; + + #[storage] + struct Storage { + world_dispatcher: IWorldDispatcher, + } + + #[external(v0)] + fn name(self: @ContractState) -> felt252 { + 'proxy' + } + + #[external(v0)] + impl Upgradeable of dojo::upgradable::IUpgradeable { + fn upgrade(ref self: ContractState, new_class_hash: starknet::ClassHash) { + let caller = starknet::get_caller_address(); + assert( + self.world_dispatcher.read().contract_address == caller, 'only World can upgrade' + ); + dojo::upgradable::UpgradeableTrait::upgrade(new_class_hash); + } + } + + + #[external(v0)] + fn execute(self: @ContractState, value: felt252) -> felt252 { + value + } + + } + + #[starknet::contract] + mod ctxnamed { + use dojo::world; + use dojo::world::IWorldDispatcher; + use dojo::world::IWorldDispatcherTrait; + + #[storage] + struct Storage { + world_dispatcher: IWorldDispatcher, + } + + #[external(v0)] + fn name(self: @ContractState) -> felt252 { + 'ctxnamed' + } + + #[external(v0)] + impl Upgradeable of dojo::upgradable::IUpgradeable { + fn upgrade(ref self: ContractState, new_class_hash: starknet::ClassHash) { + let caller = starknet::get_caller_address(); + assert( + self.world_dispatcher.read().contract_address == caller, 'only World can upgrade' + ); + dojo::upgradable::UpgradeableTrait::upgrade(new_class_hash); + } + } + + use traits::Into; + use dojo::world::Context; + + #[external(v0)] + fn execute(self: @ContractState, ctx2: Context, name: felt252) { + return (); + } + + } diff --git a/crates/dojo-lang/src/print.rs b/crates/dojo-lang/src/print.rs index 0506fa368c..a4dd13c112 100644 --- a/crates/dojo-lang/src/print.rs +++ b/crates/dojo-lang/src/print.rs @@ -31,7 +31,7 @@ pub fn derive_print(db: &dyn SyntaxGroup, struct_ast: ItemStruct) -> RewriteNode $print$ } }", - UnorderedHashMap::from([ + &UnorderedHashMap::from([ ( "type_name".to_string(), RewriteNode::new_trimmed(struct_ast.name(db).as_syntax_node()), diff --git a/crates/dojo-lang/src/semantics/test_utils.rs b/crates/dojo-lang/src/semantics/test_utils.rs index de4bddb053..ad74412d33 100644 --- a/crates/dojo-lang/src/semantics/test_utils.rs +++ b/crates/dojo-lang/src/semantics/test_utils.rs @@ -23,7 +23,7 @@ use cairo_lang_syntax::node::db::{SyntaxDatabase, SyntaxGroup}; use cairo_lang_utils::ordered_hash_map::OrderedHashMap; use cairo_lang_utils::{extract_matches, OptionFrom, Upcast}; use camino::Utf8PathBuf; -use dojo_test_utils::compiler::get_test_corelib; +use dojo_test_utils::compiler::corelib; use once_cell::sync::Lazy; use crate::inline_macros::emit::EmitMacro; @@ -59,7 +59,7 @@ impl DojoSemanticDatabase { db.set_inline_macro_plugins(inline_plugins.into()); - init_dev_corelib(&mut db, get_test_corelib()); + init_dev_corelib(&mut db, corelib()); let dojo_path = Utf8PathBuf::from_path_buf("../../crates/dojo-core/src".into()).unwrap(); let dojo_path: PathBuf = dojo_path.canonicalize_utf8().unwrap().into(); let core_crate = db.intern_crate(CrateLongId::Real("dojo".into())); diff --git a/crates/dojo-lang/src/semantics/tests.rs b/crates/dojo-lang/src/semantics/tests.rs index d4cf9e3f7e..604c87e6d0 100644 --- a/crates/dojo-lang/src/semantics/tests.rs +++ b/crates/dojo-lang/src/semantics/tests.rs @@ -3,6 +3,7 @@ use cairo_lang_semantic::db::SemanticGroup; use cairo_lang_semantic::expr::fmt::ExprFormatter; use cairo_lang_semantic::test_utils::setup_test_expr; use cairo_lang_semantic::Expr; +use cairo_lang_test_utils::parse_test_file::TestRunnerResult; use cairo_lang_test_utils::test_file_test; use cairo_lang_utils::ordered_hash_map::OrderedHashMap; @@ -22,25 +23,11 @@ test_file_test!( pub fn test_semantics( inputs: &OrderedHashMap, _args: &OrderedHashMap, -) -> Result, String> { +) -> TestRunnerResult { let mut db = DojoSemanticDatabase::default(); let (expr, diagnostics, expr_formatter) = semantics_test_setup(inputs, &mut db); - if inputs.get("no_diagnostics").is_some() && "" != diagnostics.as_str() { - return Err("Expanded get!() shouldn't have diagnostic issues.".into()); - } - - if let Some(dojo_semantic) = inputs.get("dojo_semantic") { - if dojo_semantic.as_str() == "get_success" { - if let Expr::Block(blk) = &expr { - blk.tail.expect("Expanded get!() should have a tail"); - } else { - return Err("Expression should be block".into()); - } - } - } - - Ok(OrderedHashMap::from([ + TestRunnerResult::success(OrderedHashMap::from([ ("expected".into(), format!("{:#?}", expr.debug(&expr_formatter))), ("semantic_diagnostics".into(), diagnostics), ])) diff --git a/crates/dojo-language-server/Cargo.toml b/crates/dojo-language-server/Cargo.toml index d62ad3b71a..c3a8a7d99b 100644 --- a/crates/dojo-language-server/Cargo.toml +++ b/crates/dojo-language-server/Cargo.toml @@ -16,6 +16,7 @@ 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-test-runner.workspace = true cairo-lang-utils.workspace = true clap.workspace = true diff --git a/crates/dojo-language-server/src/bin/language_server.rs b/crates/dojo-language-server/src/bin/language_server.rs index 48b07d6f9e..d9a78c4316 100644 --- a/crates/dojo-language-server/src/bin/language_server.rs +++ b/crates/dojo-language-server/src/bin/language_server.rs @@ -5,7 +5,7 @@ use cairo_lang_filesystem::cfg::{Cfg, CfgSet}; use cairo_lang_language_server::Backend; use cairo_lang_starknet::inline_macros::selector::SelectorMacro; use cairo_lang_starknet::plugin::StarkNetPlugin; -use cairo_lang_test_runner::plugin::TestPlugin; +use cairo_lang_test_plugin::TestPlugin; use cairo_lang_utils::logging::init_logging; use clap::Parser; use dojo_lang::inline_macros::emit::EmitMacro; @@ -34,9 +34,9 @@ async fn main() { let db = RootDatabase::builder() .with_cfg(CfgSet::from_iter([Cfg::name("test")])) - .with_macro_plugin(Arc::new(TestPlugin::default())) .with_macro_plugin(Arc::new(BuiltinDojoPlugin)) .with_macro_plugin(Arc::new(StarkNetPlugin::default())) + .with_macro_plugin(Arc::new(TestPlugin::default())) .with_inline_macro_plugin(EmitMacro::NAME, Arc::new(EmitMacro)) .with_inline_macro_plugin(GetMacro::NAME, Arc::new(GetMacro)) .with_inline_macro_plugin(SetMacro::NAME, Arc::new(SetMacro)) diff --git a/crates/dojo-primitives/Scarb.lock b/crates/dojo-primitives/Scarb.lock new file mode 100644 index 0000000000..6e779d4e2d --- /dev/null +++ b/crates/dojo-primitives/Scarb.lock @@ -0,0 +1,20 @@ +# Code generated by scarb DO NOT EDIT. +version = 1 + +[[package]] +name = "dojo" +version = "0.3.1" +dependencies = [ + "dojo_plugin", +] + +[[package]] +name = "dojo_plugin" +version = "0.3.1" + +[[package]] +name = "dojo_primitives" +version = "0.3.1" +dependencies = [ + "dojo", +] diff --git a/crates/dojo-primitives/Scarb.toml b/crates/dojo-primitives/Scarb.toml index 29d29a7571..5cd35a59da 100644 --- a/crates/dojo-primitives/Scarb.toml +++ b/crates/dojo-primitives/Scarb.toml @@ -1,5 +1,5 @@ [package] -cairo-version = "2.2.0" +cairo-version = "2.3.0" description = "Implementations of common primitives for the Dojo games" name = "dojo_primitives" version = "0.3.1" diff --git a/crates/dojo-test-utils/build.rs b/crates/dojo-test-utils/build.rs index 60efa28ba3..e26a8409cc 100644 --- a/crates/dojo-test-utils/build.rs +++ b/crates/dojo-test-utils/build.rs @@ -4,10 +4,10 @@ fn main() { use camino::{Utf8Path, Utf8PathBuf}; use dojo_lang::compiler::DojoCompiler; - use dojo_lang::plugin::CairoPluginRepository; + use dojo_lang::plugin::{BuiltinDojoPlugin, CairoPluginRepository}; use scarb::compiler::CompilerRepository; - use scarb::core::Config; - use scarb::ops; + use scarb::core::{Config, TargetKind}; + use scarb::ops::{self, CompileOpts}; use scarb_ui::Verbosity; let project_paths = @@ -37,12 +37,18 @@ fn main() { .log_filter_directive(env::var_os("SCARB_LOG")) .compilers(compilers) .cairo_plugins(cairo_plugins.into()) + .custom_source_patches(vec![BuiltinDojoPlugin::manifest_dependency()]) .build() .unwrap(); let ws = ops::read_workspace(config.manifest_path(), &config).unwrap(); let packages = ws.members().map(|p| p.id).collect(); - ops::compile(packages, &ws).unwrap(); + ops::compile( + packages, + CompileOpts { include_targets: vec![], exclude_targets: vec![TargetKind::TEST] }, + &ws, + ) + .unwrap(); } } diff --git a/crates/dojo-test-utils/src/compiler.rs b/crates/dojo-test-utils/src/compiler.rs index c0ce78eb11..d5d9b60974 100644 --- a/crates/dojo-test-utils/src/compiler.rs +++ b/crates/dojo-test-utils/src/compiler.rs @@ -4,7 +4,7 @@ use std::path::PathBuf; use assert_fs::TempDir; use camino::{Utf8Path, Utf8PathBuf}; use dojo_lang::compiler::DojoCompiler; -use dojo_lang::plugin::CairoPluginRepository; +use dojo_lang::plugin::{BuiltinDojoPlugin, CairoPluginRepository}; use scarb::compiler::CompilerRepository; use scarb::core::Config; use scarb::ops; @@ -18,19 +18,22 @@ pub fn build_test_config(path: &str) -> anyhow::Result { let cache_dir = TempDir::new().unwrap(); let config_dir = TempDir::new().unwrap(); + let target_dir = TempDir::new().unwrap(); let path = Utf8PathBuf::from_path_buf(path.into()).unwrap(); Config::builder(path.canonicalize_utf8().unwrap()) .global_cache_dir_override(Some(Utf8Path::from_path(cache_dir.path()).unwrap())) .global_config_dir_override(Some(Utf8Path::from_path(config_dir.path()).unwrap())) + .target_dir_override(Some(Utf8Path::from_path(target_dir.path()).unwrap().to_path_buf())) .ui_verbosity(Verbosity::Verbose) + .custom_source_patches(vec![BuiltinDojoPlugin::manifest_dependency()]) .log_filter_directive(env::var_os("SCARB_LOG")) .compilers(compilers) .cairo_plugins(cairo_plugins.into()) .build() } -pub fn get_test_corelib() -> PathBuf { +pub fn corelib() -> PathBuf { let config = build_test_config("./src/manifest_test_data/spawn-and-move/Scarb.toml").unwrap(); let ws = ops::read_workspace(config.manifest_path(), &config).unwrap(); let resolve = ops::resolve_workspace(&ws).unwrap(); diff --git a/crates/dojo-world/Cargo.toml b/crates/dojo-world/Cargo.toml index 993e6c79ac..a250f1545d 100644 --- a/crates/dojo-world/Cargo.toml +++ b/crates/dojo-world/Cargo.toml @@ -27,7 +27,7 @@ tracing.workspace = true dojo-types = { path = "../dojo-types", optional = true } http = { version = "0.2.9", optional = true } ipfs-api-backend-hyper = { git = "https://github.com/ferristseng/rust-ipfs-api", rev = "af2c17f7b19ef5b9898f458d97a90055c3605633", features = [ "with-hyper-rustls" ], optional = true } -scarb = { git = "https://github.com/software-mansion/scarb", rev = "7adb7fd", optional = true } +scarb = { git = "https://github.com/software-mansion/scarb", rev = "f306f9a", optional = true } tokio = { version = "1.32.0", features = [ "time" ], default-features = false, optional = true } url = { version = "2.2.2", optional = true } diff --git a/crates/dojo-world/src/contracts/model_test.rs b/crates/dojo-world/src/contracts/model_test.rs index c191febd19..b1aac76302 100644 --- a/crates/dojo-world/src/contracts/model_test.rs +++ b/crates/dojo-world/src/contracts/model_test.rs @@ -62,7 +62,7 @@ async fn test_model() { assert_eq!( position.class_hash(), FieldElement::from_hex_be( - "0x06ffc643cbc4b2fb9c424242b18175a5e142269b45f4463d1cd4dddb7a2e5095" + "0x06f8b85d1f68eab7612e3f4ea178c6386cedb30a6925c9f662a251c640b86d96" ) .unwrap() ); diff --git a/crates/dojo-world/src/manifest.rs b/crates/dojo-world/src/manifest.rs index 0782a3403f..f6e1ad9028 100644 --- a/crates/dojo-world/src/manifest.rs +++ b/crates/dojo-world/src/manifest.rs @@ -128,7 +128,7 @@ impl Manifest { /// Load the manifest from a file at the given path. pub fn load_from_path(path: impl AsRef) -> Result { let file = fs::File::open(path)?; - Ok(serde_json::from_reader(file)?) + Ok(Self::try_from(file)?) } /// Writes the manifest into a file at the given path. Will return error if the file doesn't @@ -204,6 +204,20 @@ impl Manifest { } } +impl TryFrom for Manifest { + type Error = serde_json::Error; + fn try_from(file: std::fs::File) -> Result { + serde_json::from_reader(std::io::BufReader::new(file)) + } +} + +impl TryFrom<&std::fs::File> for Manifest { + type Error = serde_json::Error; + fn try_from(file: &std::fs::File) -> Result { + serde_json::from_reader(std::io::BufReader::new(file)) + } +} + async fn get_remote_models_and_contracts( world: FieldElement, provider: P, diff --git a/crates/katana/core/Cargo.toml b/crates/katana/core/Cargo.toml index ca42d54c28..ce8994164f 100644 --- a/crates/katana/core/Cargo.toml +++ b/crates/katana/core/Cargo.toml @@ -10,8 +10,8 @@ version.workspace = true anyhow.workspace = true async-trait.workspace = true blockifier.workspace = true -cairo-lang-casm = "2.2.0" -cairo-lang-starknet = "2.2.0" +cairo-lang-casm = "2.3.0" +cairo-lang-starknet = "2.3.0" cairo-vm.workspace = true convert_case.workspace = true ethers = { version = "2.0.8", optional = true } diff --git a/crates/katana/rpc/Cargo.toml b/crates/katana/rpc/Cargo.toml index 3ad2feb3d3..110afdab8d 100644 --- a/crates/katana/rpc/Cargo.toml +++ b/crates/katana/rpc/Cargo.toml @@ -9,7 +9,7 @@ version.workspace = true [dependencies] anyhow.workspace = true blockifier.workspace = true -cairo-lang-starknet = "2.2.0" +cairo-lang-starknet = "2.3.0" cairo-vm.workspace = true flate2.workspace = true futures.workspace = true diff --git a/crates/sozo/Cargo.toml b/crates/sozo/Cargo.toml index 4bebf94dd9..0044f5e68d 100644 --- a/crates/sozo/Cargo.toml +++ b/crates/sozo/Cargo.toml @@ -16,6 +16,7 @@ cairo-lang-project.workspace = true cairo-lang-sierra-to-casm.workspace = true cairo-lang-sierra.workspace = true cairo-lang-starknet.workspace = true +cairo-lang-test-plugin.workspace = true cairo-lang-test-runner.workspace = true camino.workspace = true clap-verbosity-flag = "2.0.1" diff --git a/crates/sozo/src/commands/build.rs b/crates/sozo/src/commands/build.rs index f9541762ed..860978b49d 100644 --- a/crates/sozo/src/commands/build.rs +++ b/crates/sozo/src/commands/build.rs @@ -1,7 +1,7 @@ use anyhow::Result; use clap::Args; -use scarb::core::Config; -use scarb::ops; +use scarb::core::{Config, TargetKind}; +use scarb::ops::{self, CompileOpts}; #[derive(Args, Debug)] pub struct BuildArgs; @@ -10,6 +10,10 @@ impl BuildArgs { pub fn run(self, config: &Config) -> Result<()> { let ws = scarb::ops::read_workspace(config.manifest_path(), config)?; let packages = ws.members().map(|p| p.id).collect(); - ops::compile(packages, &ws) + ops::compile( + packages, + CompileOpts { include_targets: vec![], exclude_targets: vec![TargetKind::TEST] }, + &ws, + ) } } diff --git a/crates/sozo/src/commands/events.rs b/crates/sozo/src/commands/events.rs index 2410e0b8d0..50592f565e 100644 --- a/crates/sozo/src/commands/events.rs +++ b/crates/sozo/src/commands/events.rs @@ -1,12 +1,11 @@ use std::collections::HashMap; use anyhow::{anyhow, Result}; -use cairo_lang_starknet::abi::{self, Event, Item}; +use cairo_lang_starknet::abi::{self, Event}; use clap::Parser; use dojo_world::manifest::Manifest; use dojo_world::metadata::dojo_metadata_from_workspace; use scarb::core::Config; -use starknet::core::utils::starknet_keccak; use super::options::starknet::StarknetOptions; use super::options::world::WorldOptions; @@ -47,7 +46,7 @@ pub struct EventsArgs { impl EventsArgs { pub fn run(self, config: &Config) -> Result<()> { - let target_dir = config.target_dir().path_existent().unwrap(); + let target_dir = config.target_dir_override().unwrap(); let manifest_path = target_dir.join(config.profile().as_str()).join("manifest.json"); if !manifest_path.exists() { @@ -69,22 +68,22 @@ impl EventsArgs { } fn extract_events(manifest: &Manifest) -> HashMap> { - fn inner_helper(events: &mut HashMap>, contract: &Option) { - if let Some(contract) = contract { - for item in &contract.items { - if let Item::Event(e) = item { - match e.kind { - abi::EventKind::Struct { .. } => { - let event_name = - starknet_keccak(e.name.split("::").last().unwrap().as_bytes()); - let vec = events.entry(event_name.to_string()).or_default(); - vec.push(e.clone()); - } - abi::EventKind::Enum { .. } => (), - } - } - } - } + fn inner_helper(_events: &mut HashMap>, _contract: &Option) { + // if let Some(contract) = contract { + // for item in &contract.items { + // if let Item::Event(e) = item { + // match e.kind { + // abi::EventKind::Struct { .. } => { + // let event_name = + // starknet_keccak(e.name.split("::").last().unwrap().as_bytes()); + // let vec = events.entry(event_name.to_string()).or_default(); + // vec.push(e.clone()); + // } + // abi::EventKind::Enum { .. } => (), + // } + // } + // } + // } } let mut events_map = HashMap::new(); diff --git a/crates/sozo/src/commands/migrate.rs b/crates/sozo/src/commands/migrate.rs index 4e20cee5c2..a37e578fa2 100644 --- a/crates/sozo/src/commands/migrate.rs +++ b/crates/sozo/src/commands/migrate.rs @@ -1,6 +1,7 @@ use anyhow::Result; use clap::Args; -use scarb::core::Config; +use scarb::core::{Config, TargetKind}; +use scarb::ops::CompileOpts; use super::options::account::AccountOptions; use super::options::starknet::StarknetOptions; @@ -49,7 +50,11 @@ impl MigrateArgs { if !target_dir.join("manifest.json").exists() { let packages = ws.members().map(|p| p.id).collect(); - scarb::ops::compile(packages, &ws)?; + scarb::ops::compile( + packages, + CompileOpts { include_targets: vec![], exclude_targets: vec![TargetKind::TEST] }, + &ws, + )?; } // TODO: Check the updated scarb way to read profile specific values diff --git a/crates/sozo/src/commands/test.rs b/crates/sozo/src/commands/test.rs index a01f103109..391a484380 100644 --- a/crates/sozo/src/commands/test.rs +++ b/crates/sozo/src/commands/test.rs @@ -10,8 +10,8 @@ use cairo_lang_filesystem::cfg::{Cfg, CfgSet}; use cairo_lang_filesystem::ids::Directory; use cairo_lang_starknet::inline_macros::selector::SelectorMacro; use cairo_lang_starknet::plugin::StarkNetPlugin; -use cairo_lang_test_runner::plugin::TestPlugin; -use cairo_lang_test_runner::TestRunner; +use cairo_lang_test_plugin::TestPlugin; +use cairo_lang_test_runner::{CompiledTestRunner, TestCompiler, TestRunConfig}; use clap::Args; use dojo_lang::compiler::{collect_core_crate_ids, collect_external_crate_ids, Props}; use dojo_lang::inline_macros::emit::EmitMacro; @@ -68,15 +68,14 @@ impl TestArgs { bail!("failed to compile"); } - let runner = TestRunner { - db, - main_crate_ids, - test_crate_ids, + let config = TestRunConfig { filter: self.filter.clone(), - include_ignored: self.include_ignored, ignored: self.ignored, - starknet: true, + include_ignored: self.include_ignored, }; + + let compiler = TestCompiler { db, main_crate_ids, test_crate_ids, starknet: true }; + let runner = CompiledTestRunner { compiled: compiler.build()?, config }; runner.run()?; println!(); diff --git a/crates/sozo/src/main.rs b/crates/sozo/src/main.rs index 93ec26d3ee..46f50ab274 100644 --- a/crates/sozo/src/main.rs +++ b/crates/sozo/src/main.rs @@ -6,7 +6,7 @@ use anyhow::Result; use camino::Utf8PathBuf; use clap::Parser; use dojo_lang::compiler::DojoCompiler; -use dojo_lang::plugin::CairoPluginRepository; +use dojo_lang::plugin::{BuiltinDojoPlugin, CairoPluginRepository}; use scarb::compiler::CompilerRepository; use scarb::core::{Config, TomlManifest}; use scarb_ui::{OutputFormat, Ui}; @@ -42,6 +42,7 @@ fn cli_main(args: SozoArgs) -> Result<()> { .profile(args.profile_spec.determine()?) .offline(args.offline) .cairo_plugins(cairo_plugins.into()) + .custom_source_patches(vec![BuiltinDojoPlugin::manifest_dependency()]) .ui_verbosity(args.ui_verbosity()) .compilers(compilers) .build()?; diff --git a/crates/torii/client/wasm/Cargo.lock b/crates/torii/client/wasm/Cargo.lock index f1adcf4d71..ef760d4069 100644 --- a/crates/torii/client/wasm/Cargo.lock +++ b/crates/torii/client/wasm/Cargo.lock @@ -30,9 +30,9 @@ dependencies = [ [[package]] name = "ahash" -version = "0.7.6" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +checksum = "5a824f2aa7e75a0c98c5a504fceb80649e9c35265d44525b5f94de4771a395cd" dependencies = [ "getrandom", "once_cell", @@ -41,13 +41,14 @@ dependencies = [ [[package]] name = "ahash" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +checksum = "cd7d5a2cecb58716e47d67d5703a249964b14c7be1ec3cad3affc295b2d1c35d" dependencies = [ "cfg-if", "once_cell", "version_check", + "zerocopy", ] [[package]] @@ -345,9 +346,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.4" +version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" [[package]] name = "bigdecimal" @@ -448,9 +449,9 @@ dependencies = [ [[package]] name = "cairo-lang-casm" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc7f7cb89bc3f52c2c738f3e87c8f8773bd3456cae1d322d100d4b0da584f3c" +checksum = "4b89fd5edce5c0b128fa25f76f07db322ae9b28c123619ddcd11df18a73d3217" dependencies = [ "cairo-lang-utils", "indoc", @@ -465,9 +466,9 @@ dependencies = [ [[package]] name = "cairo-lang-compiler" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4f2c54b065f7fd97bf8d5df76cbcbbd01d8a8c319d281796ee20ecc48e16ca8" +checksum = "7fc2689f520038019ddc8884ee36f6df04a66fe46906c9d1ac76e8e9675e55f0" dependencies = [ "anyhow", "cairo-lang-defs", @@ -483,26 +484,24 @@ dependencies = [ "cairo-lang-syntax", "cairo-lang-utils", "itertools 0.11.0", - "log", "salsa", - "smol_str", "thiserror", ] [[package]] name = "cairo-lang-debug" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "873ba77d4c3f780c727c7d6c738cded22b3f6d4023e30546dfe14f97a087887e" +checksum = "3544967c563b53066163794d3c400270faf4617cfdd33ba1f74296efdca14e9d" dependencies = [ "cairo-lang-utils", ] [[package]] name = "cairo-lang-defs" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5031fff038c27ed43769b73a6f5d41aeaea34df9af862e024c23fbb4f076249" +checksum = "a07a54c419c573bc2610c2b3d672420723ca38b79a4cae2f24e0287173524e18" dependencies = [ "cairo-lang-debug", "cairo-lang-diagnostics", @@ -510,7 +509,6 @@ dependencies = [ "cairo-lang-parser", "cairo-lang-syntax", "cairo-lang-utils", - "indexmap 2.0.2", "itertools 0.11.0", "salsa", "smol_str", @@ -518,34 +516,31 @@ dependencies = [ [[package]] name = "cairo-lang-diagnostics" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b6cb1492e5784e1076320a5018ce7584f391b2f3b414bc0a8ab7c289fa118ce" +checksum = "82dc3934a47960155812cc181e7e2a3d48f2df447c23fcdbecff966855244162" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", "cairo-lang-utils", "itertools 0.11.0", - "salsa", ] [[package]] name = "cairo-lang-eq-solver" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c35dddbc63b2a4870891cc74498726aa32bfaa518596352f9bb101411cc4c584" +checksum = "2f944eae57f6c31fa0157811117b584cba4556770e2e5db4fd856459b877680f" dependencies = [ "cairo-lang-utils", "good_lp", - "indexmap 2.0.2", - "itertools 0.11.0", ] [[package]] name = "cairo-lang-filesystem" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32ce0b8e66a6085ae157d43b5c162d60166f0027d6f125c50ee74e4dc7916ff6" +checksum = "79b9b4f02ee6da5526a58b054dae3dce8ff592ae5e740c1d028ebd7e8218e1dc" dependencies = [ "cairo-lang-debug", "cairo-lang-utils", @@ -557,9 +552,9 @@ dependencies = [ [[package]] name = "cairo-lang-lowering" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29cc679f501725e03ee703559ed27d084c6f4031bd51ff86378cf845a85ee207" +checksum = "f5654b46630d3e8e740ebb058d344aa62ca92c5b1cbc5febbb993abe1ab622cb" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -578,14 +573,13 @@ dependencies = [ "num-traits 0.2.17", "once_cell", "salsa", - "smol_str", ] [[package]] name = "cairo-lang-parser" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdcadb046659134466bc7e11961ea8a56969dae8a54d8f985955ce0b95185c7f" +checksum = "1f42707f9db24a7c15b82b1d26615c3038323b6136c76739622ea3a3877a8ed7" dependencies = [ "cairo-lang-diagnostics", "cairo-lang-filesystem", @@ -594,7 +588,6 @@ dependencies = [ "cairo-lang-utils", "colored", "itertools 0.11.0", - "log", "num-bigint", "num-traits 0.2.17", "salsa", @@ -604,9 +597,9 @@ dependencies = [ [[package]] name = "cairo-lang-plugins" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4632790cd4ea11d4849934456a400eae7ed419f6d721f24a6b637df67b7e902f" +checksum = "11b58c906cfb2d64ab630c1417a9dac15dea0859978cc5b2b61dab7fa098a9b9" dependencies = [ "cairo-lang-defs", "cairo-lang-diagnostics", @@ -617,16 +610,15 @@ dependencies = [ "indent", "indoc", "itertools 0.11.0", - "num-bigint", "salsa", "smol_str", ] [[package]] name = "cairo-lang-proc-macros" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "170838817fc33ddb65e0a9480526df0b226b148a0fca0a5cd7071be4c6683157" +checksum = "178c68268a904eba03c07714b2c29d1f97d6754e74931f5d465961f901a88d59" dependencies = [ "cairo-lang-debug", "quote", @@ -635,9 +627,9 @@ dependencies = [ [[package]] name = "cairo-lang-project" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4162ee976c61fdeb3b621f4a76fd256e46a5c0890f750a3a9d2c9560a3bc1daf" +checksum = "f5eb369e0b51a8f03ad92dc2981387cb9b35cba6d117271ef307a14a14ff58b0" dependencies = [ "cairo-lang-filesystem", "cairo-lang-utils", @@ -649,22 +641,20 @@ dependencies = [ [[package]] name = "cairo-lang-semantic" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e544fa9a222bf2d007df2b5fc9b21c2a20ab7e17d6fefbcbc193de209451cd" +checksum = "7564b5ea75237c83b6b7e39d9177fcf13f34f035bf8bd5f659198ac8f6ee78b9" 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-utils", "id-arena", "itertools 0.11.0", - "log", "num-bigint", "num-traits 0.2.17", "once_cell", @@ -674,10 +664,11 @@ dependencies = [ [[package]] name = "cairo-lang-sierra" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5e136b79e95a14ef38a2be91a67ceb85317407d336a5b0d418c33b23c78596a" +checksum = "ada598c1f7a7c343cf5d604c0f028000fcc17d67c036d797d5cd3b7fd8777e1a" dependencies = [ + "anyhow", "cairo-lang-utils", "const-fnv1a-hash", "convert_case", @@ -697,9 +688,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-ap-change" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "511ca7708faa7ba8d14ae26e1d60ead2d02028c8f664baf5ecb0fd6a0d1e20f6" +checksum = "00cf99976ca90ceeb11895521feb34b1be8e0f98b6ca79e9a4018148d7ff7888" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -711,9 +702,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-gas" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "351a25bc010b910919c01d5c57e937b0c3d330fc30d92702c0cb4061819df8df" +checksum = "0f64f8d381ef4f97ecdbfae7f9f77fe6aa18191696e52b112e53c75a84af7e84" dependencies = [ "cairo-lang-eq-solver", "cairo-lang-sierra", @@ -725,9 +716,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-generator" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "114091bb971c06fd072aca816af1c3f62566cd8a4b1453c786155161a36c7bce" +checksum = "dfee5967e7967c71cee15f545faf5288a9c6046c60ecff89748c65d9654a7be4" dependencies = [ "cairo-lang-debug", "cairo-lang-defs", @@ -735,14 +726,10 @@ dependencies = [ "cairo-lang-filesystem", "cairo-lang-lowering", "cairo-lang-parser", - "cairo-lang-plugins", - "cairo-lang-proc-macros", "cairo-lang-semantic", "cairo-lang-sierra", "cairo-lang-syntax", "cairo-lang-utils", - "id-arena", - "indexmap 2.0.2", "itertools 0.11.0", "num-bigint", "once_cell", @@ -752,9 +739,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-to-casm" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa1c799de62972dfd7112d563000695be94305b6f7d9bedd29f347799bf03e1c" +checksum = "4af7d2812d283b63f074a1ab4135fe0db586bf1b5edaa7ef2129f3067c9e894a" dependencies = [ "assert_matches", "cairo-felt", @@ -766,7 +753,6 @@ dependencies = [ "cairo-lang-utils", "indoc", "itertools 0.11.0", - "log", "num-bigint", "num-traits 0.2.17", "thiserror", @@ -774,9 +760,9 @@ dependencies = [ [[package]] name = "cairo-lang-sierra-type-size" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2fe73d9d58aaf9088f6ba802bcf43ce9ca4bd198190cf5bf91caa7d408dd11a" +checksum = "8b753a6569f903c3637dda7ef944455a91b2b004f5294262ab1e823914ea65e5" dependencies = [ "cairo-lang-sierra", "cairo-lang-utils", @@ -784,9 +770,9 @@ dependencies = [ [[package]] name = "cairo-lang-starknet" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75df624e71e33a31a924e799dd2a9a8284204b41d8db9c51803317bd9edff81f" +checksum = "6866e7599234986acb221cbc5a9720731e4b6d068e87ce07d6437e51f8fc8a24" dependencies = [ "anyhow", "cairo-felt", @@ -796,22 +782,17 @@ dependencies = [ "cairo-lang-diagnostics", "cairo-lang-filesystem", "cairo-lang-lowering", - "cairo-lang-parser", - "cairo-lang-plugins", "cairo-lang-semantic", "cairo-lang-sierra", - "cairo-lang-sierra-ap-change", - "cairo-lang-sierra-gas", "cairo-lang-sierra-generator", "cairo-lang-sierra-to-casm", "cairo-lang-syntax", "cairo-lang-utils", + "const_format", "convert_case", - "genco", "indent", "indoc", "itertools 0.11.0", - "log", "num-bigint", "num-integer", "num-traits 0.2.17", @@ -825,9 +806,9 @@ dependencies = [ [[package]] name = "cairo-lang-syntax" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b1af0ae21f9e539f97cfdf56f5ce0934dae5d87f568fd778c3d624a102f8dbb" +checksum = "b91c81cd720549131e80598172d6a9db3d62795ab6be1060b7efed463c793bd1" dependencies = [ "cairo-lang-debug", "cairo-lang-filesystem", @@ -836,15 +817,14 @@ dependencies = [ "num-traits 0.2.17", "salsa", "smol_str", - "thiserror", "unescaper", ] [[package]] name = "cairo-lang-syntax-codegen" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "822ffabf24f6a5506262edcece315260a82d9dfba3abe6548791a6d654563ad0" +checksum = "04f2e93b768bf5fff62bcd445fda45c98cdb4e58a81b2095bda01cdbf00e2e6a" dependencies = [ "genco", "xshell", @@ -852,14 +832,13 @@ dependencies = [ [[package]] name = "cairo-lang-utils" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f974b6e859f0b09c0f13ec8188c96e9e8bbb5da04214f911dbb5bcda67cb812b" +checksum = "3a676a06f80da115e9ef2669e708ee3d2a495224ebc6e5464e8d6132d0e8266b" dependencies = [ "indexmap 2.0.2", "itertools 0.11.0", "num-bigint", - "num-integer", "num-traits 0.2.17", "parity-scale-codec", "schemars", @@ -949,6 +928,26 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32b13ea120a812beba79e34316b3942a857c86ec1593cb34f27bb28272ce2cca" +[[package]] +name = "const_format" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a214c7af3d04997541b18d432afaff4c455e79e2029079647e72fc2bd27673" +dependencies = [ + "const_format_proc_macros", +] + +[[package]] +name = "const_format_proc_macros" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f6ff08fd20f4f299298a28e2dfa8a8ba1036e6cd2460ac1de7b425d76f2500" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + [[package]] name = "convert_case" version = "0.6.0" @@ -1609,7 +1608,7 @@ version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" dependencies = [ - "ahash 0.8.3", + "ahash 0.8.5", "allocator-api2", ] @@ -1737,7 +1736,7 @@ dependencies = [ "futures-util", "http", "hyper", - "rustls 0.21.7", + "rustls 0.21.8", "tokio", "tokio-rustls 0.24.1", ] @@ -1891,9 +1890,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" +checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "is-terminal" @@ -2091,9 +2090,9 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.8" +version = "0.8.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "927a765cd3fc26206e66b296465fa9d3e5ab003e651c1b3c060e7956d96b19d2" +checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" dependencies = [ "libc", "wasi", @@ -2738,7 +2737,7 @@ version = "0.11.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "046cd98826c46c2ac8ddecae268eb5c2e58628688a5fc7a2643704a73faba95b" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", "bytes", "encoding_rs", "futures-core", @@ -2755,7 +2754,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", - "rustls 0.21.7", + "rustls 0.21.8", "rustls-pemfile", "serde", "serde_json", @@ -2875,12 +2874,12 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.7" +version = "0.21.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" +checksum = "446e14c5cda4f3f30fe71863c34ec70f5ac79d6087097ad0bb433e1be5edf04c" dependencies = [ "log", - "ring 0.16.20", + "ring 0.17.5", "rustls-webpki", "sct", ] @@ -2891,17 +2890,17 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", ] [[package]] name = "rustls-webpki" -version = "0.101.6" +version = "0.101.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c7d5dece342910d9ba34d259310cae3e0154b873b35408b787b59bce53d34fe" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" dependencies = [ - "ring 0.16.20", - "untrusted 0.7.1", + "ring 0.17.5", + "untrusted 0.9.0", ] [[package]] @@ -3096,9 +3095,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" +checksum = "12022b835073e5b11e90a14f86838ceb1c8fb0325b72416845c487ac0fa95e80" dependencies = [ "serde", ] @@ -3286,7 +3285,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa8241483a83a3f33aa5fff7e7d9def398ff9990b2752b6c6112b83c6d246029" dependencies = [ - "ahash 0.7.6", + "ahash 0.7.7", "atoi", "bitflags 1.3.2", "byteorder", @@ -3413,7 +3412,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14139b1c39bdc2f1e663c12090ff5108fe50ebe62c09e15e32988dfaf445a7e4" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", "flate2", "hex", "serde", @@ -3796,7 +3795,7 @@ version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" dependencies = [ - "rustls 0.21.7", + "rustls 0.21.8", "tokio", ] @@ -3839,9 +3838,9 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" dependencies = [ "serde", ] @@ -3866,7 +3865,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3082666a3a6433f7f511c7192923fa1fe07c69332d3c6a2e6bb040b569199d5a" dependencies = [ "async-trait", - "base64 0.21.4", + "base64 0.21.5", "bytes", "flate2", "futures-core", @@ -3891,7 +3890,7 @@ dependencies = [ "async-stream", "async-trait", "axum", - "base64 0.21.4", + "base64 0.21.5", "bytes", "h2", "http", @@ -3941,7 +3940,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac5987e92915a51a4b05e69a0ef903a7b76f16674f7ee66534f87fd3323e2d3a" dependencies = [ - "base64 0.21.4", + "base64 0.21.5", "byteorder", "bytes", "futures-util", @@ -4561,6 +4560,26 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e2c411759b501fb9501aac2b1b2d287a6e93e5bdcf13c25306b23e1b716dd0e" +[[package]] +name = "zerocopy" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c19fae0c8a9efc6a8281f2e623db8af1db9e57852e04cde3e754dd2dc29340f" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc56589e9ddd1f1c28d4b4b5c773ce232910a6bb67a70133d61c9e347585efe9" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.38", +] + [[package]] name = "zeroize" version = "1.6.0" diff --git a/crates/torii/client/wasm/yarn.lock b/crates/torii/client/wasm/yarn.lock index c77ea551c9..1767c15e99 100644 --- a/crates/torii/client/wasm/yarn.lock +++ b/crates/torii/client/wasm/yarn.lock @@ -303,7 +303,7 @@ ansi-html-community@0.0.8: integrity sha512-1APHAyr3+PCamwNw3bXCPp4HFLONZt/yIH0sZp0/469KWNTEy+qN5jQ3GVX6DMZ1UXAi34yVwtTeaG/HpBuuzw== ansi-regex@^2.0.0: - version "2.2.0" + version "2.3.0" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.2.0.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" integrity sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA== @@ -997,7 +997,7 @@ enhanced-resolve@^5.15.0: tapable "^2.2.0" entities@^2.0.0: - version "2.2.0" + version "2.3.0" resolved "https://registry.yarnpkg.com/entities/-/entities-2.2.0.tgz#098dc90ebb83d8dffa089d55256b351d34c4da55" integrity sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A== @@ -1584,7 +1584,7 @@ internal-ip@^4.3.0: ipaddr.js "^1.9.0" interpret@^2.2.0: - version "2.2.0" + version "2.3.0" resolved "https://registry.yarnpkg.com/interpret/-/interpret-2.2.0.tgz#1a78a0b5965c40a5416d007ad6f50ad27c417df9" integrity sha512-Ju0Bz/cEia55xDwUWEa8+olFpCiQoypjnQySseKtmjNrnps3P+xfpUmGr90T7yjlVJmOtybRvPXhKMbHr+fWnw== @@ -1701,7 +1701,7 @@ is-extendable@^1.0.1: is-plain-object "^2.0.4" is-extglob@^2.1.0, is-extglob@^2.2.0: - version "2.2.0" + version "2.3.0" resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.2.0.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== @@ -1732,7 +1732,7 @@ is-number@^3.0.0: kind-of "^3.0.2" is-path-cwd@^2.0.0: - version "2.2.0" + version "2.3.0" resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-2.2.0.tgz#67d43b82664a7b5191fd9119127eb300048a9fdb" integrity sha512-w942bTcih8fdJPJmQHFzkS76NEP8Kzzvmw92cXsazb8intwLqPibPPdXf4ANdKV3rYMuuQYGIWtvz9JilB3NFQ== @@ -2084,7 +2084,7 @@ node-releases@^2.0.13: integrity sha512-uYr7J37ae/ORWdZeQ1xxMJe3NtdmqMC/JZK+geofDrkLUApKRHPd18/TxtBOJ4A0/+uUIliorNrfYV6s1b02eQ== normalize-path@^2.2.0: - version "2.2.0" + version "2.3.0" resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.2.0.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9" integrity sha512-3pKJwH184Xo/lnH6oyP1q2pMd7HcypqqmRs91/6/i2CGtWwIKGCkOOMTm/zXbgTEWHw1uNpNi/igc3ePOYHb6w== dependencies: @@ -2103,7 +2103,7 @@ npm-run-path@^2.0.0: path-key "^2.0.0" nth-check@^2.0.1: - version "2.2.0" + version "2.3.0" resolved "https://registry.yarnpkg.com/nth-check/-/nth-check-2.2.0.tgz#c9eab428effce36cd6b92c924bdb000ef1f1ed1d" integrity sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w== dependencies: @@ -2225,7 +2225,7 @@ p-retry@^3.0.1: retry "^0.12.0" p-try@^2.0.0: - version "2.2.0" + version "2.3.0" resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== @@ -2414,7 +2414,7 @@ qs@^6.11.0: side-channel "^1.0.4" querystringify@^2.2.0: - version "2.2.0" + version "2.3.0" resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-2.2.0.tgz#3345941b4153cb9d082d8eee4cda2016a9aef7f6" integrity sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ== @@ -2527,7 +2527,7 @@ repeat-string@^1.6.1: integrity sha512-PV0dzCYDNfRi1jCDbJzpW7jNNDRuCOG/jI5ctQcGKt/clZD+YcPS3yIlWuTJMmESC8aevCFmWJy5wjAFgNqN6w== require-directory@^2.2.0: - version "2.2.0" + version "2.3.0" resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.2.0.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q== @@ -2778,7 +2778,7 @@ signal-exit@^3.0.0: integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== snapdragon-node@^2.0.1: - version "2.2.0" + version "2.3.0" resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.2.0.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" integrity sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw== dependencies: @@ -3028,7 +3028,7 @@ to-object-path@^0.3.0: kind-of "^3.0.2" to-regex-range@^2.1.0: - version "2.2.0" + version "2.3.0" resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-2.2.0.tgz#7c80c17b9dfebe599e27367e0d4dd5590141db38" integrity sha512-ZZWNfCjUokXXDGXFpZehJIkZqq91BcULFq/Pi7M5i4JnxXdhMKAK682z8bCW3o8Hj1wuuzoKcW3DfVzaP6VuNg== dependencies: diff --git a/crates/torii/core/src/engine.rs b/crates/torii/core/src/engine.rs index 823a466d7a..8c7e7312e5 100644 --- a/crates/torii/core/src/engine.rs +++ b/crates/torii/core/src/engine.rs @@ -3,7 +3,7 @@ use std::time::Duration; use anyhow::Result; use dojo_world::contracts::world::WorldContractReader; use starknet::core::types::{ - BlockId, BlockWithTxs, Event, InvokeTransaction, InvokeTransactionReceipt, + BlockId, BlockWithTxs, Event, InvokeTransaction, InvokeTransactionReceipt, InvokeTransactionV1, MaybePendingBlockWithTxs, MaybePendingTransactionReceipt, Transaction, TransactionReceipt, }; use starknet::core::utils::get_selector_from_name; @@ -147,36 +147,48 @@ where _ => continue, }; - let receipt = match self + let receipt = self .provider .get_transaction_receipt(invoke_transaction.transaction_hash) .await - { - Ok(receipt) => receipt, + .ok() + .and_then(|receipt| match receipt { + MaybePendingTransactionReceipt::Receipt(TransactionReceipt::Invoke( + receipt, + )) => Some(receipt), + _ => None, + }); + + let invoke_receipt = match receipt { + Some(receipt) => receipt, _ => continue, }; - let receipt = match receipt { - MaybePendingTransactionReceipt::Receipt(receipt) => receipt, - _ => continue, - }; - - if let TransactionReceipt::Invoke(invoke_receipt) = receipt.clone() { - for (event_idx, event) in invoke_receipt.events.iter().enumerate() { - if event.from_address != self.world.address() { - continue; - } + let mut world_event = false; + for (event_idx, event) in invoke_receipt.events.iter().enumerate() { + if event.from_address != self.world.address() { + continue; + } - let event_id = format!( - "0x{:064x}:0x{:04x}:0x{:04x}", - block.block_number, tx_idx, event_idx - ); + world_event = true; + let event_id = + format!("0x{:064x}:0x{:04x}:0x{:04x}", block.block_number, tx_idx, event_idx); - Self::process_event(self, &block, &invoke_receipt, &event_id, event).await?; - } + Self::process_event(self, &block, &invoke_receipt, &event_id, event).await?; } - Self::process_transaction(self, &block, &receipt).await?; + if world_event { + let transaction_id = format!("0x{:064x}:0x{:04x}", block.block_number, tx_idx); + + Self::process_transaction( + self, + &block, + &invoke_receipt, + &transaction_id, + invoke_transaction, + ) + .await?; + } } info!("processed block: {}", block.block_number); @@ -194,10 +206,21 @@ where async fn process_transaction( &mut self, block: &BlockWithTxs, - receipt: &TransactionReceipt, + invoke_receipt: &InvokeTransactionReceipt, + transaction_id: &str, + transaction: &InvokeTransactionV1, ) -> Result<()> { for processor in &self.processors.transaction { - processor.process(self.db, self.provider.as_ref(), block, receipt).await? + processor + .process( + self.db, + self.provider.as_ref(), + block, + invoke_receipt, + transaction, + transaction_id, + ) + .await? } Ok(()) diff --git a/crates/torii/core/src/processors/mod.rs b/crates/torii/core/src/processors/mod.rs index 661990dc5b..528076ad20 100644 --- a/crates/torii/core/src/processors/mod.rs +++ b/crates/torii/core/src/processors/mod.rs @@ -1,7 +1,7 @@ use anyhow::{Error, Result}; use async_trait::async_trait; use dojo_world::contracts::world::WorldContractReader; -use starknet::core::types::{BlockWithTxs, Event, InvokeTransactionReceipt, TransactionReceipt}; +use starknet::core::types::{BlockWithTxs, Event, InvokeTransactionReceipt, InvokeTransactionV1}; use starknet::providers::Provider; use crate::sql::Sql; @@ -9,6 +9,7 @@ use crate::sql::Sql; pub mod metadata_update; pub mod register_model; pub mod store_set_record; +pub mod store_transaction; #[async_trait] pub trait EventProcessor

@@ -42,6 +43,8 @@ pub trait TransactionProcessor { db: &mut Sql, provider: &P, block: &BlockWithTxs, - transaction_receipt: &TransactionReceipt, + invoke_receipt: &InvokeTransactionReceipt, + transaction: &InvokeTransactionV1, + transaction_id: &str, ) -> Result<(), Error>; } diff --git a/crates/torii/core/src/processors/store_system_call.rs b/crates/torii/core/src/processors/store_system_call.rs deleted file mode 100644 index b0cfdb8c20..0000000000 --- a/crates/torii/core/src/processors/store_system_call.rs +++ /dev/null @@ -1,56 +0,0 @@ -use std::str::FromStr; - -use anyhow::{Error, Ok, Result}; -use async_trait::async_trait; -use starknet::core::types::{ - BlockWithTxs, FieldElement, InvokeTransaction, Transaction, TransactionReceipt, -}; -use starknet::core::utils::parse_cairo_short_string; -use starknet::providers::Provider; - -use super::TransactionProcessor; -use crate::sql::Sql; - -#[derive(Default)] -pub struct StoreSystemCallProcessor; - -const SYSTEM_NAME_OFFSET: usize = 6; -const ENTRYPOINT_OFFSET: usize = 2; -const EXECUTE_ENTRYPOINT: &str = - "0x240060cdb34fcc260f41eac7474ee1d7c80b7e3607daff9ac67c7ea2ebb1c44"; - -#[async_trait] -impl TransactionProcessor

for StoreSystemCallProcessor { - async fn process( - &self, - db: &Sql, - _provider: &P, - block: &BlockWithTxs, - transaction_receipt: &TransactionReceipt, - ) -> Result<(), Error> { - if let TransactionReceipt::Invoke(_) = transaction_receipt { - for tx in &block.transactions { - if let Some((tx_hash, system_name, calldata)) = parse_transaction(tx) { - let system_name = parse_cairo_short_string(&system_name)?; - - db.store_system_call(system_name, tx_hash, calldata).await?; - } - } - } - - Ok(()) - } -} - -fn parse_transaction( - transaction: &Transaction, -) -> Option<(FieldElement, FieldElement, &Vec)> { - if let Transaction::Invoke(InvokeTransaction::V1(tx)) = transaction { - let entrypoint_felt = FieldElement::from_str(EXECUTE_ENTRYPOINT).unwrap(); - if tx.calldata[ENTRYPOINT_OFFSET] == entrypoint_felt { - return Some((tx.transaction_hash, tx.calldata[SYSTEM_NAME_OFFSET], &tx.calldata)); - } - } - - None -} diff --git a/crates/torii/core/src/processors/store_transaction.rs b/crates/torii/core/src/processors/store_transaction.rs new file mode 100644 index 0000000000..ee4a4c6386 --- /dev/null +++ b/crates/torii/core/src/processors/store_transaction.rs @@ -0,0 +1,27 @@ +use anyhow::{Error, Ok, Result}; +use async_trait::async_trait; +use starknet::core::types::{BlockWithTxs, InvokeTransactionReceipt, InvokeTransactionV1}; +use starknet::providers::Provider; + +use super::TransactionProcessor; +use crate::sql::Sql; + +#[derive(Default)] +pub struct StoreTransactionProcessor; + +#[async_trait] +impl TransactionProcessor

for StoreTransactionProcessor { + async fn process( + &self, + db: &mut Sql, + _provider: &P, + _block: &BlockWithTxs, + _receipt: &InvokeTransactionReceipt, + transaction: &InvokeTransactionV1, + transaction_id: &str, + ) -> Result<(), Error> { + db.store_transaction(transaction, transaction_id); + + Ok(()) + } +} diff --git a/crates/torii/core/src/sql.rs b/crates/torii/core/src/sql.rs index 315a3ca33d..74b67d8655 100644 --- a/crates/torii/core/src/sql.rs +++ b/crates/torii/core/src/sql.rs @@ -8,7 +8,7 @@ use dojo_types::schema::Ty; use sqlx::pool::PoolConnection; use sqlx::sqlite::SqliteRow; use sqlx::{Executor, Pool, Row, Sqlite}; -use starknet::core::types::{Event, FieldElement}; +use starknet::core::types::{Event, FieldElement, InvokeTransactionV1}; use starknet_crypto::poseidon_hash_many; use super::World; @@ -200,20 +200,21 @@ impl Sql { Ok(rows.drain(..).map(|row| serde_json::from_str(&row.2).unwrap()).collect()) } - pub fn store_system_call( - &mut self, - system: String, - transaction_hash: FieldElement, - calldata: &[FieldElement], - ) { - let query = format!( - "INSERT OR IGNORE INTO system_calls (data, transaction_hash, system_id) VALUES ('{}', \ - '{:#x}', '{}')", - calldata.iter().map(|c| format!("{:#x}", c)).collect::>().join(","), - transaction_hash, - system + pub fn store_transaction(&mut self, transaction: &InvokeTransactionV1, transaction_id: &str) { + let txn_query = format!( + "INSERT OR IGNORE INTO transactions (id, transaction_hash, sender_address, calldata, \ + max_fee, signature, nonce) VALUES + ('{}', '{:#x}', '{}', '{}', '{:#x}', '{}', '{:#x}')", + transaction_id, + transaction.transaction_hash, + transaction.sender_address, + felts_sql_string(&transaction.calldata), + transaction.max_fee, + felts_sql_string(&transaction.signature), + transaction.nonce ); - self.query_queue.push(query); + + self.query_queue.push(txn_query); } pub fn store_event(&mut self, event_id: &str, event: &Event, transaction_hash: FieldElement) { @@ -319,6 +320,7 @@ impl Sql { fn build_model_query(&mut self, path: Vec, model: &Ty, model_idx: usize) { let table_id = path.join("$"); + let mut indices = Vec::new(); let mut query = format!( "CREATE TABLE IF NOT EXISTS [{table_id}] (entity_id TEXT NOT NULL PRIMARY KEY, \ @@ -332,6 +334,9 @@ impl Sql { if let Ok(cairo_type) = Primitive::from_str(&member.ty.name()) { query.push_str(&format!("external_{name} {}, ", cairo_type.to_sql_type())); + indices.push(format!( + "CREATE INDEX idx_{table_id}_{name} ON [{table_id}] (external_{name});" + )); } else if let Ty::Enum(e) = &member.ty { let all_options = e .options @@ -344,6 +349,10 @@ impl Sql { "external_{name} TEXT CHECK(external_{name} IN ({all_options})) NOT NULL, ", )); + indices.push(format!( + "CREATE INDEX idx_{table_id}_{name} ON [{table_id}] (external_{name});" + )); + options = Some(format!( r#""{}""#, e.options.iter().map(|c| c.name.clone()).collect::>().join(",") @@ -375,6 +384,7 @@ impl Sql { query.push_str("FOREIGN KEY (entity_id) REFERENCES entities(id));"); self.query_queue.push(query); + self.query_queue.extend(indices); } pub async fn execute(&mut self) -> Result<()> { diff --git a/crates/torii/graphql/src/mapping.rs b/crates/torii/graphql/src/mapping.rs index e387569093..7dd304c4e9 100644 --- a/crates/torii/graphql/src/mapping.rs +++ b/crates/torii/graphql/src/mapping.rs @@ -47,26 +47,31 @@ lazy_static! { TypeData::Simple(TypeRef::named(GraphqlType::DateTime.to_string())), ), ]); - pub static ref SYSTEM_CALL_TYPE_MAPPING: TypeMapping = IndexMap::from([ + pub static ref TRANSACTION_MAPPING: TypeMapping = IndexMap::from([ (Name::new("id"), TypeData::Simple(TypeRef::named(TypeRef::ID))), - (Name::new("transaction_hash"), TypeData::Simple(TypeRef::named(TypeRef::STRING))), - (Name::new("data"), TypeData::Simple(TypeRef::named(TypeRef::STRING))), - (Name::new("system_id"), TypeData::Simple(TypeRef::named(TypeRef::ID))), ( - Name::new("created_at"), - TypeData::Simple(TypeRef::named(GraphqlType::DateTime.to_string())), + Name::new("transaction_hash"), + TypeData::Simple(TypeRef::named(Primitive::Felt252(None).to_string())) ), - ]); - pub static ref SYSTEM_TYPE_MAPPING: TypeMapping = IndexMap::from([ - (Name::new("id"), TypeData::Simple(TypeRef::named(TypeRef::ID))), - (Name::new("name"), TypeData::Simple(TypeRef::named(TypeRef::STRING))), ( - Name::new("class_hash"), - TypeData::Simple(TypeRef::named(Primitive::Felt252(None).to_string())), + Name::new("sender_address"), + TypeData::Simple(TypeRef::named(Primitive::Felt252(None).to_string())) ), ( - Name::new("transaction_hash"), - TypeData::Simple(TypeRef::named(Primitive::Felt252(None).to_string())), + Name::new("calldata"), + TypeData::Simple(TypeRef::named_list(Primitive::Felt252(None).to_string())) + ), + ( + Name::new("max_fee"), + TypeData::Simple(TypeRef::named(Primitive::Felt252(None).to_string())) + ), + ( + Name::new("signature"), + TypeData::Simple(TypeRef::named_list(Primitive::Felt252(None).to_string())) + ), + ( + Name::new("nonce"), + TypeData::Simple(TypeRef::named(Primitive::Felt252(None).to_string())) ), ( Name::new("created_at"), diff --git a/crates/torii/graphql/src/object/event.rs b/crates/torii/graphql/src/object/event.rs index 855e2fbc5d..247963e5c6 100644 --- a/crates/torii/graphql/src/object/event.rs +++ b/crates/torii/graphql/src/object/event.rs @@ -4,12 +4,10 @@ use sqlx::{Pool, Sqlite}; use super::connection::{connection_arguments, connection_output, parse_connection_arguments}; use super::inputs::keys_input::{keys_argument, parse_keys_argument}; -use super::{ObjectTrait, TypeMapping, ValueMapping}; -use crate::mapping::{EVENT_TYPE_MAPPING, SYSTEM_CALL_TYPE_MAPPING}; +use super::{ObjectTrait, TypeMapping}; +use crate::mapping::EVENT_TYPE_MAPPING; use crate::query::constants::{EVENT_TABLE, ID_COLUMN}; -use crate::query::data::{count_rows, fetch_multiple_rows, fetch_single_row}; -use crate::query::value_mapping_from_row; -use crate::utils::extract; +use crate::query::data::{count_rows, fetch_multiple_rows}; pub struct EventObject; @@ -73,20 +71,4 @@ impl ObjectTrait for EventObject { Some(field) } - - fn related_fields(&self) -> Option> { - Some(vec![Field::new("systemCall", TypeRef::named_nn("SystemCall"), |ctx| { - FieldFuture::new(async move { - let mut conn = ctx.data::>()?.acquire().await?; - let event_values = ctx.parent_value.try_downcast_ref::()?; - let syscall_id = extract::(event_values, "system_call_id")?; - let data = - fetch_single_row(&mut conn, "system_calls", "id", &syscall_id.to_string()) - .await?; - let system_call = value_mapping_from_row(&data, &SYSTEM_CALL_TYPE_MAPPING, false)?; - - Ok(Some(Value::Object(system_call))) - }) - })]) - } } diff --git a/crates/torii/graphql/src/object/mod.rs b/crates/torii/graphql/src/object/mod.rs index d78107dab6..bffce6ece5 100644 --- a/crates/torii/graphql/src/object/mod.rs +++ b/crates/torii/graphql/src/object/mod.rs @@ -5,8 +5,7 @@ pub mod inputs; pub mod metadata; pub mod model; pub mod model_data; -pub mod system; -pub mod system_call; +pub mod transaction; use async_graphql::dynamic::{ Enum, Field, FieldFuture, InputObject, InputValue, Object, SubscriptionField, TypeRef, diff --git a/crates/torii/graphql/src/object/system.rs b/crates/torii/graphql/src/object/system.rs deleted file mode 100644 index 72b70d51cb..0000000000 --- a/crates/torii/graphql/src/object/system.rs +++ /dev/null @@ -1,46 +0,0 @@ -use async_graphql::dynamic::{Field, FieldFuture, TypeRef}; -use async_graphql::Value; -use sqlx::{Pool, Sqlite}; - -use super::{ObjectTrait, TypeMapping, ValueMapping}; -use crate::mapping::{SYSTEM_CALL_TYPE_MAPPING, SYSTEM_TYPE_MAPPING}; -use crate::query::constants::{SYSTEM_CALL_TABLE, SYSTEM_TABLE}; -use crate::query::data::fetch_single_row; -use crate::query::value_mapping_from_row; -use crate::utils::extract; - -pub struct SystemObject; - -impl ObjectTrait for SystemObject { - fn name(&self) -> (&str, &str) { - ("system", "systems") - } - - fn type_name(&self) -> &str { - "System" - } - - fn type_mapping(&self) -> &TypeMapping { - &SYSTEM_TYPE_MAPPING - } - - fn table_name(&self) -> Option<&str> { - Some(SYSTEM_TABLE) - } - - fn related_fields(&self) -> Option> { - Some(vec![Field::new("systemCalls", TypeRef::named_nn_list_nn("SystemCall"), |ctx| { - FieldFuture::new(async move { - let mut conn = ctx.data::>()?.acquire().await?; - let event_values = ctx.parent_value.try_downcast_ref::()?; - let syscall_id = extract::(event_values, "system_call_id")?; - let data = - fetch_single_row(&mut conn, SYSTEM_CALL_TABLE, "id", &syscall_id.to_string()) - .await?; - let system_call = value_mapping_from_row(&data, &SYSTEM_CALL_TYPE_MAPPING, false)?; - - Ok(Some(Value::Object(system_call))) - }) - })]) - } -} diff --git a/crates/torii/graphql/src/object/system_call.rs b/crates/torii/graphql/src/object/system_call.rs deleted file mode 100644 index e8557e8d5c..0000000000 --- a/crates/torii/graphql/src/object/system_call.rs +++ /dev/null @@ -1,44 +0,0 @@ -use async_graphql::dynamic::{Field, FieldFuture, TypeRef}; -use async_graphql::Value; -use sqlx::{Pool, Sqlite}; - -use super::{ObjectTrait, TypeMapping, ValueMapping}; -use crate::mapping::{SYSTEM_CALL_TYPE_MAPPING, SYSTEM_TYPE_MAPPING}; -use crate::query::constants::SYSTEM_CALL_TABLE; -use crate::query::data::fetch_single_row; -use crate::query::value_mapping_from_row; -use crate::utils::extract; - -pub struct SystemCallObject; - -impl ObjectTrait for SystemCallObject { - fn name(&self) -> (&str, &str) { - ("systemCall", "systemCalls") - } - - fn type_name(&self) -> &str { - "SystemCall" - } - - fn type_mapping(&self) -> &TypeMapping { - &SYSTEM_CALL_TYPE_MAPPING - } - - fn table_name(&self) -> Option<&str> { - Some(SYSTEM_CALL_TABLE) - } - - fn related_fields(&self) -> Option> { - Some(vec![Field::new("system", TypeRef::named_nn("System"), |ctx| { - FieldFuture::new(async move { - let mut conn = ctx.data::>()?.acquire().await?; - let syscall_values = ctx.parent_value.try_downcast_ref::()?; - let system_id = extract::(syscall_values, "system_id")?; - let system = fetch_single_row(&mut conn, "systems", "id", &system_id).await?; - let result = value_mapping_from_row(&system, &SYSTEM_TYPE_MAPPING, false)?; - - Ok(Some(Value::Object(result))) - }) - })]) - } -} diff --git a/crates/torii/graphql/src/object/transaction.rs b/crates/torii/graphql/src/object/transaction.rs new file mode 100644 index 0000000000..3ba04578d1 --- /dev/null +++ b/crates/torii/graphql/src/object/transaction.rs @@ -0,0 +1,23 @@ +use super::{ObjectTrait, TypeMapping}; +use crate::mapping::TRANSACTION_MAPPING; +use crate::query::constants::TRANSACTION_TABLE; + +pub struct TransactionObject; + +impl ObjectTrait for TransactionObject { + fn name(&self) -> (&str, &str) { + ("transaction", "transactions") + } + + fn type_name(&self) -> &str { + "Transaction" + } + + fn type_mapping(&self) -> &TypeMapping { + &TRANSACTION_MAPPING + } + + fn table_name(&self) -> Option<&str> { + Some(TRANSACTION_TABLE) + } +} diff --git a/crates/torii/graphql/src/query/constants.rs b/crates/torii/graphql/src/query/constants.rs index 49802ed183..0da5b346fc 100644 --- a/crates/torii/graphql/src/query/constants.rs +++ b/crates/torii/graphql/src/query/constants.rs @@ -4,8 +4,7 @@ pub const BOOLEAN_TRUE: i64 = 1; pub const ENTITY_TABLE: &str = "entities"; pub const EVENT_TABLE: &str = "events"; pub const MODEL_TABLE: &str = "models"; -pub const SYSTEM_CALL_TABLE: &str = "system_calls"; -pub const SYSTEM_TABLE: &str = "systems"; +pub const TRANSACTION_TABLE: &str = "transactions"; pub const METADATA_TABLE: &str = "metadata"; pub const ID_COLUMN: &str = "id"; diff --git a/crates/torii/graphql/src/route.rs b/crates/torii/graphql/src/route.rs index 4774fafce9..1ed98fe769 100644 --- a/crates/torii/graphql/src/route.rs +++ b/crates/torii/graphql/src/route.rs @@ -1,27 +1,44 @@ -use std::convert::Infallible; - use async_graphql::dynamic::Schema; use async_graphql::http::{playground_source, GraphQLPlaygroundConfig}; -use async_graphql_warp::graphql_subscription; +use async_graphql::Request; +use async_graphql_warp::{graphql, graphql_subscription}; +use serde_json::json; use sqlx::{Pool, Sqlite}; use url::Url; -use warp::Filter; +use warp::{Filter, Rejection, Reply}; use super::schema::build_schema; +use crate::query::constants::MODEL_TABLE; +use crate::query::data::count_rows; pub async fn filter( pool: &Pool, external_url: Option, -) -> impl Filter + Clone { +) -> impl Filter + Clone { let schema = build_schema(pool).await.unwrap(); - let graphql_post = warp::path("graphql") - .and(async_graphql_warp::graphql(schema.clone())) - .and_then(|(schema, request): (Schema, async_graphql::Request)| async move { + let mut conn = pool.acquire().await.unwrap(); + let num_models = count_rows(&mut conn, MODEL_TABLE, &None, &None).await.unwrap(); + + graphql_filter(schema, external_url, num_models == 0) +} + +fn graphql_filter( + schema: Schema, + external_url: Option, + is_empty: bool, +) -> impl Filter + Clone { + let graphql_post = warp::path("graphql").and(graphql(schema.clone())).and_then( + move |(schema, request): (Schema, Request)| async move { + if is_empty { + return Ok::<_, Rejection>(empty_response()); + } + // Execute query let response = schema.execute(request).await; // Return result - Ok::<_, Infallible>(warp::reply::json(&response)) - }); + Ok::<_, Rejection>(warp::reply::json(&response)) + }, + ); let subscription_endpoint = if let Some(external_url) = external_url { format!("{external_url}/graphql/ws").replace("http", "ws") @@ -39,3 +56,12 @@ pub async fn filter( graphql_subscription(schema).or(graphql_post).or(playground_filter) } + +fn empty_response() -> warp::reply::Json { + let empty_response = json!({ + "errors": [{ + "message": "World does not have any indexed data yet." + }] + }); + warp::reply::json(&empty_response) +} diff --git a/crates/torii/graphql/src/schema.rs b/crates/torii/graphql/src/schema.rs index 0b09e21ed2..b4dae3ea79 100644 --- a/crates/torii/graphql/src/schema.rs +++ b/crates/torii/graphql/src/schema.rs @@ -9,12 +9,11 @@ use super::object::connection::page_info::PageInfoObject; use super::object::entity::EntityObject; use super::object::event::EventObject; use super::object::model_data::ModelDataObject; -use super::object::system::SystemObject; -use super::object::system_call::SystemCallObject; use super::object::ObjectTrait; use super::types::ScalarType; use crate::object::metadata::MetadataObject; use crate::object::model::ModelObject; +use crate::object::transaction::TransactionObject; use crate::query::type_mapping_query; // The graphql schema is built dynamically at runtime, this is because we won't know the schema of @@ -22,29 +21,8 @@ use crate::query::type_mapping_query; // events, their schema is known but we generate them dynamically as well because async-graphql // does not allow mixing of static and dynamic schemas. pub async fn build_schema(pool: &SqlitePool) -> Result { - let mut schema_builder = Schema::build("Query", None, Some("Subscription")); - // predefined objects - let mut objects: Vec> = vec![ - Box::new(EntityObject), - Box::new(MetadataObject), - Box::new(ModelObject), - Box::new(SystemObject), - Box::new(EventObject), - Box::new(SystemCallObject), - Box::new(PageInfoObject), - ]; - - // build model data gql objects - let (data_objects, data_union) = build_data_objects(pool).await?; - objects.extend(data_objects); - - // register model data unions - schema_builder = schema_builder.register(data_union); - - // register default scalars - for scalar_type in ScalarType::all().iter() { - schema_builder = schema_builder.register(Scalar::new(scalar_type)); - } + // build world gql objects + let (objects, union) = build_objects(pool).await?; // collect resolvers for single and plural queries let queries: Vec = objects @@ -58,6 +36,16 @@ pub async fn build_schema(pool: &SqlitePool) -> Result { query_root = query_root.field(query); } + let mut schema_builder = Schema::build("Query", None, Some("Subscription")); + + // register model data unions + schema_builder = schema_builder.register(union); + + // register default scalars + for scalar_type in ScalarType::all().iter() { + schema_builder = schema_builder.register(Scalar::new(scalar_type)); + } + for object in &objects { // register enum objects if let Some(input_objects) = object.enum_objects() { @@ -111,16 +99,24 @@ pub async fn build_schema(pool: &SqlitePool) -> Result { .map_err(|e| e.into()) } -async fn build_data_objects(pool: &SqlitePool) -> Result<(Vec>, Union)> { +async fn build_objects(pool: &SqlitePool) -> Result<(Vec>, Union)> { let mut conn = pool.acquire().await?; - let mut objects: Vec> = Vec::new(); - let models: Vec = sqlx::query_as("SELECT * FROM models").fetch_all(&mut conn).await?; + // predefined objects + let mut objects: Vec> = vec![ + Box::new(EntityObject), + Box::new(EventObject), + Box::new(MetadataObject), + Box::new(ModelObject), + Box::new(PageInfoObject), + Box::new(TransactionObject), + ]; + // model union object let mut union = Union::new("ModelUnion"); - // model state objects + // model data objects for model in models { let type_mapping = type_mapping_query(&mut conn, &model.id).await?; diff --git a/crates/torii/graphql/src/tests/mod.rs b/crates/torii/graphql/src/tests/mod.rs index b463bad595..65ae4f9f93 100644 --- a/crates/torii/graphql/src/tests/mod.rs +++ b/crates/torii/graphql/src/tests/mod.rs @@ -251,7 +251,7 @@ pub async fn spinup_types_test() -> Result { execute_strategy(&ws, &migration, &account, None).await.unwrap(); // Execute `create` and insert 10 records into storage - let records_contract = "0x1f04153fabe135513a5ef65f45089ababccfee01b001f8b29d95639d4cfaa0c"; + let records_contract = "0x4ff40a178c593ce3cb432b020b8546508f27048a56e1256694b459ba78de001"; let InvokeTransactionResult { transaction_hash } = account .execute(vec![Call { calldata: vec![FieldElement::from_str("0xa").unwrap()], diff --git a/crates/torii/graphql/src/tests/types-test/Scarb.lock b/crates/torii/graphql/src/tests/types-test/Scarb.lock new file mode 100644 index 0000000000..4e78038358 --- /dev/null +++ b/crates/torii/graphql/src/tests/types-test/Scarb.lock @@ -0,0 +1,20 @@ +# Code generated by scarb DO NOT EDIT. +version = 1 + +[[package]] +name = "dojo" +version = "0.3.1" +dependencies = [ + "dojo_plugin", +] + +[[package]] +name = "dojo_plugin" +version = "0.3.1" + +[[package]] +name = "types_test" +version = "0.1.0" +dependencies = [ + "dojo", +] diff --git a/crates/torii/migrations/20230316154230_setup.sql b/crates/torii/migrations/20230316154230_setup.sql index 254c351342..04ee400253 100644 --- a/crates/torii/migrations/20230316154230_setup.sql +++ b/crates/torii/migrations/20230316154230_setup.sql @@ -51,17 +51,6 @@ CREATE TABLE model_members( CREATE INDEX idx_model_members_model_id ON model_members (model_id); -CREATE TABLE system_calls ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - data TEXT NOT NULL, - transaction_hash TEXT NOT NULL, - system_id TEXT NOT NULL, - created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - UNIQUE (transaction_hash) -); - -CREATE INDEX idx_system_calls_created_at ON system_calls (created_at); - CREATE TABLE entities ( id TEXT NOT NULL PRIMARY KEY, keys TEXT, @@ -83,4 +72,28 @@ CREATE TABLE events ( created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ); -CREATE INDEX idx_events_keys ON events (keys); \ No newline at end of file +CREATE INDEX idx_events_keys ON events (keys); + +CREATE TABLE transactions ( + id TEXT NOT NULL PRIMARY KEY, + transaction_hash TEXT NOT NULL, + sender_address TEXT NOT NULL, + calldata TEXT NOT NULL, + max_fee TEXT NOT NULL, + signature TEXT NOT NULL, + nonce TEXT NOT NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + UNIQUE (transaction_hash) +); + +CREATE TABLE transaction_receipts ( + id TEXT NOT NULL PRIMARY KEY, + transaction_hash TEXT NOT NULL, + actual_fee TEXT NOT NULL, + finality_status TEXT NOT NULL, + block_hash TEXT NOT NULL, + block_number INTEGER NOT NULL, + execution_result TEXT NOT NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + UNIQUE (transaction_hash) +); diff --git a/crates/torii/server/src/cli.rs b/crates/torii/server/src/cli.rs index d5a74637b5..859fdfd792 100644 --- a/crates/torii/server/src/cli.rs +++ b/crates/torii/server/src/cli.rs @@ -15,6 +15,7 @@ use torii_core::engine::{Engine, EngineConfig, Processors}; use torii_core::processors::metadata_update::MetadataUpdateProcessor; use torii_core::processors::register_model::RegisterModelProcessor; use torii_core::processors::store_set_record::StoreSetRecordProcessor; +use torii_core::processors::store_transaction::StoreTransactionProcessor; use torii_core::sql::Sql; use tracing::error; use tracing_subscriber::fmt; @@ -96,7 +97,7 @@ async fn main() -> anyhow::Result<()> { Box::new(StoreSetRecordProcessor), Box::new(MetadataUpdateProcessor), ], - // transaction: vec![Box::new(StoreSystemCallProcessor)], + transaction: vec![Box::new(StoreTransactionProcessor)], ..Processors::default() }; diff --git a/examples/spawn-and-move/Scarb.lock b/examples/spawn-and-move/Scarb.lock new file mode 100644 index 0000000000..9644acb888 --- /dev/null +++ b/examples/spawn-and-move/Scarb.lock @@ -0,0 +1,20 @@ +# Code generated by scarb DO NOT EDIT. +version = 1 + +[[package]] +name = "dojo" +version = "0.3.1" +dependencies = [ + "dojo_plugin", +] + +[[package]] +name = "dojo_examples" +version = "0.3.1" +dependencies = [ + "dojo", +] + +[[package]] +name = "dojo_plugin" +version = "0.3.1" diff --git a/examples/spawn-and-move/Scarb.toml b/examples/spawn-and-move/Scarb.toml index be13fe92f8..925e6b6dd6 100644 --- a/examples/spawn-and-move/Scarb.toml +++ b/examples/spawn-and-move/Scarb.toml @@ -1,5 +1,5 @@ [package] -cairo-version = "2.2.0" +cairo-version = "2.3.0" name = "dojo_examples" version = "0.3.1" @@ -8,7 +8,6 @@ sierra-replace-ids = true [dependencies] dojo = { path = "../../crates/dojo-core" } -# dojo_erc = { path = "../../crates/dojo-erc" } [[target.dojo]] build-external-contracts = []