From c24b82f366868c3b3680055bc7dd58c4211ec65b Mon Sep 17 00:00:00 2001 From: "remy.baranx@gmail.com" Date: Sun, 14 Apr 2024 15:25:17 +0800 Subject: [PATCH] update dojo-lang tests --- crates/dojo-lang/src/plugin_test_data/model | 1098 +++++++++++------- crates/dojo-lang/src/plugin_test_data/system | 104 +- crates/dojo-lang/src/semantics/test_data/get | 56 +- crates/dojo-lang/src/semantics/test_data/set | 22 +- 4 files changed, 737 insertions(+), 543 deletions(-) diff --git a/crates/dojo-lang/src/plugin_test_data/model b/crates/dojo-lang/src/plugin_test_data/model index 1f89d0769b..c34371cd5c 100644 --- a/crates/dojo-lang/src/plugin_test_data/model +++ b/crates/dojo-lang/src/plugin_test_data/model @@ -294,7 +294,7 @@ struct Player { type OtherPlayer = Player; impl BadModelMultipleVersionsModel of dojo::model::Model { - fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: Span) -> BadModelMultipleVersions { + fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::model::ModelLayout) -> BadModelMultipleVersions { let values = dojo::world::IWorldDispatcherTrait::entity(world, selector!("BadModelMultipleVersions"), keys, layout); // TODO: Generate method to deserialize from keys / values directly to avoid @@ -316,20 +316,25 @@ impl BadModelMultipleVersionsModel of dojo::model::Model ByteArray { + fn name() -> ByteArray { "BadModelMultipleVersions" } #[inline(always)] - fn version(self: @BadModelMultipleVersions) -> u8 { + fn version() -> u8 { 0 } #[inline(always)] - fn selector(self: @BadModelMultipleVersions) -> felt252 { + fn selector() -> felt252 { "BadModelMultipleVersions" } + #[inline(always)] + fn instance_selector(self: @BadModelMultipleVersions) -> felt252 { + dojo::model::Model::::selector() + } + #[inline(always)] fn keys(self: @BadModelMultipleVersions) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -345,16 +350,29 @@ impl BadModelMultipleVersionsModel of dojo::model::Model Span { + fn layout() -> dojo::model::ModelLayout { let mut layout = core::array::ArrayTrait::new(); dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + dojo::model::ModelLayout::Serial(core::array::ArrayTrait::span(@layout)) + } + + #[inline(always)] + fn instance_layout(self: @BadModelMultipleVersions) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() } #[inline(always)] - fn packed_size(self: @BadModelMultipleVersions) -> usize { - let mut layout = self.layout(); - dojo::packing::calculate_packed_size(ref layout) + fn packed_size() -> usize { + match dojo::model::Model::::layout() { + dojo::model::ModelLayout::Serial(layout) => { + let mut layout = layout.clone(); + dojo::packing::calculate_packed_size(ref layout) + }, + _ => { + panic!("Unexpected error"); + 0 + } + } } } @@ -374,15 +392,15 @@ mod bad_model_multiple_versions { #[abi(embed_v0)] impl DojoModelImpl of dojo::model::IModel{ fn selector(self: @ContractState) -> felt252 { - "BadModelMultipleVersions" + dojo::model::Model::::selector() } fn name(self: @ContractState) -> ByteArray { - "BadModelMultipleVersions" + dojo::model::Model::::name() } fn version(self: @ContractState) -> u8 { - 0 + dojo::model::Model::::version() } fn unpacked_size(self: @ContractState) -> usize { @@ -390,16 +408,11 @@ mod bad_model_multiple_versions { } fn packed_size(self: @ContractState) -> usize { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - let mut layout_span = layout.span(); - dojo::packing::calculate_packed_size(ref layout_span) + dojo::model::Model::::packed_size() } - fn layout(self: @ContractState) -> Span { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + fn layout(self: @ContractState) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() } fn schema(self: @ContractState) -> dojo::database::introspect::Ty { @@ -415,7 +428,7 @@ mod bad_model_multiple_versions { } impl BadModelBadVersionTypeModel of dojo::model::Model { - fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: Span) -> BadModelBadVersionType { + fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::model::ModelLayout) -> BadModelBadVersionType { let values = dojo::world::IWorldDispatcherTrait::entity(world, selector!("BadModelBadVersionType"), keys, layout); // TODO: Generate method to deserialize from keys / values directly to avoid @@ -437,20 +450,25 @@ impl BadModelBadVersionTypeModel of dojo::model::Model { } #[inline(always)] - fn name(self: @BadModelBadVersionType) -> ByteArray { + fn name() -> ByteArray { "BadModelBadVersionType" } #[inline(always)] - fn version(self: @BadModelBadVersionType) -> u8 { + fn version() -> u8 { 1 } #[inline(always)] - fn selector(self: @BadModelBadVersionType) -> felt252 { + fn selector() -> felt252 { selector!("BadModelBadVersionType") } + #[inline(always)] + fn instance_selector(self: @BadModelBadVersionType) -> felt252 { + dojo::model::Model::::selector() + } + #[inline(always)] fn keys(self: @BadModelBadVersionType) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -466,16 +484,29 @@ impl BadModelBadVersionTypeModel of dojo::model::Model { } #[inline(always)] - fn layout(self: @BadModelBadVersionType) -> Span { + fn layout() -> dojo::model::ModelLayout { let mut layout = core::array::ArrayTrait::new(); dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + dojo::model::ModelLayout::Serial(core::array::ArrayTrait::span(@layout)) + } + + #[inline(always)] + fn instance_layout(self: @BadModelBadVersionType) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() } #[inline(always)] - fn packed_size(self: @BadModelBadVersionType) -> usize { - let mut layout = self.layout(); - dojo::packing::calculate_packed_size(ref layout) + fn packed_size() -> usize { + match dojo::model::Model::::layout() { + dojo::model::ModelLayout::Serial(layout) => { + let mut layout = layout.clone(); + dojo::packing::calculate_packed_size(ref layout) + }, + _ => { + panic!("Unexpected error"); + 0 + } + } } } @@ -495,15 +526,15 @@ mod bad_model_bad_version_type { #[abi(embed_v0)] impl DojoModelImpl of dojo::model::IModel{ fn selector(self: @ContractState) -> felt252 { - selector!("BadModelBadVersionType") + dojo::model::Model::::selector() } fn name(self: @ContractState) -> ByteArray { - "BadModelBadVersionType" + dojo::model::Model::::name() } fn version(self: @ContractState) -> u8 { - 1 + dojo::model::Model::::version() } fn unpacked_size(self: @ContractState) -> usize { @@ -511,16 +542,11 @@ mod bad_model_bad_version_type { } fn packed_size(self: @ContractState) -> usize { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - let mut layout_span = layout.span(); - dojo::packing::calculate_packed_size(ref layout_span) + dojo::model::Model::::packed_size() } - fn layout(self: @ContractState) -> Span { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + fn layout(self: @ContractState) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() } fn schema(self: @ContractState) -> dojo::database::introspect::Ty { @@ -536,7 +562,7 @@ mod bad_model_bad_version_type { } impl BadModelNoVersionValueModel of dojo::model::Model { - fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: Span) -> BadModelNoVersionValue { + fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::model::ModelLayout) -> BadModelNoVersionValue { let values = dojo::world::IWorldDispatcherTrait::entity(world, selector!("BadModelNoVersionValue"), keys, layout); // TODO: Generate method to deserialize from keys / values directly to avoid @@ -558,20 +584,25 @@ impl BadModelNoVersionValueModel of dojo::model::Model { } #[inline(always)] - fn name(self: @BadModelNoVersionValue) -> ByteArray { + fn name() -> ByteArray { "BadModelNoVersionValue" } #[inline(always)] - fn version(self: @BadModelNoVersionValue) -> u8 { + fn version() -> u8 { 1 } #[inline(always)] - fn selector(self: @BadModelNoVersionValue) -> felt252 { + fn selector() -> felt252 { selector!("BadModelNoVersionValue") } + #[inline(always)] + fn instance_selector(self: @BadModelNoVersionValue) -> felt252 { + dojo::model::Model::::selector() + } + #[inline(always)] fn keys(self: @BadModelNoVersionValue) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -587,16 +618,29 @@ impl BadModelNoVersionValueModel of dojo::model::Model { } #[inline(always)] - fn layout(self: @BadModelNoVersionValue) -> Span { + fn layout() -> dojo::model::ModelLayout { let mut layout = core::array::ArrayTrait::new(); dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + dojo::model::ModelLayout::Serial(core::array::ArrayTrait::span(@layout)) + } + + #[inline(always)] + fn instance_layout(self: @BadModelNoVersionValue) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() } #[inline(always)] - fn packed_size(self: @BadModelNoVersionValue) -> usize { - let mut layout = self.layout(); - dojo::packing::calculate_packed_size(ref layout) + fn packed_size() -> usize { + match dojo::model::Model::::layout() { + dojo::model::ModelLayout::Serial(layout) => { + let mut layout = layout.clone(); + dojo::packing::calculate_packed_size(ref layout) + }, + _ => { + panic!("Unexpected error"); + 0 + } + } } } @@ -616,15 +660,15 @@ mod bad_model_no_version_value { #[abi(embed_v0)] impl DojoModelImpl of dojo::model::IModel{ fn selector(self: @ContractState) -> felt252 { - selector!("BadModelNoVersionValue") + dojo::model::Model::::selector() } fn name(self: @ContractState) -> ByteArray { - "BadModelNoVersionValue" + dojo::model::Model::::name() } fn version(self: @ContractState) -> u8 { - 1 + dojo::model::Model::::version() } fn unpacked_size(self: @ContractState) -> usize { @@ -632,16 +676,11 @@ mod bad_model_no_version_value { } fn packed_size(self: @ContractState) -> usize { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - let mut layout_span = layout.span(); - dojo::packing::calculate_packed_size(ref layout_span) + dojo::model::Model::::packed_size() } - fn layout(self: @ContractState) -> Span { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + fn layout(self: @ContractState) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() } fn schema(self: @ContractState) -> dojo::database::introspect::Ty { @@ -657,7 +696,7 @@ mod bad_model_no_version_value { } impl BadModelUnexpectedArgWithValueModel of dojo::model::Model { - fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: Span) -> BadModelUnexpectedArgWithValue { + fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::model::ModelLayout) -> BadModelUnexpectedArgWithValue { let values = dojo::world::IWorldDispatcherTrait::entity(world, selector!("BadModelUnexpectedArgWithValue"), keys, layout); // TODO: Generate method to deserialize from keys / values directly to avoid @@ -679,20 +718,25 @@ impl BadModelUnexpectedArgWithValueModel of dojo::model::Model ByteArray { + fn name() -> ByteArray { "BadModelUnexpectedArgWithValue" } #[inline(always)] - fn version(self: @BadModelUnexpectedArgWithValue) -> u8 { + fn version() -> u8 { 1 } #[inline(always)] - fn selector(self: @BadModelUnexpectedArgWithValue) -> felt252 { + fn selector() -> felt252 { selector!("BadModelUnexpectedArgWithValue") } + #[inline(always)] + fn instance_selector(self: @BadModelUnexpectedArgWithValue) -> felt252 { + dojo::model::Model::::selector() + } + #[inline(always)] fn keys(self: @BadModelUnexpectedArgWithValue) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -708,16 +752,29 @@ impl BadModelUnexpectedArgWithValueModel of dojo::model::Model Span { + fn layout() -> dojo::model::ModelLayout { let mut layout = core::array::ArrayTrait::new(); dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + dojo::model::ModelLayout::Serial(core::array::ArrayTrait::span(@layout)) } #[inline(always)] - fn packed_size(self: @BadModelUnexpectedArgWithValue) -> usize { - let mut layout = self.layout(); - dojo::packing::calculate_packed_size(ref layout) + fn instance_layout(self: @BadModelUnexpectedArgWithValue) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() + } + + #[inline(always)] + fn packed_size() -> usize { + match dojo::model::Model::::layout() { + dojo::model::ModelLayout::Serial(layout) => { + let mut layout = layout.clone(); + dojo::packing::calculate_packed_size(ref layout) + }, + _ => { + panic!("Unexpected error"); + 0 + } + } } } @@ -737,15 +794,15 @@ mod bad_model_unexpected_arg_with_value { #[abi(embed_v0)] impl DojoModelImpl of dojo::model::IModel{ fn selector(self: @ContractState) -> felt252 { - selector!("BadModelUnexpectedArgWithValue") + dojo::model::Model::::selector() } fn name(self: @ContractState) -> ByteArray { - "BadModelUnexpectedArgWithValue" + dojo::model::Model::::name() } fn version(self: @ContractState) -> u8 { - 1 + dojo::model::Model::::version() } fn unpacked_size(self: @ContractState) -> usize { @@ -753,16 +810,11 @@ mod bad_model_unexpected_arg_with_value { } fn packed_size(self: @ContractState) -> usize { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - let mut layout_span = layout.span(); - dojo::packing::calculate_packed_size(ref layout_span) + dojo::model::Model::::packed_size() } - fn layout(self: @ContractState) -> Span { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + fn layout(self: @ContractState) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() } fn schema(self: @ContractState) -> dojo::database::introspect::Ty { @@ -778,7 +830,7 @@ mod bad_model_unexpected_arg_with_value { } impl BadModelUnexpectedArgModel of dojo::model::Model { - fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: Span) -> BadModelUnexpectedArg { + fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::model::ModelLayout) -> BadModelUnexpectedArg { let values = dojo::world::IWorldDispatcherTrait::entity(world, selector!("BadModelUnexpectedArg"), keys, layout); // TODO: Generate method to deserialize from keys / values directly to avoid @@ -800,20 +852,25 @@ impl BadModelUnexpectedArgModel of dojo::model::Model { } #[inline(always)] - fn name(self: @BadModelUnexpectedArg) -> ByteArray { + fn name() -> ByteArray { "BadModelUnexpectedArg" } #[inline(always)] - fn version(self: @BadModelUnexpectedArg) -> u8 { + fn version() -> u8 { 1 } #[inline(always)] - fn selector(self: @BadModelUnexpectedArg) -> felt252 { + fn selector() -> felt252 { selector!("BadModelUnexpectedArg") } + #[inline(always)] + fn instance_selector(self: @BadModelUnexpectedArg) -> felt252 { + dojo::model::Model::::selector() + } + #[inline(always)] fn keys(self: @BadModelUnexpectedArg) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -829,16 +886,29 @@ impl BadModelUnexpectedArgModel of dojo::model::Model { } #[inline(always)] - fn layout(self: @BadModelUnexpectedArg) -> Span { + fn layout() -> dojo::model::ModelLayout { let mut layout = core::array::ArrayTrait::new(); dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + dojo::model::ModelLayout::Serial(core::array::ArrayTrait::span(@layout)) } #[inline(always)] - fn packed_size(self: @BadModelUnexpectedArg) -> usize { - let mut layout = self.layout(); - dojo::packing::calculate_packed_size(ref layout) + fn instance_layout(self: @BadModelUnexpectedArg) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() + } + + #[inline(always)] + fn packed_size() -> usize { + match dojo::model::Model::::layout() { + dojo::model::ModelLayout::Serial(layout) => { + let mut layout = layout.clone(); + dojo::packing::calculate_packed_size(ref layout) + }, + _ => { + panic!("Unexpected error"); + 0 + } + } } } @@ -858,15 +928,15 @@ mod bad_model_unexpected_arg { #[abi(embed_v0)] impl DojoModelImpl of dojo::model::IModel{ fn selector(self: @ContractState) -> felt252 { - selector!("BadModelUnexpectedArg") + dojo::model::Model::::selector() } fn name(self: @ContractState) -> ByteArray { - "BadModelUnexpectedArg" + dojo::model::Model::::name() } fn version(self: @ContractState) -> u8 { - 1 + dojo::model::Model::::version() } fn unpacked_size(self: @ContractState) -> usize { @@ -874,16 +944,11 @@ mod bad_model_unexpected_arg { } fn packed_size(self: @ContractState) -> usize { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - let mut layout_span = layout.span(); - dojo::packing::calculate_packed_size(ref layout_span) + dojo::model::Model::::packed_size() } - fn layout(self: @ContractState) -> Span { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + fn layout(self: @ContractState) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() } fn schema(self: @ContractState) -> dojo::database::introspect::Ty { @@ -899,7 +964,7 @@ mod bad_model_unexpected_arg { } impl BadModelNotSupportedVersionModel of dojo::model::Model { - fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: Span) -> BadModelNotSupportedVersion { + fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::model::ModelLayout) -> BadModelNotSupportedVersion { let values = dojo::world::IWorldDispatcherTrait::entity(world, selector!("BadModelNotSupportedVersion"), keys, layout); // TODO: Generate method to deserialize from keys / values directly to avoid @@ -921,20 +986,25 @@ impl BadModelNotSupportedVersionModel of dojo::model::Model ByteArray { + fn name() -> ByteArray { "BadModelNotSupportedVersion" } #[inline(always)] - fn version(self: @BadModelNotSupportedVersion) -> u8 { + fn version() -> u8 { 1 } #[inline(always)] - fn selector(self: @BadModelNotSupportedVersion) -> felt252 { + fn selector() -> felt252 { selector!("BadModelNotSupportedVersion") } + #[inline(always)] + fn instance_selector(self: @BadModelNotSupportedVersion) -> felt252 { + dojo::model::Model::::selector() + } + #[inline(always)] fn keys(self: @BadModelNotSupportedVersion) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -950,16 +1020,29 @@ impl BadModelNotSupportedVersionModel of dojo::model::Model Span { + fn layout() -> dojo::model::ModelLayout { let mut layout = core::array::ArrayTrait::new(); dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + dojo::model::ModelLayout::Serial(core::array::ArrayTrait::span(@layout)) + } + + #[inline(always)] + fn instance_layout(self: @BadModelNotSupportedVersion) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() } #[inline(always)] - fn packed_size(self: @BadModelNotSupportedVersion) -> usize { - let mut layout = self.layout(); - dojo::packing::calculate_packed_size(ref layout) + fn packed_size() -> usize { + match dojo::model::Model::::layout() { + dojo::model::ModelLayout::Serial(layout) => { + let mut layout = layout.clone(); + dojo::packing::calculate_packed_size(ref layout) + }, + _ => { + panic!("Unexpected error"); + 0 + } + } } } @@ -979,15 +1062,15 @@ mod bad_model_not_supported_version { #[abi(embed_v0)] impl DojoModelImpl of dojo::model::IModel{ fn selector(self: @ContractState) -> felt252 { - selector!("BadModelNotSupportedVersion") + dojo::model::Model::::selector() } fn name(self: @ContractState) -> ByteArray { - "BadModelNotSupportedVersion" + dojo::model::Model::::name() } fn version(self: @ContractState) -> u8 { - 1 + dojo::model::Model::::version() } fn unpacked_size(self: @ContractState) -> usize { @@ -995,16 +1078,11 @@ mod bad_model_not_supported_version { } fn packed_size(self: @ContractState) -> usize { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - let mut layout_span = layout.span(); - dojo::packing::calculate_packed_size(ref layout_span) + dojo::model::Model::::packed_size() } - fn layout(self: @ContractState) -> Span { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + fn layout(self: @ContractState) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() } fn schema(self: @ContractState) -> dojo::database::introspect::Ty { @@ -1020,7 +1098,7 @@ mod bad_model_not_supported_version { } impl BadModelMultipleLayoutsModel of dojo::model::Model { - fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: Span) -> BadModelMultipleLayouts { + fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::model::ModelLayout) -> BadModelMultipleLayouts { let values = dojo::world::IWorldDispatcherTrait::entity(world, selector!("BadModelMultipleLayouts"), keys, layout); // TODO: Generate method to deserialize from keys / values directly to avoid @@ -1042,20 +1120,25 @@ impl BadModelMultipleLayoutsModel of dojo::model::Model } #[inline(always)] - fn name(self: @BadModelMultipleLayouts) -> ByteArray { + fn name() -> ByteArray { "BadModelMultipleLayouts" } #[inline(always)] - fn version(self: @BadModelMultipleLayouts) -> u8 { + fn version() -> u8 { 1 } #[inline(always)] - fn selector(self: @BadModelMultipleLayouts) -> felt252 { + fn selector() -> felt252 { selector!("BadModelMultipleLayouts") } + #[inline(always)] + fn instance_selector(self: @BadModelMultipleLayouts) -> felt252 { + dojo::model::Model::::selector() + } + #[inline(always)] fn keys(self: @BadModelMultipleLayouts) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -1071,16 +1154,29 @@ impl BadModelMultipleLayoutsModel of dojo::model::Model } #[inline(always)] - fn layout(self: @BadModelMultipleLayouts) -> Span { + fn layout() -> dojo::model::ModelLayout { let mut layout = core::array::ArrayTrait::new(); dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + dojo::model::ModelLayout::Serial(core::array::ArrayTrait::span(@layout)) } #[inline(always)] - fn packed_size(self: @BadModelMultipleLayouts) -> usize { - let mut layout = self.layout(); - dojo::packing::calculate_packed_size(ref layout) + fn instance_layout(self: @BadModelMultipleLayouts) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() + } + + #[inline(always)] + fn packed_size() -> usize { + match dojo::model::Model::::layout() { + dojo::model::ModelLayout::Serial(layout) => { + let mut layout = layout.clone(); + dojo::packing::calculate_packed_size(ref layout) + }, + _ => { + panic!("Unexpected error"); + 0 + } + } } } @@ -1100,15 +1196,15 @@ mod bad_model_multiple_layouts { #[abi(embed_v0)] impl DojoModelImpl of dojo::model::IModel{ fn selector(self: @ContractState) -> felt252 { - selector!("BadModelMultipleLayouts") + dojo::model::Model::::selector() } fn name(self: @ContractState) -> ByteArray { - "BadModelMultipleLayouts" + dojo::model::Model::::name() } fn version(self: @ContractState) -> u8 { - 1 + dojo::model::Model::::version() } fn unpacked_size(self: @ContractState) -> usize { @@ -1116,16 +1212,11 @@ mod bad_model_multiple_layouts { } fn packed_size(self: @ContractState) -> usize { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - let mut layout_span = layout.span(); - dojo::packing::calculate_packed_size(ref layout_span) + dojo::model::Model::::packed_size() } - fn layout(self: @ContractState) -> Span { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + fn layout(self: @ContractState) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() } fn schema(self: @ContractState) -> dojo::database::introspect::Ty { @@ -1141,7 +1232,7 @@ mod bad_model_multiple_layouts { } impl BadModelBadLayoutTypeModel of dojo::model::Model { - fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: Span) -> BadModelBadLayoutType { + fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::model::ModelLayout) -> BadModelBadLayoutType { let values = dojo::world::IWorldDispatcherTrait::entity(world, selector!("BadModelBadLayoutType"), keys, layout); // TODO: Generate method to deserialize from keys / values directly to avoid @@ -1163,20 +1254,25 @@ impl BadModelBadLayoutTypeModel of dojo::model::Model { } #[inline(always)] - fn name(self: @BadModelBadLayoutType) -> ByteArray { + fn name() -> ByteArray { "BadModelBadLayoutType" } #[inline(always)] - fn version(self: @BadModelBadLayoutType) -> u8 { + fn version() -> u8 { 1 } #[inline(always)] - fn selector(self: @BadModelBadLayoutType) -> felt252 { + fn selector() -> felt252 { selector!("BadModelBadLayoutType") } + #[inline(always)] + fn instance_selector(self: @BadModelBadLayoutType) -> felt252 { + dojo::model::Model::::selector() + } + #[inline(always)] fn keys(self: @BadModelBadLayoutType) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -1192,16 +1288,29 @@ impl BadModelBadLayoutTypeModel of dojo::model::Model { } #[inline(always)] - fn layout(self: @BadModelBadLayoutType) -> Span { + fn layout() -> dojo::model::ModelLayout { let mut layout = core::array::ArrayTrait::new(); dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + dojo::model::ModelLayout::Serial(core::array::ArrayTrait::span(@layout)) } #[inline(always)] - fn packed_size(self: @BadModelBadLayoutType) -> usize { - let mut layout = self.layout(); - dojo::packing::calculate_packed_size(ref layout) + fn instance_layout(self: @BadModelBadLayoutType) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() + } + + #[inline(always)] + fn packed_size() -> usize { + match dojo::model::Model::::layout() { + dojo::model::ModelLayout::Serial(layout) => { + let mut layout = layout.clone(); + dojo::packing::calculate_packed_size(ref layout) + }, + _ => { + panic!("Unexpected error"); + 0 + } + } } } @@ -1221,15 +1330,15 @@ mod bad_model_bad_layout_type { #[abi(embed_v0)] impl DojoModelImpl of dojo::model::IModel{ fn selector(self: @ContractState) -> felt252 { - selector!("BadModelBadLayoutType") + dojo::model::Model::::selector() } fn name(self: @ContractState) -> ByteArray { - "BadModelBadLayoutType" + dojo::model::Model::::name() } fn version(self: @ContractState) -> u8 { - 1 + dojo::model::Model::::version() } fn unpacked_size(self: @ContractState) -> usize { @@ -1237,16 +1346,11 @@ mod bad_model_bad_layout_type { } fn packed_size(self: @ContractState) -> usize { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - let mut layout_span = layout.span(); - dojo::packing::calculate_packed_size(ref layout_span) + dojo::model::Model::::packed_size() } - fn layout(self: @ContractState) -> Span { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + fn layout(self: @ContractState) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() } fn schema(self: @ContractState) -> dojo::database::introspect::Ty { @@ -1262,7 +1366,7 @@ mod bad_model_bad_layout_type { } impl BadModelNoLayoutValueModel of dojo::model::Model { - fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: Span) -> BadModelNoLayoutValue { + fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::model::ModelLayout) -> BadModelNoLayoutValue { let values = dojo::world::IWorldDispatcherTrait::entity(world, selector!("BadModelNoLayoutValue"), keys, layout); // TODO: Generate method to deserialize from keys / values directly to avoid @@ -1284,20 +1388,25 @@ impl BadModelNoLayoutValueModel of dojo::model::Model { } #[inline(always)] - fn name(self: @BadModelNoLayoutValue) -> ByteArray { + fn name() -> ByteArray { "BadModelNoLayoutValue" } #[inline(always)] - fn version(self: @BadModelNoLayoutValue) -> u8 { + fn version() -> u8 { 1 } #[inline(always)] - fn selector(self: @BadModelNoLayoutValue) -> felt252 { + fn selector() -> felt252 { selector!("BadModelNoLayoutValue") } + #[inline(always)] + fn instance_selector(self: @BadModelNoLayoutValue) -> felt252 { + dojo::model::Model::::selector() + } + #[inline(always)] fn keys(self: @BadModelNoLayoutValue) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -1313,16 +1422,29 @@ impl BadModelNoLayoutValueModel of dojo::model::Model { } #[inline(always)] - fn layout(self: @BadModelNoLayoutValue) -> Span { + fn layout() -> dojo::model::ModelLayout { let mut layout = core::array::ArrayTrait::new(); dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + dojo::model::ModelLayout::Serial(core::array::ArrayTrait::span(@layout)) } #[inline(always)] - fn packed_size(self: @BadModelNoLayoutValue) -> usize { - let mut layout = self.layout(); - dojo::packing::calculate_packed_size(ref layout) + fn instance_layout(self: @BadModelNoLayoutValue) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() + } + + #[inline(always)] + fn packed_size() -> usize { + match dojo::model::Model::::layout() { + dojo::model::ModelLayout::Serial(layout) => { + let mut layout = layout.clone(); + dojo::packing::calculate_packed_size(ref layout) + }, + _ => { + panic!("Unexpected error"); + 0 + } + } } } @@ -1342,15 +1464,15 @@ mod bad_model_no_layout_value { #[abi(embed_v0)] impl DojoModelImpl of dojo::model::IModel{ fn selector(self: @ContractState) -> felt252 { - selector!("BadModelNoLayoutValue") + dojo::model::Model::::selector() } fn name(self: @ContractState) -> ByteArray { - "BadModelNoLayoutValue" + dojo::model::Model::::name() } fn version(self: @ContractState) -> u8 { - 1 + dojo::model::Model::::version() } fn unpacked_size(self: @ContractState) -> usize { @@ -1358,16 +1480,11 @@ mod bad_model_no_layout_value { } fn packed_size(self: @ContractState) -> usize { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - let mut layout_span = layout.span(); - dojo::packing::calculate_packed_size(ref layout_span) + dojo::model::Model::::packed_size() } - fn layout(self: @ContractState) -> Span { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + fn layout(self: @ContractState) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() } fn schema(self: @ContractState) -> dojo::database::introspect::Ty { @@ -1383,7 +1500,7 @@ mod bad_model_no_layout_value { } impl BadModelNotSupportedLayoutModel of dojo::model::Model { - fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: Span) -> BadModelNotSupportedLayout { + fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::model::ModelLayout) -> BadModelNotSupportedLayout { let values = dojo::world::IWorldDispatcherTrait::entity(world, selector!("BadModelNotSupportedLayout"), keys, layout); // TODO: Generate method to deserialize from keys / values directly to avoid @@ -1405,20 +1522,25 @@ impl BadModelNotSupportedLayoutModel of dojo::model::Model ByteArray { + fn name() -> ByteArray { "BadModelNotSupportedLayout" } #[inline(always)] - fn version(self: @BadModelNotSupportedLayout) -> u8 { + fn version() -> u8 { 1 } #[inline(always)] - fn selector(self: @BadModelNotSupportedLayout) -> felt252 { + fn selector() -> felt252 { selector!("BadModelNotSupportedLayout") } + #[inline(always)] + fn instance_selector(self: @BadModelNotSupportedLayout) -> felt252 { + dojo::model::Model::::selector() + } + #[inline(always)] fn keys(self: @BadModelNotSupportedLayout) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -1434,16 +1556,29 @@ impl BadModelNotSupportedLayoutModel of dojo::model::Model Span { + fn layout() -> dojo::model::ModelLayout { let mut layout = core::array::ArrayTrait::new(); dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + dojo::model::ModelLayout::Serial(core::array::ArrayTrait::span(@layout)) + } + + #[inline(always)] + fn instance_layout(self: @BadModelNotSupportedLayout) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() } #[inline(always)] - fn packed_size(self: @BadModelNotSupportedLayout) -> usize { - let mut layout = self.layout(); - dojo::packing::calculate_packed_size(ref layout) + fn packed_size() -> usize { + match dojo::model::Model::::layout() { + dojo::model::ModelLayout::Serial(layout) => { + let mut layout = layout.clone(); + dojo::packing::calculate_packed_size(ref layout) + }, + _ => { + panic!("Unexpected error"); + 0 + } + } } } @@ -1463,15 +1598,15 @@ mod bad_model_not_supported_layout { #[abi(embed_v0)] impl DojoModelImpl of dojo::model::IModel{ fn selector(self: @ContractState) -> felt252 { - selector!("BadModelNotSupportedLayout") + dojo::model::Model::::selector() } fn name(self: @ContractState) -> ByteArray { - "BadModelNotSupportedLayout" + dojo::model::Model::::name() } fn version(self: @ContractState) -> u8 { - 1 + dojo::model::Model::::version() } fn unpacked_size(self: @ContractState) -> usize { @@ -1479,16 +1614,11 @@ mod bad_model_not_supported_layout { } fn packed_size(self: @ContractState) -> usize { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - let mut layout_span = layout.span(); - dojo::packing::calculate_packed_size(ref layout_span) + dojo::model::Model::::packed_size() } - fn layout(self: @ContractState) -> Span { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + fn layout(self: @ContractState) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() } fn schema(self: @ContractState) -> dojo::database::introspect::Ty { @@ -1504,7 +1634,7 @@ mod bad_model_not_supported_layout { } impl Modelv0Model of dojo::model::Model { - fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: Span) -> Modelv0 { + fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::model::ModelLayout) -> Modelv0 { let values = dojo::world::IWorldDispatcherTrait::entity(world, selector!("Modelv0"), keys, layout); // TODO: Generate method to deserialize from keys / values directly to avoid @@ -1526,20 +1656,25 @@ impl Modelv0Model of dojo::model::Model { } #[inline(always)] - fn name(self: @Modelv0) -> ByteArray { + fn name() -> ByteArray { "Modelv0" } #[inline(always)] - fn version(self: @Modelv0) -> u8 { + fn version() -> u8 { 0 } #[inline(always)] - fn selector(self: @Modelv0) -> felt252 { + fn selector() -> felt252 { "Modelv0" } + #[inline(always)] + fn instance_selector(self: @Modelv0) -> felt252 { + dojo::model::Model::::selector() + } + #[inline(always)] fn keys(self: @Modelv0) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -1555,16 +1690,29 @@ impl Modelv0Model of dojo::model::Model { } #[inline(always)] - fn layout(self: @Modelv0) -> Span { + fn layout() -> dojo::model::ModelLayout { let mut layout = core::array::ArrayTrait::new(); dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + dojo::model::ModelLayout::Serial(core::array::ArrayTrait::span(@layout)) + } + + #[inline(always)] + fn instance_layout(self: @Modelv0) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() } #[inline(always)] - fn packed_size(self: @Modelv0) -> usize { - let mut layout = self.layout(); - dojo::packing::calculate_packed_size(ref layout) + fn packed_size() -> usize { + match dojo::model::Model::::layout() { + dojo::model::ModelLayout::Serial(layout) => { + let mut layout = layout.clone(); + dojo::packing::calculate_packed_size(ref layout) + }, + _ => { + panic!("Unexpected error"); + 0 + } + } } } @@ -1584,15 +1732,15 @@ mod modelv_0 { #[abi(embed_v0)] impl DojoModelImpl of dojo::model::IModel{ fn selector(self: @ContractState) -> felt252 { - "Modelv0" + dojo::model::Model::::selector() } fn name(self: @ContractState) -> ByteArray { - "Modelv0" + dojo::model::Model::::name() } fn version(self: @ContractState) -> u8 { - 0 + dojo::model::Model::::version() } fn unpacked_size(self: @ContractState) -> usize { @@ -1600,16 +1748,11 @@ mod modelv_0 { } fn packed_size(self: @ContractState) -> usize { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - let mut layout_span = layout.span(); - dojo::packing::calculate_packed_size(ref layout_span) + dojo::model::Model::::packed_size() } - fn layout(self: @ContractState) -> Span { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + fn layout(self: @ContractState) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() } fn schema(self: @ContractState) -> dojo::database::introspect::Ty { @@ -1625,7 +1768,7 @@ mod modelv_0 { } impl ModelSerialShortStringModel of dojo::model::Model { - fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: Span) -> ModelSerialShortString { + fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::model::ModelLayout) -> ModelSerialShortString { let values = dojo::world::IWorldDispatcherTrait::entity(world, selector!("ModelSerialShortString"), keys, layout); // TODO: Generate method to deserialize from keys / values directly to avoid @@ -1647,20 +1790,25 @@ impl ModelSerialShortStringModel of dojo::model::Model { } #[inline(always)] - fn name(self: @ModelSerialShortString) -> ByteArray { + fn name() -> ByteArray { "ModelSerialShortString" } #[inline(always)] - fn version(self: @ModelSerialShortString) -> u8 { + fn version() -> u8 { 1 } #[inline(always)] - fn selector(self: @ModelSerialShortString) -> felt252 { + fn selector() -> felt252 { selector!("ModelSerialShortString") } + #[inline(always)] + fn instance_selector(self: @ModelSerialShortString) -> felt252 { + dojo::model::Model::::selector() + } + #[inline(always)] fn keys(self: @ModelSerialShortString) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -1676,16 +1824,29 @@ impl ModelSerialShortStringModel of dojo::model::Model { } #[inline(always)] - fn layout(self: @ModelSerialShortString) -> Span { + fn layout() -> dojo::model::ModelLayout { let mut layout = core::array::ArrayTrait::new(); dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + dojo::model::ModelLayout::Serial(core::array::ArrayTrait::span(@layout)) + } + + #[inline(always)] + fn instance_layout(self: @ModelSerialShortString) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() } #[inline(always)] - fn packed_size(self: @ModelSerialShortString) -> usize { - let mut layout = self.layout(); - dojo::packing::calculate_packed_size(ref layout) + fn packed_size() -> usize { + match dojo::model::Model::::layout() { + dojo::model::ModelLayout::Serial(layout) => { + let mut layout = layout.clone(); + dojo::packing::calculate_packed_size(ref layout) + }, + _ => { + panic!("Unexpected error"); + 0 + } + } } } @@ -1705,15 +1866,15 @@ mod model_serial_short_string { #[abi(embed_v0)] impl DojoModelImpl of dojo::model::IModel{ fn selector(self: @ContractState) -> felt252 { - selector!("ModelSerialShortString") + dojo::model::Model::::selector() } fn name(self: @ContractState) -> ByteArray { - "ModelSerialShortString" + dojo::model::Model::::name() } fn version(self: @ContractState) -> u8 { - 1 + dojo::model::Model::::version() } fn unpacked_size(self: @ContractState) -> usize { @@ -1721,16 +1882,11 @@ mod model_serial_short_string { } fn packed_size(self: @ContractState) -> usize { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - let mut layout_span = layout.span(); - dojo::packing::calculate_packed_size(ref layout_span) + dojo::model::Model::::packed_size() } - fn layout(self: @ContractState) -> Span { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + fn layout(self: @ContractState) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() } fn schema(self: @ContractState) -> dojo::database::introspect::Ty { @@ -1746,7 +1902,7 @@ mod model_serial_short_string { } impl ModelSerialStringModel of dojo::model::Model { - fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: Span) -> ModelSerialString { + fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::model::ModelLayout) -> ModelSerialString { let values = dojo::world::IWorldDispatcherTrait::entity(world, selector!("ModelSerialString"), keys, layout); // TODO: Generate method to deserialize from keys / values directly to avoid @@ -1768,20 +1924,25 @@ impl ModelSerialStringModel of dojo::model::Model { } #[inline(always)] - fn name(self: @ModelSerialString) -> ByteArray { + fn name() -> ByteArray { "ModelSerialString" } #[inline(always)] - fn version(self: @ModelSerialString) -> u8 { + fn version() -> u8 { 1 } #[inline(always)] - fn selector(self: @ModelSerialString) -> felt252 { + fn selector() -> felt252 { selector!("ModelSerialString") } + #[inline(always)] + fn instance_selector(self: @ModelSerialString) -> felt252 { + dojo::model::Model::::selector() + } + #[inline(always)] fn keys(self: @ModelSerialString) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -1797,16 +1958,29 @@ impl ModelSerialStringModel of dojo::model::Model { } #[inline(always)] - fn layout(self: @ModelSerialString) -> Span { + fn layout() -> dojo::model::ModelLayout { let mut layout = core::array::ArrayTrait::new(); dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + dojo::model::ModelLayout::Serial(core::array::ArrayTrait::span(@layout)) } #[inline(always)] - fn packed_size(self: @ModelSerialString) -> usize { - let mut layout = self.layout(); - dojo::packing::calculate_packed_size(ref layout) + fn instance_layout(self: @ModelSerialString) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() + } + + #[inline(always)] + fn packed_size() -> usize { + match dojo::model::Model::::layout() { + dojo::model::ModelLayout::Serial(layout) => { + let mut layout = layout.clone(); + dojo::packing::calculate_packed_size(ref layout) + }, + _ => { + panic!("Unexpected error"); + 0 + } + } } } @@ -1826,15 +2000,15 @@ mod model_serial_string { #[abi(embed_v0)] impl DojoModelImpl of dojo::model::IModel{ fn selector(self: @ContractState) -> felt252 { - selector!("ModelSerialString") + dojo::model::Model::::selector() } fn name(self: @ContractState) -> ByteArray { - "ModelSerialString" + dojo::model::Model::::name() } fn version(self: @ContractState) -> u8 { - 1 + dojo::model::Model::::version() } fn unpacked_size(self: @ContractState) -> usize { @@ -1842,16 +2016,11 @@ mod model_serial_string { } fn packed_size(self: @ContractState) -> usize { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - let mut layout_span = layout.span(); - dojo::packing::calculate_packed_size(ref layout_span) + dojo::model::Model::::packed_size() } - fn layout(self: @ContractState) -> Span { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + fn layout(self: @ContractState) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() } fn schema(self: @ContractState) -> dojo::database::introspect::Ty { @@ -1867,7 +2036,7 @@ mod model_serial_string { } impl PositionModel of dojo::model::Model { - fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: Span) -> Position { + fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::model::ModelLayout) -> Position { let values = dojo::world::IWorldDispatcherTrait::entity(world, selector!("Position"), keys, layout); // TODO: Generate method to deserialize from keys / values directly to avoid @@ -1889,20 +2058,25 @@ impl PositionModel of dojo::model::Model { } #[inline(always)] - fn name(self: @Position) -> ByteArray { + fn name() -> ByteArray { "Position" } #[inline(always)] - fn version(self: @Position) -> u8 { + fn version() -> u8 { 1 } #[inline(always)] - fn selector(self: @Position) -> felt252 { + fn selector() -> felt252 { selector!("Position") } + #[inline(always)] + fn instance_selector(self: @Position) -> felt252 { + dojo::model::Model::::selector() + } + #[inline(always)] fn keys(self: @Position) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -1918,16 +2092,29 @@ impl PositionModel of dojo::model::Model { } #[inline(always)] - fn layout(self: @Position) -> Span { + fn layout() -> dojo::model::ModelLayout { let mut layout = core::array::ArrayTrait::new(); dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + dojo::model::ModelLayout::Serial(core::array::ArrayTrait::span(@layout)) } #[inline(always)] - fn packed_size(self: @Position) -> usize { - let mut layout = self.layout(); - dojo::packing::calculate_packed_size(ref layout) + fn instance_layout(self: @Position) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() + } + + #[inline(always)] + fn packed_size() -> usize { + match dojo::model::Model::::layout() { + dojo::model::ModelLayout::Serial(layout) => { + let mut layout = layout.clone(); + dojo::packing::calculate_packed_size(ref layout) + }, + _ => { + panic!("Unexpected error"); + 0 + } + } } } @@ -1947,15 +2134,15 @@ mod position { #[abi(embed_v0)] impl DojoModelImpl of dojo::model::IModel{ fn selector(self: @ContractState) -> felt252 { - selector!("Position") + dojo::model::Model::::selector() } fn name(self: @ContractState) -> ByteArray { - "Position" + dojo::model::Model::::name() } fn version(self: @ContractState) -> u8 { - 1 + dojo::model::Model::::version() } fn unpacked_size(self: @ContractState) -> usize { @@ -1963,16 +2150,11 @@ mod position { } fn packed_size(self: @ContractState) -> usize { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - let mut layout_span = layout.span(); - dojo::packing::calculate_packed_size(ref layout_span) + dojo::model::Model::::packed_size() } - fn layout(self: @ContractState) -> Span { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + fn layout(self: @ContractState) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() } fn schema(self: @ContractState) -> dojo::database::introspect::Ty { @@ -1988,7 +2170,7 @@ mod position { } impl RolesModel of dojo::model::Model { - fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: Span) -> Roles { + fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::model::ModelLayout) -> Roles { let values = dojo::world::IWorldDispatcherTrait::entity(world, selector!("Roles"), keys, layout); // TODO: Generate method to deserialize from keys / values directly to avoid @@ -2010,20 +2192,25 @@ impl RolesModel of dojo::model::Model { } #[inline(always)] - fn name(self: @Roles) -> ByteArray { + fn name() -> ByteArray { "Roles" } #[inline(always)] - fn version(self: @Roles) -> u8 { + fn version() -> u8 { 1 } #[inline(always)] - fn selector(self: @Roles) -> felt252 { + fn selector() -> felt252 { selector!("Roles") } + #[inline(always)] + fn instance_selector(self: @Roles) -> felt252 { + dojo::model::Model::::selector() + } + #[inline(always)] fn keys(self: @Roles) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -2039,16 +2226,29 @@ impl RolesModel of dojo::model::Model { } #[inline(always)] - fn layout(self: @Roles) -> Span { + fn layout() -> dojo::model::ModelLayout { let mut layout = core::array::ArrayTrait::new(); dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + dojo::model::ModelLayout::Serial(core::array::ArrayTrait::span(@layout)) + } + + #[inline(always)] + fn instance_layout(self: @Roles) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() } #[inline(always)] - fn packed_size(self: @Roles) -> usize { - let mut layout = self.layout(); - dojo::packing::calculate_packed_size(ref layout) + fn packed_size() -> usize { + match dojo::model::Model::::layout() { + dojo::model::ModelLayout::Serial(layout) => { + let mut layout = layout.clone(); + dojo::packing::calculate_packed_size(ref layout) + }, + _ => { + panic!("Unexpected error"); + 0 + } + } } } @@ -2068,15 +2268,15 @@ mod roles { #[abi(embed_v0)] impl DojoModelImpl of dojo::model::IModel{ fn selector(self: @ContractState) -> felt252 { - selector!("Roles") + dojo::model::Model::::selector() } fn name(self: @ContractState) -> ByteArray { - "Roles" + dojo::model::Model::::name() } fn version(self: @ContractState) -> u8 { - 1 + dojo::model::Model::::version() } fn unpacked_size(self: @ContractState) -> usize { @@ -2084,16 +2284,11 @@ mod roles { } fn packed_size(self: @ContractState) -> usize { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - let mut layout_span = layout.span(); - dojo::packing::calculate_packed_size(ref layout_span) + dojo::model::Model::::packed_size() } - fn layout(self: @ContractState) -> Span { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + fn layout(self: @ContractState) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() } fn schema(self: @ContractState) -> dojo::database::introspect::Ty { @@ -2109,7 +2304,7 @@ mod roles { } impl OnlyKeyModelModel of dojo::model::Model { - fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: Span) -> OnlyKeyModel { + fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::model::ModelLayout) -> OnlyKeyModel { let values = dojo::world::IWorldDispatcherTrait::entity(world, selector!("OnlyKeyModel"), keys, layout); // TODO: Generate method to deserialize from keys / values directly to avoid @@ -2131,20 +2326,25 @@ impl OnlyKeyModelModel of dojo::model::Model { } #[inline(always)] - fn name(self: @OnlyKeyModel) -> ByteArray { + fn name() -> ByteArray { "OnlyKeyModel" } #[inline(always)] - fn version(self: @OnlyKeyModel) -> u8 { + fn version() -> u8 { 1 } #[inline(always)] - fn selector(self: @OnlyKeyModel) -> felt252 { + fn selector() -> felt252 { selector!("OnlyKeyModel") } + #[inline(always)] + fn instance_selector(self: @OnlyKeyModel) -> felt252 { + dojo::model::Model::::selector() + } + #[inline(always)] fn keys(self: @OnlyKeyModel) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -2160,16 +2360,29 @@ impl OnlyKeyModelModel of dojo::model::Model { } #[inline(always)] - fn layout(self: @OnlyKeyModel) -> Span { + fn layout() -> dojo::model::ModelLayout { let mut layout = core::array::ArrayTrait::new(); dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + dojo::model::ModelLayout::Serial(core::array::ArrayTrait::span(@layout)) } #[inline(always)] - fn packed_size(self: @OnlyKeyModel) -> usize { - let mut layout = self.layout(); - dojo::packing::calculate_packed_size(ref layout) + fn instance_layout(self: @OnlyKeyModel) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() + } + + #[inline(always)] + fn packed_size() -> usize { + match dojo::model::Model::::layout() { + dojo::model::ModelLayout::Serial(layout) => { + let mut layout = layout.clone(); + dojo::packing::calculate_packed_size(ref layout) + }, + _ => { + panic!("Unexpected error"); + 0 + } + } } } @@ -2189,15 +2402,15 @@ mod only_key_model { #[abi(embed_v0)] impl DojoModelImpl of dojo::model::IModel{ fn selector(self: @ContractState) -> felt252 { - selector!("OnlyKeyModel") + dojo::model::Model::::selector() } fn name(self: @ContractState) -> ByteArray { - "OnlyKeyModel" + dojo::model::Model::::name() } fn version(self: @ContractState) -> u8 { - 1 + dojo::model::Model::::version() } fn unpacked_size(self: @ContractState) -> usize { @@ -2205,16 +2418,11 @@ mod only_key_model { } fn packed_size(self: @ContractState) -> usize { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - let mut layout_span = layout.span(); - dojo::packing::calculate_packed_size(ref layout_span) + dojo::model::Model::::packed_size() } - fn layout(self: @ContractState) -> Span { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + fn layout(self: @ContractState) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() } fn schema(self: @ContractState) -> dojo::database::introspect::Ty { @@ -2230,7 +2438,7 @@ mod only_key_model { } impl U256KeyModelModel of dojo::model::Model { - fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: Span) -> U256KeyModel { + fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::model::ModelLayout) -> U256KeyModel { let values = dojo::world::IWorldDispatcherTrait::entity(world, selector!("U256KeyModel"), keys, layout); // TODO: Generate method to deserialize from keys / values directly to avoid @@ -2252,20 +2460,25 @@ impl U256KeyModelModel of dojo::model::Model { } #[inline(always)] - fn name(self: @U256KeyModel) -> ByteArray { + fn name() -> ByteArray { "U256KeyModel" } #[inline(always)] - fn version(self: @U256KeyModel) -> u8 { + fn version() -> u8 { 1 } #[inline(always)] - fn selector(self: @U256KeyModel) -> felt252 { + fn selector() -> felt252 { selector!("U256KeyModel") } + #[inline(always)] + fn instance_selector(self: @U256KeyModel) -> felt252 { + dojo::model::Model::::selector() + } + #[inline(always)] fn keys(self: @U256KeyModel) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -2281,16 +2494,29 @@ impl U256KeyModelModel of dojo::model::Model { } #[inline(always)] - fn layout(self: @U256KeyModel) -> Span { + fn layout() -> dojo::model::ModelLayout { let mut layout = core::array::ArrayTrait::new(); dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + dojo::model::ModelLayout::Serial(core::array::ArrayTrait::span(@layout)) } #[inline(always)] - fn packed_size(self: @U256KeyModel) -> usize { - let mut layout = self.layout(); - dojo::packing::calculate_packed_size(ref layout) + fn instance_layout(self: @U256KeyModel) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() + } + + #[inline(always)] + fn packed_size() -> usize { + match dojo::model::Model::::layout() { + dojo::model::ModelLayout::Serial(layout) => { + let mut layout = layout.clone(); + dojo::packing::calculate_packed_size(ref layout) + }, + _ => { + panic!("Unexpected error"); + 0 + } + } } } @@ -2310,15 +2536,15 @@ mod u_256_key_model { #[abi(embed_v0)] impl DojoModelImpl of dojo::model::IModel{ fn selector(self: @ContractState) -> felt252 { - selector!("U256KeyModel") + dojo::model::Model::::selector() } fn name(self: @ContractState) -> ByteArray { - "U256KeyModel" + dojo::model::Model::::name() } fn version(self: @ContractState) -> u8 { - 1 + dojo::model::Model::::version() } fn unpacked_size(self: @ContractState) -> usize { @@ -2326,16 +2552,11 @@ mod u_256_key_model { } fn packed_size(self: @ContractState) -> usize { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - let mut layout_span = layout.span(); - dojo::packing::calculate_packed_size(ref layout_span) + dojo::model::Model::::packed_size() } - fn layout(self: @ContractState) -> Span { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + fn layout(self: @ContractState) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() } fn schema(self: @ContractState) -> dojo::database::introspect::Ty { @@ -2351,7 +2572,7 @@ mod u_256_key_model { } impl PlayerModel of dojo::model::Model { - fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: Span) -> Player { + fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::model::ModelLayout) -> Player { let values = dojo::world::IWorldDispatcherTrait::entity(world, selector!("Player"), keys, layout); // TODO: Generate method to deserialize from keys / values directly to avoid @@ -2373,20 +2594,25 @@ impl PlayerModel of dojo::model::Model { } #[inline(always)] - fn name(self: @Player) -> ByteArray { + fn name() -> ByteArray { "Player" } #[inline(always)] - fn version(self: @Player) -> u8 { + fn version() -> u8 { 1 } #[inline(always)] - fn selector(self: @Player) -> felt252 { + fn selector() -> felt252 { selector!("Player") } + #[inline(always)] + fn instance_selector(self: @Player) -> felt252 { + dojo::model::Model::::selector() + } + #[inline(always)] fn keys(self: @Player) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -2402,16 +2628,29 @@ impl PlayerModel of dojo::model::Model { } #[inline(always)] - fn layout(self: @Player) -> Span { + fn layout() -> dojo::model::ModelLayout { let mut layout = core::array::ArrayTrait::new(); dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + dojo::model::ModelLayout::Serial(core::array::ArrayTrait::span(@layout)) } #[inline(always)] - fn packed_size(self: @Player) -> usize { - let mut layout = self.layout(); - dojo::packing::calculate_packed_size(ref layout) + fn instance_layout(self: @Player) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() + } + + #[inline(always)] + fn packed_size() -> usize { + match dojo::model::Model::::layout() { + dojo::model::ModelLayout::Serial(layout) => { + let mut layout = layout.clone(); + dojo::packing::calculate_packed_size(ref layout) + }, + _ => { + panic!("Unexpected error"); + 0 + } + } } } @@ -2431,15 +2670,15 @@ mod player { #[abi(embed_v0)] impl DojoModelImpl of dojo::model::IModel{ fn selector(self: @ContractState) -> felt252 { - selector!("Player") + dojo::model::Model::::selector() } fn name(self: @ContractState) -> ByteArray { - "Player" + dojo::model::Model::::name() } fn version(self: @ContractState) -> u8 { - 1 + dojo::model::Model::::version() } fn unpacked_size(self: @ContractState) -> usize { @@ -2447,16 +2686,11 @@ mod player { } fn packed_size(self: @ContractState) -> usize { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - let mut layout_span = layout.span(); - dojo::packing::calculate_packed_size(ref layout_span) + dojo::model::Model::::packed_size() } - fn layout(self: @ContractState) -> Span { - let mut layout = core::array::ArrayTrait::new(); - dojo::database::introspect::Introspect::::layout(ref layout); - core::array::ArrayTrait::span(@layout) + fn layout(self: @ContractState) -> dojo::model::ModelLayout { + dojo::model::Model::::layout() } fn schema(self: @ContractState) -> dojo::database::introspect::Ty { @@ -2553,361 +2787,361 @@ struct U256KeyModel { ^**********^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelMultipleVersions]:72:1 + --> test_src/lib.cairo[BadModelMultipleVersions]:90:1 #[starknet::contract] ^*******************^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelBadVersionType]:72:1 + --> test_src/lib.cairo[BadModelBadVersionType]:90:1 #[starknet::contract] ^*******************^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelNoVersionValue]:72:1 + --> test_src/lib.cairo[BadModelNoVersionValue]:90:1 #[starknet::contract] ^*******************^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelUnexpectedArgWithValue]:72:1 + --> test_src/lib.cairo[BadModelUnexpectedArgWithValue]:90:1 #[starknet::contract] ^*******************^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelUnexpectedArg]:72:1 + --> test_src/lib.cairo[BadModelUnexpectedArg]:90:1 #[starknet::contract] ^*******************^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelNotSupportedVersion]:72:1 + --> test_src/lib.cairo[BadModelNotSupportedVersion]:90:1 #[starknet::contract] ^*******************^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelMultipleLayouts]:72:1 + --> test_src/lib.cairo[BadModelMultipleLayouts]:90:1 #[starknet::contract] ^*******************^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelBadLayoutType]:72:1 + --> test_src/lib.cairo[BadModelBadLayoutType]:90:1 #[starknet::contract] ^*******************^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelNoLayoutValue]:72:1 + --> test_src/lib.cairo[BadModelNoLayoutValue]:90:1 #[starknet::contract] ^*******************^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelNotSupportedLayout]:72:1 + --> test_src/lib.cairo[BadModelNotSupportedLayout]:90:1 #[starknet::contract] ^*******************^ error: Unsupported attribute. - --> test_src/lib.cairo[Modelv0]:72:1 + --> test_src/lib.cairo[Modelv0]:90:1 #[starknet::contract] ^*******************^ error: Unsupported attribute. - --> test_src/lib.cairo[ModelSerialShortString]:72:1 + --> test_src/lib.cairo[ModelSerialShortString]:90:1 #[starknet::contract] ^*******************^ error: Unsupported attribute. - --> test_src/lib.cairo[ModelSerialString]:72:1 + --> test_src/lib.cairo[ModelSerialString]:90:1 #[starknet::contract] ^*******************^ error: Unsupported attribute. - --> test_src/lib.cairo[Position]:72:1 + --> test_src/lib.cairo[Position]:90:1 #[starknet::contract] ^*******************^ error: Unsupported attribute. - --> test_src/lib.cairo[Roles]:72:1 + --> test_src/lib.cairo[Roles]:90:1 #[starknet::contract] ^*******************^ error: Unsupported attribute. - --> test_src/lib.cairo[OnlyKeyModel]:72:1 + --> test_src/lib.cairo[OnlyKeyModel]:90:1 #[starknet::contract] ^*******************^ error: Unsupported attribute. - --> test_src/lib.cairo[U256KeyModel]:72:1 + --> test_src/lib.cairo[U256KeyModel]:90:1 #[starknet::contract] ^*******************^ error: Unsupported attribute. - --> test_src/lib.cairo[Player]:72:1 + --> test_src/lib.cairo[Player]:90:1 #[starknet::contract] ^*******************^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelMultipleVersions]:77:5 + --> test_src/lib.cairo[BadModelMultipleVersions]:95:5 #[storage] ^********^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelMultipleVersions]:80:5 + --> test_src/lib.cairo[BadModelMultipleVersions]:98:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelMultipleVersions]:116:5 + --> test_src/lib.cairo[BadModelMultipleVersions]:129:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelBadVersionType]:77:5 + --> test_src/lib.cairo[BadModelBadVersionType]:95:5 #[storage] ^********^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelBadVersionType]:80:5 + --> test_src/lib.cairo[BadModelBadVersionType]:98:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelBadVersionType]:116:5 + --> test_src/lib.cairo[BadModelBadVersionType]:129:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelNoVersionValue]:77:5 + --> test_src/lib.cairo[BadModelNoVersionValue]:95:5 #[storage] ^********^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelNoVersionValue]:80:5 + --> test_src/lib.cairo[BadModelNoVersionValue]:98:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelNoVersionValue]:116:5 + --> test_src/lib.cairo[BadModelNoVersionValue]:129:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelUnexpectedArgWithValue]:77:5 + --> test_src/lib.cairo[BadModelUnexpectedArgWithValue]:95:5 #[storage] ^********^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelUnexpectedArgWithValue]:80:5 + --> test_src/lib.cairo[BadModelUnexpectedArgWithValue]:98:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelUnexpectedArgWithValue]:116:5 + --> test_src/lib.cairo[BadModelUnexpectedArgWithValue]:129:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelUnexpectedArg]:77:5 + --> test_src/lib.cairo[BadModelUnexpectedArg]:95:5 #[storage] ^********^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelUnexpectedArg]:80:5 + --> test_src/lib.cairo[BadModelUnexpectedArg]:98:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelUnexpectedArg]:116:5 + --> test_src/lib.cairo[BadModelUnexpectedArg]:129:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelNotSupportedVersion]:77:5 + --> test_src/lib.cairo[BadModelNotSupportedVersion]:95:5 #[storage] ^********^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelNotSupportedVersion]:80:5 + --> test_src/lib.cairo[BadModelNotSupportedVersion]:98:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelNotSupportedVersion]:116:5 + --> test_src/lib.cairo[BadModelNotSupportedVersion]:129:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelMultipleLayouts]:77:5 + --> test_src/lib.cairo[BadModelMultipleLayouts]:95:5 #[storage] ^********^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelMultipleLayouts]:80:5 + --> test_src/lib.cairo[BadModelMultipleLayouts]:98:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelMultipleLayouts]:116:5 + --> test_src/lib.cairo[BadModelMultipleLayouts]:129:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelBadLayoutType]:77:5 + --> test_src/lib.cairo[BadModelBadLayoutType]:95:5 #[storage] ^********^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelBadLayoutType]:80:5 + --> test_src/lib.cairo[BadModelBadLayoutType]:98:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelBadLayoutType]:116:5 + --> test_src/lib.cairo[BadModelBadLayoutType]:129:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelNoLayoutValue]:77:5 + --> test_src/lib.cairo[BadModelNoLayoutValue]:95:5 #[storage] ^********^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelNoLayoutValue]:80:5 + --> test_src/lib.cairo[BadModelNoLayoutValue]:98:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelNoLayoutValue]:116:5 + --> test_src/lib.cairo[BadModelNoLayoutValue]:129:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelNotSupportedLayout]:77:5 + --> test_src/lib.cairo[BadModelNotSupportedLayout]:95:5 #[storage] ^********^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelNotSupportedLayout]:80:5 + --> test_src/lib.cairo[BadModelNotSupportedLayout]:98:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[BadModelNotSupportedLayout]:116:5 + --> test_src/lib.cairo[BadModelNotSupportedLayout]:129:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[Modelv0]:77:5 + --> test_src/lib.cairo[Modelv0]:95:5 #[storage] ^********^ error: Unsupported attribute. - --> test_src/lib.cairo[Modelv0]:80:5 + --> test_src/lib.cairo[Modelv0]:98:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[Modelv0]:116:5 + --> test_src/lib.cairo[Modelv0]:129:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[ModelSerialShortString]:77:5 + --> test_src/lib.cairo[ModelSerialShortString]:95:5 #[storage] ^********^ error: Unsupported attribute. - --> test_src/lib.cairo[ModelSerialShortString]:80:5 + --> test_src/lib.cairo[ModelSerialShortString]:98:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[ModelSerialShortString]:116:5 + --> test_src/lib.cairo[ModelSerialShortString]:129:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[ModelSerialString]:77:5 + --> test_src/lib.cairo[ModelSerialString]:95:5 #[storage] ^********^ error: Unsupported attribute. - --> test_src/lib.cairo[ModelSerialString]:80:5 + --> test_src/lib.cairo[ModelSerialString]:98:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[ModelSerialString]:116:5 + --> test_src/lib.cairo[ModelSerialString]:129:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[Position]:77:5 + --> test_src/lib.cairo[Position]:95:5 #[storage] ^********^ error: Unsupported attribute. - --> test_src/lib.cairo[Position]:80:5 + --> test_src/lib.cairo[Position]:98:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[Position]:116:5 + --> test_src/lib.cairo[Position]:129:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[Roles]:77:5 + --> test_src/lib.cairo[Roles]:95:5 #[storage] ^********^ error: Unsupported attribute. - --> test_src/lib.cairo[Roles]:80:5 + --> test_src/lib.cairo[Roles]:98:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[Roles]:116:5 + --> test_src/lib.cairo[Roles]:129:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[OnlyKeyModel]:77:5 + --> test_src/lib.cairo[OnlyKeyModel]:95:5 #[storage] ^********^ error: Unsupported attribute. - --> test_src/lib.cairo[OnlyKeyModel]:80:5 + --> test_src/lib.cairo[OnlyKeyModel]:98:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[OnlyKeyModel]:116:5 + --> test_src/lib.cairo[OnlyKeyModel]:129:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[U256KeyModel]:77:5 + --> test_src/lib.cairo[U256KeyModel]:95:5 #[storage] ^********^ error: Unsupported attribute. - --> test_src/lib.cairo[U256KeyModel]:80:5 + --> test_src/lib.cairo[U256KeyModel]:98:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[U256KeyModel]:116:5 + --> test_src/lib.cairo[U256KeyModel]:129:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[Player]:77:5 + --> test_src/lib.cairo[Player]:95:5 #[storage] ^********^ error: Unsupported attribute. - --> test_src/lib.cairo[Player]:80:5 + --> test_src/lib.cairo[Player]:98:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[Player]:116:5 + --> test_src/lib.cairo[Player]:129:5 #[abi(embed_v0)] ^**************^ diff --git a/crates/dojo-lang/src/plugin_test_data/system b/crates/dojo-lang/src/plugin_test_data/system index e9ce18bde4..6673499c1e 100644 --- a/crates/dojo-lang/src/plugin_test_data/system +++ b/crates/dojo-lang/src/plugin_test_data/system @@ -400,162 +400,162 @@ error: Unsupported attribute. ^********^ error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo[spawn]:10:21 + --> test_src/lib.cairo[spawn]:11:21 component!(path: dojo::components::upgradeable::upgradeable, storage: upgradeable, event: UpgradeableEvent); ^**********************************************************************************************************^ error: Unsupported attribute. - --> test_src/lib.cairo[spawn]:12:21 + --> test_src/lib.cairo[spawn]:13:21 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[spawn]:19:21 + --> test_src/lib.cairo[spawn]:20:21 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[spawn]:26:21 + --> test_src/lib.cairo[spawn]:27:21 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[spawn]:36:13 + --> test_src/lib.cairo[spawn]:37:13 #[event] ^******^ error: Unsupported attribute. - --> test_src/lib.cairo[spawn]:42:13 + --> test_src/lib.cairo[spawn]:43:13 #[storage] ^********^ error: Unsupported attribute. - --> test_src/lib.cairo[spawn]:45:17 + --> test_src/lib.cairo[spawn]:46:17 #[substorage(v0)] ^***************^ error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo[proxy]:10:21 + --> test_src/lib.cairo[proxy]:11:21 component!(path: dojo::components::upgradeable::upgradeable, storage: upgradeable, event: UpgradeableEvent); ^**********************************************************************************************************^ error: Unsupported attribute. - --> test_src/lib.cairo[proxy]:12:21 + --> test_src/lib.cairo[proxy]:13:21 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[proxy]:19:21 + --> test_src/lib.cairo[proxy]:20:21 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[proxy]:26:21 + --> test_src/lib.cairo[proxy]:27:21 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[proxy]:33:13 + --> test_src/lib.cairo[proxy]:34:13 #[event] ^******^ error: Unsupported attribute. - --> test_src/lib.cairo[proxy]:39:13 + --> test_src/lib.cairo[proxy]:40:13 #[storage] ^********^ error: Unsupported attribute. - --> test_src/lib.cairo[proxy]:42:17 + --> test_src/lib.cairo[proxy]:43:17 #[substorage(v0)] ^***************^ error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo[ctxnamed]:10:21 + --> test_src/lib.cairo[ctxnamed]:11:21 component!(path: dojo::components::upgradeable::upgradeable, storage: upgradeable, event: UpgradeableEvent); ^**********************************************************************************************************^ error: Unsupported attribute. - --> test_src/lib.cairo[ctxnamed]:12:21 + --> test_src/lib.cairo[ctxnamed]:13:21 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[ctxnamed]:19:21 + --> test_src/lib.cairo[ctxnamed]:20:21 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[ctxnamed]:26:21 + --> test_src/lib.cairo[ctxnamed]:27:21 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[ctxnamed]:36:13 + --> test_src/lib.cairo[ctxnamed]:37:13 #[event] ^******^ error: Unsupported attribute. - --> test_src/lib.cairo[ctxnamed]:42:13 + --> test_src/lib.cairo[ctxnamed]:43:13 #[storage] ^********^ error: Unsupported attribute. - --> test_src/lib.cairo[ctxnamed]:45:17 + --> test_src/lib.cairo[ctxnamed]:46:17 #[substorage(v0)] ^***************^ error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo[withevent]:10:21 + --> test_src/lib.cairo[withevent]:11:21 component!(path: dojo::components::upgradeable::upgradeable, storage: upgradeable, event: UpgradeableEvent); ^**********************************************************************************************************^ error: Unsupported attribute. - --> test_src/lib.cairo[withevent]:12:21 + --> test_src/lib.cairo[withevent]:13:21 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[withevent]:19:21 + --> test_src/lib.cairo[withevent]:20:21 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[withevent]:26:21 + --> test_src/lib.cairo[withevent]:27:21 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[withevent]:30:13 + --> test_src/lib.cairo[withevent]:31:13 #[event] ^******^ error: Unsupported attribute. - --> test_src/lib.cairo[withevent]:42:13 + --> test_src/lib.cairo[withevent]:43:13 #[storage] ^********^ error: Unsupported attribute. - --> test_src/lib.cairo[withevent]:45:17 + --> test_src/lib.cairo[withevent]:46:17 #[substorage(v0)] ^***************^ error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo[withcomponent]:10:21 + --> test_src/lib.cairo[withcomponent]:11:21 component!(path: dojo::components::upgradeable::upgradeable, storage: upgradeable, event: UpgradeableEvent); ^**********************************************************************************************************^ error: Unsupported attribute. - --> test_src/lib.cairo[withcomponent]:12:21 + --> test_src/lib.cairo[withcomponent]:13:21 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[withcomponent]:19:21 + --> test_src/lib.cairo[withcomponent]:20:21 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[withcomponent]:26:21 + --> test_src/lib.cairo[withcomponent]:27:21 #[abi(embed_v0)] ^**************^ @@ -570,52 +570,52 @@ error: Unknown inline item macro: 'component'. ^*********************************************************************************************^ error: Unsupported attribute. - --> test_src/lib.cairo[withcomponent]:32:13 + --> test_src/lib.cairo[withcomponent]:33:13 #[storage] ^********^ error: Unsupported attribute. - --> test_src/lib.cairo[withcomponent]:35:17 + --> test_src/lib.cairo[withcomponent]:36:17 #[substorage(v0)] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo[withcomponent]:37:25 + --> test_src/lib.cairo[withcomponent]:38:25 #[substorage(v0)] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo[withcomponent]:39:9 + --> test_src/lib.cairo[withcomponent]:40:9 #[substorage(v0)] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo[withcomponent]:43:13 + --> test_src/lib.cairo[withcomponent]:44:13 #[event] ^******^ error: Unsupported attribute. - --> test_src/lib.cairo[withcomponent]:47:25 + --> test_src/lib.cairo[withcomponent]:48:25 #[flat] ^*****^ error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo[MyFaultyContract]:10:21 + --> test_src/lib.cairo[MyFaultyContract]:11:21 component!(path: dojo::components::upgradeable::upgradeable, storage: upgradeable, event: UpgradeableEvent); ^**********************************************************************************************************^ error: Unsupported attribute. - --> test_src/lib.cairo[MyFaultyContract]:12:21 + --> test_src/lib.cairo[MyFaultyContract]:13:21 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[MyFaultyContract]:19:21 + --> test_src/lib.cairo[MyFaultyContract]:20:21 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[MyFaultyContract]:26:21 + --> test_src/lib.cairo[MyFaultyContract]:27:21 #[abi(embed_v0)] ^**************^ @@ -625,37 +625,37 @@ error: Unsupported attribute. ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[MyFaultyContract]:60:13 + --> test_src/lib.cairo[MyFaultyContract]:61:13 #[event] ^******^ error: Unsupported attribute. - --> test_src/lib.cairo[MyFaultyContract]:66:13 + --> test_src/lib.cairo[MyFaultyContract]:67:13 #[storage] ^********^ error: Unsupported attribute. - --> test_src/lib.cairo[MyFaultyContract]:69:17 + --> test_src/lib.cairo[MyFaultyContract]:70:17 #[substorage(v0)] ^***************^ error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo[MyNominalContract]:10:21 + --> test_src/lib.cairo[MyNominalContract]:11:21 component!(path: dojo::components::upgradeable::upgradeable, storage: upgradeable, event: UpgradeableEvent); ^**********************************************************************************************************^ error: Unsupported attribute. - --> test_src/lib.cairo[MyNominalContract]:12:21 + --> test_src/lib.cairo[MyNominalContract]:13:21 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[MyNominalContract]:19:21 + --> test_src/lib.cairo[MyNominalContract]:20:21 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[MyNominalContract]:26:21 + --> test_src/lib.cairo[MyNominalContract]:27:21 #[abi(embed_v0)] ^**************^ @@ -665,17 +665,17 @@ error: Unsupported attribute. ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo[MyNominalContract]:64:13 + --> test_src/lib.cairo[MyNominalContract]:65:13 #[event] ^******^ error: Unsupported attribute. - --> test_src/lib.cairo[MyNominalContract]:70:13 + --> test_src/lib.cairo[MyNominalContract]:71:13 #[storage] ^********^ error: Unsupported attribute. - --> test_src/lib.cairo[MyNominalContract]:73:17 + --> test_src/lib.cairo[MyNominalContract]:74:17 #[substorage(v0)] ^***************^ diff --git a/crates/dojo-lang/src/semantics/test_data/get b/crates/dojo-lang/src/semantics/test_data/get index e25825b0b4..71e1714908 100644 --- a/crates/dojo-lang/src/semantics/test_data/get +++ b/crates/dojo-lang/src/semantics/test_data/get @@ -198,49 +198,9 @@ Block( ), expr: FunctionCall( ExprFunctionCall { - function: ?7::new, + function: ?7::layout, args: [], - ty: core::array::Array::, - }, - ), - }, - ), - Expr( - StatementExpr { - expr: FunctionCall( - ExprFunctionCall { - function: ?8::layout, - args: [ - Reference( - LocalVarId(test::__Health_layout__), - ), - ], - ty: (), - }, - ), - }, - ), - Let( - StatementLet { - pattern: Variable( - __Health_layout_span__, - ), - expr: FunctionCall( - ExprFunctionCall { - function: ?9::span, - args: [ - Value( - Snapshot( - ExprSnapshot { - inner: Var( - LocalVarId(test::__Health_layout__), - ), - ty: @core::array::Array::, - }, - ), - ), - ], - ty: core::array::Span::, + ty: dojo::model::ModelLayout, }, ), }, @@ -252,7 +212,7 @@ Block( ), expr: FunctionCall( ExprFunctionCall { - function: ?10::entity, + function: ?8::entity, args: [ Value( Var( @@ -266,11 +226,11 @@ Block( ), Value( Var( - LocalVarId(test::__Health_layout_span__), + LocalVarId(test::__Health_layout__), ), ), ], - ty: ?10, + ty: ?8, }, ), }, @@ -287,6 +247,6 @@ Block( //! > semantic_diagnostics error: Trait has no implementation in context: dojo::model::Model:: - --> lib.cairo[get_inline_macro]:9:61 - let __Health: Health = dojo::model::Model::entity(world, __get_macro_keys__, __Health_layout_span__); - ^****^ + --> lib.cairo[get_inline_macro]:7:71 + let __Health_layout__ = dojo::model::Model::::layout(); + ^****^ diff --git a/crates/dojo-lang/src/semantics/test_data/set b/crates/dojo-lang/src/semantics/test_data/set index dcd45073cd..6ac01efbb3 100644 --- a/crates/dojo-lang/src/semantics/test_data/set +++ b/crates/dojo-lang/src/semantics/test_data/set @@ -84,7 +84,7 @@ Block( Let( StatementLet { pattern: Variable( - __set_macro_value__, + __set_model_instance__, ), expr: StructCtor( ExprStructCtor { @@ -129,13 +129,13 @@ Block( Value( FunctionCall( ExprFunctionCall { - function: ?7::selector, + function: ?7::instance_selector, args: [ Value( Snapshot( ExprSnapshot { inner: Var( - LocalVarId(test::__set_macro_value__), + LocalVarId(test::__set_model_instance__), ), ty: @test::Health, }, @@ -155,7 +155,7 @@ Block( Snapshot( ExprSnapshot { inner: Var( - LocalVarId(test::__set_macro_value__), + LocalVarId(test::__set_model_instance__), ), ty: @test::Health, }, @@ -175,7 +175,7 @@ Block( Snapshot( ExprSnapshot { inner: Var( - LocalVarId(test::__set_macro_value__), + LocalVarId(test::__set_model_instance__), ), ty: @test::Health, }, @@ -189,20 +189,20 @@ Block( Value( FunctionCall( ExprFunctionCall { - function: ?10::layout, + function: ?10::instance_layout, args: [ Value( Snapshot( ExprSnapshot { inner: Var( - LocalVarId(test::__set_macro_value__), + LocalVarId(test::__set_model_instance__), ), ty: @test::Health, }, ), ), ], - ty: core::array::Span::, + ty: dojo::model::ModelLayout, }, ), ), @@ -225,6 +225,6 @@ fn test_func() { let key: felt252 = 0xb0b; ^*^ error: Trait has no implementation in context: dojo::model::Model:: - --> lib.cairo[set_inline_macro]:3:54 - world.set_entity(dojo::model::Model::selector(@__set_macro_value__), - ^******^ + --> lib.cairo[set_inline_macro]:4:41 + dojo::model::Model::instance_selector(@__set_model_instance__), + ^***************^