From e8d9eb6de4cb6c643a5482646dea706c8bfd3f3f Mon Sep 17 00:00:00 2001 From: "remy.baranx@gmail.com" Date: Wed, 5 Jun 2024 14:39:35 +0800 Subject: [PATCH] update world auth --- Cargo.lock | 2 + .../contracts/src/tests/test_world.cairo | 2 +- crates/dojo-core/src/base_test.cairo | 38 +- crates/dojo-core/src/lib.cairo | 3 + crates/dojo-core/src/model.cairo | 7 +- crates/dojo-core/src/packing_test.cairo | 3 - crates/dojo-core/src/resource_metadata.cairo | 19 +- crates/dojo-core/src/test_utils.cairo | 5 +- crates/dojo-core/src/utils.cairo | 6 + crates/dojo-core/src/utils_test.cairo | 17 + crates/dojo-core/src/world.cairo | 448 +- crates/dojo-core/src/world_test.cairo | 384 +- crates/dojo-lang/Cargo.toml | 2 + .../dev/abis/base/dojo_world_world.json | 102 +- .../manifests/dev/base/dojo_world_world.toml | 4 +- crates/dojo-lang/src/model.rs | 39 +- crates/dojo-lang/src/plugin_test_data/model | 338 +- crates/dojo-world/src/contracts/abi/world.rs | 102 +- .../manifests/dev/base/dojo_world_world.toml | 4 +- .../dev/abis/base/dojo_world_world.json | 102 +- .../dojo_examples_actions_actions_moved.json | 11 + .../dojo_examples_models_emote_message.json | 11 + .../models/dojo_examples_models_moves.json | 11 + .../dojo_examples_models_player_config.json | 11 + .../models/dojo_examples_models_position.json | 11 + ...es_others_others_contract_initialized.json | 11 + .../dojo_examples_actions_actions.json | 312 ++ .../dojo_examples_others_others.json | 186 + .../abis/deployments/dojo_world_world.json | 1051 +++++ .../dojo_examples_actions_actions_moved.json | 411 ++ .../dojo_examples_models_emote_message.json | 411 ++ .../models/dojo_examples_models_moves.json | 415 ++ .../dojo_examples_models_player_config.json | 407 ++ .../models/dojo_examples_models_position.json | 399 ++ ...es_others_others_contract_initialized.json | 389 ++ .../dojo_examples_actions_actions.toml | 4 +- .../manifests/dev/base/dojo_world_world.toml | 4 +- .../dojo_examples_actions_actions_moved.toml | 4 +- .../dojo_examples_models_emote_message.toml | 4 +- .../models/dojo_examples_models_moves.toml | 4 +- .../dojo_examples_models_player_config.toml | 4 +- .../models/dojo_examples_models_position.toml | 4 +- ...es_others_others_contract_initialized.toml | 4 +- .../manifests/dev/manifest.json | 4167 +++++++++++++++++ .../manifests/dev/manifest.toml | 173 + examples/spawn-and-move/src/actions.cairo | 2 +- 46 files changed, 9754 insertions(+), 294 deletions(-) create mode 100644 crates/dojo-core/src/utils.cairo create mode 100644 crates/dojo-core/src/utils_test.cairo create mode 100644 examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples_actions_actions.json create mode 100644 examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples_others_others.json create mode 100644 examples/spawn-and-move/manifests/dev/abis/deployments/dojo_world_world.json create mode 100644 examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_actions_actions_moved.json create mode 100644 examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_emote_message.json create mode 100644 examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_moves.json create mode 100644 examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_player_config.json create mode 100644 examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_position.json create mode 100644 examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_others_others_contract_initialized.json create mode 100644 examples/spawn-and-move/manifests/dev/manifest.json create mode 100644 examples/spawn-and-move/manifests/dev/manifest.toml diff --git a/Cargo.lock b/Cargo.lock index 530db77742..b45a1d2f49 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4564,6 +4564,7 @@ name = "dojo-lang" version = "0.7.0-alpha.5" dependencies = [ "anyhow", + "cainome", "cairo-lang-compiler 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "cairo-lang-debug 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", "cairo-lang-defs 2.6.3 (git+https://github.com/starkware-libs/cairo?rev=d9984ef58e2f704909e271f2f01327f520ded632)", @@ -4603,6 +4604,7 @@ dependencies = [ "serde_with", "smol_str", "starknet", + "starknet-crypto 0.6.2", "test-log", "thiserror", "toml 0.8.13", diff --git a/crates/benches/contracts/src/tests/test_world.cairo b/crates/benches/contracts/src/tests/test_world.cairo index b7c8309913..74dfd8023e 100644 --- a/crates/benches/contracts/src/tests/test_world.cairo +++ b/crates/benches/contracts/src/tests/test_world.cairo @@ -25,7 +25,7 @@ mod tests { let mut models = array![position::TEST_CLASS_HASH, moves::TEST_CLASS_HASH]; // deploy world with models - let world = spawn_test_world(models); + let world = spawn_test_world("benches", models); // deploy systems contract let contract_address = world diff --git a/crates/dojo-core/src/base_test.cairo b/crates/dojo-core/src/base_test.cairo index d3c974abd3..ecdb89831f 100644 --- a/crates/dojo-core/src/base_test.cairo +++ b/crates/dojo-core/src/base_test.cairo @@ -49,7 +49,7 @@ use contract_upgrade::{IQuantumLeapDispatcher, IQuantumLeapDispatcherTrait}; // Utils fn deploy_world() -> IWorldDispatcher { - spawn_test_world(array![]) + spawn_test_world("dojo", array![]) } // A test contract needs to be used instead of previously used base contract since. @@ -111,6 +111,8 @@ fn test_upgrade_direct() { trait IMetadataOnly { fn selector(self: @T) -> felt252; fn name(self: @T) -> ByteArray; + fn namespace(self: @T) -> ByteArray; + fn namespace_selector(self: @T) -> felt252; } #[starknet::contract] @@ -125,6 +127,14 @@ mod invalid_legacy_model { 0x742c3d09472a40914dedcbd609788fd547bde613d6c4d4c2f15d41f4e241f25 } + fn namespace(self: @ContractState) -> ByteArray { + "dojo" + } + + fn namespace_selector(self: @ContractState) -> felt252 { + dojo::utils::hash(@Self::namespace(self)) + } + fn name(self: @ContractState) -> ByteArray { "invalid_legacy_model" } @@ -144,6 +154,14 @@ mod invalid_legacy_model_world { 0 } + fn namespace(self: @ContractState) -> ByteArray { + "dojo" + } + + fn namespace_selector(self: @ContractState) -> felt252 { + dojo::utils::hash(@Self::namespace(self)) + } + fn name(self: @ContractState) -> ByteArray { "invalid_legacy_model" } @@ -160,7 +178,15 @@ mod invalid_model { fn selector(self: @ContractState) -> felt252 { // NOTE: Need to update this value if address changes // Pre-computed address of a contract deployed through the world. - 0x42503befcd7ad05718645aca9c5ddd83b53dca440f9239ce2dcf63018fba16 + 0x60b3bc751486f95a16596f7f7346b37cf48b2137f1d7e7c9de11c31d0c40479 + } + + fn namespace(self: @ContractState) -> ByteArray { + "dojo" + } + + fn namespace_selector(self: @ContractState) -> felt252 { + dojo::utils::hash(@Self::namespace(self)) } fn name(self: @ContractState) -> ByteArray { @@ -182,6 +208,14 @@ mod invalid_model_world { 0 } + fn namespace(self: @ContractState) -> ByteArray { + "dojo" + } + + fn namespace_selector(self: @ContractState) -> felt252 { + dojo::utils::hash(@Self::namespace(self)) + } + fn name(self: @ContractState) -> ByteArray { "invalid_model_world" } diff --git a/crates/dojo-core/src/lib.cairo b/crates/dojo-core/src/lib.cairo index adbe199c73..e93db16fad 100644 --- a/crates/dojo-core/src/lib.cairo +++ b/crates/dojo-core/src/lib.cairo @@ -13,6 +13,9 @@ mod packing_test; mod world; #[cfg(test)] mod world_test; +mod utils; +#[cfg(test)] +mod utils_test; // Since Scarb 2.6.0 there's an optimization that does not // build tests for dependencies and it's not configurable. diff --git a/crates/dojo-core/src/model.cairo b/crates/dojo-core/src/model.cairo index a8a6dd8c3f..ad2c69a300 100644 --- a/crates/dojo-core/src/model.cairo +++ b/crates/dojo-core/src/model.cairo @@ -10,6 +10,7 @@ trait Model { fn selector() -> felt252; fn instance_selector(self: @T) -> felt252; fn namespace() -> ByteArray; + fn namespace_selector() -> felt252; fn keys(self: @T) -> Span; fn values(self: @T) -> Span; fn layout() -> dojo::database::introspect::Layout; @@ -23,6 +24,7 @@ trait IModel { fn name(self: @T) -> ByteArray; fn version(self: @T) -> u8; fn namespace(self: @T) -> ByteArray; + fn namespace_selector(self: @T) -> felt252; fn unpacked_size(self: @T) -> Option; fn packed_size(self: @T) -> Option; fn layout(self: @T) -> dojo::database::introspect::Layout; @@ -38,7 +40,7 @@ trait IModel { /// * `class_hash` - Class Hash of the model. fn deploy_and_get_metadata( salt: felt252, class_hash: starknet::ClassHash -) -> SyscallResult<(starknet::ContractAddress, ByteArray, felt252, ByteArray)> { +) -> SyscallResult<(starknet::ContractAddress, ByteArray, felt252, ByteArray, felt252)> { let (contract_address, _) = starknet::deploy_syscall( class_hash, salt, array![].span(), false, )?; @@ -46,5 +48,6 @@ fn deploy_and_get_metadata( let name = model.name(); let selector = model.selector(); let namespace = model.namespace(); - Result::Ok((contract_address, name, selector, namespace)) + let namespace_selector = model.namespace_selector(); + Result::Ok((contract_address, name, selector, namespace, namespace_selector)) } diff --git a/crates/dojo-core/src/packing_test.cairo b/crates/dojo-core/src/packing_test.cairo index 58d340aff6..5a26c19e3b 100644 --- a/crates/dojo-core/src/packing_test.cairo +++ b/crates/dojo-core/src/packing_test.cairo @@ -349,9 +349,6 @@ fn test_pack_with_offset() { assert!(packed.len() == 2, "bad packed length"); - println!("first item: {}", *packed.at(0)); - println!("second item: {}", *packed.at(1)); - assert!(*packed.at(0) == 0x70006, "bad packed first item"); assert!(*packed.at(1) == 0x0900000000000000000000000000000008, "bad packed second item"); } diff --git a/crates/dojo-core/src/resource_metadata.cairo b/crates/dojo-core/src/resource_metadata.cairo index a67a2a7d2c..020c67f4f6 100644 --- a/crates/dojo-core/src/resource_metadata.cairo +++ b/crates/dojo-core/src/resource_metadata.cairo @@ -3,12 +3,9 @@ //! Manually expand to ensure that dojo-core //! does not depend on dojo plugin to be built. //! -use dojo::world::{IWorldDispatcherTrait, DOJO_NAMESPACE_SELECTOR}; - +use dojo::world::{IWorldDispatcherTrait}; use dojo::model::Model; -const RESOURCE_METADATA_SELECTOR: felt252 = selector!("ResourceMetadata"); - fn initial_address() -> starknet::ContractAddress { starknet::contract_address_const::<0>() } @@ -19,7 +16,7 @@ fn initial_class_hash() -> starknet::ClassHash { >() } -#[derive(Drop, Serde, PartialEq, Clone)] +#[derive(Drop, Serde, PartialEq, Clone, Debug)] struct ResourceMetadata { // #[key] resource_id: felt252, @@ -32,7 +29,7 @@ impl ResourceMetadataModel of dojo::model::Model { keys: Span, layout: dojo::database::introspect::Layout ) -> ResourceMetadata { - let values = world.entity(RESOURCE_METADATA_SELECTOR, keys, layout); + let values = world.entity(Self::selector(), keys, layout); let mut serialized = core::array::ArrayTrait::new(); core::array::serialize_array_helper(keys, ref serialized); core::array::serialize_array_helper(values, ref serialized); @@ -61,7 +58,7 @@ impl ResourceMetadataModel of dojo::model::Model { #[inline(always)] fn selector() -> felt252 { poseidon::poseidon_hash_span( - array![DOJO_NAMESPACE_SELECTOR, RESOURCE_METADATA_SELECTOR].span() + array![Self::namespace_selector(), selector!("ResourceMetadata")].span() ) } @@ -71,8 +68,11 @@ impl ResourceMetadataModel of dojo::model::Model { } fn namespace() -> ByteArray { - // TODO: in future Cairo versions, it should be possible to create const ByteArray - "Dojo" + "__DOJO__" + } + + fn namespace_selector() -> felt252 { + dojo::utils::hash(@Self::namespace()) } #[inline(always)] @@ -152,7 +152,6 @@ impl ResourceMetadataIntrospect<> of dojo::database::introspect::Introspect Co deploy_contract(class_hash, array![world.contract_address.into()].span()) } -fn spawn_test_world(models: Array) -> IWorldDispatcher { +fn spawn_test_world(namespace: ByteArray, models: Array) -> IWorldDispatcher { let salt = testing::get_available_gas(); // deploy world @@ -54,6 +54,9 @@ fn spawn_test_world(models: Array) -> IWorldDispatcher { let world = IWorldDispatcher { contract_address: world_address }; + // register namespace + world.register_namespace(namespace); + // register models let mut index = 0; loop { diff --git a/crates/dojo-core/src/utils.cairo b/crates/dojo-core/src/utils.cairo new file mode 100644 index 0000000000..92654ce538 --- /dev/null +++ b/crates/dojo-core/src/utils.cairo @@ -0,0 +1,6 @@ +/// Compute the poseidon hash of a serialized ByteArray +fn hash(data: @ByteArray) -> felt252 { + let mut serialized = ArrayTrait::new(); + Serde::serialize(data, ref serialized); + poseidon::poseidon_hash_span(serialized.span()) +} diff --git a/crates/dojo-core/src/utils_test.cairo b/crates/dojo-core/src/utils_test.cairo new file mode 100644 index 0000000000..34b6195f9e --- /dev/null +++ b/crates/dojo-core/src/utils_test.cairo @@ -0,0 +1,17 @@ +#[derive(Drop, Copy, Serde)] +#[dojo::model(namespace: "my namespace")] +struct MyModel { + #[key] + x: u8, + y: u8 +} + +#[test] +fn test_hash_computation() { + // Be sure that the namespace hash computed in `dojo-lang` in Rust is equal + // to the one computed in Cairo by dojo::utils:hash + let namespace = dojo::model::Model::::namespace(); + let namespace_selector = dojo::model::Model::::namespace_selector(); + + assert(dojo::utils::hash(@namespace) == namespace_selector, 'invalid computed hash'); +} diff --git a/crates/dojo-core/src/world.cairo b/crates/dojo-core/src/world.cairo index 21744471e5..a41ea080cc 100644 --- a/crates/dojo-core/src/world.cairo +++ b/crates/dojo-core/src/world.cairo @@ -3,14 +3,13 @@ use traits::{Into, TryInto}; use option::OptionTrait; use dojo::resource_metadata::ResourceMetadata; -const DOJO_NAMESPACE_SELECTOR: felt252 = selector!("Dojo"); - #[starknet::interface] trait IWorld { fn metadata(self: @T, resource_id: felt252) -> ResourceMetadata; fn set_metadata(ref self: T, metadata: ResourceMetadata); fn model(self: @T, selector: felt252) -> (ClassHash, ContractAddress); fn register_model(ref self: T, class_hash: ClassHash); + fn register_namespace(ref self: T, namespace: ByteArray); fn deploy_contract( ref self: T, salt: felt252, class_hash: ClassHash, init_calldata: Span ) -> ContractAddress; @@ -31,13 +30,21 @@ trait IWorld { ref self: T, model: felt252, keys: Span, layout: dojo::database::introspect::Layout ); fn base(self: @T) -> ClassHash; + + /// In Dojo, there are 2 levels of authorization: `owner` and `writer`. + /// Only accounts can own a resource while any contract can write to a resource, + /// as soon as it has granted the write access from an owner of the resource. fn is_owner(self: @T, address: ContractAddress, resource: felt252) -> bool; fn grant_owner(ref self: T, address: ContractAddress, resource: felt252); fn revoke_owner(ref self: T, address: ContractAddress, resource: felt252); - fn is_writer(self: @T, model: felt252, contract: ContractAddress) -> bool; - fn grant_writer(ref self: T, model: felt252, contract: ContractAddress); - fn revoke_writer(ref self: T, model: felt252, contract: ContractAddress); + fn is_writer(self: @T, resource: felt252, contract: ContractAddress) -> bool; + fn grant_writer(ref self: T, resource: felt252, contract: ContractAddress); + fn revoke_writer(ref self: T, resource: felt252, contract: ContractAddress); + + fn can_write_resource(self: @T, resource_id: felt252, contract: ContractAddress) -> bool; + fn can_write_model(self: @T, model_id: felt252, contract: ContractAddress) -> bool; + fn can_write_namespace(self: @T, namespace_id: felt252, contract: ContractAddress) -> bool; } #[starknet::interface] @@ -64,9 +71,18 @@ mod Errors { const METADATA_DESER: felt252 = 'metadata deser error'; const NOT_OWNER: felt252 = 'not owner'; const NOT_OWNER_WRITER: felt252 = 'not owner or writer'; + const NO_WRITE_ACCESS: felt252 = 'no write access'; + const NO_MODEL_WRITE_ACCESS: felt252 = 'no model write access'; + const NO_NAMESPACE_WRITE_ACCESS: felt252 = 'no namespace write access'; + const NAMESPACE_NOT_REGISTERED: felt252 = 'namespace not registered'; + const NOT_REGISTERED: felt252 = 'resource not registered'; const INVALID_MODEL_NAME: felt252 = 'invalid model name'; + const INVALID_NAMESPACE_NAME: felt252 = 'invalid namespace name'; + const INVALID_RESOURCE_SELECTOR: felt252 = 'invalid resource selector'; const OWNER_ONLY_UPGRADE: felt252 = 'only owner can upgrade'; const OWNER_ONLY_UPDATE: felt252 = 'only owner can update'; + const NAMESPACE_ALREADY_REGISTERED: felt252 = 'namespace already registered'; + const UNEXPECTED_ERROR: felt252 = 'unexpected error'; } #[starknet::contract] @@ -93,14 +109,14 @@ mod world { use dojo::database::introspect::{Introspect, Layout, FieldLayout}; use dojo::components::upgradeable::{IUpgradeableDispatcher, IUpgradeableDispatcherTrait}; use dojo::config::component::Config; - use dojo::model::Model; + use dojo::model::{Model, IModelDispatcher, IModelDispatcherImpl}; use dojo::interfaces::{ IUpgradeableState, IFactRegistryDispatcher, IFactRegistryDispatcherImpl, StorageUpdate, ProgramOutput }; use dojo::world::{IWorldDispatcher, IWorld, IUpgradeableWorld}; use dojo::resource_metadata; - use dojo::resource_metadata::{ResourceMetadata, RESOURCE_METADATA_SELECTOR}; + use dojo::resource_metadata::ResourceMetadata; use super::Errors; @@ -118,12 +134,13 @@ mod world { #[event] #[derive(Drop, starknet::Event)] - enum Event { + pub enum Event { WorldSpawned: WorldSpawned, ContractDeployed: ContractDeployed, ContractUpgraded: ContractUpgraded, WorldUpgraded: WorldUpgraded, MetadataUpdate: MetadataUpdate, + NamespaceRegistered: NamespaceRegistered, ModelRegistered: ModelRegistered, StoreSetRecord: StoreSetRecord, StoreDelRecord: StoreDelRecord, @@ -168,6 +185,12 @@ mod world { uri: ByteArray } + #[derive(Drop, starknet::Event, Debug, PartialEq)] + pub struct NamespaceRegistered { + namespace: ByteArray, + hash: felt252 + } + #[derive(Drop, starknet::Event)] struct ModelRegistered { name: ByteArray, @@ -193,7 +216,7 @@ mod world { #[derive(Drop, starknet::Event)] struct WriterUpdated { - model: felt252, + resource: felt252, contract: ContractAddress, value: bool } @@ -210,8 +233,7 @@ mod world { contract_base: ClassHash, nonce: usize, models_count: usize, - models: LegacyMap::, - deployed_contracts: LegacyMap::, + resources: LegacyMap::, owners: LegacyMap::<(felt252, ContractAddress), bool>, writers: LegacyMap::<(felt252, ContractAddress), bool>, #[substorage(v0)] @@ -219,17 +241,45 @@ mod world { initialized_contract: LegacyMap::, } + #[derive(Drop, starknet::Store, Default, Debug)] + enum ResourceData { + Model: (ClassHash, ContractAddress), + Contract, + Namespace, + #[default] + None, + } + + #[generate_trait] + impl ResourceDataIsNoneImpl of ResourceDataIsNoneTrait { + fn is_none(self: @ResourceData) -> bool { + match self { + ResourceData::None => true, + _ => false + } + } + } + #[constructor] fn constructor(ref self: ContractState, contract_base: ClassHash) { let creator = starknet::get_tx_info().unbox().account_contract_address; self.contract_base.write(contract_base); - self.owners.write((WORLD, creator), true); + + self.resources.write(WORLD, ResourceData::Contract); self - .models + .resources .write( - RESOURCE_METADATA_SELECTOR, - (resource_metadata::initial_class_hash(), resource_metadata::initial_address()) + dojo::model::Model::::selector(), + ResourceData::Model( + (resource_metadata::initial_class_hash(), resource_metadata::initial_address()) + ) ); + self.owners.write((WORLD, creator), true); + + let dojo_namespace_hash = dojo::utils::hash(@"__DOJO__"); + + self.resources.write(dojo_namespace_hash, ResourceData::Namespace); + self.owners.write((dojo_namespace_hash, creator), true); EventEmitter::emit(ref self, WorldSpawned { address: get_contract_address(), creator }); } @@ -244,7 +294,7 @@ mod world { fn metadata(self: @ContractState, resource_id: felt252) -> ResourceMetadata { let mut data = self ._read_model_data( - RESOURCE_METADATA_SELECTOR, + dojo::model::Model::::selector(), array![resource_id].span(), Model::::layout() ); @@ -263,7 +313,10 @@ mod world { /// /// `metadata` - The metadata content for the resource. fn set_metadata(ref self: ContractState, metadata: ResourceMetadata) { - assert_can_write(@self, metadata.resource_id, get_caller_address()); + assert( + self.can_write_resource(metadata.resource_id, get_caller_address()), + Errors::NO_WRITE_ACCESS + ); let model = Model::::selector(); let keys = Model::::keys(@metadata); @@ -294,16 +347,17 @@ mod world { /// Grants ownership of the resource to the address. /// Can only be called by an existing owner or the world admin. - /// + /// + /// Note that this resource must have been registered to the world first. + /// /// # Arguments /// /// * `address` - The contract address. /// * `resource` - The resource. fn grant_owner(ref self: ContractState, address: ContractAddress, resource: felt252) { - let caller = get_caller_address(); - assert( - self.is_owner(caller, resource) || self.is_owner(caller, WORLD), Errors::NOT_OWNER - ); + assert(!self.resources.read(resource).is_none(), Errors::NOT_REGISTERED); + assert(self.is_account_owner(resource), Errors::NOT_OWNER); + self.owners.write((resource, address), true); EventEmitter::emit(ref self, OwnerUpdated { address, resource, value: true }); @@ -312,72 +366,158 @@ mod world { /// Revokes owner permission to the contract for the model. /// Can only be called by an existing owner or the world admin. /// + /// Note that this resource must have been registered to the world first. + /// /// # Arguments /// /// * `address` - The contract address. /// * `resource` - The resource. fn revoke_owner(ref self: ContractState, address: ContractAddress, resource: felt252) { - let caller = get_caller_address(); - assert( - self.is_owner(caller, resource) || self.is_owner(caller, WORLD), Errors::NOT_OWNER - ); + assert(!self.resources.read(resource).is_none(), Errors::NOT_REGISTERED); + assert(self.is_account_owner(resource), Errors::NOT_OWNER); + self.owners.write((resource, address), false); EventEmitter::emit(ref self, OwnerUpdated { address, resource, value: false }); } - /// Checks if the provided contract is a writer of the model. + /// Checks if the provided contract is a writer of the resource. + /// + /// Note: that this function just indicates if a contract has the `writer` role for the resource, + /// without applying any specific rule. For example, for a model, the write access right + /// to the model namespace is not checked. + /// It does not even check if the contract is an owner of the resource. + /// Please use more high-level functions such `can_write_model` for that. /// /// # Arguments /// - /// * `model` - The name of the model. + /// * `resource` - The hash of the resource name. /// * `contract` - The name of the contract. /// /// # Returns /// - /// * `bool` - True if the contract is a writer of the model, false otherwise - fn is_writer(self: @ContractState, model: felt252, contract: ContractAddress) -> bool { - self.writers.read((model, contract)) + /// * `bool` - True if the contract is a writer of the resource, false otherwise + fn is_writer(self: @ContractState, resource: felt252, contract: ContractAddress) -> bool { + self.writers.read((resource, contract)) } - /// Grants writer permission to the contract for the model. - /// Can only be called by an existing model owner or the world admin. + /// Grants writer permission to the contract for the resource. + /// Can only be called by an existing resource owner or the world admin. + /// + /// Note that this resource must have been registered to the world first. /// /// # Arguments /// - /// * `model` - The name of the model. + /// * `resource` - The hash of the resource name. /// * `contract` - The name of the contract. - fn grant_writer(ref self: ContractState, model: felt252, contract: ContractAddress) { - let caller = get_caller_address(); + fn grant_writer(ref self: ContractState, resource: felt252, contract: ContractAddress) { + assert(!self.resources.read(resource).is_none(), Errors::NOT_REGISTERED); + assert(self.is_account_owner(resource), Errors::NOT_OWNER); - assert( - self.is_owner(caller, model) || self.is_owner(caller, WORLD), - Errors::NOT_OWNER_WRITER - ); - self.writers.write((model, contract), true); + self.writers.write((resource, contract), true); - EventEmitter::emit(ref self, WriterUpdated { model, contract, value: true }); + EventEmitter::emit(ref self, WriterUpdated { resource, contract, value: true }); } /// Revokes writer permission to the contract for the model. /// Can only be called by an existing model writer, owner or the world admin. /// + /// Note that this resource must have been registered to the world first. + /// /// # Arguments /// /// * `model` - The name of the model. /// * `contract` - The name of the contract. - fn revoke_writer(ref self: ContractState, model: felt252, contract: ContractAddress) { - let caller = get_caller_address(); + fn revoke_writer(ref self: ContractState, resource: felt252, contract: ContractAddress) { + assert(!self.resources.read(resource).is_none(), Errors::NOT_REGISTERED); + let caller = get_caller_address(); assert( - self.is_writer(model, caller) - || self.is_owner(caller, model) - || self.is_owner(caller, WORLD), + self.is_writer(resource, caller) || self.is_account_owner(resource), Errors::NOT_OWNER_WRITER ); - self.writers.write((model, contract), false); + self.writers.write((resource, contract), false); + + EventEmitter::emit(ref self, WriterUpdated { resource, contract, value: false }); + } + + /// Checks if the provided contract can write to the resource. + /// + /// Note: Contrary to `is_writer`, this function checks resource specific rules. + /// For example, for a model, it checks if the contract is a write/owner of the resource, + /// OR a write/owner of the namespace. + /// + /// # Arguments + /// + /// * `resource_id` - The resource IUpgradeableDispatcher. + /// * `contract` - The name of the contract. + /// + /// # Returns + /// + /// * `bool` - True if the contract can write to the resource, false otherwise + fn can_write_resource( + self: @ContractState, resource_id: felt252, contract: ContractAddress + ) -> bool { + // TODO: use match self.resources... directly when https://github.com/starkware-libs/cairo/pull/5743 fixed + let resource: ResourceData = self.resources.read(resource_id); + match resource { + ResourceData::Model((_, model_address)) => self + ._check_model_write_access(resource_id, model_address, contract), + ResourceData::Namespace | + ResourceData::Contract => self._check_basic_write_access(resource_id, contract), + ResourceData::None => panic_with_felt252(Errors::INVALID_RESOURCE_SELECTOR) + } + } - EventEmitter::emit(ref self, WriterUpdated { model, contract, value: false }); + /// Checks if the provided contract can write to the model. + /// It panics if the resource selector is not a model. + /// + /// Note: Contrary to `is_writer`, this function checks if the contract is a write/owner of the model, + /// OR a write/owner of the namespace. + /// + /// # Arguments + /// + /// * `model_id` - The model selector. + /// * `contract` - The name of the contract. + /// + /// # Returns + /// + /// * `bool` - True if the contract can write to the model, false otherwise + fn can_write_model( + self: @ContractState, model_id: felt252, contract: ContractAddress + ) -> bool { + // TODO: use match self.resources... directly when https://github.com/starkware-libs/cairo/pull/5743 fixed + let resource: ResourceData = self.resources.read(model_id); + match resource { + ResourceData::Model((_, model_address)) => self + ._check_model_write_access(model_id, model_address, contract), + _ => panic_with_felt252(Errors::INVALID_RESOURCE_SELECTOR) + } + } + + /// Checks if the provided contract can write to the namespace. + /// It panics if the resource selector is not a namespace. + /// + /// Note: Contrary to `is_writer`, this function also checks if the caller account is + /// the owner of the namespace. + /// + /// # Arguments + /// + /// * `namespace_id` - The namespace selector. + /// * `contract` - The name of the contract. + /// + /// # Returns + /// + /// * `bool` - True if the contract can write to the namespace, false otherwise + fn can_write_namespace( + self: @ContractState, namespace_id: felt252, contract: ContractAddress + ) -> bool { + // TODO: use match self.resources... directly when https://github.com/starkware-libs/cairo/pull/5743 fixed + let resource: ResourceData = self.resources.read(namespace_id); + match resource { + ResourceData::Namespace => self._check_basic_write_access(namespace_id, contract), + _ => panic_with_felt252(Errors::INVALID_RESOURCE_SELECTOR) + } } /// Registers a model in the world. If the model is already registered, @@ -390,7 +530,8 @@ mod world { let caller = get_caller_address(); let salt = self.models_count.read(); - let (address, name, selector, namespace) = dojo::model::deploy_and_get_metadata( + let (address, name, selector, namespace, namespace_selector) = + dojo::model::deploy_and_get_metadata( salt.into(), class_hash ) .unwrap_syscall(); @@ -401,25 +542,38 @@ mod world { starknet::contract_address::ContractAddressZeroable::zero(), ); - // Avoids a model name to conflict with already deployed contract, - // which can cause ACL issue with current ACL implementation. - if selector.is_zero() || self.deployed_contracts.read(selector).is_non_zero() { + assert( + !self._is_namespace_registered(namespace_selector), Errors::NAMESPACE_NOT_REGISTERED + ); + assert( + self.can_write_namespace(namespace_selector, get_caller_address()), + Errors::NO_NAMESPACE_WRITE_ACCESS + ); + + if selector.is_zero() { panic_with_felt252(Errors::INVALID_MODEL_NAME); } - // If model is already registered, validate permission to update. - let model_data: (ClassHash, ContractAddress) = self.models.read(selector); - let (current_class_hash, current_address) = model_data; - - if current_class_hash.is_non_zero() { - assert(self.is_owner(caller, selector), Errors::OWNER_ONLY_UPDATE); - prev_class_hash = current_class_hash; - prev_address = current_address; - } else { - self.owners.write((selector, caller), true); + // TODO: use match self.resources... directly when https://github.com/starkware-libs/cairo/pull/5743 fixed + let resource: ResourceData = self.resources.read(selector); + + match resource { + // If model is already registered, validate permission to update. + ResourceData::Model(( + model_hash, model_address + )) => { + assert(self.is_account_owner(selector), Errors::OWNER_ONLY_UPDATE); + prev_class_hash = model_hash; + prev_address = model_address; + }, + // new model + ResourceData::None => { self.owners.write((selector, caller), true); }, + // Avoids a model name to conflict with already registered resource, + // which can cause ACL issue with current ACL implementation. + _ => panic_with_felt252(Errors::INVALID_MODEL_NAME) }; - self.models.write(selector, (class_hash, address)); + self.resources.write(selector, ResourceData::Model((class_hash, address))); EventEmitter::emit( ref self, ModelRegistered { @@ -428,6 +582,35 @@ mod world { ); } + /// Registers a namespace in the world. + /// + /// # Arguments + /// + /// * `namespace` - The name of the namespace to be registered. + fn register_namespace(ref self: ContractState, namespace: ByteArray) { + let caller_account = self._get_account_address(); + + let hash = dojo::utils::hash(@namespace); + + // TODO: use match self.resources... directly when https://github.com/starkware-libs/cairo/pull/5743 fixed + let resource: ResourceData = self.resources.read(hash); + match resource { + ResourceData::Namespace => { + if !self.is_account_owner(hash) { + panic_with_felt252(Errors::NAMESPACE_ALREADY_REGISTERED); + } + }, + ResourceData::None => { + self.resources.write(hash, ResourceData::Namespace); + self.owners.write((hash, caller_account), true); + + EventEmitter::emit(ref self, NamespaceRegistered { namespace, hash }); + }, + _ => { panic_with_felt252(Errors::INVALID_NAMESPACE_NAME); } + }; + } + + /// Gets the class hash of a registered model. /// /// # Arguments @@ -438,7 +621,12 @@ mod world { /// /// * (`ClassHash`, `ContractAddress`) - The class hash and the contract address of the model. fn model(self: @ContractState, selector: felt252) -> (ClassHash, ContractAddress) { - self.models.read(selector) + // TODO: use match self.resources... directly when https://github.com/starkware-libs/cairo/pull/5743 fixed + let resource: ResourceData = self.resources.read(selector); + match resource { + ResourceData::Model(m) => m, + _ => panic_with_felt252(Errors::INVALID_RESOURCE_SELECTOR) + } } /// Deploys a contract associated with the world. @@ -475,7 +663,7 @@ mod world { self.owners.write((contract_address.into(), get_caller_address()), true); - self.deployed_contracts.write(contract_address.into(), class_hash.into()); + self.resources.write(contract_address.into(), ResourceData::Contract); EventEmitter::emit( ref self, ContractDeployed { salt, class_hash, address: contract_address } @@ -497,7 +685,7 @@ mod world { fn upgrade_contract( ref self: ContractState, address: ContractAddress, class_hash: ClassHash ) -> ClassHash { - assert(is_account_owner(@self, address.into()), Errors::NOT_OWNER); + assert(self.is_account_owner(address.into()), Errors::NOT_OWNER); IUpgradeableDispatcher { contract_address: address }.upgrade(class_hash); EventEmitter::emit(ref self, ContractUpgraded { class_hash, address }); class_hash @@ -543,7 +731,9 @@ mod world { values: Span, layout: dojo::database::introspect::Layout ) { - assert_can_write(@self, model, get_caller_address()); + assert( + self.can_write_model(model, get_caller_address()), Errors::NO_MODEL_WRITE_ACCESS + ); self._write_model_data(model, keys, values, layout); EventEmitter::emit(ref self, StoreSetRecord { table: model, keys, values }); @@ -564,7 +754,9 @@ mod world { keys: Span, layout: dojo::database::introspect::Layout ) { - assert_can_write(@self, model, get_caller_address()); + assert( + self.can_write_model(model, get_caller_address()), Errors::NO_MODEL_WRITE_ACCESS + ); self._delete_model_data(model, keys, layout); EventEmitter::emit(ref self, StoreDelRecord { table: model, keys }); @@ -612,10 +804,7 @@ mod world { /// * `new_class_hash` - The new world class hash. fn upgrade(ref self: ContractState, new_class_hash: ClassHash) { assert(new_class_hash.is_non_zero(), 'invalid class_hash'); - assert( - IWorld::is_owner(@self, get_tx_info().unbox().account_contract_address, WORLD), - Errors::OWNER_ONLY_UPGRADE, - ); + assert(self.is_account_world_owner(), Errors::OWNER_ONLY_UPGRADE); // upgrade to new_class_hash replace_class_syscall(new_class_hash).unwrap(); @@ -673,37 +862,92 @@ mod world { } } - /// Asserts that the current caller can write to the model. - /// - /// # Arguments - /// - /// * `resource` - The selector of the resource being written to. - /// * `caller` - The selector of the caller writing. - fn assert_can_write(self: @ContractState, resource: felt252, caller: ContractAddress) { - assert( - IWorld::is_writer(self, resource, caller) || is_account_owner(self, resource), - 'not writer' - ); - } - - /// Verifies if the calling account is owner of the resource or the - /// owner of the world. - /// - /// # Arguments - /// - /// * `resource` - The selector of the resource being verified. - /// - /// # Returns - /// - /// * `bool` - True if the calling account is the owner of the resource or the owner of the world, - /// false otherwise. - fn is_account_owner(self: @ContractState, resource: felt252) -> bool { - IWorld::is_owner(self, get_tx_info().unbox().account_contract_address, resource) - || IWorld::is_owner(self, get_tx_info().unbox().account_contract_address, WORLD) - } - #[generate_trait] impl Self of SelfTrait { + #[inline(always)] + fn _get_account_address(self: @ContractState) -> ContractAddress { + get_tx_info().unbox().account_contract_address + } + + /// Verifies if the calling account is owner of the resource or the + /// owner of the world. + /// + /// # Arguments + /// + /// * `resource` - The selector of the resource being verified. + /// + /// # Returns + /// + /// * `bool` - True if the calling account is the owner of the resource or the owner of the world, + /// false otherwise. + #[inline(always)] + fn is_account_owner(self: @ContractState, resource: felt252) -> bool { + IWorld::is_owner(self, self._get_account_address(), resource) + || self.is_account_world_owner() + } + + /// Verifies if the calling account has write access to the resource. + /// + /// # Arguments + /// + /// * `resource` - The selector of the resource being verified. + /// + /// # Returns + /// + /// * `bool` - True if the calling account has write access to the resource, + /// false otherwise. + #[inline(always)] + fn is_account_writer(self: @ContractState, resource: felt252) -> bool { + IWorld::is_writer(self, resource, self._get_account_address()) + } + + /// Verifies if the calling account is the world owner. + /// + /// # Returns + /// + /// * `bool` - True if the calling account is the world owner, false otherwise. + #[inline(always)] + fn is_account_world_owner(self: @ContractState) -> bool { + IWorld::is_owner(self, self._get_account_address(), WORLD) + } + + /// Indicates if the provided namespace is already registered + #[inline(always)] + fn _is_namespace_registered(self: @ContractState, namespace_selector: felt252) -> bool { + // TODO: use match self.resources... directly when https://github.com/starkware-libs/cairo/pull/5743 fixed + let resource: ResourceData = self.resources.read(namespace_selector); + match resource { + ResourceData::Namespace => true, + _ => false + } + } + + /// Check if a contract can write to the model by checking if the contract + /// is a writer/owner of the model OR a writer/owner of the model namespace. + /// + /// #Arguments + /// TODO + fn _check_model_write_access( + self: @ContractState, + model_id: felt252, + model_address: ContractAddress, + contract: ContractAddress + ) -> bool { + if !self.is_writer(model_id, contract) && !self.is_account_owner(model_id) { + let model = IModelDispatcher { contract_address: model_address }; + self._check_basic_write_access(model.namespace_selector(), contract) + } else { + true + } + } + + /// TODO + fn _check_basic_write_access( + self: @ContractState, resource_id: felt252, contract: ContractAddress + ) -> bool { + self.is_writer(resource_id, contract) || self.is_account_owner(resource_id) + } + /// Write a new model record. /// /// # Arguments diff --git a/crates/dojo-core/src/world_test.cairo b/crates/dojo-core/src/world_test.cairo index 5106cba9a4..d887c06c3e 100644 --- a/crates/dojo-core/src/world_test.cairo +++ b/crates/dojo-core/src/world_test.cairo @@ -11,8 +11,9 @@ use dojo::benchmarks; use dojo::config::interface::{IConfigDispatcher, IConfigDispatcherImpl}; use dojo::world::{ IWorldDispatcher, IWorldDispatcherTrait, world, IUpgradeableWorld, IUpgradeableWorldDispatcher, - IUpgradeableWorldDispatcherTrait, ResourceMetadata + IUpgradeableWorldDispatcherTrait, ResourceMetadata, }; +use dojo::world::world::NamespaceRegistered; use dojo::database::introspect::{Introspect, Layout, FieldLayout}; use dojo::database::MAX_ARRAY_LENGTH; use dojo::test_utils::{spawn_test_world, deploy_with_world_address, assert_array}; @@ -246,6 +247,8 @@ fn get_key_test() -> Span { trait IMetadataOnly { fn selector(self: @T) -> felt252; fn name(self: @T) -> ByteArray; + fn namespace(self: @T) -> ByteArray; + fn namespace_selector(self: @T) -> felt252; } #[starknet::contract] @@ -256,7 +259,15 @@ mod resource_metadata_malicious { #[abi(embed_v0)] impl InvalidModelName of super::IMetadataOnly { fn selector(self: @ContractState) -> felt252 { - selector!("ResourceMetadata") + dojo::model::Model::::selector() + } + + fn namespace(self: @ContractState) -> ByteArray { + "dojo" + } + + fn namespace_selector(self: @ContractState) -> felt252 { + dojo::utils::hash(@Self::namespace(self)) } fn name(self: @ContractState) -> ByteArray { @@ -300,7 +311,7 @@ mod bar { .world .read() .delete_entity( - selector!("Foo"), + dojo::model::Model::::selector(), array![get_caller_address().into()].span(), dojo::model::Model::::layout() ); @@ -406,7 +417,7 @@ fn test_model_class_hash_getter() { let world = deploy_world(); world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); - let (foo_class_hash, _) = world.model(selector!("Foo")); + let (foo_class_hash, _) = world.model(dojo::model::Model::::selector()); assert(foo_class_hash == foo::TEST_CLASS_HASH.try_into().unwrap(), 'foo wrong class hash'); } @@ -421,6 +432,66 @@ fn test_legacy_model_class_hash_getter() { assert(foo_class_hash == foo::TEST_CLASS_HASH.try_into().unwrap(), 'foo wrong class hash'); } +#[test] +fn test_register_namespace() { + let world = deploy_world(); + + let caller = starknet::contract_address_const::<0xb0b>(); + starknet::testing::set_account_contract_address(caller); + + drop_all_events(world.contract_address); + + let namespace = "namespace"; + let hash = dojo::utils::hash(@namespace); + + world.register_namespace(namespace); + + assert(world.is_owner(caller, hash), 'namespace not registered'); + + assert_eq!( + starknet::testing::pop_log(world.contract_address), + Option::Some(NamespaceRegistered { namespace: "namespace", hash }) + ); +} + +#[test] +fn test_register_namespace_already_registered_same_caller() { + let world = deploy_world(); + + let caller = starknet::contract_address_const::<0xb0b>(); + starknet::testing::set_account_contract_address(caller); + + let namespace = "namespace"; + let hash = dojo::utils::hash(@namespace); + + world.register_namespace(namespace); + + drop_all_events(world.contract_address); + + world.register_namespace("namespace"); + + assert(world.is_owner(caller, hash), 'namespace not registered'); + + let event = starknet::testing::pop_log_raw(world.contract_address); + assert(event.is_none(), 'unexpected event'); +} + +#[test] +#[should_panic(expected: ('namespace already registered', 'ENTRYPOINT_FAILED',))] +fn test_register_namespace_already_registered_other_caller() { + let world = deploy_world(); + + let account = starknet::contract_address_const::<0xb0b>(); + starknet::testing::set_account_contract_address(account); + + world.register_namespace("namespace"); + + let another_account = starknet::contract_address_const::<0xa11ce>(); + starknet::testing::set_account_contract_address(another_account); + + world.register_namespace("namespace"); +} + #[test] #[available_gas(6000000)] fn test_emit() { @@ -470,7 +541,7 @@ fn test_set_entity_unauthorized() { // Utils fn deploy_world() -> IWorldDispatcher { - spawn_test_world(array![]) + spawn_test_world("dojo", array![]) } #[test] @@ -490,13 +561,13 @@ fn test_set_metadata_world() { #[test] #[available_gas(60000000)] fn test_set_metadata_model_writer() { - let world = spawn_test_world(array![foo::TEST_CLASS_HASH],); + let world = spawn_test_world("dojo", array![foo::TEST_CLASS_HASH],); let bar_contract = IbarDispatcher { contract_address: deploy_with_world_address(bar::TEST_CLASS_HASH, world) }; - world.grant_writer(selector!("Foo"), bar_contract.contract_address); + world.grant_writer(dojo::model::Model::::selector(), bar_contract.contract_address); let bob = starknet::contract_address_const::<0xb0b>(); starknet::testing::set_account_contract_address(bob); @@ -505,18 +576,18 @@ fn test_set_metadata_model_writer() { bar_contract.set_foo(1337, 1337); let metadata = ResourceMetadata { - resource_id: selector!("Foo"), metadata_uri: format!("ipfs:bob") + resource_id: dojo::model::Model::::selector(), metadata_uri: format!("ipfs:bob") }; // A system that has write access on a model should be able to update the metadata. // This follows conventional ACL model. world.set_metadata(metadata.clone()); - assert(world.metadata(selector!("Foo")) == metadata, 'bad metadata'); + assert(world.metadata(dojo::model::Model::::selector()) == metadata, 'bad metadata'); } #[test] #[available_gas(60000000)] -#[should_panic(expected: ('not writer', 'ENTRYPOINT_FAILED',))] +#[should_panic(expected: ('no write access', 'ENTRYPOINT_FAILED',))] fn test_set_metadata_same_model_rules() { let world = deploy_world(); @@ -541,6 +612,9 @@ fn test_metadata_update_owner_only() { let bob = starknet::contract_address_const::<0xb0b>(); starknet::testing::set_contract_address(bob); + + world.grant_owner(bob, dojo::utils::hash(@"dojo")); + starknet::testing::set_account_contract_address(bob); world.register_model(resource_metadata_malicious::TEST_CLASS_HASH.try_into().unwrap()); @@ -550,24 +624,26 @@ fn test_metadata_update_owner_only() { #[available_gas(6000000)] fn test_owner() { let world = deploy_world(); + world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); + let foo_selector = dojo::model::Model::::selector(); let alice = starknet::contract_address_const::<0x1337>(); let bob = starknet::contract_address_const::<0x1338>(); assert(!world.is_owner(alice, 0), 'should not be owner'); - assert(!world.is_owner(bob, 42), 'should not be owner'); + assert(!world.is_owner(bob, foo_selector), 'should not be owner'); world.grant_owner(alice, 0); assert(world.is_owner(alice, 0), 'should be owner'); - world.grant_owner(bob, 42); - assert(world.is_owner(bob, 42), 'should be owner'); + world.grant_owner(bob, foo_selector); + assert(world.is_owner(bob, foo_selector), 'should be owner'); world.revoke_owner(alice, 0); assert(!world.is_owner(alice, 0), 'should not be owner'); - world.revoke_owner(bob, 42); - assert(!world.is_owner(bob, 42), 'should not be owner'); + world.revoke_owner(bob, foo_selector); + assert(!world.is_owner(bob, foo_selector), 'should not be owner'); } #[test] @@ -577,7 +653,7 @@ fn test_set_owner_fails_for_non_owner() { let world = deploy_world(); let alice = starknet::contract_address_const::<0x1337>(); - starknet::testing::set_contract_address(alice); + starknet::testing::set_account_contract_address(alice); world.revoke_owner(alice, 0); assert(!world.is_owner(alice, 0), 'should not be owner'); @@ -589,28 +665,39 @@ fn test_set_owner_fails_for_non_owner() { #[available_gas(6000000)] fn test_writer() { let world = deploy_world(); + world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); + let foo_selector = dojo::model::Model::::selector(); - assert(!world.is_writer(42, 69.try_into().unwrap()), 'should not be writer'); + assert(!world.is_writer(foo_selector, 69.try_into().unwrap()), 'should not be writer'); - world.grant_writer(42, 69.try_into().unwrap()); - assert(world.is_writer(42, 69.try_into().unwrap()), 'should be writer'); + world.grant_writer(foo_selector, 69.try_into().unwrap()); + assert(world.is_writer(foo_selector, 69.try_into().unwrap()), 'should be writer'); - world.revoke_writer(42, 69.try_into().unwrap()); - assert(!world.is_writer(42, 69.try_into().unwrap()), 'should not be writer'); + world.revoke_writer(foo_selector, 69.try_into().unwrap()); + assert(!world.is_writer(foo_selector, 69.try_into().unwrap()), 'should not be writer'); +} + +#[test] +#[should_panic(expected: ('resource not registered', 'ENTRYPOINT_FAILED'))] +fn test_writer_not_registered_resource() { + let world = deploy_world(); + + // 42 is not a registered resource ID + world.grant_writer(42, 69.try_into().unwrap()); } #[test] #[available_gas(6000000)] #[should_panic] fn test_system_not_writer_fail() { - let world = spawn_test_world(array![foo::TEST_CLASS_HASH],); + let world = spawn_test_world("dojo", array![foo::TEST_CLASS_HASH],); let bar_address = deploy_with_world_address(bar::TEST_CLASS_HASH, world); let bar_contract = IbarDispatcher { contract_address: bar_address }; // Caller is not owner now - let caller = starknet::contract_address_const::<0x1337>(); - starknet::testing::set_account_contract_address(caller); + let account = starknet::contract_address_const::<0xb0b>(); + starknet::testing::set_account_contract_address(account); // Should panic, system not writer bar_contract.set_foo(25, 16); @@ -618,13 +705,13 @@ fn test_system_not_writer_fail() { #[test] fn test_system_writer_access() { - let world = spawn_test_world(array![foo::TEST_CLASS_HASH],); + let world = spawn_test_world("dojo", array![foo::TEST_CLASS_HASH],); let bar_address = deploy_with_world_address(bar::TEST_CLASS_HASH, world); let bar_contract = IbarDispatcher { contract_address: bar_address }; - world.grant_writer(selector!("Foo"), bar_address); - assert(world.is_writer(selector!("Foo"), bar_address), 'should be writer'); + world.grant_writer(dojo::model::Model::::selector(), bar_address); + assert(world.is_writer(dojo::model::Model::::selector(), bar_address), 'should be writer'); // Caller is not owner now let caller = starknet::contract_address_const::<0x1337>(); @@ -651,14 +738,14 @@ fn test_set_writer_fails_for_non_owner() { #[test] fn test_execute_multiple_worlds() { // Deploy world contract - let world1 = spawn_test_world(array![foo::TEST_CLASS_HASH],); + let world1 = spawn_test_world("dojo", array![foo::TEST_CLASS_HASH],); let bar1_contract = IbarDispatcher { contract_address: deploy_with_world_address(bar::TEST_CLASS_HASH, world1) }; // Deploy another world contract - let world2 = spawn_test_world(array![foo::TEST_CLASS_HASH],); + let world2 = spawn_test_world("dojo", array![foo::TEST_CLASS_HASH],); let bar2_contract = IbarDispatcher { contract_address: deploy_with_world_address(bar::TEST_CLASS_HASH, world2) @@ -680,7 +767,7 @@ fn test_execute_multiple_worlds() { #[test] #[available_gas(60000000)] fn bench_execute() { - let world = spawn_test_world(array![foo::TEST_CLASS_HASH],); + let world = spawn_test_world("dojo", array![foo::TEST_CLASS_HASH],); let bar_contract = IbarDispatcher { contract_address: deploy_with_world_address(bar::TEST_CLASS_HASH, world) }; @@ -701,30 +788,6 @@ fn bench_execute() { assert(data.a == 1337, 'data not stored'); } -#[test] -fn bench_execute_complex() { - let world = spawn_test_world(array![foo::TEST_CLASS_HASH],); - let bar_contract = IbarDispatcher { - contract_address: deploy_with_world_address(bar::TEST_CLASS_HASH, world) - }; - - let alice = starknet::contract_address_const::<0x1337>(); - starknet::testing::set_contract_address(alice); - - let gas = testing::get_available_gas(); - gas::withdraw_gas().unwrap(); - bar_contract.set_char(1337, 1337); - end(gas, 'char set call'); - - let gas = testing::get_available_gas(); - gas::withdraw_gas().unwrap(); - let data = get!(world, alice, Character); - end(gas, 'char get macro'); - - assert(data.heigth == 1337, 'data not stored'); -} - - #[starknet::interface] trait IWorldUpgrade { fn hello(self: @TContractState) -> felt252; @@ -861,14 +924,12 @@ fn test_can_call_init() { fn test_set_entity_with_fixed_layout() { let world = deploy_world(); world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); - - let selector = selector!("foo"); + let selector = dojo::model::Model::::selector(); let keys = get_key_test(); let values = create_foo(); let layout = dojo::model::Model::::layout(); world.set_entity(selector, get_key_test(), values, layout); - let read_values = world.entity(selector, keys, layout); assert_array(read_values, values); } @@ -878,7 +939,7 @@ fn test_set_entity_with_struct_layout() { let world = deploy_world(); world.register_model(struct_simple_model::TEST_CLASS_HASH.try_into().unwrap()); - let selector = selector!("struct_simple_model"); + let selector = dojo::model::Model::::selector(); let keys = get_key_test(); let values = create_struct_simple_model(); let layout = dojo::model::Model::::layout(); @@ -894,7 +955,7 @@ fn test_set_entity_with_struct_tuple_layout() { let world = deploy_world(); world.register_model(struct_with_tuple::TEST_CLASS_HASH.try_into().unwrap()); - let selector = selector!("struct_with_tuple"); + let selector = dojo::model::Model::::selector(); let keys = get_key_test(); let values = create_struct_with_tuple(); let layout = dojo::model::Model::::layout(); @@ -910,7 +971,7 @@ fn test_set_entity_with_struct_enum_layout() { let world = deploy_world(); world.register_model(struct_with_enum::TEST_CLASS_HASH.try_into().unwrap()); - let selector = selector!("struct_with_enum"); + let selector = dojo::model::Model::::selector(); let keys = get_key_test(); let values = create_struct_with_enum_first_variant(); let layout = dojo::model::Model::::layout(); @@ -934,7 +995,7 @@ fn test_set_entity_with_struct_simple_array_layout() { let world = deploy_world(); world.register_model(struct_simple_array_model::TEST_CLASS_HASH.try_into().unwrap()); - let selector = selector!("struct_simple_array_model"); + let selector = dojo::model::Model::::selector(); let keys = get_key_test(); let values = create_struct_simple_array_model(); let layout = dojo::model::Model::::layout(); @@ -950,7 +1011,7 @@ fn test_set_entity_with_struct_complex_array_layout() { let world = deploy_world(); world.register_model(struct_complex_array_model::TEST_CLASS_HASH.try_into().unwrap()); - let selector = selector!("struct_complex_array_model"); + let selector = dojo::model::Model::::selector(); let keys = get_key_test(); let values = create_struct_complex_array_model(); let layout = dojo::model::Model::::layout(); @@ -966,7 +1027,7 @@ fn test_set_entity_with_struct_layout_and_byte_array() { let world = deploy_world(); world.register_model(struct_byte_array_model::TEST_CLASS_HASH.try_into().unwrap()); - let selector = selector!("struct_byte_array_model"); + let selector = dojo::model::Model::::selector(); let keys = get_key_test(); let values = create_struct_byte_array_model(); let layout = dojo::model::Model::::layout(); @@ -982,7 +1043,7 @@ fn test_set_entity_with_nested_elements() { let world = deploy_world(); world.register_model(struct_nested_model::TEST_CLASS_HASH.try_into().unwrap()); - let selector = selector!("struct_nested_model"); + let selector = dojo::model::Model::::selector(); let keys = get_key_test(); let values = create_struct_nested_model(); let layout = dojo::model::Model::::layout(); @@ -1009,7 +1070,7 @@ fn test_set_entity_with_struct_generics_enum_layout() { let world = deploy_world(); world.register_model(struct_with_generic::TEST_CLASS_HASH.try_into().unwrap()); - let selector = selector!("struct_with_generic"); + let selector = dojo::model::Model::::selector(); let keys = get_key_test(); let values = create_struct_generic_first_variant(); let layout = dojo::model::Model::::layout(); @@ -1032,13 +1093,12 @@ fn test_set_entity_with_struct_generics_enum_layout() { fn test_delete_entity_with_fixed_layout() { let world = deploy_world(); world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); - - let selector = selector!("foo"); + let selector = dojo::model::Model::::selector(); let keys = get_key_test(); let values = create_foo(); let layout = dojo::model::Model::::layout(); - world.set_entity(selector, keys, values, layout); + world.set_entity(selector, get_key_test(), values, layout); world.delete_entity(selector, keys, layout); @@ -1053,7 +1113,7 @@ fn test_delete_entity_with_simple_struct_layout() { let world = deploy_world(); world.register_model(struct_simple_model::TEST_CLASS_HASH.try_into().unwrap()); - let selector = selector!("struct_simple_model"); + let selector = dojo::model::Model::::selector(); let keys = get_key_test(); let values = create_struct_simple_model(); let layout = dojo::model::Model::::layout(); @@ -1073,7 +1133,7 @@ fn test_delete_entity_with_struct_simple_array_layout() { let world = deploy_world(); world.register_model(struct_simple_array_model::TEST_CLASS_HASH.try_into().unwrap()); - let selector = selector!("struct_simple_array_model"); + let selector = dojo::model::Model::::selector(); let keys = get_key_test(); let values = create_struct_simple_array_model(); let layout = dojo::model::Model::::layout(); @@ -1096,7 +1156,7 @@ fn test_delete_entity_with_complex_array_struct_layout() { let world = deploy_world(); world.register_model(struct_complex_array_model::TEST_CLASS_HASH.try_into().unwrap()); - let selector = selector!("struct_complex_array_model"); + let selector = dojo::model::Model::::selector(); let keys = get_key_test(); let values = create_struct_complex_array_model(); @@ -1120,7 +1180,7 @@ fn test_delete_entity_with_struct_tuple_layout() { let world = deploy_world(); world.register_model(struct_with_tuple::TEST_CLASS_HASH.try_into().unwrap()); - let selector = selector!("struct_with_tuple"); + let selector = dojo::model::Model::::selector(); let keys = get_key_test(); let values = create_struct_with_tuple(); let layout = dojo::model::Model::::layout(); @@ -1141,7 +1201,7 @@ fn test_delete_entity_with_struct_enum_layout() { let world = deploy_world(); world.register_model(struct_with_enum::TEST_CLASS_HASH.try_into().unwrap()); - let selector = selector!("struct_with_enum"); + let selector = dojo::model::Model::::selector(); let keys = get_key_test(); let values = create_struct_with_enum_first_variant(); let layout = dojo::model::Model::::layout(); @@ -1163,7 +1223,7 @@ fn test_delete_entity_with_struct_layout_and_byte_array() { let world = deploy_world(); world.register_model(struct_byte_array_model::TEST_CLASS_HASH.try_into().unwrap()); - let selector = selector!("struct_byte_array_model"); + let selector = dojo::model::Model::::selector(); let keys = get_key_test(); let values = create_struct_byte_array_model(); let layout = dojo::model::Model::::layout(); @@ -1184,7 +1244,7 @@ fn test_delete_entity_with_nested_elements() { let world = deploy_world(); world.register_model(struct_nested_model::TEST_CLASS_HASH.try_into().unwrap()); - let selector = selector!("struct_nested_model"); + let selector = dojo::model::Model::::selector(); let keys = get_key_test(); let values = create_struct_nested_model(); let layout = dojo::model::Model::::layout(); @@ -1205,7 +1265,7 @@ fn test_delete_entity_with_struct_generics_enum_layout() { let world = deploy_world(); world.register_model(struct_with_generic::TEST_CLASS_HASH.try_into().unwrap()); - let selector = selector!("struct_with_generic"); + let selector = dojo::model::Model::::selector(); let keys = get_key_test(); let values = create_struct_generic_first_variant(); let layout = dojo::model::Model::::layout(); @@ -1233,7 +1293,10 @@ fn test_set_entity_with_unexpected_array_model_layout() { world .set_entity( - selector!("struct_simple_array_model"), array![].span(), array![].span(), layout + dojo::model::Model::::selector(), + array![].span(), + array![].span(), + layout ); } @@ -1249,7 +1312,10 @@ fn test_set_entity_with_unexpected_tuple_model_layout() { world .set_entity( - selector!("struct_simple_array_model"), array![].span(), array![].span(), layout + dojo::model::Model::::selector(), + array![].span(), + array![].span(), + layout ); } @@ -1263,7 +1329,10 @@ fn test_delete_entity_with_unexpected_array_model_layout() { array![dojo::database::introspect::Introspect::::layout()].span() ); - world.delete_entity(selector!("struct_simple_array_model"), array![].span(), layout); + world + .delete_entity( + dojo::model::Model::::selector(), array![].span(), layout + ); } #[test] @@ -1276,7 +1345,10 @@ fn test_delete_entity_with_unexpected_tuple_model_layout() { array![dojo::database::introspect::Introspect::::layout()].span() ); - world.delete_entity(selector!("struct_simple_array_model"), array![].span(), layout); + world + .delete_entity( + dojo::model::Model::::selector(), array![].span(), layout + ); } #[test] @@ -1289,7 +1361,7 @@ fn test_get_entity_with_unexpected_array_model_layout() { array![dojo::database::introspect::Introspect::::layout()].span() ); - world.entity(selector!("struct_simple_array_model"), array![].span(), layout); + world.entity(dojo::model::Model::::selector(), array![].span(), layout); } #[test] @@ -1302,7 +1374,7 @@ fn test_get_entity_with_unexpected_tuple_model_layout() { array![dojo::database::introspect::Introspect::::layout()].span() ); - world.entity(selector!("struct_simple_array_model"), array![].span(), layout); + world.entity(dojo::model::Model::::selector(), array![].span(), layout); } @@ -1310,22 +1382,13 @@ fn test_get_entity_with_unexpected_tuple_model_layout() { #[should_panic(expected: ('Invalid values length', 'ENTRYPOINT_FAILED',))] fn test_set_entity_with_bad_values_length_error_for_array_layout() { let world = deploy_world(); + world.register_model(struct_simple_array_model::TEST_CLASS_HASH.try_into().unwrap()); - let selector = selector!("a_selector"); + let selector = dojo::model::Model::::selector(); let keys = get_key_test(); - let layout = Layout::Struct( - array![ - FieldLayout { - selector: selector!("a"), - layout: Layout::Array( - array![dojo::database::introspect::Introspect::::layout()].span() - ) - }, - ] - .span() - ); + let layout = dojo::model::Model::::layout(); - world.set_entity(selector, keys, array![].span(), layout); + world.set_entity(selector, keys, array![1].span(), layout); } #[test] @@ -1334,7 +1397,7 @@ fn test_set_entity_with_too_big_array_length() { let world = deploy_world(); world.register_model(struct_simple_array_model::TEST_CLASS_HASH.try_into().unwrap()); - let selector = selector!("struct_simple_array_model"); + let selector = dojo::model::Model::::selector(); let keys = get_key_test(); let values: Span = array![ 1, MAX_ARRAY_LENGTH.try_into().unwrap() + 1, 10, 20, 30, 40, 2 @@ -1351,7 +1414,7 @@ fn test_set_entity_with_struct_layout_and_bad_byte_array_length() { let world = deploy_world(); world.register_model(struct_byte_array_model::TEST_CLASS_HASH.try_into().unwrap()); - let selector = selector!("struct_byte_array_model"); + let selector = dojo::model::Model::::selector(); let keys = get_key_test(); let values: Span = array![ 1, MAX_ARRAY_LENGTH.try_into().unwrap(), 'first', 'second', 'third', 'pending', 7 @@ -1368,10 +1431,135 @@ fn test_set_entity_with_struct_layout_and_bad_value_length_for_byte_array() { let world = deploy_world(); world.register_model(struct_byte_array_model::TEST_CLASS_HASH.try_into().unwrap()); - let selector = selector!("struct_byte_array_model"); + let selector = dojo::model::Model::::selector(); let keys = get_key_test(); let values: Span = array![1, 3, 'first', 'second', 'third', 'pending'].span(); let layout = dojo::model::Model::::layout(); world.set_entity(selector, keys, values, layout); } + +fn write_foo_record(world: dojo::world::IWorldDispatcher) { + let selector = dojo::model::Model::::selector(); + let values = create_foo(); + let layout = dojo::model::Model::::layout(); + + world.set_entity(selector, get_key_test(), values, layout); +} + +#[test] +fn test_write_model_for_namespace_owner() { + let world = deploy_world(); + world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); + + let account = starknet::contract_address_const::<0xb0b>(); + let contract = starknet::contract_address_const::<0xdeadbeef>(); + + // the caller account is a model namespace owner + world.grant_owner(account, dojo::model::Model::::namespace_selector()); + starknet::testing::set_account_contract_address(account); + starknet::testing::set_contract_address(contract); + + write_foo_record(world); +} + +#[test] +fn test_write_model_for_model_owner() { + let world = deploy_world(); + world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); + + // the caller account is a model owner + let account = starknet::contract_address_const::<0xb0b>(); + let contract = starknet::contract_address_const::<0xdeadbeef>(); + + world.grant_owner(account, dojo::model::Model::::selector()); + starknet::testing::set_account_contract_address(account); + starknet::testing::set_contract_address(contract); + + write_foo_record(world); +} + +#[test] +fn test_write_model_for_namespace_writer() { + let world = deploy_world(); + world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); + + let account = starknet::contract_address_const::<0xb0b>(); + let contract = starknet::contract_address_const::<0xdeadbeef>(); + + world.grant_writer(dojo::model::Model::::namespace_selector(), contract); + + // the account does not own anything + starknet::testing::set_account_contract_address(account); + starknet::testing::set_contract_address(contract); + + write_foo_record(world); +} + +#[test] +fn test_write_model_for_model_writer() { + let world = deploy_world(); + world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); + + let account = starknet::contract_address_const::<0xb0b>(); + let contract = starknet::contract_address_const::<0xdeadbeef>(); + + world.grant_writer(dojo::model::Model::::selector(), contract); + + // the account does not own anything + starknet::testing::set_account_contract_address(account); + starknet::testing::set_contract_address(contract); + + write_foo_record(world); +} + +#[test] +fn test_write_namespace_for_namespace_owner() { + let world = deploy_world(); + + let account = starknet::contract_address_const::<0xb0b>(); + let contract = starknet::contract_address_const::<0xdeadbeef>(); + + world.grant_owner(account, dojo::model::Model::::namespace_selector()); + + // the account owns the Foo model namespace so it should be able to deploy + // and register the model. + starknet::testing::set_account_contract_address(account); + starknet::testing::set_contract_address(contract); + + world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); +} + +#[test] +fn test_write_namespace_for_namespace_writer() { + let world = deploy_world(); + + let account = starknet::contract_address_const::<0xb0b>(); + let contract = starknet::contract_address_const::<0xdeadbeef>(); + + world.grant_writer(dojo::model::Model::::namespace_selector(), account); + + // the account has write access to the Foo model namespace so it should be able + // to deploy and register the model. + starknet::testing::set_account_contract_address(account); + starknet::testing::set_contract_address(contract); + + world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); +} + +#[test] +#[should_panic(expected: ('no model write access', 'ENTRYPOINT_FAILED',))] +fn test_write_model_no_write_access() { + let world = deploy_world(); + world.register_model(foo::TEST_CLASS_HASH.try_into().unwrap()); + + // the caller account does not own the model nor the model namespace nor the world + let account = starknet::contract_address_const::<0xb0b>(); + starknet::testing::set_account_contract_address(account); + + // the contract is not a writer for the model nor for the model namespace + let contract = starknet::contract_address_const::<0xdeadbeef>(); + starknet::testing::set_contract_address(contract); + + write_foo_record(world); +} diff --git a/crates/dojo-lang/Cargo.toml b/crates/dojo-lang/Cargo.toml index 2f7b17357a..d3fc5caed2 100644 --- a/crates/dojo-lang/Cargo.toml +++ b/crates/dojo-lang/Cargo.toml @@ -11,6 +11,7 @@ testing = [ ] [dependencies] anyhow.workspace = true +cainome.workspace = true cairo-lang-compiler.workspace = true cairo-lang-debug.workspace = true cairo-lang-defs.workspace = true @@ -46,6 +47,7 @@ serde_json.workspace = true serde_with.workspace = true smol_str.workspace = true starknet.workspace = true +starknet-crypto.workspace = true thiserror.workspace = true toml.workspace = true tracing.workspace = true diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/abis/base/dojo_world_world.json b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/abis/base/dojo_world_world.json index f4a84c2e42..46ff48c2bd 100644 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/abis/base/dojo_world_world.json +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/abis/base/dojo_world_world.json @@ -194,6 +194,18 @@ "outputs": [], "state_mutability": "external" }, + { + "type": "function", + "name": "register_namespace", + "inputs": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray" + } + ], + "outputs": [], + "state_mutability": "external" + }, { "type": "function", "name": "deploy_contract", @@ -401,7 +413,7 @@ "name": "is_writer", "inputs": [ { - "name": "model", + "name": "resource", "type": "core::felt252" }, { @@ -421,7 +433,7 @@ "name": "grant_writer", "inputs": [ { - "name": "model", + "name": "resource", "type": "core::felt252" }, { @@ -437,7 +449,7 @@ "name": "revoke_writer", "inputs": [ { - "name": "model", + "name": "resource", "type": "core::felt252" }, { @@ -447,6 +459,66 @@ ], "outputs": [], "state_mutability": "external" + }, + { + "type": "function", + "name": "can_write_resource", + "inputs": [ + { + "name": "resource_id", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "can_write_model", + "inputs": [ + { + "name": "model_id", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "can_write_namespace", + "inputs": [ + { + "name": "namespace_id", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" } ] }, @@ -714,6 +786,23 @@ } ] }, + { + "type": "event", + "name": "dojo::world::world::NamespaceRegistered", + "kind": "struct", + "members": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "data" + }, + { + "name": "hash", + "type": "core::felt252", + "kind": "data" + } + ] + }, { "type": "event", "name": "dojo::world::world::ModelRegistered", @@ -796,7 +885,7 @@ "kind": "struct", "members": [ { - "name": "model", + "name": "resource", "type": "core::felt252", "kind": "data" }, @@ -917,6 +1006,11 @@ "type": "dojo::world::world::MetadataUpdate", "kind": "nested" }, + { + "name": "NamespaceRegistered", + "type": "dojo::world::world::NamespaceRegistered", + "kind": "nested" + }, { "name": "ModelRegistered", "type": "dojo::world::world::ModelRegistered", diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo_world_world.toml b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo_world_world.toml index f195eecea6..0a1a32ae11 100644 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo_world_world.toml +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo_world_world.toml @@ -1,5 +1,5 @@ kind = "Class" -class_hash = "0x610b8797d5ca3d551eb33a4086b13893f10d8d60b8ff23da40d4bd8d907dccb" -original_class_hash = "0x610b8797d5ca3d551eb33a4086b13893f10d8d60b8ff23da40d4bd8d907dccb" +class_hash = "0x5ea21a99b526829a2aee5704b92b67431dc54a8204621307208f382302bfe18" +original_class_hash = "0x5ea21a99b526829a2aee5704b92b67431dc54a8204621307208f382302bfe18" abi = "manifests/dev/abis/base/dojo_world_world.json" name = "dojo::world::world" diff --git a/crates/dojo-lang/src/model.rs b/crates/dojo-lang/src/model.rs index 54c3a0e46d..b36f24287a 100644 --- a/crates/dojo-lang/src/model.rs +++ b/crates/dojo-lang/src/model.rs @@ -1,5 +1,6 @@ use std::collections::HashMap; +use cainome::cairo_serde::{ByteArray, CairoSerde}; use cairo_lang_defs::patcher::RewriteNode; use cairo_lang_defs::plugin::PluginDiagnostic; use cairo_lang_diagnostics::Severity; @@ -10,8 +11,8 @@ use cairo_lang_syntax::node::{Terminal, TypedStablePtr, TypedSyntaxNode}; use cairo_lang_utils::unordered_hash_map::UnorderedHashMap; use convert_case::{Case, Casing}; use dojo_world::manifest::Member; -use starknet::core::crypto::compute_hash_on_elements; use starknet::core::utils::get_selector_from_name; +use starknet_crypto::{poseidon_hash_many, FieldElement}; use crate::plugin::{DojoAuxData, Model, DOJO_MODEL_ATTR}; @@ -182,6 +183,13 @@ fn get_model_parameters( parameters } +// compute the hash of a namespace hash using the same method, +// than in the world contract in Cairo. +fn compute_namespace_hash(namespace: &str) -> FieldElement { + let ba = ByteArray::from_string(namespace).unwrap(); + poseidon_hash_many(&ByteArray::cairo_serialize(&ba)) +} + /// A handler for Dojo code that modifies a model struct. /// Parameters: /// * db: The semantic database. @@ -203,14 +211,16 @@ pub fn handle_model_struct( Option::Some(x) => x, Option::None => package_id, }; + let model_namespace_hash = compute_namespace_hash(&model_namespace); + let (model_version, model_selector) = match parameters.version { 0 => (RewriteNode::Text("0".to_string()), RewriteNode::Text(format!("\"{model_name}\""))), _ => ( RewriteNode::Text(DEFAULT_MODEL_VERSION.to_string()), RewriteNode::Text( - compute_hash_on_elements(&[ - get_selector_from_name(model_namespace.as_str()).unwrap(), - get_selector_from_name(model_name.as_str()).unwrap(), + poseidon_hash_many(&[ + model_namespace_hash, + get_selector_from_name(&model_name).unwrap(), ]) .to_string(), ), @@ -290,8 +300,12 @@ pub fn handle_model_struct( impl $type_name$Model of dojo::model::Model<$type_name$> { fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: \ dojo::database::introspect::Layout) -> $type_name$ { - let values = dojo::world::IWorldDispatcherTrait::entity(world, $model_selector$, keys, \ - layout); + let values = dojo::world::IWorldDispatcherTrait::entity( + world, + Self::selector(), + keys, + layout + ); // TODO: Generate method to deserialize from keys / values directly to avoid // serializing to intermediate array. @@ -337,6 +351,11 @@ impl $type_name$Model of dojo::model::Model<$type_name$> { \"$model_namespace$\" } + #[inline(always)] + fn namespace_selector() -> felt252 { + $model_namespace_hash$ + } + #[inline(always)] fn keys(self: @$type_name$) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -410,6 +429,10 @@ mod $contract_name$ { dojo::model::Model::<$type_name$>::namespace() } + fn namespace_selector(self: @ContractState) -> felt252 { + dojo::model::Model::<$type_name$>::namespace_selector() + } + fn unpacked_size(self: @ContractState) -> Option { dojo::database::introspect::Introspect::<$type_name$>::size() } @@ -443,6 +466,10 @@ mod $contract_name$ { ("model_version".to_string(), model_version), ("model_selector".to_string(), model_selector), ("model_namespace".to_string(), RewriteNode::Text(model_namespace)), + ( + "model_namespace_hash".to_string(), + RewriteNode::Text(model_namespace_hash.to_string()), + ), ]), ), diagnostics, diff --git a/crates/dojo-lang/src/plugin_test_data/model b/crates/dojo-lang/src/plugin_test_data/model index eea8da4bc3..5fa981c021 100644 --- a/crates/dojo-lang/src/plugin_test_data/model +++ b/crates/dojo-lang/src/plugin_test_data/model @@ -383,7 +383,12 @@ dojo::database::introspect::Member { impl BadModelMultipleVersionsModel of dojo::model::Model { fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::database::introspect::Layout) -> BadModelMultipleVersions { - let values = dojo::world::IWorldDispatcherTrait::entity(world, "BadModelMultipleVersions", keys, layout); + let values = dojo::world::IWorldDispatcherTrait::entity( + world, + Self::selector(), + keys, + layout + ); // TODO: Generate method to deserialize from keys / values directly to avoid // serializing to intermediate array. @@ -428,6 +433,11 @@ impl BadModelMultipleVersionsModel of dojo::model::Model felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + #[inline(always)] fn keys(self: @BadModelMultipleVersions) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -501,6 +511,10 @@ mod bad_model_multiple_versions { dojo::model::Model::::namespace() } + fn namespace_selector(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_selector() + } + fn unpacked_size(self: @ContractState) -> Option { dojo::database::introspect::Introspect::::size() } @@ -568,7 +582,12 @@ dojo::database::introspect::Member { impl BadModelBadVersionTypeModel of dojo::model::Model { fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::database::introspect::Layout) -> BadModelBadVersionType { - let values = dojo::world::IWorldDispatcherTrait::entity(world, 1328490678548261030641337267691834978998294794989655995202042129060194161684, keys, layout); + let values = dojo::world::IWorldDispatcherTrait::entity( + world, + Self::selector(), + keys, + layout + ); // TODO: Generate method to deserialize from keys / values directly to avoid // serializing to intermediate array. @@ -600,7 +619,7 @@ impl BadModelBadVersionTypeModel of dojo::model::Model { #[inline(always)] fn selector() -> felt252 { - 1328490678548261030641337267691834978998294794989655995202042129060194161684 + 2220028225472623771565879151107937756128278188926561595847890470425724914905 } #[inline(always)] @@ -613,6 +632,11 @@ impl BadModelBadVersionTypeModel of dojo::model::Model { "dojo_plugin" } + #[inline(always)] + fn namespace_selector() -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + #[inline(always)] fn keys(self: @BadModelBadVersionType) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -686,6 +710,10 @@ mod bad_model_bad_version_type { dojo::model::Model::::namespace() } + fn namespace_selector(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_selector() + } + fn unpacked_size(self: @ContractState) -> Option { dojo::database::introspect::Introspect::::size() } @@ -753,7 +781,12 @@ dojo::database::introspect::Member { impl BadModelNoVersionValueModel of dojo::model::Model { fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::database::introspect::Layout) -> BadModelNoVersionValue { - let values = dojo::world::IWorldDispatcherTrait::entity(world, 2563290186540557578184607310169104167507779969166476545204350608742403389791, keys, layout); + let values = dojo::world::IWorldDispatcherTrait::entity( + world, + Self::selector(), + keys, + layout + ); // TODO: Generate method to deserialize from keys / values directly to avoid // serializing to intermediate array. @@ -785,7 +818,7 @@ impl BadModelNoVersionValueModel of dojo::model::Model { #[inline(always)] fn selector() -> felt252 { - 2563290186540557578184607310169104167507779969166476545204350608742403389791 + 2422098561748028006685872682620738997298104147327551912949175142176336762559 } #[inline(always)] @@ -798,6 +831,11 @@ impl BadModelNoVersionValueModel of dojo::model::Model { "dojo_plugin" } + #[inline(always)] + fn namespace_selector() -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + #[inline(always)] fn keys(self: @BadModelNoVersionValue) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -871,6 +909,10 @@ mod bad_model_no_version_value { dojo::model::Model::::namespace() } + fn namespace_selector(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_selector() + } + fn unpacked_size(self: @ContractState) -> Option { dojo::database::introspect::Introspect::::size() } @@ -938,7 +980,12 @@ dojo::database::introspect::Member { impl BadModelUnexpectedArgWithValueModel of dojo::model::Model { fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::database::introspect::Layout) -> BadModelUnexpectedArgWithValue { - let values = dojo::world::IWorldDispatcherTrait::entity(world, 2673038208654531893677735695545893989692599822427583260178927986134975485945, keys, layout); + let values = dojo::world::IWorldDispatcherTrait::entity( + world, + Self::selector(), + keys, + layout + ); // TODO: Generate method to deserialize from keys / values directly to avoid // serializing to intermediate array. @@ -970,7 +1017,7 @@ impl BadModelUnexpectedArgWithValueModel of dojo::model::Model felt252 { - 2673038208654531893677735695545893989692599822427583260178927986134975485945 + 3228902798306661327621997908082571168228892515286198692168401280811110425709 } #[inline(always)] @@ -983,6 +1030,11 @@ impl BadModelUnexpectedArgWithValueModel of dojo::model::Model felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + #[inline(always)] fn keys(self: @BadModelUnexpectedArgWithValue) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -1056,6 +1108,10 @@ mod bad_model_unexpected_arg_with_value { dojo::model::Model::::namespace() } + fn namespace_selector(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_selector() + } + fn unpacked_size(self: @ContractState) -> Option { dojo::database::introspect::Introspect::::size() } @@ -1123,7 +1179,12 @@ dojo::database::introspect::Member { impl BadModelUnexpectedArgModel of dojo::model::Model { fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::database::introspect::Layout) -> BadModelUnexpectedArg { - let values = dojo::world::IWorldDispatcherTrait::entity(world, 1224229364036546903342041909445102469325991986871290755629163933447114651905, keys, layout); + let values = dojo::world::IWorldDispatcherTrait::entity( + world, + Self::selector(), + keys, + layout + ); // TODO: Generate method to deserialize from keys / values directly to avoid // serializing to intermediate array. @@ -1155,7 +1216,7 @@ impl BadModelUnexpectedArgModel of dojo::model::Model { #[inline(always)] fn selector() -> felt252 { - 1224229364036546903342041909445102469325991986871290755629163933447114651905 + 699000271968550521002644648397492384434485690903658554108378678787320184762 } #[inline(always)] @@ -1168,6 +1229,11 @@ impl BadModelUnexpectedArgModel of dojo::model::Model { "dojo_plugin" } + #[inline(always)] + fn namespace_selector() -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + #[inline(always)] fn keys(self: @BadModelUnexpectedArg) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -1241,6 +1307,10 @@ mod bad_model_unexpected_arg { dojo::model::Model::::namespace() } + fn namespace_selector(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_selector() + } + fn unpacked_size(self: @ContractState) -> Option { dojo::database::introspect::Introspect::::size() } @@ -1308,7 +1378,12 @@ dojo::database::introspect::Member { impl BadModelNotSupportedVersionModel of dojo::model::Model { fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::database::introspect::Layout) -> BadModelNotSupportedVersion { - let values = dojo::world::IWorldDispatcherTrait::entity(world, 2693060860765171165552186894141395989956120379694596245793626576164537749892, keys, layout); + let values = dojo::world::IWorldDispatcherTrait::entity( + world, + Self::selector(), + keys, + layout + ); // TODO: Generate method to deserialize from keys / values directly to avoid // serializing to intermediate array. @@ -1340,7 +1415,7 @@ impl BadModelNotSupportedVersionModel of dojo::model::Model felt252 { - 2693060860765171165552186894141395989956120379694596245793626576164537749892 + 1938275553232803054401782929658259458596535249469239494812818556235989221496 } #[inline(always)] @@ -1353,6 +1428,11 @@ impl BadModelNotSupportedVersionModel of dojo::model::Model felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + #[inline(always)] fn keys(self: @BadModelNotSupportedVersion) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -1426,6 +1506,10 @@ mod bad_model_not_supported_version { dojo::model::Model::::namespace() } + fn namespace_selector(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_selector() + } + fn unpacked_size(self: @ContractState) -> Option { dojo::database::introspect::Introspect::::size() } @@ -1493,7 +1577,12 @@ dojo::database::introspect::Member { impl Modelv0Model of dojo::model::Model { fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::database::introspect::Layout) -> Modelv0 { - let values = dojo::world::IWorldDispatcherTrait::entity(world, "Modelv0", keys, layout); + let values = dojo::world::IWorldDispatcherTrait::entity( + world, + Self::selector(), + keys, + layout + ); // TODO: Generate method to deserialize from keys / values directly to avoid // serializing to intermediate array. @@ -1538,6 +1627,11 @@ impl Modelv0Model of dojo::model::Model { "dojo_plugin" } + #[inline(always)] + fn namespace_selector() -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + #[inline(always)] fn keys(self: @Modelv0) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -1611,6 +1705,10 @@ mod modelv_0 { dojo::model::Model::::namespace() } + fn namespace_selector(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_selector() + } + fn unpacked_size(self: @ContractState) -> Option { dojo::database::introspect::Introspect::::size() } @@ -1678,7 +1776,12 @@ dojo::database::introspect::Member { impl ModelWithShortStringNamespaceModel of dojo::model::Model { fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::database::introspect::Layout) -> ModelWithShortStringNamespace { - let values = dojo::world::IWorldDispatcherTrait::entity(world, 908843835781413480281479064211888426230564843385953943520719627399111604848, keys, layout); + let values = dojo::world::IWorldDispatcherTrait::entity( + world, + Self::selector(), + keys, + layout + ); // TODO: Generate method to deserialize from keys / values directly to avoid // serializing to intermediate array. @@ -1710,7 +1813,7 @@ impl ModelWithShortStringNamespaceModel of dojo::model::Model felt252 { - 908843835781413480281479064211888426230564843385953943520719627399111604848 + 3541778179344734228781257685127882973025320161442849162880926850078457574474 } #[inline(always)] @@ -1723,6 +1826,11 @@ impl ModelWithShortStringNamespaceModel of dojo::model::Model felt252 { + 1685136890688416384941629523783652800960468745356230625531475538826800548713 + } + #[inline(always)] fn keys(self: @ModelWithShortStringNamespace) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -1796,6 +1904,10 @@ mod model_with_short_string_namespace { dojo::model::Model::::namespace() } + fn namespace_selector(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_selector() + } + fn unpacked_size(self: @ContractState) -> Option { dojo::database::introspect::Introspect::::size() } @@ -1863,7 +1975,12 @@ dojo::database::introspect::Member { impl ModelWithStringNamespaceModel of dojo::model::Model { fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::database::introspect::Layout) -> ModelWithStringNamespace { - let values = dojo::world::IWorldDispatcherTrait::entity(world, 1195800889756330538219341914002026521825502205298023374414486448741553459567, keys, layout); + let values = dojo::world::IWorldDispatcherTrait::entity( + world, + Self::selector(), + keys, + layout + ); // TODO: Generate method to deserialize from keys / values directly to avoid // serializing to intermediate array. @@ -1895,7 +2012,7 @@ impl ModelWithStringNamespaceModel of dojo::model::Model felt252 { - 1195800889756330538219341914002026521825502205298023374414486448741553459567 + 3400071221116515406929081296780299569378692042413593831019759313075217662884 } #[inline(always)] @@ -1908,6 +2025,11 @@ impl ModelWithStringNamespaceModel of dojo::model::Model felt252 { + 1685136890688416384941629523783652800960468745356230625531475538826800548713 + } + #[inline(always)] fn keys(self: @ModelWithStringNamespace) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -1981,6 +2103,10 @@ mod model_with_string_namespace { dojo::model::Model::::namespace() } + fn namespace_selector(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_selector() + } + fn unpacked_size(self: @ContractState) -> Option { dojo::database::introspect::Introspect::::size() } @@ -2048,7 +2174,12 @@ dojo::database::introspect::Member { impl PositionModel of dojo::model::Model { fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::database::introspect::Layout) -> Position { - let values = dojo::world::IWorldDispatcherTrait::entity(world, 780131961254999218926699387313671119697686212444320207125197199790388267108, keys, layout); + let values = dojo::world::IWorldDispatcherTrait::entity( + world, + Self::selector(), + keys, + layout + ); // TODO: Generate method to deserialize from keys / values directly to avoid // serializing to intermediate array. @@ -2080,7 +2211,7 @@ impl PositionModel of dojo::model::Model { #[inline(always)] fn selector() -> felt252 { - 780131961254999218926699387313671119697686212444320207125197199790388267108 + 3374696559405830365138569833236913581624468565711146581891547388386764749772 } #[inline(always)] @@ -2093,6 +2224,11 @@ impl PositionModel of dojo::model::Model { "dojo_plugin" } + #[inline(always)] + fn namespace_selector() -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + #[inline(always)] fn keys(self: @Position) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -2166,6 +2302,10 @@ mod position { dojo::model::Model::::namespace() } + fn namespace_selector(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_selector() + } + fn unpacked_size(self: @ContractState) -> Option { dojo::database::introspect::Introspect::::size() } @@ -2233,7 +2373,12 @@ impl RolesIntrospect<> of dojo::database::introspect::Introspect> { impl RolesModel of dojo::model::Model { fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::database::introspect::Layout) -> Roles { - let values = dojo::world::IWorldDispatcherTrait::entity(world, 1813854070001996949863591022911318990310667735893978960758671531995176136510, keys, layout); + let values = dojo::world::IWorldDispatcherTrait::entity( + world, + Self::selector(), + keys, + layout + ); // TODO: Generate method to deserialize from keys / values directly to avoid // serializing to intermediate array. @@ -2265,7 +2410,7 @@ impl RolesModel of dojo::model::Model { #[inline(always)] fn selector() -> felt252 { - 1813854070001996949863591022911318990310667735893978960758671531995176136510 + 2181365514540647021440185322278914205736798283654093759018221677928744300449 } #[inline(always)] @@ -2278,6 +2423,11 @@ impl RolesModel of dojo::model::Model { "dojo_plugin" } + #[inline(always)] + fn namespace_selector() -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + #[inline(always)] fn keys(self: @Roles) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -2351,6 +2501,10 @@ mod roles { dojo::model::Model::::namespace() } + fn namespace_selector(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_selector() + } + fn unpacked_size(self: @ContractState) -> Option { dojo::database::introspect::Introspect::::size() } @@ -2410,7 +2564,12 @@ impl OnlyKeyModelIntrospect<> of dojo::database::introspect::Introspect { fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::database::introspect::Layout) -> OnlyKeyModel { - let values = dojo::world::IWorldDispatcherTrait::entity(world, 2405260607599285220269895754287754281924828259291400057240994731977427504855, keys, layout); + let values = dojo::world::IWorldDispatcherTrait::entity( + world, + Self::selector(), + keys, + layout + ); // TODO: Generate method to deserialize from keys / values directly to avoid // serializing to intermediate array. @@ -2442,7 +2601,7 @@ impl OnlyKeyModelModel of dojo::model::Model { #[inline(always)] fn selector() -> felt252 { - 2405260607599285220269895754287754281924828259291400057240994731977427504855 + 2007129177695053907342496785652778975125464194499954048230324979126281871028 } #[inline(always)] @@ -2455,6 +2614,11 @@ impl OnlyKeyModelModel of dojo::model::Model { "dojo_plugin" } + #[inline(always)] + fn namespace_selector() -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + #[inline(always)] fn keys(self: @OnlyKeyModel) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -2528,6 +2692,10 @@ mod only_key_model { dojo::model::Model::::namespace() } + fn namespace_selector(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_selector() + } + fn unpacked_size(self: @ContractState) -> Option { dojo::database::introspect::Introspect::::size() } @@ -2587,7 +2755,12 @@ impl U256KeyModelIntrospect<> of dojo::database::introspect::Introspect { fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::database::introspect::Layout) -> U256KeyModel { - let values = dojo::world::IWorldDispatcherTrait::entity(world, 2214934721641268872136059988111426431361696496517481776861737588960518540657, keys, layout); + let values = dojo::world::IWorldDispatcherTrait::entity( + world, + Self::selector(), + keys, + layout + ); // TODO: Generate method to deserialize from keys / values directly to avoid // serializing to intermediate array. @@ -2619,7 +2792,7 @@ impl U256KeyModelModel of dojo::model::Model { #[inline(always)] fn selector() -> felt252 { - 2214934721641268872136059988111426431361696496517481776861737588960518540657 + 903415927654065027809189751914703742988689485415971145128869809492231681231 } #[inline(always)] @@ -2632,6 +2805,11 @@ impl U256KeyModelModel of dojo::model::Model { "dojo_plugin" } + #[inline(always)] + fn namespace_selector() -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + #[inline(always)] fn keys(self: @U256KeyModel) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -2705,6 +2883,10 @@ mod u_256_key_model { dojo::model::Model::::namespace() } + fn namespace_selector(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_selector() + } + fn unpacked_size(self: @ContractState) -> Option { dojo::database::introspect::Introspect::::size() } @@ -2777,7 +2959,12 @@ dojo::database::introspect::Member { impl PlayerModel of dojo::model::Model { fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::database::introspect::Layout) -> Player { - let values = dojo::world::IWorldDispatcherTrait::entity(world, 3282816838912909166952662531585434570382134251332736033649582937556903048603, keys, layout); + let values = dojo::world::IWorldDispatcherTrait::entity( + world, + Self::selector(), + keys, + layout + ); // TODO: Generate method to deserialize from keys / values directly to avoid // serializing to intermediate array. @@ -2809,7 +2996,7 @@ impl PlayerModel of dojo::model::Model { #[inline(always)] fn selector() -> felt252 { - 3282816838912909166952662531585434570382134251332736033649582937556903048603 + 3040039725624028612857117314159622173948639024403738586967383880726364318343 } #[inline(always)] @@ -2822,6 +3009,11 @@ impl PlayerModel of dojo::model::Model { "dojo_plugin" } + #[inline(always)] + fn namespace_selector() -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + #[inline(always)] fn keys(self: @Player) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -2895,6 +3087,10 @@ mod player { dojo::model::Model::::namespace() } + fn namespace_selector(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_selector() + } + fn unpacked_size(self: @ContractState) -> Option { dojo::database::introspect::Introspect::::size() } @@ -2976,7 +3172,12 @@ dojo::database::introspect::Member { impl ModelWithSimpleArrayModel of dojo::model::Model { fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::database::introspect::Layout) -> ModelWithSimpleArray { - let values = dojo::world::IWorldDispatcherTrait::entity(world, 428398365980342193506683545527246984767540667557156516776183042818306470102, keys, layout); + let values = dojo::world::IWorldDispatcherTrait::entity( + world, + Self::selector(), + keys, + layout + ); // TODO: Generate method to deserialize from keys / values directly to avoid // serializing to intermediate array. @@ -3008,7 +3209,7 @@ impl ModelWithSimpleArrayModel of dojo::model::Model { #[inline(always)] fn selector() -> felt252 { - 428398365980342193506683545527246984767540667557156516776183042818306470102 + 3036954399876376294871492953842815136706946196043772739930393238510938492701 } #[inline(always)] @@ -3021,6 +3222,11 @@ impl ModelWithSimpleArrayModel of dojo::model::Model { "dojo_plugin" } + #[inline(always)] + fn namespace_selector() -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + #[inline(always)] fn keys(self: @ModelWithSimpleArray) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -3094,6 +3300,10 @@ mod model_with_simple_array { dojo::model::Model::::namespace() } + fn namespace_selector(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_selector() + } + fn unpacked_size(self: @ContractState) -> Option { dojo::database::introspect::Introspect::::size() } @@ -3171,7 +3381,12 @@ dojo::database::introspect::Member { impl ModelWithByteArrayModel of dojo::model::Model { fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::database::introspect::Layout) -> ModelWithByteArray { - let values = dojo::world::IWorldDispatcherTrait::entity(world, 1415842713520720365008531776366925016968418335857151223741573835616553244527, keys, layout); + let values = dojo::world::IWorldDispatcherTrait::entity( + world, + Self::selector(), + keys, + layout + ); // TODO: Generate method to deserialize from keys / values directly to avoid // serializing to intermediate array. @@ -3203,7 +3418,7 @@ impl ModelWithByteArrayModel of dojo::model::Model { #[inline(always)] fn selector() -> felt252 { - 1415842713520720365008531776366925016968418335857151223741573835616553244527 + 914257355871692663555400222064678579332468514265503486623625414079568159620 } #[inline(always)] @@ -3216,6 +3431,11 @@ impl ModelWithByteArrayModel of dojo::model::Model { "dojo_plugin" } + #[inline(always)] + fn namespace_selector() -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + #[inline(always)] fn keys(self: @ModelWithByteArray) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -3289,6 +3509,10 @@ mod model_with_byte_array { dojo::model::Model::::namespace() } + fn namespace_selector(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_selector() + } + fn unpacked_size(self: @ContractState) -> Option { dojo::database::introspect::Introspect::::size() } @@ -3370,7 +3594,12 @@ dojo::database::introspect::Member { impl ModelWithComplexArrayModel of dojo::model::Model { fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::database::introspect::Layout) -> ModelWithComplexArray { - let values = dojo::world::IWorldDispatcherTrait::entity(world, 3789516274586448246401580725561021230678078848434268104936624903602884878, keys, layout); + let values = dojo::world::IWorldDispatcherTrait::entity( + world, + Self::selector(), + keys, + layout + ); // TODO: Generate method to deserialize from keys / values directly to avoid // serializing to intermediate array. @@ -3402,7 +3631,7 @@ impl ModelWithComplexArrayModel of dojo::model::Model { #[inline(always)] fn selector() -> felt252 { - 3789516274586448246401580725561021230678078848434268104936624903602884878 + 3164665466483661975987698474266369868071863350236593405828168142524780862623 } #[inline(always)] @@ -3415,6 +3644,11 @@ impl ModelWithComplexArrayModel of dojo::model::Model { "dojo_plugin" } + #[inline(always)] + fn namespace_selector() -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + #[inline(always)] fn keys(self: @ModelWithComplexArray) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -3488,6 +3722,10 @@ mod model_with_complex_array { dojo::model::Model::::namespace() } + fn namespace_selector(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_selector() + } + fn unpacked_size(self: @ContractState) -> Option { dojo::database::introspect::Introspect::::size() } @@ -3576,7 +3814,12 @@ dojo::database::introspect::Introspect::::ty() impl ModelWithTupleModel of dojo::model::Model { fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::database::introspect::Layout) -> ModelWithTuple { - let values = dojo::world::IWorldDispatcherTrait::entity(world, 178721364414635954317574884109106083824876124753204149353802103206698633482, keys, layout); + let values = dojo::world::IWorldDispatcherTrait::entity( + world, + Self::selector(), + keys, + layout + ); // TODO: Generate method to deserialize from keys / values directly to avoid // serializing to intermediate array. @@ -3608,7 +3851,7 @@ impl ModelWithTupleModel of dojo::model::Model { #[inline(always)] fn selector() -> felt252 { - 178721364414635954317574884109106083824876124753204149353802103206698633482 + 3149657041939436190320476033972885001037726402607627355532923429092518312672 } #[inline(always)] @@ -3621,6 +3864,11 @@ impl ModelWithTupleModel of dojo::model::Model { "dojo_plugin" } + #[inline(always)] + fn namespace_selector() -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + #[inline(always)] fn keys(self: @ModelWithTuple) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -3694,6 +3942,10 @@ mod model_with_tuple { dojo::model::Model::::namespace() } + fn namespace_selector(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_selector() + } + fn unpacked_size(self: @ContractState) -> Option { dojo::database::introspect::Introspect::::size() } @@ -3791,7 +4043,12 @@ dojo::database::introspect::Introspect::::ty() impl ModelWithTupleNoPrimitivesModel of dojo::model::Model { fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::database::introspect::Layout) -> ModelWithTupleNoPrimitives { - let values = dojo::world::IWorldDispatcherTrait::entity(world, 1645672343860516512500770165827090085028240114004430888548878691171811972068, keys, layout); + let values = dojo::world::IWorldDispatcherTrait::entity( + world, + Self::selector(), + keys, + layout + ); // TODO: Generate method to deserialize from keys / values directly to avoid // serializing to intermediate array. @@ -3823,7 +4080,7 @@ impl ModelWithTupleNoPrimitivesModel of dojo::model::Model felt252 { - 1645672343860516512500770165827090085028240114004430888548878691171811972068 + 2223560621328332620401976875870433867783943832758255435639225261648312876047 } #[inline(always)] @@ -3836,6 +4093,11 @@ impl ModelWithTupleNoPrimitivesModel of dojo::model::Model felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + #[inline(always)] fn keys(self: @ModelWithTupleNoPrimitives) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -3909,6 +4171,10 @@ mod model_with_tuple_no_primitives { dojo::model::Model::::namespace() } + fn namespace_selector(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_selector() + } + fn unpacked_size(self: @ContractState) -> Option { dojo::database::introspect::Introspect::::size() } diff --git a/crates/dojo-world/src/contracts/abi/world.rs b/crates/dojo-world/src/contracts/abi/world.rs index 55a4178257..b65fc0ffa8 100644 --- a/crates/dojo-world/src/contracts/abi/world.rs +++ b/crates/dojo-world/src/contracts/abi/world.rs @@ -200,6 +200,18 @@ abigen!( "outputs": [], "state_mutability": "external" }, + { + "type": "function", + "name": "register_namespace", + "inputs": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray" + } + ], + "outputs": [], + "state_mutability": "external" + }, { "type": "function", "name": "deploy_contract", @@ -407,7 +419,7 @@ abigen!( "name": "is_writer", "inputs": [ { - "name": "model", + "name": "resource", "type": "core::felt252" }, { @@ -427,7 +439,7 @@ abigen!( "name": "grant_writer", "inputs": [ { - "name": "model", + "name": "resource", "type": "core::felt252" }, { @@ -443,7 +455,7 @@ abigen!( "name": "revoke_writer", "inputs": [ { - "name": "model", + "name": "resource", "type": "core::felt252" }, { @@ -453,6 +465,66 @@ abigen!( ], "outputs": [], "state_mutability": "external" + }, + { + "type": "function", + "name": "can_write_resource", + "inputs": [ + { + "name": "resource_id", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "can_write_model", + "inputs": [ + { + "name": "model_id", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "can_write_namespace", + "inputs": [ + { + "name": "namespace_id", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" } ] }, @@ -720,6 +792,23 @@ abigen!( } ] }, + { + "type": "event", + "name": "dojo::world::world::NamespaceRegistered", + "kind": "struct", + "members": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "data" + }, + { + "name": "hash", + "type": "core::felt252", + "kind": "data" + } + ] + }, { "type": "event", "name": "dojo::world::world::ModelRegistered", @@ -802,7 +891,7 @@ abigen!( "kind": "struct", "members": [ { - "name": "model", + "name": "resource", "type": "core::felt252", "kind": "data" }, @@ -923,6 +1012,11 @@ abigen!( "type": "dojo::world::world::MetadataUpdate", "kind": "nested" }, + { + "name": "NamespaceRegistered", + "type": "dojo::world::world::NamespaceRegistered", + "kind": "nested" + }, { "name": "ModelRegistered", "type": "dojo::world::world::ModelRegistered", diff --git a/crates/torii/types-test/manifests/dev/base/dojo_world_world.toml b/crates/torii/types-test/manifests/dev/base/dojo_world_world.toml index f195eecea6..0a1a32ae11 100644 --- a/crates/torii/types-test/manifests/dev/base/dojo_world_world.toml +++ b/crates/torii/types-test/manifests/dev/base/dojo_world_world.toml @@ -1,5 +1,5 @@ kind = "Class" -class_hash = "0x610b8797d5ca3d551eb33a4086b13893f10d8d60b8ff23da40d4bd8d907dccb" -original_class_hash = "0x610b8797d5ca3d551eb33a4086b13893f10d8d60b8ff23da40d4bd8d907dccb" +class_hash = "0x5ea21a99b526829a2aee5704b92b67431dc54a8204621307208f382302bfe18" +original_class_hash = "0x5ea21a99b526829a2aee5704b92b67431dc54a8204621307208f382302bfe18" abi = "manifests/dev/abis/base/dojo_world_world.json" name = "dojo::world::world" diff --git a/examples/spawn-and-move/manifests/dev/abis/base/dojo_world_world.json b/examples/spawn-and-move/manifests/dev/abis/base/dojo_world_world.json index f4a84c2e42..46ff48c2bd 100644 --- a/examples/spawn-and-move/manifests/dev/abis/base/dojo_world_world.json +++ b/examples/spawn-and-move/manifests/dev/abis/base/dojo_world_world.json @@ -194,6 +194,18 @@ "outputs": [], "state_mutability": "external" }, + { + "type": "function", + "name": "register_namespace", + "inputs": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray" + } + ], + "outputs": [], + "state_mutability": "external" + }, { "type": "function", "name": "deploy_contract", @@ -401,7 +413,7 @@ "name": "is_writer", "inputs": [ { - "name": "model", + "name": "resource", "type": "core::felt252" }, { @@ -421,7 +433,7 @@ "name": "grant_writer", "inputs": [ { - "name": "model", + "name": "resource", "type": "core::felt252" }, { @@ -437,7 +449,7 @@ "name": "revoke_writer", "inputs": [ { - "name": "model", + "name": "resource", "type": "core::felt252" }, { @@ -447,6 +459,66 @@ ], "outputs": [], "state_mutability": "external" + }, + { + "type": "function", + "name": "can_write_resource", + "inputs": [ + { + "name": "resource_id", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "can_write_model", + "inputs": [ + { + "name": "model_id", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "can_write_namespace", + "inputs": [ + { + "name": "namespace_id", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" } ] }, @@ -714,6 +786,23 @@ } ] }, + { + "type": "event", + "name": "dojo::world::world::NamespaceRegistered", + "kind": "struct", + "members": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "data" + }, + { + "name": "hash", + "type": "core::felt252", + "kind": "data" + } + ] + }, { "type": "event", "name": "dojo::world::world::ModelRegistered", @@ -796,7 +885,7 @@ "kind": "struct", "members": [ { - "name": "model", + "name": "resource", "type": "core::felt252", "kind": "data" }, @@ -917,6 +1006,11 @@ "type": "dojo::world::world::MetadataUpdate", "kind": "nested" }, + { + "name": "NamespaceRegistered", + "type": "dojo::world::world::NamespaceRegistered", + "kind": "nested" + }, { "name": "ModelRegistered", "type": "dojo::world::world::ModelRegistered", diff --git a/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_actions_actions_moved.json b/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_actions_actions_moved.json index a1449a31ab..48393eae33 100644 --- a/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_actions_actions_moved.json +++ b/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_actions_actions_moved.json @@ -282,6 +282,17 @@ ], "state_mutability": "view" }, + { + "type": "function", + "name": "namespace_selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, { "type": "function", "name": "unpacked_size", diff --git a/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_models_emote_message.json b/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_models_emote_message.json index ee7829ccd1..fab719f8b1 100644 --- a/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_models_emote_message.json +++ b/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_models_emote_message.json @@ -282,6 +282,17 @@ ], "state_mutability": "view" }, + { + "type": "function", + "name": "namespace_selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, { "type": "function", "name": "unpacked_size", diff --git a/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_models_moves.json b/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_models_moves.json index 8bf0f554d1..0ffb6d39fd 100644 --- a/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_models_moves.json +++ b/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_models_moves.json @@ -282,6 +282,17 @@ ], "state_mutability": "view" }, + { + "type": "function", + "name": "namespace_selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, { "type": "function", "name": "unpacked_size", diff --git a/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_models_player_config.json b/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_models_player_config.json index 6838a60718..602ff624a7 100644 --- a/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_models_player_config.json +++ b/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_models_player_config.json @@ -282,6 +282,17 @@ ], "state_mutability": "view" }, + { + "type": "function", + "name": "namespace_selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, { "type": "function", "name": "unpacked_size", diff --git a/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_models_position.json b/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_models_position.json index 6d330887ff..6396707e5e 100644 --- a/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_models_position.json +++ b/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_models_position.json @@ -282,6 +282,17 @@ ], "state_mutability": "view" }, + { + "type": "function", + "name": "namespace_selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, { "type": "function", "name": "unpacked_size", diff --git a/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_others_others_contract_initialized.json b/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_others_others_contract_initialized.json index aff79d923c..b85b095e69 100644 --- a/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_others_others_contract_initialized.json +++ b/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_others_others_contract_initialized.json @@ -282,6 +282,17 @@ ], "state_mutability": "view" }, + { + "type": "function", + "name": "namespace_selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, { "type": "function", "name": "unpacked_size", diff --git a/examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples_actions_actions.json b/examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples_actions_actions.json new file mode 100644 index 0000000000..b3f5f551f4 --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples_actions_actions.json @@ -0,0 +1,312 @@ +[ + { + "type": "impl", + "name": "DojoResourceProviderImpl", + "interface_name": "dojo::world::IDojoResourceProvider" + }, + { + "type": "interface", + "name": "dojo::world::IDojoResourceProvider", + "items": [ + { + "type": "function", + "name": "dojo_resource", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "NamespaceImpl", + "interface_name": "dojo::world::INamespace" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "dojo::world::INamespace", + "items": [ + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "WorldProviderImpl", + "interface_name": "dojo::world::IWorldProvider" + }, + { + "type": "struct", + "name": "dojo::world::IWorldDispatcher", + "members": [ + { + "name": "contract_address", + "type": "core::starknet::contract_address::ContractAddress" + } + ] + }, + { + "type": "interface", + "name": "dojo::world::IWorldProvider", + "items": [ + { + "type": "function", + "name": "world", + "inputs": [], + "outputs": [ + { + "type": "dojo::world::IWorldDispatcher" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "ActionsComputedImpl", + "interface_name": "dojo_examples::actions::IActionsComputed" + }, + { + "type": "struct", + "name": "dojo_examples::models::Vec2", + "members": [ + { + "name": "x", + "type": "core::integer::u32" + }, + { + "name": "y", + "type": "core::integer::u32" + } + ] + }, + { + "type": "struct", + "name": "dojo_examples::models::Position", + "members": [ + { + "name": "player", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "vec", + "type": "dojo_examples::models::Vec2" + } + ] + }, + { + "type": "interface", + "name": "dojo_examples::actions::IActionsComputed", + "items": [ + { + "type": "function", + "name": "tile_terrain", + "inputs": [ + { + "name": "vec", + "type": "dojo_examples::models::Vec2" + } + ], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "quadrant", + "inputs": [ + { + "name": "pos", + "type": "dojo_examples::models::Position" + } + ], + "outputs": [ + { + "type": "core::integer::u8" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "ActionsImpl", + "interface_name": "dojo_examples::actions::IActions" + }, + { + "type": "enum", + "name": "dojo_examples::models::Direction", + "variants": [ + { + "name": "None", + "type": "()" + }, + { + "name": "Left", + "type": "()" + }, + { + "name": "Right", + "type": "()" + }, + { + "name": "Up", + "type": "()" + }, + { + "name": "Down", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo_examples::actions::IActions", + "items": [ + { + "type": "function", + "name": "spawn", + "inputs": [], + "outputs": [], + "state_mutability": "view" + }, + { + "type": "function", + "name": "move", + "inputs": [ + { + "name": "direction", + "type": "dojo_examples::models::Direction" + } + ], + "outputs": [], + "state_mutability": "view" + }, + { + "type": "function", + "name": "set_player_config", + "inputs": [ + { + "name": "name", + "type": "core::byte_array::ByteArray" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "IDojoInitImpl", + "interface_name": "dojo_examples::actions::actions::IDojoInit" + }, + { + "type": "interface", + "name": "dojo_examples::actions::actions::IDojoInit", + "items": [ + { + "type": "function", + "name": "dojo_init", + "inputs": [], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "UpgradableImpl", + "interface_name": "dojo::components::upgradeable::IUpgradeable" + }, + { + "type": "interface", + "name": "dojo::components::upgradeable::IUpgradeable", + "items": [ + { + "type": "function", + "name": "upgrade", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "event", + "name": "dojo::components::upgradeable::upgradeable::Upgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::components::upgradeable::upgradeable::Event", + "kind": "enum", + "variants": [ + { + "name": "Upgraded", + "type": "dojo::components::upgradeable::upgradeable::Upgraded", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "dojo_examples::actions::actions::Event", + "kind": "enum", + "variants": [ + { + "name": "UpgradeableEvent", + "type": "dojo::components::upgradeable::upgradeable::Event", + "kind": "nested" + } + ] + } +] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples_others_others.json b/examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples_others_others.json new file mode 100644 index 0000000000..3ea51659d5 --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples_others_others.json @@ -0,0 +1,186 @@ +[ + { + "type": "impl", + "name": "DojoResourceProviderImpl", + "interface_name": "dojo::world::IDojoResourceProvider" + }, + { + "type": "interface", + "name": "dojo::world::IDojoResourceProvider", + "items": [ + { + "type": "function", + "name": "dojo_resource", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "NamespaceImpl", + "interface_name": "dojo::world::INamespace" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "dojo::world::INamespace", + "items": [ + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "WorldProviderImpl", + "interface_name": "dojo::world::IWorldProvider" + }, + { + "type": "struct", + "name": "dojo::world::IWorldDispatcher", + "members": [ + { + "name": "contract_address", + "type": "core::starknet::contract_address::ContractAddress" + } + ] + }, + { + "type": "interface", + "name": "dojo::world::IWorldProvider", + "items": [ + { + "type": "function", + "name": "world", + "inputs": [], + "outputs": [ + { + "type": "dojo::world::IWorldDispatcher" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "IDojoInitImpl", + "interface_name": "dojo_examples::others::others::IDojoInit" + }, + { + "type": "interface", + "name": "dojo_examples::others::others::IDojoInit", + "items": [ + { + "type": "function", + "name": "dojo_init", + "inputs": [ + { + "name": "actions_address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "actions_class", + "type": "core::starknet::class_hash::ClassHash" + }, + { + "name": "value", + "type": "core::integer::u8" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "UpgradableImpl", + "interface_name": "dojo::components::upgradeable::IUpgradeable" + }, + { + "type": "interface", + "name": "dojo::components::upgradeable::IUpgradeable", + "items": [ + { + "type": "function", + "name": "upgrade", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "event", + "name": "dojo::components::upgradeable::upgradeable::Upgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::components::upgradeable::upgradeable::Event", + "kind": "enum", + "variants": [ + { + "name": "Upgraded", + "type": "dojo::components::upgradeable::upgradeable::Upgraded", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "dojo_examples::others::others::Event", + "kind": "enum", + "variants": [ + { + "name": "UpgradeableEvent", + "type": "dojo::components::upgradeable::upgradeable::Event", + "kind": "nested" + } + ] + } +] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/abis/deployments/dojo_world_world.json b/examples/spawn-and-move/manifests/dev/abis/deployments/dojo_world_world.json new file mode 100644 index 0000000000..46ff48c2bd --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/abis/deployments/dojo_world_world.json @@ -0,0 +1,1051 @@ +[ + { + "type": "impl", + "name": "World", + "interface_name": "dojo::world::IWorld" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "struct", + "name": "dojo::resource_metadata::ResourceMetadata", + "members": [ + { + "name": "resource_id", + "type": "core::felt252" + }, + { + "name": "metadata_uri", + "type": "core::byte_array::ByteArray" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "enum", + "name": "core::bool", + "variants": [ + { + "name": "False", + "type": "()" + }, + { + "name": "True", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::world::IWorld", + "items": [ + { + "type": "function", + "name": "metadata", + "inputs": [ + { + "name": "resource_id", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "dojo::resource_metadata::ResourceMetadata" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "set_metadata", + "inputs": [ + { + "name": "metadata", + "type": "dojo::resource_metadata::ResourceMetadata" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "model", + "inputs": [ + { + "name": "selector", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "(core::starknet::class_hash::ClassHash, core::starknet::contract_address::ContractAddress)" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "register_model", + "inputs": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "register_namespace", + "inputs": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "deploy_contract", + "inputs": [ + { + "name": "salt", + "type": "core::felt252" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + }, + { + "name": "init_calldata", + "type": "core::array::Span::" + } + ], + "outputs": [ + { + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "upgrade_contract", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [ + { + "type": "core::starknet::class_hash::ClassHash" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "uuid", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u32" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "emit", + "inputs": [ + { + "name": "keys", + "type": "core::array::Array::" + }, + { + "name": "values", + "type": "core::array::Span::" + } + ], + "outputs": [], + "state_mutability": "view" + }, + { + "type": "function", + "name": "entity", + "inputs": [ + { + "name": "model", + "type": "core::felt252" + }, + { + "name": "keys", + "type": "core::array::Span::" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ], + "outputs": [ + { + "type": "core::array::Span::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "set_entity", + "inputs": [ + { + "name": "model", + "type": "core::felt252" + }, + { + "name": "keys", + "type": "core::array::Span::" + }, + { + "name": "values", + "type": "core::array::Span::" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "delete_entity", + "inputs": [ + { + "name": "model", + "type": "core::felt252" + }, + { + "name": "keys", + "type": "core::array::Span::" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "base", + "inputs": [], + "outputs": [ + { + "type": "core::starknet::class_hash::ClassHash" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "is_owner", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "resource", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "grant_owner", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "resource", + "type": "core::felt252" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "revoke_owner", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "resource", + "type": "core::felt252" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "is_writer", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "grant_writer", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "revoke_writer", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "can_write_resource", + "inputs": [ + { + "name": "resource_id", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "can_write_model", + "inputs": [ + { + "name": "model_id", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "can_write_namespace", + "inputs": [ + { + "name": "namespace_id", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "UpgradeableWorld", + "interface_name": "dojo::world::IUpgradeableWorld" + }, + { + "type": "interface", + "name": "dojo::world::IUpgradeableWorld", + "items": [ + { + "type": "function", + "name": "upgrade", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "impl", + "name": "UpgradeableState", + "interface_name": "dojo::interfaces::IUpgradeableState" + }, + { + "type": "struct", + "name": "dojo::interfaces::StorageUpdate", + "members": [ + { + "name": "key", + "type": "core::felt252" + }, + { + "name": "value", + "type": "core::felt252" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::interfaces::ProgramOutput", + "members": [ + { + "name": "prev_state_root", + "type": "core::felt252" + }, + { + "name": "new_state_root", + "type": "core::felt252" + }, + { + "name": "block_number", + "type": "core::felt252" + }, + { + "name": "block_hash", + "type": "core::felt252" + }, + { + "name": "config_hash", + "type": "core::felt252" + }, + { + "name": "world_da_hash", + "type": "core::felt252" + }, + { + "name": "message_to_starknet_segment", + "type": "core::array::Span::" + }, + { + "name": "message_to_appchain_segment", + "type": "core::array::Span::" + } + ] + }, + { + "type": "interface", + "name": "dojo::interfaces::IUpgradeableState", + "items": [ + { + "type": "function", + "name": "upgrade_state", + "inputs": [ + { + "name": "new_state", + "type": "core::array::Span::" + }, + { + "name": "program_output", + "type": "dojo::interfaces::ProgramOutput" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "impl", + "name": "ConfigImpl", + "interface_name": "dojo::config::interface::IConfig" + }, + { + "type": "interface", + "name": "dojo::config::interface::IConfig", + "items": [ + { + "type": "function", + "name": "set_program_hash", + "inputs": [ + { + "name": "program_hash", + "type": "core::felt252" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "get_program_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "set_facts_registry", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "get_facts_registry", + "inputs": [], + "outputs": [ + { + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "constructor", + "name": "constructor", + "inputs": [ + { + "name": "contract_base", + "type": "core::starknet::class_hash::ClassHash" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::WorldSpawned", + "kind": "struct", + "members": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "creator", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::ContractDeployed", + "kind": "struct", + "members": [ + { + "name": "salt", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::ContractUpgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::WorldUpgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::MetadataUpdate", + "kind": "struct", + "members": [ + { + "name": "resource", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "uri", + "type": "core::byte_array::ByteArray", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::NamespaceRegistered", + "kind": "struct", + "members": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "data" + }, + { + "name": "hash", + "type": "core::felt252", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::ModelRegistered", + "kind": "struct", + "members": [ + { + "name": "name", + "type": "core::byte_array::ByteArray", + "kind": "data" + }, + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "data" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "prev_class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "prev_address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::StoreSetRecord", + "kind": "struct", + "members": [ + { + "name": "table", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "keys", + "type": "core::array::Span::", + "kind": "data" + }, + { + "name": "values", + "type": "core::array::Span::", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::StoreDelRecord", + "kind": "struct", + "members": [ + { + "name": "table", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "keys", + "type": "core::array::Span::", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::WriterUpdated", + "kind": "struct", + "members": [ + { + "name": "resource", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "value", + "type": "core::bool", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::OwnerUpdated", + "kind": "struct", + "members": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "resource", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "value", + "type": "core::bool", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::config::component::Config::ProgramHashUpdate", + "kind": "struct", + "members": [ + { + "name": "program_hash", + "type": "core::felt252", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::config::component::Config::FactsRegistryUpdate", + "kind": "struct", + "members": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::config::component::Config::Event", + "kind": "enum", + "variants": [ + { + "name": "ProgramHashUpdate", + "type": "dojo::config::component::Config::ProgramHashUpdate", + "kind": "nested" + }, + { + "name": "FactsRegistryUpdate", + "type": "dojo::config::component::Config::FactsRegistryUpdate", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::StateUpdated", + "kind": "struct", + "members": [ + { + "name": "da_hash", + "type": "core::felt252", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::Event", + "kind": "enum", + "variants": [ + { + "name": "WorldSpawned", + "type": "dojo::world::world::WorldSpawned", + "kind": "nested" + }, + { + "name": "ContractDeployed", + "type": "dojo::world::world::ContractDeployed", + "kind": "nested" + }, + { + "name": "ContractUpgraded", + "type": "dojo::world::world::ContractUpgraded", + "kind": "nested" + }, + { + "name": "WorldUpgraded", + "type": "dojo::world::world::WorldUpgraded", + "kind": "nested" + }, + { + "name": "MetadataUpdate", + "type": "dojo::world::world::MetadataUpdate", + "kind": "nested" + }, + { + "name": "NamespaceRegistered", + "type": "dojo::world::world::NamespaceRegistered", + "kind": "nested" + }, + { + "name": "ModelRegistered", + "type": "dojo::world::world::ModelRegistered", + "kind": "nested" + }, + { + "name": "StoreSetRecord", + "type": "dojo::world::world::StoreSetRecord", + "kind": "nested" + }, + { + "name": "StoreDelRecord", + "type": "dojo::world::world::StoreDelRecord", + "kind": "nested" + }, + { + "name": "WriterUpdated", + "type": "dojo::world::world::WriterUpdated", + "kind": "nested" + }, + { + "name": "OwnerUpdated", + "type": "dojo::world::world::OwnerUpdated", + "kind": "nested" + }, + { + "name": "ConfigEvent", + "type": "dojo::config::component::Config::Event", + "kind": "nested" + }, + { + "name": "StateUpdated", + "type": "dojo::world::world::StateUpdated", + "kind": "nested" + } + ] + } +] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_actions_actions_moved.json b/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_actions_actions_moved.json new file mode 100644 index 0000000000..48393eae33 --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_actions_actions_moved.json @@ -0,0 +1,411 @@ +[ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::IModel" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::database::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::database::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::database::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::IModel", + "items": [ + { + "type": "function", + "name": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "version", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u8" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "movedImpl", + "interface_name": "dojo_examples::actions::actions::Imoved" + }, + { + "type": "enum", + "name": "dojo_examples::models::Direction", + "variants": [ + { + "name": "None", + "type": "()" + }, + { + "name": "Left", + "type": "()" + }, + { + "name": "Right", + "type": "()" + }, + { + "name": "Up", + "type": "()" + }, + { + "name": "Down", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "dojo_examples::actions::actions::Moved", + "members": [ + { + "name": "player", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "direction", + "type": "dojo_examples::models::Direction" + } + ] + }, + { + "type": "interface", + "name": "dojo_examples::actions::actions::Imoved", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "dojo_examples::actions::actions::Moved" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "dojo_examples::actions::actions::moved::Event", + "kind": "enum", + "variants": [] + } +] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_emote_message.json b/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_emote_message.json new file mode 100644 index 0000000000..fab719f8b1 --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_emote_message.json @@ -0,0 +1,411 @@ +[ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::IModel" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::database::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::database::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::database::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::IModel", + "items": [ + { + "type": "function", + "name": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "version", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u8" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "emote_messageImpl", + "interface_name": "dojo_examples::models::Iemote_message" + }, + { + "type": "enum", + "name": "dojo_examples::models::Emote", + "variants": [ + { + "name": "None", + "type": "()" + }, + { + "name": "Happy", + "type": "()" + }, + { + "name": "Sad", + "type": "()" + }, + { + "name": "Angry", + "type": "()" + }, + { + "name": "Love", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "dojo_examples::models::EmoteMessage", + "members": [ + { + "name": "identity", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "emote", + "type": "dojo_examples::models::Emote" + } + ] + }, + { + "type": "interface", + "name": "dojo_examples::models::Iemote_message", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "dojo_examples::models::EmoteMessage" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "dojo_examples::models::emote_message::Event", + "kind": "enum", + "variants": [] + } +] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_moves.json b/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_moves.json new file mode 100644 index 0000000000..0ffb6d39fd --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_moves.json @@ -0,0 +1,415 @@ +[ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::IModel" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::database::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::database::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::database::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::IModel", + "items": [ + { + "type": "function", + "name": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "version", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u8" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "movesImpl", + "interface_name": "dojo_examples::models::Imoves" + }, + { + "type": "enum", + "name": "dojo_examples::models::Direction", + "variants": [ + { + "name": "None", + "type": "()" + }, + { + "name": "Left", + "type": "()" + }, + { + "name": "Right", + "type": "()" + }, + { + "name": "Up", + "type": "()" + }, + { + "name": "Down", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "dojo_examples::models::Moves", + "members": [ + { + "name": "player", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "remaining", + "type": "core::integer::u8" + }, + { + "name": "last_direction", + "type": "dojo_examples::models::Direction" + } + ] + }, + { + "type": "interface", + "name": "dojo_examples::models::Imoves", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "dojo_examples::models::Moves" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "dojo_examples::models::moves::Event", + "kind": "enum", + "variants": [] + } +] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_player_config.json b/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_player_config.json new file mode 100644 index 0000000000..602ff624a7 --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_player_config.json @@ -0,0 +1,407 @@ +[ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::IModel" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::database::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::database::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::database::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::IModel", + "items": [ + { + "type": "function", + "name": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "version", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u8" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "player_configImpl", + "interface_name": "dojo_examples::models::Iplayer_config" + }, + { + "type": "struct", + "name": "dojo_examples::models::PlayerItem", + "members": [ + { + "name": "item_id", + "type": "core::integer::u32" + }, + { + "name": "quantity", + "type": "core::integer::u32" + } + ] + }, + { + "type": "struct", + "name": "dojo_examples::models::PlayerConfig", + "members": [ + { + "name": "player", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "name", + "type": "core::byte_array::ByteArray" + }, + { + "name": "items", + "type": "core::array::Array::" + }, + { + "name": "favorite_item", + "type": "core::option::Option::" + } + ] + }, + { + "type": "interface", + "name": "dojo_examples::models::Iplayer_config", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "dojo_examples::models::PlayerConfig" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "dojo_examples::models::player_config::Event", + "kind": "enum", + "variants": [] + } +] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_position.json b/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_position.json new file mode 100644 index 0000000000..6396707e5e --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_position.json @@ -0,0 +1,399 @@ +[ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::IModel" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::database::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::database::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::database::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::IModel", + "items": [ + { + "type": "function", + "name": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "version", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u8" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "positionImpl", + "interface_name": "dojo_examples::models::Iposition" + }, + { + "type": "struct", + "name": "dojo_examples::models::Vec2", + "members": [ + { + "name": "x", + "type": "core::integer::u32" + }, + { + "name": "y", + "type": "core::integer::u32" + } + ] + }, + { + "type": "struct", + "name": "dojo_examples::models::Position", + "members": [ + { + "name": "player", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "vec", + "type": "dojo_examples::models::Vec2" + } + ] + }, + { + "type": "interface", + "name": "dojo_examples::models::Iposition", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "dojo_examples::models::Position" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "dojo_examples::models::position::Event", + "kind": "enum", + "variants": [] + } +] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_others_others_contract_initialized.json b/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_others_others_contract_initialized.json new file mode 100644 index 0000000000..b85b095e69 --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_others_others_contract_initialized.json @@ -0,0 +1,389 @@ +[ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::IModel" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::database::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::database::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::database::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::IModel", + "items": [ + { + "type": "function", + "name": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "version", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u8" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "contract_initializedImpl", + "interface_name": "dojo_examples::others::others::Icontract_initialized" + }, + { + "type": "struct", + "name": "dojo_examples::others::others::ContractInitialized", + "members": [ + { + "name": "contract_address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "contract_class", + "type": "core::starknet::class_hash::ClassHash" + }, + { + "name": "value", + "type": "core::integer::u8" + } + ] + }, + { + "type": "interface", + "name": "dojo_examples::others::others::Icontract_initialized", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "dojo_examples::others::others::ContractInitialized" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "dojo_examples::others::others::contract_initialized::Event", + "kind": "enum", + "variants": [] + } +] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples_actions_actions.toml b/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples_actions_actions.toml index ef58666478..ba399906a8 100644 --- a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples_actions_actions.toml +++ b/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples_actions_actions.toml @@ -1,6 +1,6 @@ kind = "DojoContract" -class_hash = "0x2b18df588421416bd5caaad640a80147b42cd5b131f50ddd36039b715807011" -original_class_hash = "0x2b18df588421416bd5caaad640a80147b42cd5b131f50ddd36039b715807011" +class_hash = "0x23fe3f856c7647f393a05606ad10481f98f13436d6bd844faad4f1d5aac17f9" +original_class_hash = "0x23fe3f856c7647f393a05606ad10481f98f13436d6bd844faad4f1d5aac17f9" base_class_hash = "0x0" abi = "manifests/dev/abis/base/contracts/dojo_examples_actions_actions.json" reads = [] diff --git a/examples/spawn-and-move/manifests/dev/base/dojo_world_world.toml b/examples/spawn-and-move/manifests/dev/base/dojo_world_world.toml index f195eecea6..0a1a32ae11 100644 --- a/examples/spawn-and-move/manifests/dev/base/dojo_world_world.toml +++ b/examples/spawn-and-move/manifests/dev/base/dojo_world_world.toml @@ -1,5 +1,5 @@ kind = "Class" -class_hash = "0x610b8797d5ca3d551eb33a4086b13893f10d8d60b8ff23da40d4bd8d907dccb" -original_class_hash = "0x610b8797d5ca3d551eb33a4086b13893f10d8d60b8ff23da40d4bd8d907dccb" +class_hash = "0x5ea21a99b526829a2aee5704b92b67431dc54a8204621307208f382302bfe18" +original_class_hash = "0x5ea21a99b526829a2aee5704b92b67431dc54a8204621307208f382302bfe18" abi = "manifests/dev/abis/base/dojo_world_world.json" name = "dojo::world::world" diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_actions_actions_moved.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_actions_actions_moved.toml index 6638f643fb..84074c889e 100644 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_actions_actions_moved.toml +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_actions_actions_moved.toml @@ -1,6 +1,6 @@ kind = "DojoModel" -class_hash = "0x6b2b029759c01123f15af42be8d8c35dcf5a6864907cf68b45deae5061c62ce" -original_class_hash = "0x6b2b029759c01123f15af42be8d8c35dcf5a6864907cf68b45deae5061c62ce" +class_hash = "0x2c331d31a2f7233eb0c044c542d88a13b17d7f3e27b2922a404867279c21989" +original_class_hash = "0x2c331d31a2f7233eb0c044c542d88a13b17d7f3e27b2922a404867279c21989" abi = "manifests/dev/abis/base/models/dojo_examples_actions_actions_moved.json" name = "dojo_examples::actions::actions::moved" diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_emote_message.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_emote_message.toml index 7a6baa9471..4cb3ff75a9 100644 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_emote_message.toml +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_emote_message.toml @@ -1,6 +1,6 @@ kind = "DojoModel" -class_hash = "0x7f14bf1375cb110dc6779affbceaf1f302f95bed3ac2adcb84357a549e804c7" -original_class_hash = "0x7f14bf1375cb110dc6779affbceaf1f302f95bed3ac2adcb84357a549e804c7" +class_hash = "0x6ffbf802dccf7a0828a57d41f13b56eeca63789efe3a6f7c60f7f374f1c310c" +original_class_hash = "0x6ffbf802dccf7a0828a57d41f13b56eeca63789efe3a6f7c60f7f374f1c310c" abi = "manifests/dev/abis/base/models/dojo_examples_models_emote_message.json" name = "dojo_examples::models::emote_message" diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_moves.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_moves.toml index 2c8a1d3110..c9c43f1846 100644 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_moves.toml +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_moves.toml @@ -1,6 +1,6 @@ kind = "DojoModel" -class_hash = "0x6a9b532ba97c389f90f2fc0ee487a8651321cf5e3f31ff667d139fb0d07aaba" -original_class_hash = "0x6a9b532ba97c389f90f2fc0ee487a8651321cf5e3f31ff667d139fb0d07aaba" +class_hash = "0x779ad55281689e940e72d4da77daa436bbd45eaeb7ddc3bbde9dc2dffad9f6b" +original_class_hash = "0x779ad55281689e940e72d4da77daa436bbd45eaeb7ddc3bbde9dc2dffad9f6b" abi = "manifests/dev/abis/base/models/dojo_examples_models_moves.json" name = "dojo_examples::models::moves" diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_player_config.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_player_config.toml index a70c0a45fa..63147f85a4 100644 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_player_config.toml +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_player_config.toml @@ -1,6 +1,6 @@ kind = "DojoModel" -class_hash = "0x1c5fd16d2013c917f05b484e0c8e1ef4804b46ca45759ed1cf4d19e55b95ec0" -original_class_hash = "0x1c5fd16d2013c917f05b484e0c8e1ef4804b46ca45759ed1cf4d19e55b95ec0" +class_hash = "0x5ce0a1e74d66aeca78fc09a73e7b1c49f67fca36753a5c0b0028be5a3da01ce" +original_class_hash = "0x5ce0a1e74d66aeca78fc09a73e7b1c49f67fca36753a5c0b0028be5a3da01ce" abi = "manifests/dev/abis/base/models/dojo_examples_models_player_config.json" name = "dojo_examples::models::player_config" diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_position.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_position.toml index bf4beaac14..b25057fe15 100644 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_position.toml +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_position.toml @@ -1,6 +1,6 @@ kind = "DojoModel" -class_hash = "0x388e2d7941568d72369f8ede13d01be9de96827c8c19ede6a47ad42861b209a" -original_class_hash = "0x388e2d7941568d72369f8ede13d01be9de96827c8c19ede6a47ad42861b209a" +class_hash = "0x602ea3f7ab1aa676845ad696165e72c518f1fb059f2d3eff1e1418f58c894e9" +original_class_hash = "0x602ea3f7ab1aa676845ad696165e72c518f1fb059f2d3eff1e1418f58c894e9" abi = "manifests/dev/abis/base/models/dojo_examples_models_position.json" name = "dojo_examples::models::position" diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_others_others_contract_initialized.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_others_others_contract_initialized.toml index e1eba316c4..c952946720 100644 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_others_others_contract_initialized.toml +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_others_others_contract_initialized.toml @@ -1,6 +1,6 @@ kind = "DojoModel" -class_hash = "0x201188e333f79877d683043cfa6e663c4048a1d3df76559f60aabb1bbfa6830" -original_class_hash = "0x201188e333f79877d683043cfa6e663c4048a1d3df76559f60aabb1bbfa6830" +class_hash = "0x71c8a02c5db4966da6ca1ff73125c0c31ec35298babf8e0814146898ab11092" +original_class_hash = "0x71c8a02c5db4966da6ca1ff73125c0c31ec35298babf8e0814146898ab11092" abi = "manifests/dev/abis/base/models/dojo_examples_others_others_contract_initialized.json" name = "dojo_examples::others::others::contract_initialized" diff --git a/examples/spawn-and-move/manifests/dev/manifest.json b/examples/spawn-and-move/manifests/dev/manifest.json new file mode 100644 index 0000000000..2eb9f9d6c5 --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/manifest.json @@ -0,0 +1,4167 @@ +{ + "world": { + "kind": "WorldContract", + "class_hash": "0x5ea21a99b526829a2aee5704b92b67431dc54a8204621307208f382302bfe18", + "original_class_hash": "0x5ea21a99b526829a2aee5704b92b67431dc54a8204621307208f382302bfe18", + "abi": [ + { + "type": "impl", + "name": "World", + "interface_name": "dojo::world::IWorld" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "struct", + "name": "dojo::resource_metadata::ResourceMetadata", + "members": [ + { + "name": "resource_id", + "type": "core::felt252" + }, + { + "name": "metadata_uri", + "type": "core::byte_array::ByteArray" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "enum", + "name": "core::bool", + "variants": [ + { + "name": "False", + "type": "()" + }, + { + "name": "True", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::world::IWorld", + "items": [ + { + "type": "function", + "name": "metadata", + "inputs": [ + { + "name": "resource_id", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "dojo::resource_metadata::ResourceMetadata" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "set_metadata", + "inputs": [ + { + "name": "metadata", + "type": "dojo::resource_metadata::ResourceMetadata" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "model", + "inputs": [ + { + "name": "selector", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "(core::starknet::class_hash::ClassHash, core::starknet::contract_address::ContractAddress)" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "register_model", + "inputs": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "register_namespace", + "inputs": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "deploy_contract", + "inputs": [ + { + "name": "salt", + "type": "core::felt252" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + }, + { + "name": "init_calldata", + "type": "core::array::Span::" + } + ], + "outputs": [ + { + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "upgrade_contract", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [ + { + "type": "core::starknet::class_hash::ClassHash" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "uuid", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u32" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "emit", + "inputs": [ + { + "name": "keys", + "type": "core::array::Array::" + }, + { + "name": "values", + "type": "core::array::Span::" + } + ], + "outputs": [], + "state_mutability": "view" + }, + { + "type": "function", + "name": "entity", + "inputs": [ + { + "name": "model", + "type": "core::felt252" + }, + { + "name": "keys", + "type": "core::array::Span::" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ], + "outputs": [ + { + "type": "core::array::Span::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "set_entity", + "inputs": [ + { + "name": "model", + "type": "core::felt252" + }, + { + "name": "keys", + "type": "core::array::Span::" + }, + { + "name": "values", + "type": "core::array::Span::" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "delete_entity", + "inputs": [ + { + "name": "model", + "type": "core::felt252" + }, + { + "name": "keys", + "type": "core::array::Span::" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "base", + "inputs": [], + "outputs": [ + { + "type": "core::starknet::class_hash::ClassHash" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "is_owner", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "resource", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "grant_owner", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "resource", + "type": "core::felt252" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "revoke_owner", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "resource", + "type": "core::felt252" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "is_writer", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "grant_writer", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "revoke_writer", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "can_write_resource", + "inputs": [ + { + "name": "resource_id", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "can_write_model", + "inputs": [ + { + "name": "model_id", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "can_write_namespace", + "inputs": [ + { + "name": "namespace_id", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "UpgradeableWorld", + "interface_name": "dojo::world::IUpgradeableWorld" + }, + { + "type": "interface", + "name": "dojo::world::IUpgradeableWorld", + "items": [ + { + "type": "function", + "name": "upgrade", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "impl", + "name": "UpgradeableState", + "interface_name": "dojo::interfaces::IUpgradeableState" + }, + { + "type": "struct", + "name": "dojo::interfaces::StorageUpdate", + "members": [ + { + "name": "key", + "type": "core::felt252" + }, + { + "name": "value", + "type": "core::felt252" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::interfaces::ProgramOutput", + "members": [ + { + "name": "prev_state_root", + "type": "core::felt252" + }, + { + "name": "new_state_root", + "type": "core::felt252" + }, + { + "name": "block_number", + "type": "core::felt252" + }, + { + "name": "block_hash", + "type": "core::felt252" + }, + { + "name": "config_hash", + "type": "core::felt252" + }, + { + "name": "world_da_hash", + "type": "core::felt252" + }, + { + "name": "message_to_starknet_segment", + "type": "core::array::Span::" + }, + { + "name": "message_to_appchain_segment", + "type": "core::array::Span::" + } + ] + }, + { + "type": "interface", + "name": "dojo::interfaces::IUpgradeableState", + "items": [ + { + "type": "function", + "name": "upgrade_state", + "inputs": [ + { + "name": "new_state", + "type": "core::array::Span::" + }, + { + "name": "program_output", + "type": "dojo::interfaces::ProgramOutput" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "impl", + "name": "ConfigImpl", + "interface_name": "dojo::config::interface::IConfig" + }, + { + "type": "interface", + "name": "dojo::config::interface::IConfig", + "items": [ + { + "type": "function", + "name": "set_program_hash", + "inputs": [ + { + "name": "program_hash", + "type": "core::felt252" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "get_program_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "set_facts_registry", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "get_facts_registry", + "inputs": [], + "outputs": [ + { + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "constructor", + "name": "constructor", + "inputs": [ + { + "name": "contract_base", + "type": "core::starknet::class_hash::ClassHash" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::WorldSpawned", + "kind": "struct", + "members": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "creator", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::ContractDeployed", + "kind": "struct", + "members": [ + { + "name": "salt", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::ContractUpgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::WorldUpgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::MetadataUpdate", + "kind": "struct", + "members": [ + { + "name": "resource", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "uri", + "type": "core::byte_array::ByteArray", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::NamespaceRegistered", + "kind": "struct", + "members": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "data" + }, + { + "name": "hash", + "type": "core::felt252", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::ModelRegistered", + "kind": "struct", + "members": [ + { + "name": "name", + "type": "core::byte_array::ByteArray", + "kind": "data" + }, + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "data" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "prev_class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "prev_address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::StoreSetRecord", + "kind": "struct", + "members": [ + { + "name": "table", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "keys", + "type": "core::array::Span::", + "kind": "data" + }, + { + "name": "values", + "type": "core::array::Span::", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::StoreDelRecord", + "kind": "struct", + "members": [ + { + "name": "table", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "keys", + "type": "core::array::Span::", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::WriterUpdated", + "kind": "struct", + "members": [ + { + "name": "resource", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "value", + "type": "core::bool", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::OwnerUpdated", + "kind": "struct", + "members": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "resource", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "value", + "type": "core::bool", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::config::component::Config::ProgramHashUpdate", + "kind": "struct", + "members": [ + { + "name": "program_hash", + "type": "core::felt252", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::config::component::Config::FactsRegistryUpdate", + "kind": "struct", + "members": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::config::component::Config::Event", + "kind": "enum", + "variants": [ + { + "name": "ProgramHashUpdate", + "type": "dojo::config::component::Config::ProgramHashUpdate", + "kind": "nested" + }, + { + "name": "FactsRegistryUpdate", + "type": "dojo::config::component::Config::FactsRegistryUpdate", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::StateUpdated", + "kind": "struct", + "members": [ + { + "name": "da_hash", + "type": "core::felt252", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::Event", + "kind": "enum", + "variants": [ + { + "name": "WorldSpawned", + "type": "dojo::world::world::WorldSpawned", + "kind": "nested" + }, + { + "name": "ContractDeployed", + "type": "dojo::world::world::ContractDeployed", + "kind": "nested" + }, + { + "name": "ContractUpgraded", + "type": "dojo::world::world::ContractUpgraded", + "kind": "nested" + }, + { + "name": "WorldUpgraded", + "type": "dojo::world::world::WorldUpgraded", + "kind": "nested" + }, + { + "name": "MetadataUpdate", + "type": "dojo::world::world::MetadataUpdate", + "kind": "nested" + }, + { + "name": "NamespaceRegistered", + "type": "dojo::world::world::NamespaceRegistered", + "kind": "nested" + }, + { + "name": "ModelRegistered", + "type": "dojo::world::world::ModelRegistered", + "kind": "nested" + }, + { + "name": "StoreSetRecord", + "type": "dojo::world::world::StoreSetRecord", + "kind": "nested" + }, + { + "name": "StoreDelRecord", + "type": "dojo::world::world::StoreDelRecord", + "kind": "nested" + }, + { + "name": "WriterUpdated", + "type": "dojo::world::world::WriterUpdated", + "kind": "nested" + }, + { + "name": "OwnerUpdated", + "type": "dojo::world::world::OwnerUpdated", + "kind": "nested" + }, + { + "name": "ConfigEvent", + "type": "dojo::config::component::Config::Event", + "kind": "nested" + }, + { + "name": "StateUpdated", + "type": "dojo::world::world::StateUpdated", + "kind": "nested" + } + ] + } + ], + "address": "0x62ab1d9dff4097a6662ffd8dc561a46aaabb398ef059bd6f696f3548c95835a", + "transaction_hash": "0x4b69cfc5f9a36eaa92a30464f75169ac578319c5e34566b91b00f0df5749f60", + "block_number": 3, + "seed": "dojo_examples", + "metadata": { + "profile_name": "dev", + "rpc_url": "http://localhost:5050/" + }, + "name": "dojo::world::world" + }, + "base": { + "kind": "Class", + "class_hash": "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46", + "original_class_hash": "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46", + "abi": null, + "name": "dojo::base::base" + }, + "contracts": [ + { + "kind": "DojoContract", + "address": null, + "class_hash": "0x23fe3f856c7647f393a05606ad10481f98f13436d6bd844faad4f1d5aac17f9", + "original_class_hash": "0x23fe3f856c7647f393a05606ad10481f98f13436d6bd844faad4f1d5aac17f9", + "base_class_hash": "0x0", + "abi": [ + { + "type": "impl", + "name": "DojoResourceProviderImpl", + "interface_name": "dojo::world::IDojoResourceProvider" + }, + { + "type": "interface", + "name": "dojo::world::IDojoResourceProvider", + "items": [ + { + "type": "function", + "name": "dojo_resource", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "NamespaceImpl", + "interface_name": "dojo::world::INamespace" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "dojo::world::INamespace", + "items": [ + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "WorldProviderImpl", + "interface_name": "dojo::world::IWorldProvider" + }, + { + "type": "struct", + "name": "dojo::world::IWorldDispatcher", + "members": [ + { + "name": "contract_address", + "type": "core::starknet::contract_address::ContractAddress" + } + ] + }, + { + "type": "interface", + "name": "dojo::world::IWorldProvider", + "items": [ + { + "type": "function", + "name": "world", + "inputs": [], + "outputs": [ + { + "type": "dojo::world::IWorldDispatcher" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "ActionsComputedImpl", + "interface_name": "dojo_examples::actions::IActionsComputed" + }, + { + "type": "struct", + "name": "dojo_examples::models::Vec2", + "members": [ + { + "name": "x", + "type": "core::integer::u32" + }, + { + "name": "y", + "type": "core::integer::u32" + } + ] + }, + { + "type": "struct", + "name": "dojo_examples::models::Position", + "members": [ + { + "name": "player", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "vec", + "type": "dojo_examples::models::Vec2" + } + ] + }, + { + "type": "interface", + "name": "dojo_examples::actions::IActionsComputed", + "items": [ + { + "type": "function", + "name": "tile_terrain", + "inputs": [ + { + "name": "vec", + "type": "dojo_examples::models::Vec2" + } + ], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "quadrant", + "inputs": [ + { + "name": "pos", + "type": "dojo_examples::models::Position" + } + ], + "outputs": [ + { + "type": "core::integer::u8" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "ActionsImpl", + "interface_name": "dojo_examples::actions::IActions" + }, + { + "type": "enum", + "name": "dojo_examples::models::Direction", + "variants": [ + { + "name": "None", + "type": "()" + }, + { + "name": "Left", + "type": "()" + }, + { + "name": "Right", + "type": "()" + }, + { + "name": "Up", + "type": "()" + }, + { + "name": "Down", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo_examples::actions::IActions", + "items": [ + { + "type": "function", + "name": "spawn", + "inputs": [], + "outputs": [], + "state_mutability": "view" + }, + { + "type": "function", + "name": "move", + "inputs": [ + { + "name": "direction", + "type": "dojo_examples::models::Direction" + } + ], + "outputs": [], + "state_mutability": "view" + }, + { + "type": "function", + "name": "set_player_config", + "inputs": [ + { + "name": "name", + "type": "core::byte_array::ByteArray" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "IDojoInitImpl", + "interface_name": "dojo_examples::actions::actions::IDojoInit" + }, + { + "type": "interface", + "name": "dojo_examples::actions::actions::IDojoInit", + "items": [ + { + "type": "function", + "name": "dojo_init", + "inputs": [], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "UpgradableImpl", + "interface_name": "dojo::components::upgradeable::IUpgradeable" + }, + { + "type": "interface", + "name": "dojo::components::upgradeable::IUpgradeable", + "items": [ + { + "type": "function", + "name": "upgrade", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "event", + "name": "dojo::components::upgradeable::upgradeable::Upgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::components::upgradeable::upgradeable::Event", + "kind": "enum", + "variants": [ + { + "name": "Upgraded", + "type": "dojo::components::upgradeable::upgradeable::Upgraded", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "dojo_examples::actions::actions::Event", + "kind": "enum", + "variants": [ + { + "name": "UpgradeableEvent", + "type": "dojo::components::upgradeable::upgradeable::Event", + "kind": "nested" + } + ] + } + ], + "reads": [], + "writes": [ + "Moves", + "Position" + ], + "computed": [], + "init_calldata": [], + "name": "dojo_examples::actions::actions" + }, + { + "kind": "DojoContract", + "address": null, + "class_hash": "0x5c078c288959ffb9423a6c6557fcd38757e41570b271c63d7121080610c4ed4", + "original_class_hash": "0x5c078c288959ffb9423a6c6557fcd38757e41570b271c63d7121080610c4ed4", + "base_class_hash": "0x0", + "abi": [ + { + "type": "impl", + "name": "DojoResourceProviderImpl", + "interface_name": "dojo::world::IDojoResourceProvider" + }, + { + "type": "interface", + "name": "dojo::world::IDojoResourceProvider", + "items": [ + { + "type": "function", + "name": "dojo_resource", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "NamespaceImpl", + "interface_name": "dojo::world::INamespace" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "dojo::world::INamespace", + "items": [ + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "WorldProviderImpl", + "interface_name": "dojo::world::IWorldProvider" + }, + { + "type": "struct", + "name": "dojo::world::IWorldDispatcher", + "members": [ + { + "name": "contract_address", + "type": "core::starknet::contract_address::ContractAddress" + } + ] + }, + { + "type": "interface", + "name": "dojo::world::IWorldProvider", + "items": [ + { + "type": "function", + "name": "world", + "inputs": [], + "outputs": [ + { + "type": "dojo::world::IWorldDispatcher" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "IDojoInitImpl", + "interface_name": "dojo_examples::others::others::IDojoInit" + }, + { + "type": "interface", + "name": "dojo_examples::others::others::IDojoInit", + "items": [ + { + "type": "function", + "name": "dojo_init", + "inputs": [ + { + "name": "actions_address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "actions_class", + "type": "core::starknet::class_hash::ClassHash" + }, + { + "name": "value", + "type": "core::integer::u8" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "UpgradableImpl", + "interface_name": "dojo::components::upgradeable::IUpgradeable" + }, + { + "type": "interface", + "name": "dojo::components::upgradeable::IUpgradeable", + "items": [ + { + "type": "function", + "name": "upgrade", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "event", + "name": "dojo::components::upgradeable::upgradeable::Upgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::components::upgradeable::upgradeable::Event", + "kind": "enum", + "variants": [ + { + "name": "Upgraded", + "type": "dojo::components::upgradeable::upgradeable::Upgraded", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "dojo_examples::others::others::Event", + "kind": "enum", + "variants": [ + { + "name": "UpgradeableEvent", + "type": "dojo::components::upgradeable::upgradeable::Event", + "kind": "nested" + } + ] + } + ], + "reads": [], + "writes": [], + "computed": [], + "init_calldata": [ + "$contract_address:dojo_examples::actions::actions", + "$class_hash:dojo_examples::actions::actions", + "10" + ], + "name": "dojo_examples::others::others" + } + ], + "models": [ + { + "kind": "DojoModel", + "members": [ + { + "name": "player", + "type": "ContractAddress", + "key": true + }, + { + "name": "direction", + "type": "Direction", + "key": false + } + ], + "class_hash": "0x2c331d31a2f7233eb0c044c542d88a13b17d7f3e27b2922a404867279c21989", + "original_class_hash": "0x2c331d31a2f7233eb0c044c542d88a13b17d7f3e27b2922a404867279c21989", + "abi": [ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::IModel" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::database::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::database::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::database::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::IModel", + "items": [ + { + "type": "function", + "name": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "version", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u8" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "movedImpl", + "interface_name": "dojo_examples::actions::actions::Imoved" + }, + { + "type": "enum", + "name": "dojo_examples::models::Direction", + "variants": [ + { + "name": "None", + "type": "()" + }, + { + "name": "Left", + "type": "()" + }, + { + "name": "Right", + "type": "()" + }, + { + "name": "Up", + "type": "()" + }, + { + "name": "Down", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "dojo_examples::actions::actions::Moved", + "members": [ + { + "name": "player", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "direction", + "type": "dojo_examples::models::Direction" + } + ] + }, + { + "type": "interface", + "name": "dojo_examples::actions::actions::Imoved", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "dojo_examples::actions::actions::Moved" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "dojo_examples::actions::actions::moved::Event", + "kind": "enum", + "variants": [] + } + ], + "name": "dojo_examples::actions::actions::moved" + }, + { + "kind": "DojoModel", + "members": [ + { + "name": "identity", + "type": "ContractAddress", + "key": true + }, + { + "name": "emote", + "type": "Emote", + "key": false + } + ], + "class_hash": "0x6ffbf802dccf7a0828a57d41f13b56eeca63789efe3a6f7c60f7f374f1c310c", + "original_class_hash": "0x6ffbf802dccf7a0828a57d41f13b56eeca63789efe3a6f7c60f7f374f1c310c", + "abi": [ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::IModel" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::database::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::database::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::database::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::IModel", + "items": [ + { + "type": "function", + "name": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "version", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u8" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "emote_messageImpl", + "interface_name": "dojo_examples::models::Iemote_message" + }, + { + "type": "enum", + "name": "dojo_examples::models::Emote", + "variants": [ + { + "name": "None", + "type": "()" + }, + { + "name": "Happy", + "type": "()" + }, + { + "name": "Sad", + "type": "()" + }, + { + "name": "Angry", + "type": "()" + }, + { + "name": "Love", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "dojo_examples::models::EmoteMessage", + "members": [ + { + "name": "identity", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "emote", + "type": "dojo_examples::models::Emote" + } + ] + }, + { + "type": "interface", + "name": "dojo_examples::models::Iemote_message", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "dojo_examples::models::EmoteMessage" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "dojo_examples::models::emote_message::Event", + "kind": "enum", + "variants": [] + } + ], + "name": "dojo_examples::models::emote_message" + }, + { + "kind": "DojoModel", + "members": [ + { + "name": "player", + "type": "ContractAddress", + "key": true + }, + { + "name": "remaining", + "type": "u8", + "key": false + }, + { + "name": "last_direction", + "type": "Direction", + "key": false + } + ], + "class_hash": "0x779ad55281689e940e72d4da77daa436bbd45eaeb7ddc3bbde9dc2dffad9f6b", + "original_class_hash": "0x779ad55281689e940e72d4da77daa436bbd45eaeb7ddc3bbde9dc2dffad9f6b", + "abi": [ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::IModel" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::database::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::database::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::database::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::IModel", + "items": [ + { + "type": "function", + "name": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "version", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u8" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "movesImpl", + "interface_name": "dojo_examples::models::Imoves" + }, + { + "type": "enum", + "name": "dojo_examples::models::Direction", + "variants": [ + { + "name": "None", + "type": "()" + }, + { + "name": "Left", + "type": "()" + }, + { + "name": "Right", + "type": "()" + }, + { + "name": "Up", + "type": "()" + }, + { + "name": "Down", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "dojo_examples::models::Moves", + "members": [ + { + "name": "player", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "remaining", + "type": "core::integer::u8" + }, + { + "name": "last_direction", + "type": "dojo_examples::models::Direction" + } + ] + }, + { + "type": "interface", + "name": "dojo_examples::models::Imoves", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "dojo_examples::models::Moves" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "dojo_examples::models::moves::Event", + "kind": "enum", + "variants": [] + } + ], + "name": "dojo_examples::models::moves" + }, + { + "kind": "DojoModel", + "members": [ + { + "name": "player", + "type": "ContractAddress", + "key": true + }, + { + "name": "name", + "type": "ByteArray", + "key": false + }, + { + "name": "items", + "type": "Array", + "key": false + }, + { + "name": "favorite_item", + "type": "Option", + "key": false + } + ], + "class_hash": "0x5ce0a1e74d66aeca78fc09a73e7b1c49f67fca36753a5c0b0028be5a3da01ce", + "original_class_hash": "0x5ce0a1e74d66aeca78fc09a73e7b1c49f67fca36753a5c0b0028be5a3da01ce", + "abi": [ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::IModel" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::database::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::database::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::database::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::IModel", + "items": [ + { + "type": "function", + "name": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "version", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u8" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "player_configImpl", + "interface_name": "dojo_examples::models::Iplayer_config" + }, + { + "type": "struct", + "name": "dojo_examples::models::PlayerItem", + "members": [ + { + "name": "item_id", + "type": "core::integer::u32" + }, + { + "name": "quantity", + "type": "core::integer::u32" + } + ] + }, + { + "type": "struct", + "name": "dojo_examples::models::PlayerConfig", + "members": [ + { + "name": "player", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "name", + "type": "core::byte_array::ByteArray" + }, + { + "name": "items", + "type": "core::array::Array::" + }, + { + "name": "favorite_item", + "type": "core::option::Option::" + } + ] + }, + { + "type": "interface", + "name": "dojo_examples::models::Iplayer_config", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "dojo_examples::models::PlayerConfig" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "dojo_examples::models::player_config::Event", + "kind": "enum", + "variants": [] + } + ], + "name": "dojo_examples::models::player_config" + }, + { + "kind": "DojoModel", + "members": [ + { + "name": "player", + "type": "ContractAddress", + "key": true + }, + { + "name": "vec", + "type": "Vec2", + "key": false + } + ], + "class_hash": "0x602ea3f7ab1aa676845ad696165e72c518f1fb059f2d3eff1e1418f58c894e9", + "original_class_hash": "0x602ea3f7ab1aa676845ad696165e72c518f1fb059f2d3eff1e1418f58c894e9", + "abi": [ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::IModel" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::database::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::database::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::database::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::IModel", + "items": [ + { + "type": "function", + "name": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "version", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u8" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "positionImpl", + "interface_name": "dojo_examples::models::Iposition" + }, + { + "type": "struct", + "name": "dojo_examples::models::Vec2", + "members": [ + { + "name": "x", + "type": "core::integer::u32" + }, + { + "name": "y", + "type": "core::integer::u32" + } + ] + }, + { + "type": "struct", + "name": "dojo_examples::models::Position", + "members": [ + { + "name": "player", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "vec", + "type": "dojo_examples::models::Vec2" + } + ] + }, + { + "type": "interface", + "name": "dojo_examples::models::Iposition", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "dojo_examples::models::Position" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "dojo_examples::models::position::Event", + "kind": "enum", + "variants": [] + } + ], + "name": "dojo_examples::models::position" + }, + { + "kind": "DojoModel", + "members": [ + { + "name": "contract_address", + "type": "ContractAddress", + "key": true + }, + { + "name": "contract_class", + "type": "ClassHash", + "key": false + }, + { + "name": "value", + "type": "u8", + "key": false + } + ], + "class_hash": "0x71c8a02c5db4966da6ca1ff73125c0c31ec35298babf8e0814146898ab11092", + "original_class_hash": "0x71c8a02c5db4966da6ca1ff73125c0c31ec35298babf8e0814146898ab11092", + "abi": [ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::IModel" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::database::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::database::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::database::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::IModel", + "items": [ + { + "type": "function", + "name": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "version", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u8" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "contract_initializedImpl", + "interface_name": "dojo_examples::others::others::Icontract_initialized" + }, + { + "type": "struct", + "name": "dojo_examples::others::others::ContractInitialized", + "members": [ + { + "name": "contract_address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "contract_class", + "type": "core::starknet::class_hash::ClassHash" + }, + { + "name": "value", + "type": "core::integer::u8" + } + ] + }, + { + "type": "interface", + "name": "dojo_examples::others::others::Icontract_initialized", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "dojo_examples::others::others::ContractInitialized" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "dojo_examples::others::others::contract_initialized::Event", + "kind": "enum", + "variants": [] + } + ], + "name": "dojo_examples::others::others::contract_initialized" + } + ] +} \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/manifest.toml b/examples/spawn-and-move/manifests/dev/manifest.toml new file mode 100644 index 0000000000..0383195ee1 --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/manifest.toml @@ -0,0 +1,173 @@ +[world] +kind = "WorldContract" +class_hash = "0x5ea21a99b526829a2aee5704b92b67431dc54a8204621307208f382302bfe18" +original_class_hash = "0x5ea21a99b526829a2aee5704b92b67431dc54a8204621307208f382302bfe18" +abi = "manifests/dev/abis/deployments/dojo_world_world.json" +address = "0x62ab1d9dff4097a6662ffd8dc561a46aaabb398ef059bd6f696f3548c95835a" +transaction_hash = "0x4b69cfc5f9a36eaa92a30464f75169ac578319c5e34566b91b00f0df5749f60" +block_number = 3 +seed = "dojo_examples" +name = "dojo::world::world" + +[world.metadata] +profile_name = "dev" +rpc_url = "http://localhost:5050/" + +[base] +kind = "Class" +class_hash = "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46" +original_class_hash = "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46" +name = "dojo::base::base" + +[[contracts]] +kind = "DojoContract" +class_hash = "0x23fe3f856c7647f393a05606ad10481f98f13436d6bd844faad4f1d5aac17f9" +original_class_hash = "0x23fe3f856c7647f393a05606ad10481f98f13436d6bd844faad4f1d5aac17f9" +base_class_hash = "0x0" +abi = "manifests/dev/abis/deployments/contracts/dojo_examples_actions_actions.json" +reads = [] +writes = [ + "Moves", + "Position", +] +computed = [] +init_calldata = [] +name = "dojo_examples::actions::actions" + +[[contracts]] +kind = "DojoContract" +class_hash = "0x5c078c288959ffb9423a6c6557fcd38757e41570b271c63d7121080610c4ed4" +original_class_hash = "0x5c078c288959ffb9423a6c6557fcd38757e41570b271c63d7121080610c4ed4" +base_class_hash = "0x0" +abi = "manifests/dev/abis/deployments/contracts/dojo_examples_others_others.json" +reads = [] +writes = [] +computed = [] +init_calldata = [ + "$contract_address:dojo_examples::actions::actions", + "$class_hash:dojo_examples::actions::actions", + "10", +] +name = "dojo_examples::others::others" + +[[models]] +kind = "DojoModel" +class_hash = "0x2c331d31a2f7233eb0c044c542d88a13b17d7f3e27b2922a404867279c21989" +original_class_hash = "0x2c331d31a2f7233eb0c044c542d88a13b17d7f3e27b2922a404867279c21989" +abi = "manifests/dev/abis/deployments/models/dojo_examples_actions_actions_moved.json" +name = "dojo_examples::actions::actions::moved" + +[[models.members]] +name = "player" +type = "ContractAddress" +key = true + +[[models.members]] +name = "direction" +type = "Direction" +key = false + +[[models]] +kind = "DojoModel" +class_hash = "0x6ffbf802dccf7a0828a57d41f13b56eeca63789efe3a6f7c60f7f374f1c310c" +original_class_hash = "0x6ffbf802dccf7a0828a57d41f13b56eeca63789efe3a6f7c60f7f374f1c310c" +abi = "manifests/dev/abis/deployments/models/dojo_examples_models_emote_message.json" +name = "dojo_examples::models::emote_message" + +[[models.members]] +name = "identity" +type = "ContractAddress" +key = true + +[[models.members]] +name = "emote" +type = "Emote" +key = false + +[[models]] +kind = "DojoModel" +class_hash = "0x779ad55281689e940e72d4da77daa436bbd45eaeb7ddc3bbde9dc2dffad9f6b" +original_class_hash = "0x779ad55281689e940e72d4da77daa436bbd45eaeb7ddc3bbde9dc2dffad9f6b" +abi = "manifests/dev/abis/deployments/models/dojo_examples_models_moves.json" +name = "dojo_examples::models::moves" + +[[models.members]] +name = "player" +type = "ContractAddress" +key = true + +[[models.members]] +name = "remaining" +type = "u8" +key = false + +[[models.members]] +name = "last_direction" +type = "Direction" +key = false + +[[models]] +kind = "DojoModel" +class_hash = "0x5ce0a1e74d66aeca78fc09a73e7b1c49f67fca36753a5c0b0028be5a3da01ce" +original_class_hash = "0x5ce0a1e74d66aeca78fc09a73e7b1c49f67fca36753a5c0b0028be5a3da01ce" +abi = "manifests/dev/abis/deployments/models/dojo_examples_models_player_config.json" +name = "dojo_examples::models::player_config" + +[[models.members]] +name = "player" +type = "ContractAddress" +key = true + +[[models.members]] +name = "name" +type = "ByteArray" +key = false + +[[models.members]] +name = "items" +type = "Array" +key = false + +[[models.members]] +name = "favorite_item" +type = "Option" +key = false + +[[models]] +kind = "DojoModel" +class_hash = "0x602ea3f7ab1aa676845ad696165e72c518f1fb059f2d3eff1e1418f58c894e9" +original_class_hash = "0x602ea3f7ab1aa676845ad696165e72c518f1fb059f2d3eff1e1418f58c894e9" +abi = "manifests/dev/abis/deployments/models/dojo_examples_models_position.json" +name = "dojo_examples::models::position" + +[[models.members]] +name = "player" +type = "ContractAddress" +key = true + +[[models.members]] +name = "vec" +type = "Vec2" +key = false + +[[models]] +kind = "DojoModel" +class_hash = "0x71c8a02c5db4966da6ca1ff73125c0c31ec35298babf8e0814146898ab11092" +original_class_hash = "0x71c8a02c5db4966da6ca1ff73125c0c31ec35298babf8e0814146898ab11092" +abi = "manifests/dev/abis/deployments/models/dojo_examples_others_others_contract_initialized.json" +name = "dojo_examples::others::others::contract_initialized" + +[[models.members]] +name = "contract_address" +type = "ContractAddress" +key = true + +[[models.members]] +name = "contract_class" +type = "ClassHash" +key = false + +[[models.members]] +name = "value" +type = "u8" +key = false diff --git a/examples/spawn-and-move/src/actions.cairo b/examples/spawn-and-move/src/actions.cairo index 65dc16c55c..ec94a97287 100644 --- a/examples/spawn-and-move/src/actions.cairo +++ b/examples/spawn-and-move/src/actions.cairo @@ -119,7 +119,7 @@ mod tests { // models let mut models = array![position::TEST_CLASS_HASH, moves::TEST_CLASS_HASH,]; // deploy world with models - let world = spawn_test_world(models); + let world = spawn_test_world("dojo_examples", models); // deploy systems contract let contract_address = world