From 3424011d7d5a4ddfae7dbf07f51376a39a02f162 Mon Sep 17 00:00:00 2001 From: "remy.baranx@gmail.com" Date: Wed, 17 Jul 2024 14:22:54 +0200 Subject: [PATCH] add edition to Scarb.toml of Torii tests --- crates/dojo-core/src/world.cairo | 5 +- .../manifests/dev/base/dojo-world.toml | 4 +- crates/torii/types-test/Scarb.toml | 1 + crates/torii/types-test/src/contracts.cairo | 7 +- crates/torii/types-test/src/models.cairo | 97 ++++++++++--------- examples/spawn-and-move/Scarb.toml | 2 +- .../manifests/dev/base/dojo-world.toml | 4 +- .../manifests/dev/deployment/manifest.json | 16 +-- .../manifests/dev/deployment/manifest.toml | 16 +-- .../manifests/release/base/dojo-world.toml | 4 +- 10 files changed, 80 insertions(+), 76 deletions(-) diff --git a/crates/dojo-core/src/world.cairo b/crates/dojo-core/src/world.cairo index 0a6fa9c775..7929bd59b4 100644 --- a/crates/dojo-core/src/world.cairo +++ b/crates/dojo-core/src/world.cairo @@ -318,11 +318,12 @@ pub mod world { /// `resource_id` - The resource id. fn metadata(self: @ContractState, resource_id: felt252) -> ResourceMetadata { let mut values = self - .entity( + ._read_model_entity( dojo::model::Model::::selector(), - ModelIndex::Keys(array![resource_id].span()), + entity_id_from_keys(array![resource_id].span()), dojo::model::Model::::layout() ); + ResourceMetadataTrait::from_values(resource_id, ref values) } diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-world.toml b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-world.toml index b3ab13fadf..f403ca018f 100644 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-world.toml +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-world.toml @@ -1,6 +1,6 @@ kind = "Class" -class_hash = "0x6990b621c2db6fbffa4cbbe5c0d91103721c7246adc83a4b27715e2dba79eb" -original_class_hash = "0x6990b621c2db6fbffa4cbbe5c0d91103721c7246adc83a4b27715e2dba79eb" +class_hash = "0x71819175fb1971b65368cdbc486b7044ea1a15fe499296181c574e90d91adcd" +original_class_hash = "0x71819175fb1971b65368cdbc486b7044ea1a15fe499296181c574e90d91adcd" abi = "manifests/dev/base/abis/dojo-world.json" tag = "dojo-world" manifest_name = "dojo-world" diff --git a/crates/torii/types-test/Scarb.toml b/crates/torii/types-test/Scarb.toml index 1428cbe432..cb9e136633 100644 --- a/crates/torii/types-test/Scarb.toml +++ b/crates/torii/types-test/Scarb.toml @@ -1,5 +1,6 @@ [package] cairo-version = "=2.6.4" +edition = "2023_11" name = "types_test" version = "0.7.3" diff --git a/crates/torii/types-test/src/contracts.cairo b/crates/torii/types-test/src/contracts.cairo index 49fbd967ea..efb6271343 100644 --- a/crates/torii/types-test/src/contracts.cairo +++ b/crates/torii/types-test/src/contracts.cairo @@ -10,7 +10,8 @@ trait IRecords { mod records { use starknet::{ContractAddress, get_caller_address}; use types_test::models::{ - Record, RecordTrait, RecordSibling, RecordSiblingTrait, Subrecord, SubrecordTrait, Nested, NestedMore, NestedMost, Depth + Record, RecordTrait, RecordSibling, RecordSiblingTrait, Subrecord, SubrecordTrait, Nested, + NestedMore, NestedMost, Depth }; use types_test::{seed, random}; use super::IRecords; @@ -42,11 +43,11 @@ mod records { } let type_felt: felt252 = record_idx.into(); - let random_u8 = random(pedersen::pedersen(seed(), record_idx.into()), 0, 100) + let random_u8 = random(core::pedersen::pedersen(seed(), record_idx.into()), 0, 100) .try_into() .unwrap(); let random_u128 = random( - pedersen::pedersen(seed(), record_idx.into()), + core::pedersen::pedersen(seed(), record_idx.into()), 0, 0xffffffffffffffffffffffffffffffff_u128 ); diff --git a/crates/torii/types-test/src/models.cairo b/crates/torii/types-test/src/models.cairo index 489cefd6b1..0fe9a7e105 100644 --- a/crates/torii/types-test/src/models.cairo +++ b/crates/torii/types-test/src/models.cairo @@ -1,79 +1,79 @@ -use array::ArrayTrait; +use core::array::ArrayTrait; use starknet::{ContractAddress, ClassHash}; #[derive(Introspect, Drop, Serde)] #[dojo::model] -struct Record { +pub struct Record { #[key] - record_id: u32, - depth: Depth, - type_i8: i8, - type_i16: i16, - type_i32: i32, - type_i64: i64, - type_i128: i128, - type_u8: u8, - type_u16: u16, - type_u32: u32, - type_u64: u64, - type_u128: u128, - type_u256: u256, - type_bool: bool, - type_felt: felt252, - type_class_hash: ClassHash, - type_contract_address: ContractAddress, - type_deeply_nested: Nested, - type_nested_one: NestedMost, - type_nested_two: NestedMost, - random_u8: u8, - random_u128: u128, - composite_u256: u256, + pub record_id: u32, + pub depth: Depth, + pub type_i8: i8, + pub type_i16: i16, + pub type_i32: i32, + pub type_i64: i64, + pub type_i128: i128, + pub type_u8: u8, + pub type_u16: u16, + pub type_u32: u32, + pub type_u64: u64, + pub type_u128: u128, + pub type_u256: u256, + pub type_bool: bool, + pub type_felt: felt252, + pub type_class_hash: ClassHash, + pub type_contract_address: ContractAddress, + pub type_deeply_nested: Nested, + pub type_nested_one: NestedMost, + pub type_nested_two: NestedMost, + pub random_u8: u8, + pub random_u128: u128, + pub composite_u256: u256, } #[derive(Introspect, Copy, Drop, Serde)] #[dojo::model] -struct RecordSibling { +pub struct RecordSibling { #[key] - record_id: u32, - random_u8: u8 + pub record_id: u32, + pub random_u8: u8 } #[derive(Copy, Drop, Serde, Introspect)] -struct Nested { - depth: Depth, - type_number: u8, - type_string: felt252, - type_nested_more: NestedMore, +pub struct Nested { + pub depth: Depth, + pub type_number: u8, + pub type_string: felt252, + pub type_nested_more: NestedMore, } #[derive(Copy, Drop, Serde, Introspect)] -struct NestedMore { - depth: Depth, - type_number: u8, - type_string: felt252, - type_nested_most: NestedMost, +pub struct NestedMore { + pub depth: Depth, + pub type_number: u8, + pub type_string: felt252, + pub type_nested_most: NestedMost, } #[derive(Copy, Drop, Serde, Introspect)] -struct NestedMost { - depth: Depth, - type_number: u8, - type_string: felt252, +pub struct NestedMost { + pub depth: Depth, + pub type_number: u8, + pub type_string: felt252, } #[derive(Introspect, Copy, Drop, Serde)] #[dojo::model] -struct Subrecord { +pub struct Subrecord { #[key] - record_id: u32, + pub record_id: u32, #[key] - subrecord_id: u32, - type_u8: u8, - random_u8: u8, + pub subrecord_id: u32, + pub type_u8: u8, + pub random_u8: u8, } #[derive(Serde, Copy, Drop, Introspect)] -enum Depth { +pub enum Depth { Zero: (), One: (), Two: (), @@ -354,3 +354,4 @@ impl DepthIntoFelt252 of Into { // a255: u256, // } + diff --git a/examples/spawn-and-move/Scarb.toml b/examples/spawn-and-move/Scarb.toml index 25a5853233..fa83fe8e62 100644 --- a/examples/spawn-and-move/Scarb.toml +++ b/examples/spawn-and-move/Scarb.toml @@ -43,7 +43,7 @@ rpc_url = "http://localhost:5050/" # Default account for katana with seed = 0 account_address = "0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03" private_key = "0x1800000000300000180000000000030000000000003006001800006600" -world_address = "0x2bab2a15d4c71bd8e45c84ac3b1518aeca39d3818e8e556c4a56202c1679ba6" +world_address = "0x62c5e1e2ceab297dfaca3ef17ca6549635272f363bd5373c888bbacdc3d8548" [profile.release.tool.dojo] # for more info on how `merge-strategy` works see: diff --git a/examples/spawn-and-move/manifests/dev/base/dojo-world.toml b/examples/spawn-and-move/manifests/dev/base/dojo-world.toml index b3ab13fadf..f403ca018f 100644 --- a/examples/spawn-and-move/manifests/dev/base/dojo-world.toml +++ b/examples/spawn-and-move/manifests/dev/base/dojo-world.toml @@ -1,6 +1,6 @@ kind = "Class" -class_hash = "0x6990b621c2db6fbffa4cbbe5c0d91103721c7246adc83a4b27715e2dba79eb" -original_class_hash = "0x6990b621c2db6fbffa4cbbe5c0d91103721c7246adc83a4b27715e2dba79eb" +class_hash = "0x71819175fb1971b65368cdbc486b7044ea1a15fe499296181c574e90d91adcd" +original_class_hash = "0x71819175fb1971b65368cdbc486b7044ea1a15fe499296181c574e90d91adcd" abi = "manifests/dev/base/abis/dojo-world.json" tag = "dojo-world" manifest_name = "dojo-world" diff --git a/examples/spawn-and-move/manifests/dev/deployment/manifest.json b/examples/spawn-and-move/manifests/dev/deployment/manifest.json index 9c2b5edc83..6f2486e866 100644 --- a/examples/spawn-and-move/manifests/dev/deployment/manifest.json +++ b/examples/spawn-and-move/manifests/dev/deployment/manifest.json @@ -1,8 +1,8 @@ { "world": { "kind": "WorldContract", - "class_hash": "0x6990b621c2db6fbffa4cbbe5c0d91103721c7246adc83a4b27715e2dba79eb", - "original_class_hash": "0x6990b621c2db6fbffa4cbbe5c0d91103721c7246adc83a4b27715e2dba79eb", + "class_hash": "0x71819175fb1971b65368cdbc486b7044ea1a15fe499296181c574e90d91adcd", + "original_class_hash": "0x71819175fb1971b65368cdbc486b7044ea1a15fe499296181c574e90d91adcd", "abi": [ { "type": "impl", @@ -1189,8 +1189,8 @@ ] } ], - "address": "0x2bab2a15d4c71bd8e45c84ac3b1518aeca39d3818e8e556c4a56202c1679ba6", - "transaction_hash": "0x1e4e0d098436df78bfd2f61cfd24273bd2f9de70b1ad372aa5d122f2ad7cc75", + "address": "0x62c5e1e2ceab297dfaca3ef17ca6549635272f363bd5373c888bbacdc3d8548", + "transaction_hash": "0x30d768fa29fd2ba80734946a339118c1adfea82629458b054a4d4a35103db47", "block_number": 3, "seed": "dojo_examples", "metadata": { @@ -1210,7 +1210,7 @@ "contracts": [ { "kind": "DojoContract", - "address": "0x5718df0ef4ac58def63459069d160887ad637f979cf425d0ddb6fd77f3cd121", + "address": "0x604bd94012befb403ad70472bcbae1504211b17c804373ea835aec77eb1ee1", "class_hash": "0xb3f81618df8f1170864da1c68f565aafe192c30f9b73436af4823b293a7ea5", "original_class_hash": "0xb3f81618df8f1170864da1c68f565aafe192c30f9b73436af4823b293a7ea5", "base_class_hash": "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4", @@ -1641,7 +1641,7 @@ }, { "kind": "DojoContract", - "address": "0x3e629315ea75d37711b4146af01efa2f0218e8aefda2ceb42bb0fd310cb2840", + "address": "0x7e7462000391d3084e3eabd1c28f027c06ad683c787cd8173ca33d906e9a082", "class_hash": "0x14b3096b82a761f63dd47277c2b5ac18925dea43586418483939a2f1f57f674", "original_class_hash": "0x14b3096b82a761f63dd47277c2b5ac18925dea43586418483939a2f1f57f674", "base_class_hash": "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4", @@ -1878,7 +1878,7 @@ }, { "kind": "DojoContract", - "address": "0x22edd1c0f399a12c2f9789b1a36bb02e22c3300aabfeac4bfe6b7dc2a95b70d", + "address": "0xcc6decf700ca5870865e95307c74cb531728f6d50670449fa33518e4a9c3c8", "class_hash": "0x761d18a3557d98b3962ebb2c9ddae89ad586ce81de7e86c5fd1e1b4f9d0028", "original_class_hash": "0x761d18a3557d98b3962ebb2c9ddae89ad586ce81de7e86c5fd1e1b4f9d0028", "base_class_hash": "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4", @@ -2097,7 +2097,7 @@ }, { "kind": "DojoContract", - "address": "0x7d38ad1bf17abfd26749f4780b95c525cc562c8ffba994bbe8e09de36b25404", + "address": "0x6cf6ece03c80fcddd4107270a52eab493534b8ccf8346ff17d451362a4e99d0", "class_hash": "0x479bfb12dcba5398d77303e7a665fc3fedb16f2d7f9cb1f5d7e2beb3b7e2ba7", "original_class_hash": "0x479bfb12dcba5398d77303e7a665fc3fedb16f2d7f9cb1f5d7e2beb3b7e2ba7", "base_class_hash": "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4", diff --git a/examples/spawn-and-move/manifests/dev/deployment/manifest.toml b/examples/spawn-and-move/manifests/dev/deployment/manifest.toml index 44183e4072..a3f19d5d63 100644 --- a/examples/spawn-and-move/manifests/dev/deployment/manifest.toml +++ b/examples/spawn-and-move/manifests/dev/deployment/manifest.toml @@ -1,10 +1,10 @@ [world] kind = "WorldContract" -class_hash = "0x6990b621c2db6fbffa4cbbe5c0d91103721c7246adc83a4b27715e2dba79eb" -original_class_hash = "0x6990b621c2db6fbffa4cbbe5c0d91103721c7246adc83a4b27715e2dba79eb" +class_hash = "0x71819175fb1971b65368cdbc486b7044ea1a15fe499296181c574e90d91adcd" +original_class_hash = "0x71819175fb1971b65368cdbc486b7044ea1a15fe499296181c574e90d91adcd" abi = "manifests/dev/deployment/abis/dojo-world.json" -address = "0x2bab2a15d4c71bd8e45c84ac3b1518aeca39d3818e8e556c4a56202c1679ba6" -transaction_hash = "0x1e4e0d098436df78bfd2f61cfd24273bd2f9de70b1ad372aa5d122f2ad7cc75" +address = "0x62c5e1e2ceab297dfaca3ef17ca6549635272f363bd5373c888bbacdc3d8548" +transaction_hash = "0x30d768fa29fd2ba80734946a339118c1adfea82629458b054a4d4a35103db47" block_number = 3 seed = "dojo_examples" manifest_name = "dojo-world" @@ -23,7 +23,7 @@ manifest_name = "dojo-base" [[contracts]] kind = "DojoContract" -address = "0x5718df0ef4ac58def63459069d160887ad637f979cf425d0ddb6fd77f3cd121" +address = "0x604bd94012befb403ad70472bcbae1504211b17c804373ea835aec77eb1ee1" class_hash = "0xb3f81618df8f1170864da1c68f565aafe192c30f9b73436af4823b293a7ea5" original_class_hash = "0xb3f81618df8f1170864da1c68f565aafe192c30f9b73436af4823b293a7ea5" base_class_hash = "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4" @@ -40,7 +40,7 @@ manifest_name = "dojo_examples-actions-40b6994c" [[contracts]] kind = "DojoContract" -address = "0x3e629315ea75d37711b4146af01efa2f0218e8aefda2ceb42bb0fd310cb2840" +address = "0x7e7462000391d3084e3eabd1c28f027c06ad683c787cd8173ca33d906e9a082" class_hash = "0x14b3096b82a761f63dd47277c2b5ac18925dea43586418483939a2f1f57f674" original_class_hash = "0x14b3096b82a761f63dd47277c2b5ac18925dea43586418483939a2f1f57f674" base_class_hash = "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4" @@ -54,7 +54,7 @@ manifest_name = "dojo_examples-dungeon-6620e0e6" [[contracts]] kind = "DojoContract" -address = "0x22edd1c0f399a12c2f9789b1a36bb02e22c3300aabfeac4bfe6b7dc2a95b70d" +address = "0xcc6decf700ca5870865e95307c74cb531728f6d50670449fa33518e4a9c3c8" class_hash = "0x761d18a3557d98b3962ebb2c9ddae89ad586ce81de7e86c5fd1e1b4f9d0028" original_class_hash = "0x761d18a3557d98b3962ebb2c9ddae89ad586ce81de7e86c5fd1e1b4f9d0028" base_class_hash = "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4" @@ -68,7 +68,7 @@ manifest_name = "dojo_examples-mock_token-31599eb2" [[contracts]] kind = "DojoContract" -address = "0x7d38ad1bf17abfd26749f4780b95c525cc562c8ffba994bbe8e09de36b25404" +address = "0x6cf6ece03c80fcddd4107270a52eab493534b8ccf8346ff17d451362a4e99d0" class_hash = "0x479bfb12dcba5398d77303e7a665fc3fedb16f2d7f9cb1f5d7e2beb3b7e2ba7" original_class_hash = "0x479bfb12dcba5398d77303e7a665fc3fedb16f2d7f9cb1f5d7e2beb3b7e2ba7" base_class_hash = "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4" diff --git a/examples/spawn-and-move/manifests/release/base/dojo-world.toml b/examples/spawn-and-move/manifests/release/base/dojo-world.toml index 63d67ac31f..da20975053 100644 --- a/examples/spawn-and-move/manifests/release/base/dojo-world.toml +++ b/examples/spawn-and-move/manifests/release/base/dojo-world.toml @@ -1,6 +1,6 @@ kind = "Class" -class_hash = "0x6990b621c2db6fbffa4cbbe5c0d91103721c7246adc83a4b27715e2dba79eb" -original_class_hash = "0x6990b621c2db6fbffa4cbbe5c0d91103721c7246adc83a4b27715e2dba79eb" +class_hash = "0x71819175fb1971b65368cdbc486b7044ea1a15fe499296181c574e90d91adcd" +original_class_hash = "0x71819175fb1971b65368cdbc486b7044ea1a15fe499296181c574e90d91adcd" abi = "manifests/release/base/abis/dojo-world.json" tag = "dojo-world" manifest_name = "dojo-world"