diff --git a/.vscode/launch.json b/.vscode/launch.json index 89693441c5..f141a5a8c7 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -23,6 +23,21 @@ "apply" ] }, + { + "name": "Sozo", + "type": "lldb", + "request": "launch", + "program": "${workspaceFolder}/target/debug/sozo", + "args": [ + "--manifest-path", + "examples/spawn-and-move/Scarb.toml", + "events", + "--world", + "0x04c972a756d796d716f665a8079dbf9aff05bbba41a2b8194553073f31d7d393", + "--chunk-size", + "100" + ] + }, { "type": "lldb", "request": "launch", diff --git a/Cargo.lock b/Cargo.lock index 3e5c038dd6..d391c7b86e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4606,6 +4606,7 @@ name = "dojo-lang" version = "0.7.0" 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)", @@ -4637,6 +4638,7 @@ dependencies = [ "num-traits 0.2.19", "once_cell", "pretty_assertions", + "regex", "salsa", "scarb", "semver 1.0.23", @@ -4645,6 +4647,7 @@ dependencies = [ "serde_with 2.3.3", "smol_str", "starknet", + "starknet-crypto 0.6.2", "test-log", "thiserror", "toml 0.8.13", @@ -12775,6 +12778,7 @@ dependencies = [ "dojo-world", "futures", "ipfs-api-backend-hyper", + "itertools 0.12.1", "katana-runner", "notify", "notify-debouncer-mini", diff --git a/bin/sozo/src/commands/model.rs b/bin/sozo/src/commands/model.rs index c14297034a..ce7b241063 100644 --- a/bin/sozo/src/commands/model.rs +++ b/bin/sozo/src/commands/model.rs @@ -2,6 +2,7 @@ use anyhow::Result; use clap::{Args, Subcommand}; use scarb::core::Config; use sozo_ops::model; +use sozo_ops::utils::get_default_namespace_from_ws; use starknet::core::types::FieldElement; use tracing::trace; @@ -22,6 +23,10 @@ pub enum ModelCommand { #[arg(help = "The name of the model")] name: String, + #[arg(short, long)] + #[arg(help = "The model namespace. If not set, the main package ID is used.")] + namespace: Option, + #[command(flatten)] world: WorldOptions, @@ -34,6 +39,10 @@ pub enum ModelCommand { #[arg(help = "The name of the model")] name: String, + #[arg(short, long)] + #[arg(help = "The model namespace. If not set, the main package ID is used.")] + namespace: Option, + #[command(flatten)] world: WorldOptions, @@ -65,6 +74,10 @@ hashes, called 'hash' in the following documentation. #[arg(help = "The name of the model")] name: String, + #[arg(short, long)] + #[arg(help = "The model namespace. If not set, the main package ID is used.")] + namespace: Option, + #[command(flatten)] world: WorldOptions, @@ -77,6 +90,10 @@ hashes, called 'hash' in the following documentation. #[arg(help = "The name of the model")] name: String, + #[arg(short, long)] + #[arg(help = "The model namespace. If not set, the main package ID is used.")] + namespace: Option, + #[command(flatten)] world: WorldOptions, @@ -93,6 +110,10 @@ hashes, called 'hash' in the following documentation. #[arg(help = "The name of the model")] name: String, + #[arg(short, long)] + #[arg(help = "The model namespace. If not set, the main package ID is used.")] + namespace: Option, + #[arg(value_name = "KEYS")] #[arg(value_delimiter = ',')] #[arg(help = "Comma seperated values e.g., 0x12345,0x69420,...")] @@ -109,34 +130,50 @@ hashes, called 'hash' in the following documentation. impl ModelArgs { pub fn run(self, config: &Config) -> Result<()> { trace!(args = ?self); + let ws = scarb::ops::read_workspace(config.manifest_path(), config)?; let env_metadata = utils::load_metadata_from_config(config)?; + let get_namespace = |ns: Option| -> String { + match ns { + Some(x) => x, + None => { + let default_namespace = get_default_namespace_from_ws(&ws); + println!("[default namespace: {}]", default_namespace); + default_namespace + } + } + }; config.tokio_handle().block_on(async { match self.command { - ModelCommand::ClassHash { name, starknet, world } => { + ModelCommand::ClassHash { name, namespace, starknet, world } => { + let namespace = get_namespace(namespace); let world_address = world.address(env_metadata.as_ref()).unwrap(); let provider = starknet.provider(env_metadata.as_ref()).unwrap(); - model::model_class_hash(name, world_address, provider).await + model::model_class_hash(namespace, name, world_address, provider).await } - ModelCommand::ContractAddress { name, starknet, world } => { + ModelCommand::ContractAddress { name, namespace, starknet, world } => { + let namespace = get_namespace(namespace); let world_address = world.address(env_metadata.as_ref()).unwrap(); let provider = starknet.provider(env_metadata.as_ref()).unwrap(); - model::model_contract_address(name, world_address, provider).await + model::model_contract_address(namespace, name, world_address, provider).await } - ModelCommand::Layout { name, starknet, world } => { + ModelCommand::Layout { name, namespace, starknet, world } => { + let namespace = get_namespace(namespace); let world_address = world.address(env_metadata.as_ref()).unwrap(); let provider = starknet.provider(env_metadata.as_ref()).unwrap(); - model::model_layout(name, world_address, provider).await + model::model_layout(namespace, name, world_address, provider).await } - ModelCommand::Schema { name, to_json, starknet, world } => { + ModelCommand::Schema { name, namespace, to_json, starknet, world } => { + let namespace = get_namespace(namespace); let world_address = world.address(env_metadata.as_ref()).unwrap(); let provider = starknet.provider(env_metadata.as_ref()).unwrap(); - model::model_schema(name, world_address, provider, to_json).await + model::model_schema(namespace, name, world_address, provider, to_json).await } - ModelCommand::Get { name, keys, starknet, world } => { + ModelCommand::Get { name, namespace, keys, starknet, world } => { + let namespace = get_namespace(namespace); let world_address = world.address(env_metadata.as_ref()).unwrap(); let provider = starknet.provider(env_metadata.as_ref()).unwrap(); - model::model_get(name, keys, world_address, provider).await + model::model_get(namespace, name, keys, world_address, provider).await } } }) diff --git a/bin/sozo/tests/register_test.rs b/bin/sozo/tests/register_test.rs index 8cc161abee..32ab4f2ba4 100644 --- a/bin/sozo/tests/register_test.rs +++ b/bin/sozo/tests/register_test.rs @@ -8,6 +8,7 @@ use dojo_world::migration::TxnConfig; use katana_runner::KatanaRunner; use scarb::ops; use sozo_ops::migration::execute_strategy; +use sozo_ops::utils::get_default_namespace_from_ws; use starknet::accounts::Account; use starknet::core::types::{BlockId, BlockTag}; use utils::snapbox::get_snapbox; @@ -27,9 +28,15 @@ async fn reregister_models() { let target_path = ws.target_dir().path_existent().unwrap().join(ws.config().profile().to_string()); - let migration = - prepare_migration(source_project_dir.clone(), target_path, dojo_metadata.skip_migration) - .unwrap(); + let default_namespace = get_default_namespace_from_ws(&ws); + + let migration = prepare_migration( + source_project_dir.clone(), + target_path, + dojo_metadata.skip_migration, + &default_namespace, + ) + .unwrap(); let sequencer = KatanaRunner::new().expect("Failed to start runner."); 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-bindgen/src/lib.rs b/crates/dojo-bindgen/src/lib.rs index c8cbe96172..5e30b2df79 100644 --- a/crates/dojo-bindgen/src/lib.rs +++ b/crates/dojo-bindgen/src/lib.rs @@ -5,10 +5,10 @@ use std::path::PathBuf; use cainome::parser::tokens::Token; use cainome::parser::{AbiParser, TokenizedAbi}; use camino::Utf8PathBuf; -use convert_case::{Case, Casing}; use dojo_world::manifest::BaseManifest; pub mod error; -use error::{BindgenResult, Error}; +use dojo_world::utils::get_full_world_element_name; +use error::BindgenResult; mod plugins; use plugins::typescript::TypescriptPlugin; @@ -151,7 +151,10 @@ fn gather_dojo_data( } } - let contract_name = contract_manifest.name.to_string(); + let contract_name = get_full_world_element_name( + &contract_manifest.inner.namespace, + &contract_manifest.inner.name, + ); contracts.insert( contract_name.clone(), @@ -170,26 +173,18 @@ fn gather_dojo_data( let tokens = AbiParser::tokens_from_abi_string(&abi, &HashMap::new())?; - let name = model_manifest.name.to_string(); - - if let Some(model_name) = model_name_from_fully_qualified_path(&name) { - let model_pascal_case = model_name.from_case(Case::Snake).to_case(Case::Pascal); + let full_name = get_full_world_element_name( + &model_manifest.inner.namespace, + &model_manifest.inner.name, + ); - let model = DojoModel { - name: model_pascal_case.clone(), - qualified_path: name - .replace(&model_name, &model_pascal_case) - .trim_end_matches(".json") - .to_string(), - tokens: filter_model_tokens(&tokens), - }; + let model = DojoModel { + name: full_name.clone(), + qualified_path: full_name.clone(), + tokens: filter_model_tokens(&tokens), + }; - models.insert(model_pascal_case, model); - } else { - return Err(Error::Format(format!( - "Could not extract model name from file name `{name}`" - ))); - } + models.insert(full_name, model); } let world = DojoWorld { name: root_package_name.to_string() }; @@ -234,23 +229,6 @@ fn filter_model_tokens(tokens: &TokenizedAbi) -> TokenizedAbi { TokenizedAbi { structs, enums, ..Default::default() } } -/// Extracts a model name from the fully qualified path of the model. -/// -/// # Example -/// -/// The fully qualified name "dojo_examples::models::position" should return "position". -/// -/// # Arguments -/// -/// * `file_name` - Fully qualified model name. -fn model_name_from_fully_qualified_path(file_name: &str) -> Option { - let parts: Vec<&str> = file_name.split("::").collect(); - - // TODO: we may want to have inside the manifest the name of the model struct - // instead of extracting it from the file's name. - parts.last().map(|last_part| last_part.to_string()) -} - #[cfg(test)] mod tests { use dojo_test_utils::compiler; @@ -258,12 +236,6 @@ mod tests { use super::*; - #[test] - fn model_name_from_fully_qualified_path_ok() { - let file_name = "dojo_examples::models::position"; - assert_eq!(model_name_from_fully_qualified_path(file_name), Some("position".to_string())); - } - #[test] fn gather_data_ok() { let manifest_path = Utf8PathBuf::from("src/test_data/spawn-and-move/Scarb.toml"); diff --git a/crates/dojo-core/src/base_test.cairo b/crates/dojo-core/src/base_test.cairo index a90d40b071..6b2ac1aa07 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 { 0x1b1edb46931b1a98d8c6ecf2703e8483ec1d85fb75b3e9c061eab383fc8f8f1 } + 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. - 0x1b1edb46931b1a98d8c6ecf2703e8483ec1d85fb75b3e9c061eab383fc8f8f1 + 0x314a23ab2b297b235fe87bf5acade82bcef62e3a375183ab7bf1fe0a3f5e8dd + } + + 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 934e3619c7..6b1ec7a929 100644 --- a/crates/dojo-core/src/model.cairo +++ b/crates/dojo-core/src/model.cairo @@ -5,10 +5,24 @@ trait Model { fn entity( world: IWorldDispatcher, keys: Span, layout: dojo::database::introspect::Layout ) -> T; + + /// Returns the name of the model as it was written in Cairo code. fn name() -> ByteArray; fn version() -> u8; + + /// Returns the model selector built from its name and its namespace. + /// model selector = hash(hash(namespace_name), hash(model_name)) fn selector() -> felt252; fn instance_selector(self: @T) -> felt252; + + /// Returns the namespace of the model as it was written in the `dojo::model` attribute. + /// only lower case characters (a-z) and underscore (_) are allowed. + fn namespace() -> ByteArray; + + /// Returns the model namespace selector built from its namespace. + /// namespace_selector = hash(namespace_name) + fn namespace_selector() -> felt252; + fn keys(self: @T) -> Span; fn values(self: @T) -> Span; fn layout() -> dojo::database::introspect::Layout; @@ -21,6 +35,8 @@ trait IModel { fn selector(self: @T) -> felt252; 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; @@ -36,12 +52,14 @@ 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)> { +) -> SyscallResult<(starknet::ContractAddress, ByteArray, felt252, ByteArray, felt252)> { let (contract_address, _) = starknet::deploy_syscall( class_hash, salt, array![].span(), false, )?; let model = IModelDispatcher { contract_address }; let name = model.name(); let selector = model.selector(); - Result::Ok((contract_address, name, selector)) + let namespace = model.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 16935479b8..479a8e9344 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; - +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); @@ -60,7 +57,9 @@ impl ResourceMetadataModel of dojo::model::Model { #[inline(always)] fn selector() -> felt252 { - RESOURCE_METADATA_SELECTOR + poseidon::poseidon_hash_span( + array![Self::namespace_selector(), dojo::utils::hash(@Self::name())].span() + ) } #[inline(always)] @@ -68,6 +67,14 @@ impl ResourceMetadataModel of dojo::model::Model { Self::selector() } + fn namespace() -> ByteArray { + "__DOJO__" + } + + fn namespace_selector() -> felt252 { + dojo::utils::hash(@Self::namespace()) + } + #[inline(always)] fn keys(self: @ResourceMetadata) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -145,7 +152,6 @@ impl ResourceMetadataIntrospect<> of dojo::database::introspect::Introspect ByteArray { + ResourceMetadataModel::namespace() + } + #[external(v0)] fn unpacked_size(self: @ContractState) -> Option { dojo::database::introspect::Introspect::::size() diff --git a/crates/dojo-core/src/test_utils.cairo b/crates/dojo-core/src/test_utils.cairo index 0079e18429..ac5bdcb7a0 100644 --- a/crates/dojo-core/src/test_utils.cairo +++ b/crates/dojo-core/src/test_utils.cairo @@ -40,7 +40,7 @@ fn deploy_with_world_address(class_hash: felt252, world: IWorldDispatcher) -> 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..2a28ed4546 --- /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 e58610bdec..f0382fbb1f 100644 --- a/crates/dojo-core/src/world.cairo +++ b/crates/dojo-core/src/world.cairo @@ -9,6 +9,7 @@ trait IWorld { fn set_metadata(ref self: T, metadata: ResourceMetadata); fn model(self: @T, selector: felt252) -> (ClassHash, ContractAddress); fn register_model(ref self: T, class_hash: ClassHash); + fn register_namespace(ref self: T, namespace: ByteArray); fn deploy_contract( ref self: T, salt: felt252, class_hash: ClassHash, init_calldata: Span ) -> ContractAddress; @@ -29,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] @@ -53,13 +62,33 @@ trait IDojoResourceProvider { fn dojo_resource(self: @T) -> felt252; } +#[starknet::interface] +trait INamespace { + /// Returns the namespace of a contract. + /// only lower case characters (a-z) and underscore (_) are allowed. + fn namespace(self: @T) -> ByteArray; + + /// Returns the namespace selector built from its name. + /// namespace_selector = hash(namespace_name) + fn namespace_selector(self: @T) -> felt252; +} + 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] @@ -85,15 +114,16 @@ mod world { use dojo::database; use dojo::database::introspect::{Introspect, Layout, FieldLayout}; use dojo::components::upgradeable::{IUpgradeableDispatcher, IUpgradeableDispatcherTrait}; + use super::{INamespaceDispatcher, INamespaceDispatcherImpl}; 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; @@ -112,12 +142,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, @@ -148,6 +179,7 @@ mod world { salt: felt252, class_hash: ClassHash, address: ContractAddress, + namespace: ByteArray, } #[derive(Drop, starknet::Event)] @@ -162,9 +194,16 @@ 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, + namespace: ByteArray, class_hash: ClassHash, prev_class_hash: ClassHash, address: ContractAddress, @@ -186,7 +225,7 @@ mod world { #[derive(Drop, starknet::Event)] struct WriterUpdated { - model: felt252, + resource: felt252, contract: ContractAddress, value: bool } @@ -203,8 +242,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)] @@ -212,17 +250,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); self.config.initializer(creator); @@ -239,7 +305,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() ); @@ -258,7 +324,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); @@ -289,16 +358,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 }); @@ -307,72 +377,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 { model, contract, value: 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) + } + } + + /// 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, @@ -385,7 +541,8 @@ mod world { let caller = get_caller_address(); let salt = self.models_count.read(); - let (address, name, selector) = 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(); @@ -396,31 +553,75 @@ 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 { name, prev_address, address, class_hash, prev_class_hash } + ModelRegistered { + name, namespace, prev_address, address, class_hash, prev_class_hash + } ); } + /// 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 @@ -431,7 +632,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. @@ -458,6 +664,18 @@ mod world { let upgradeable_dispatcher = IUpgradeableDispatcher { contract_address }; upgradeable_dispatcher.upgrade(class_hash); + // namespace checking + let namespace_dispatcher = INamespaceDispatcher { contract_address }; + let namespace = namespace_dispatcher.namespace(); + let namespace_selector = namespace_dispatcher.namespace_selector(); + 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 self.initialized_contract.read(contract_address.into()) { panic!("Contract has already been initialized"); } else { @@ -468,10 +686,11 @@ 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 } + ref self, + ContractDeployed { salt, class_hash, address: contract_address, namespace } ); contract_address @@ -490,7 +709,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 @@ -536,7 +755,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 }); @@ -557,7 +778,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 }); @@ -605,10 +828,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(); @@ -674,37 +894,117 @@ 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 model write access. + /// That means, check if: + /// - the calling contract has the writer role for the model OR, + /// - the calling account has the owner and/or writer role for the model OR, + /// - the calling contract has the writer role for the model namespace OR + /// - the calling account has the owner and/or writer role for the model namespace. + /// + /// # Arguments + /// * `model_id` - the model selector to check. + /// * `model_address` - the model contract address. + /// * `contract` - the calling contract. + /// + /// # Returns + /// `true` if the write access is allowed, false otherwise. + /// + 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) + && !self.is_account_writer(model_id) { + let model = IModelDispatcher { contract_address: model_address }; + self._check_basic_write_access(model.namespace_selector(), contract) + } else { + true + } + } + + /// Check basic resource write access. + /// That means, check if: + /// - the calling contract has the writer role for the resource OR, + /// - the calling account has the owner and/or writer role for the resource. + /// + /// # Arguments + /// * `resource_id` - the resource selector to check. + /// * `contract` - the calling contract. + /// + /// # Returns + /// `true` if the write access is allowed, false otherwise. + /// + 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) + || self.is_account_writer(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 4d8829410e..585133be78 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}; @@ -43,6 +44,16 @@ struct Foo { b: u128, } +#[derive(Copy, Drop, Serde)] +#[dojo::model(namespace: "another_namespace")] +struct Buzz { + #[key] + caller: ContractAddress, + a: felt252, + b: u128, +} + + fn create_foo() -> Span { array![1, 2].span() } @@ -248,6 +259,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] @@ -258,7 +271,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 { @@ -302,7 +323,7 @@ mod bar { .world .read() .delete_entity( - selector!("Foo"), + dojo::model::Model::::selector(), array![get_caller_address().into()].span(), dojo::model::Model::::layout() ); @@ -408,7 +429,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'); } @@ -423,6 +444,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() { @@ -472,7 +553,7 @@ fn test_set_entity_unauthorized() { // Utils fn deploy_world() -> IWorldDispatcher { - spawn_test_world(array![]) + spawn_test_world("dojo", array![]) } #[test] @@ -492,13 +573,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); @@ -507,18 +588,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(); @@ -543,6 +624,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()); @@ -552,24 +636,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] @@ -579,7 +665,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'); @@ -591,28 +677,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); @@ -620,13 +717,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>(); @@ -653,14 +750,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) @@ -682,7 +779,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) }; @@ -703,30 +800,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; @@ -845,6 +918,9 @@ trait IDojoInit { #[dojo::contract] mod test_contract {} +#[dojo::contract(namespace: "buzz_namespace")] +mod buzz_contract {} + #[test] #[available_gas(6000000)] #[should_panic(expected: ('Only world can init', 'ENTRYPOINT_FAILED'))] @@ -863,14 +939,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); } @@ -880,7 +954,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(); @@ -896,7 +970,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(); @@ -912,7 +986,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(); @@ -936,7 +1010,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(); @@ -952,7 +1026,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(); @@ -968,7 +1042,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(); @@ -984,7 +1058,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(); @@ -1011,7 +1085,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(); @@ -1034,13 +1108,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); @@ -1055,7 +1128,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(); @@ -1075,7 +1148,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(); @@ -1098,7 +1171,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(); @@ -1122,7 +1195,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(); @@ -1143,7 +1216,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(); @@ -1165,7 +1238,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(); @@ -1186,7 +1259,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(); @@ -1207,7 +1280,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(); @@ -1235,7 +1308,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 ); } @@ -1251,7 +1327,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 ); } @@ -1265,7 +1344,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] @@ -1278,7 +1360,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] @@ -1291,7 +1376,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] @@ -1304,7 +1389,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); } @@ -1312,22 +1397,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] @@ -1336,7 +1412,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 @@ -1353,7 +1429,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 @@ -1370,10 +1446,201 @@ 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); +} + +#[test] +#[should_panic(expected: ('namespace not registered', 'ENTRYPOINT_FAILED',))] +fn test_register_model_with_unregistered_namespace() { + let world = deploy_world(); + world.register_model(buzz::TEST_CLASS_HASH.try_into().unwrap()); +} + +#[test] +fn test_deploy_contract_for_namespace_owner() { + let world = deploy_world(); + + let account = starknet::contract_address_const::<0xb0b>(); + world.grant_owner(account, dojo::utils::hash(@"dojo")); + + // the account owns the 'test_contract' namespace so it should be able to deploy + // and register the model. + starknet::testing::set_account_contract_address(account); + + world + .deploy_contract( + 'salt1', test_contract::TEST_CLASS_HASH.try_into().unwrap(), array![].span() + ); +} + +#[test] +fn test_deploy_contract_for_namespace_writer() { + let world = deploy_world(); + + let account = starknet::contract_address_const::<0xb0b>(); + world.grant_writer(dojo::utils::hash(@"dojo"), account); + + // the account has write access to the 'test_contract' namespace so it should be able + // to deploy and register the model. + starknet::testing::set_account_contract_address(account); + + world + .deploy_contract( + 'salt1', test_contract::TEST_CLASS_HASH.try_into().unwrap(), array![].span() + ); +} + +#[test] +#[should_panic(expected: ('namespace not registered', 'ENTRYPOINT_FAILED',))] +fn test_deploy_contract_with_unregistered_namespace() { + let world = deploy_world(); + world + .deploy_contract( + 'salt1', buzz_contract::TEST_CLASS_HASH.try_into().unwrap(), array![].span() + ); +} + +#[test] +#[should_panic(expected: ('no namespace write access', 'ENTRYPOINT_FAILED',))] +fn test_deploy_contract_no_namespace_write_access() { + let world = deploy_world(); + + let account = starknet::contract_address_const::<0xb0b>(); + starknet::testing::set_account_contract_address(account); + + world + .deploy_contract( + 'salt1', test_contract::TEST_CLASS_HASH.try_into().unwrap(), array![].span() + ); +} + diff --git a/crates/dojo-lang/Cargo.toml b/crates/dojo-lang/Cargo.toml index 2f7b17357a..3738efc206 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 @@ -38,6 +39,7 @@ itertools.workspace = true lazy_static.workspace = true num-traits.workspace = true once_cell.workspace = true +regex.workspace = true salsa.workspace = true scarb.workspace = true semver.workspace = true @@ -46,6 +48,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/compiler.rs b/crates/dojo-lang/src/compiler.rs index e21edfe2bb..da9ca24ead 100644 --- a/crates/dojo-lang/src/compiler.rs +++ b/crates/dojo-lang/src/compiler.rs @@ -13,17 +13,16 @@ use cairo_lang_formatter::format_string; use cairo_lang_semantic::db::SemanticGroup; use cairo_lang_starknet::compile::compile_prepared_db; use cairo_lang_starknet::contract::{find_contracts, ContractDeclaration}; -use cairo_lang_starknet::plugin::aux_data::StarkNetContractAuxData; use cairo_lang_starknet_classes::abi; use cairo_lang_starknet_classes::contract_class::ContractClass; use cairo_lang_utils::UpcastMut; use camino::{Utf8Path, Utf8PathBuf}; -use convert_case::{Case, Casing}; use dojo_world::manifest::{ AbiFormat, Class, ComputedValueEntrypoint, DojoContract, DojoModel, Manifest, ManifestMethods, ABIS_DIR, BASE_CONTRACT_NAME, BASE_DIR, CONTRACTS_DIR, MANIFESTS_DIR, MODELS_DIR, WORLD_CONTRACT_NAME, }; +use dojo_world::utils::{get_artifact_name, get_full_world_element_name, get_manifest_name}; use itertools::Itertools; use scarb::compiler::helpers::{build_compiler_config, collect_main_crate_ids}; use scarb::compiler::{CairoCompilationUnit, CompilationUnitAttributes, Compiler}; @@ -36,7 +35,7 @@ use starknet::core::types::FieldElement; use tracing::{debug, trace, trace_span}; use crate::inline_macros::utils::{SYSTEM_READS, SYSTEM_WRITES}; -use crate::plugin::{ComputedValuesAuxData, DojoAuxData}; +use crate::plugin::{ComputedValuesAuxData, DojoAuxData, Model, SystemAuxData}; use crate::semantics::utils::find_module_rw; const CAIRO_PATH_SEPARATOR: &str = "::"; @@ -258,7 +257,8 @@ fn update_manifest( &mut Manifest::new( // abi path will be written by `write_manifest` Class { class_hash: *hash, abi: None, original_class_hash: *hash }, - WORLD_CONTRACT_NAME.into(), + WORLD_CONTRACT_NAME.replace("::", "_"), + WORLD_CONTRACT_NAME.to_string(), ), abi, )?; @@ -270,7 +270,8 @@ fn update_manifest( &manifest_dir, &mut Manifest::new( Class { class_hash: *hash, abi: None, original_class_hash: *hash }, - BASE_CONTRACT_NAME.into(), + BASE_CONTRACT_NAME.replace("::", "_"), + BASE_CONTRACT_NAME.to_string(), ), &None, )?; @@ -293,22 +294,23 @@ fn update_manifest( .filter_map(|info| info.as_ref().map(|i| &i.aux_data)) .filter_map(|aux_data| aux_data.as_ref().map(|aux_data| aux_data.0.as_any())) { - if let Some(aux_data) = aux_data.downcast_ref::() { - contracts.extend(get_dojo_contract_artifacts( - db, - module_id, - aux_data, - &compiled_artifacts, - )?); - } if let Some(aux_data) = aux_data.downcast_ref::() { get_dojo_computed_values(db, module_id, aux_data, &mut computed); } if let Some(dojo_aux_data) = aux_data.downcast_ref::() { + for system in &dojo_aux_data.systems { + contracts.extend(get_dojo_contract_artifacts( + db, + module_id, + system, + &compiled_artifacts, + )?); + } + models.extend(get_dojo_model_artifacts( db, - dojo_aux_data, + &dojo_aux_data.models, *module_id, &compiled_artifacts, )?); @@ -317,9 +319,13 @@ fn update_manifest( } } + // `get_dojo_computed_values()` uses the module name as contract name to build the `computed` + // variable. That means, the namespace of the contract is not taken into account, + // but should be retrieved from the dojo::contract attribute. computed.into_iter().for_each(|(contract, computed_value_entrypoint)| { - let contract_data = - contracts.get_mut(&contract).expect("Error: Computed value contract doesn't exist."); + let contract_data = contracts + .get_mut(&contract.to_string()) + .expect("Error: Computed value contract doesn't exist."); contract_data.0.inner.computed = computed_value_entrypoint; }); @@ -355,42 +361,46 @@ fn update_manifest( #[allow(clippy::type_complexity)] fn get_dojo_model_artifacts( db: &RootDatabase, - aux_data: &DojoAuxData, + aux_data: &Vec, module_id: ModuleId, compiled_classes: &HashMap)>, ) -> anyhow::Result, Option)>> { - let mut models = HashMap::with_capacity(aux_data.models.len()); + let mut models = HashMap::with_capacity(aux_data.len()); let module_name = module_id.full_path(db); let module_name = module_name.as_str(); - for model in &aux_data.models { + for model in aux_data { if let Ok(Some(ModuleItemId::Struct(_))) = db.module_item_by_name(module_id, model.name.clone().into()) { - let model_contract_name = model.name.to_case(Case::Snake); - let model_full_name = format!("{module_name}::{}", &model_contract_name); + let full_model_name = get_full_world_element_name(&model.namespace, &model.name); + let manifest_name = get_manifest_name(&model.namespace, &model.name); + let artifact_name = get_artifact_name(module_name, &model.name); - let compiled_class = compiled_classes.get(model_full_name.as_str()).cloned(); + let compiled_class = compiled_classes.get(artifact_name.as_str()).cloned(); if let Some((class_hash, abi)) = compiled_class { models.insert( - model_full_name.clone(), + full_model_name.clone(), ( Manifest::new( DojoModel { + name: model.name.clone(), + namespace: model.namespace.clone(), class_hash, abi: None, members: model.members.clone(), original_class_hash: class_hash, }, - model_full_name.into(), + manifest_name, + artifact_name, ), abi, ), ); } else { - println!("Model {} not found in target.", model_full_name.clone()); + println!("Model {} not found in target.", full_model_name.clone()); } } } @@ -415,6 +425,7 @@ fn get_dojo_computed_values( computed_vals.push(ComputedValueEntrypoint { contract: module_name, entrypoint: aux_data.entrypoint.clone(), + namespace: aux_data.namespace.clone(), model: aux_data.model.clone(), }) } @@ -424,17 +435,21 @@ fn get_dojo_computed_values( fn get_dojo_contract_artifacts( db: &RootDatabase, module_id: &ModuleId, - aux_data: &StarkNetContractAuxData, + aux_data: &SystemAuxData, compiled_classes: &HashMap)>, -) -> anyhow::Result, Option)>> { - let contract_name = &aux_data.contract_name; +) -> anyhow::Result, Option)>> { + let contract_name = &aux_data.name; + let namespace = &aux_data.namespace; + let full_contract_name = get_full_world_element_name(namespace, contract_name); + let manifest_name = get_manifest_name(namespace, contract_name); let mut result = HashMap::new(); if !matches!(contract_name.as_ref(), "world" | "resource_metadata" | "base") { let module_name: SmolStr = module_id.full_path(db).into(); + let artifact_name = get_artifact_name(&module_name, contract_name); - if let Some((class_hash, abi)) = compiled_classes.get(&module_name as &str) { + if let Some((class_hash, abi)) = compiled_classes.get(&artifact_name as &str) { let reads = SYSTEM_READS .lock() .unwrap() @@ -451,16 +466,19 @@ fn get_dojo_contract_artifacts( let manifest = Manifest::new( DojoContract { + name: contract_name.to_string(), + namespace: namespace.to_string(), writes, reads, class_hash: *class_hash, original_class_hash: *class_hash, ..Default::default() }, - module_name.clone(), + manifest_name.to_string(), + artifact_name.to_string(), ); - result.insert(module_name, (manifest, abi.clone())); + result.insert(full_contract_name.to_string(), (manifest, abi.clone())); } } @@ -477,10 +495,10 @@ fn write_manifest_and_abi( where T: Serialize + DeserializeOwned + ManifestMethods, { - let name = manifest.name.to_string().replace("::", "_"); - - let relative_manifest_path = relative_manifest_dir.join(name.clone()).with_extension("toml"); - let relative_abi_path = relative_abis_dir.join(name.clone()).with_extension("json"); + let relative_manifest_path = + relative_manifest_dir.join(manifest.manifest_name.clone()).with_extension("toml"); + let relative_abi_path = + relative_abis_dir.join(manifest.manifest_name.clone()).with_extension("json"); if abi.is_some() { manifest.inner.set_abi(Some(AbiFormat::Path(relative_abi_path.clone()))); diff --git a/crates/dojo-lang/src/contract.rs b/crates/dojo-lang/src/contract.rs index c2a9c292ff..b43ac9fb75 100644 --- a/crates/dojo-lang/src/contract.rs +++ b/crates/dojo-lang/src/contract.rs @@ -4,17 +4,27 @@ use cairo_lang_defs::patcher::{PatchBuilder, RewriteNode}; use cairo_lang_defs::plugin::{ DynGeneratedFileAuxData, PluginDiagnostic, PluginGeneratedFile, PluginResult, }; -use cairo_lang_syntax::node::ast::MaybeModuleBody; +use cairo_lang_diagnostics::Severity; +use cairo_lang_syntax::node::ast::{ArgClause, Expr, MaybeModuleBody, OptionArgListParenthesized}; use cairo_lang_syntax::node::db::SyntaxGroup; +use cairo_lang_syntax::node::helpers::QueryAttrs; use cairo_lang_syntax::node::{ast, ids, Terminal, TypedStablePtr, TypedSyntaxNode}; use cairo_lang_utils::unordered_hash_map::UnorderedHashMap; use dojo_types::system::Dependency; +use dojo_world::utils::compute_bytearray_hash; -use crate::plugin::{DojoAuxData, SystemAuxData}; +use crate::plugin::{DojoAuxData, SystemAuxData, DOJO_CONTRACT_ATTR}; use crate::syntax::world_param::{self, WorldParamInjectionKind}; use crate::syntax::{self_param, utils as syntax_utils}; +use crate::utils::is_namespace_valid; const DOJO_INIT_FN: &str = "dojo_init"; +const CONTRACT_NAMESPACE: &str = "namespace"; + +#[derive(Clone, Default)] +pub struct ContractParameters { + namespace: Option, +} pub struct DojoContract { diagnostics: Vec, @@ -22,14 +32,45 @@ pub struct DojoContract { } impl DojoContract { - pub fn from_module(db: &dyn SyntaxGroup, module_ast: ast::ItemModule) -> PluginResult { + pub fn from_module( + db: &dyn SyntaxGroup, + module_ast: &ast::ItemModule, + package_id: String, + ) -> PluginResult { let name = module_ast.name(db).text(db); - let mut system = DojoContract { diagnostics: vec![], dependencies: HashMap::new() }; + let mut diagnostics = vec![]; + let parameters = get_parameters(db, module_ast, &mut diagnostics); + + let mut system = DojoContract { diagnostics, dependencies: HashMap::new() }; + let mut has_event = false; let mut has_storage = false; let mut has_init = false; + let contract_namespace = match parameters.namespace { + Some(x) => x.to_string(), + None => package_id, + }; + + if !is_namespace_valid(&contract_namespace) { + return PluginResult { + code: None, + diagnostics: vec![PluginDiagnostic { + stable_ptr: module_ast.stable_ptr().0, + message: format!( + "The contract namespace '{}' can only contain lower case characters (a-z) \ + and underscore (_)", + &contract_namespace, + ), + severity: Severity::Error, + }], + remove_original_item: false, + }; + } + + let contract_namespace_selector = compute_bytearray_hash(&contract_namespace); + if let MaybeModuleBody::Some(body) = module_ast.body(db) { let mut body_nodes: Vec<_> = body .items(db) @@ -99,7 +140,7 @@ impl DojoContract { body_nodes.append(&mut system.create_storage()) } - let mut builder = PatchBuilder::new(db, &module_ast); + let mut builder = PatchBuilder::new(db, module_ast); builder.add_modified(RewriteNode::interpolate_patched( " #[starknet::contract] @@ -109,7 +150,7 @@ impl DojoContract { use dojo::world::IWorldDispatcherTrait; use dojo::world::IWorldProvider; use dojo::world::IDojoResourceProvider; - + use dojo::world::INamespace; component!(path: dojo::components::upgradeable::upgradeable, storage: \ upgradeable, event: UpgradeableEvent); @@ -121,6 +162,17 @@ impl DojoContract { } } + #[abi(embed_v0)] + impl NamespaceImpl of INamespace { + fn namespace(self: @ContractState) -> ByteArray { + \"$contract_namespace$\" + } + + fn namespace_selector(self: @ContractState) -> felt252 { + $contract_namespace_selector$ + } + } + #[abi(embed_v0)] impl WorldProviderImpl of IWorldProvider { fn world(self: @ContractState) -> IWorldDispatcher { @@ -138,6 +190,14 @@ impl DojoContract { &UnorderedHashMap::from([ ("name".to_string(), RewriteNode::Text(name.to_string())), ("body".to_string(), RewriteNode::new_modified(body_nodes)), + ( + "contract_namespace".to_string(), + RewriteNode::Text(contract_namespace.clone()), + ), + ( + "contract_namespace_selector".to_string(), + RewriteNode::Text(contract_namespace_selector.to_string()), + ), ]), )); @@ -151,6 +211,7 @@ impl DojoContract { models: vec![], systems: vec![SystemAuxData { name, + namespace: contract_namespace.clone(), dependencies: system.dependencies.values().cloned().collect(), }], events: vec![], @@ -445,3 +506,104 @@ impl DojoContract { vec![RewriteNode::Copied(impl_ast.as_syntax_node())] } } + +/// Get the contract namespace from the `Expr` parameter. +fn get_contract_namespace( + db: &dyn SyntaxGroup, + arg_value: Expr, + diagnostics: &mut Vec, +) -> Option { + match arg_value { + Expr::ShortString(ss) => Some(ss.string_value(db).unwrap()), + Expr::String(s) => Some(s.string_value(db).unwrap()), + _ => { + diagnostics.push(PluginDiagnostic { + message: format!( + "The argument '{}' of dojo::contract must be a string", + CONTRACT_NAMESPACE + ), + stable_ptr: arg_value.stable_ptr().untyped(), + severity: Severity::Error, + }); + Option::None + } + } +} + +/// Get parameters of the dojo::contract attribute. +/// +/// Parameters: +/// * db: The semantic database. +/// * module_ast: The AST of the contract module. +/// * diagnostics: vector of compiler diagnostics. +/// +/// Returns: +/// * A [`ContractParameters`] object containing all the dojo::contract parameters with their +/// default values if not set in the code. +fn get_parameters( + db: &dyn SyntaxGroup, + module_ast: &ast::ItemModule, + diagnostics: &mut Vec, +) -> ContractParameters { + let mut parameters = ContractParameters::default(); + let mut processed_args: HashMap = HashMap::new(); + + if let OptionArgListParenthesized::ArgListParenthesized(arguments) = + module_ast.attributes(db).query_attr(db, DOJO_CONTRACT_ATTR).first().unwrap().arguments(db) + { + arguments.arguments(db).elements(db).iter().for_each(|a| match a.arg_clause(db) { + ArgClause::Named(x) => { + let arg_name = x.name(db).text(db).to_string(); + let arg_value = x.value(db); + + if processed_args.contains_key(&arg_name) { + diagnostics.push(PluginDiagnostic { + message: format!("Too many '{}' attributes for dojo::contract", arg_name), + stable_ptr: module_ast.stable_ptr().untyped(), + severity: Severity::Error, + }); + } else { + processed_args.insert(arg_name.clone(), true); + + match arg_name.as_str() { + CONTRACT_NAMESPACE => { + parameters.namespace = + get_contract_namespace(db, arg_value, diagnostics); + } + _ => { + diagnostics.push(PluginDiagnostic { + message: format!( + "Unexpected argument '{}' for dojo::contract", + arg_name + ), + stable_ptr: x.stable_ptr().untyped(), + severity: Severity::Warning, + }); + } + } + } + } + ArgClause::Unnamed(arg) => { + let arg_name = arg.value(db).as_syntax_node().get_text(db); + + diagnostics.push(PluginDiagnostic { + message: format!("Unexpected argument '{}' for dojo::contract", arg_name), + stable_ptr: arg.stable_ptr().untyped(), + severity: Severity::Warning, + }); + } + ArgClause::FieldInitShorthand(x) => { + diagnostics.push(PluginDiagnostic { + message: format!( + "Unexpected argument '{}' for dojo::contract", + x.name(db).name(db).text(db).to_string() + ), + stable_ptr: x.stable_ptr().untyped(), + severity: Severity::Warning, + }); + } + }) + } + + parameters +} diff --git a/crates/dojo-lang/src/lib.rs b/crates/dojo-lang/src/lib.rs index 4f7e0e4bca..4ed4b70c41 100644 --- a/crates/dojo-lang/src/lib.rs +++ b/crates/dojo-lang/src/lib.rs @@ -14,6 +14,7 @@ pub mod plugin; pub mod print; pub mod semantics; pub mod syntax; +pub mod utils; pub(crate) mod version; // Copy of non pub functions from scarb + extension. 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 c1a2447839..1eb99602ad 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" } ] }, @@ -692,6 +764,11 @@ "name": "address", "type": "core::starknet::contract_address::ContractAddress", "kind": "data" + }, + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "data" } ] }, @@ -741,6 +818,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", @@ -751,6 +845,11 @@ "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", @@ -818,7 +917,7 @@ "kind": "struct", "members": [ { - "name": "model", + "name": "resource", "type": "core::felt252", "kind": "data" }, @@ -956,6 +1055,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_base_base.toml b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo_base_base.toml index 6c4b5de67e..b322f99931 100644 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo_base_base.toml +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo_base_base.toml @@ -1,4 +1,5 @@ kind = "Class" class_hash = "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46" original_class_hash = "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46" -name = "dojo::base::base" +manifest_name = "dojo_base_base" +artifact_name = "dojo::base::base" 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 2555ec3eda..828e04961b 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,6 @@ kind = "Class" -class_hash = "0x3f63cecdc4964acafb921ba2934c6507d1b3c344edb64c2762cf08053169ab9" -original_class_hash = "0x3f63cecdc4964acafb921ba2934c6507d1b3c344edb64c2762cf08053169ab9" +class_hash = "0x1c3b775fc1586641eb7e83b2f3eaa573dc492e64ae9ce16fdeaabf525486895" +original_class_hash = "0x1c3b775fc1586641eb7e83b2f3eaa573dc492e64ae9ce16fdeaabf525486895" abi = "manifests/dev/abis/base/dojo_world_world.json" -name = "dojo::world::world" +manifest_name = "dojo_world_world" +artifact_name = "dojo::world::world" diff --git a/crates/dojo-lang/src/model.rs b/crates/dojo-lang/src/model.rs index dab07e5efe..5901e53990 100644 --- a/crates/dojo-lang/src/model.rs +++ b/crates/dojo-lang/src/model.rs @@ -10,21 +10,24 @@ 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::utils::get_selector_from_name; +use dojo_world::utils::{compute_bytearray_hash, compute_model_selector_from_hash}; use crate::plugin::{DojoAuxData, Model, DOJO_MODEL_ATTR}; +use crate::utils::is_namespace_valid; const DEFAULT_MODEL_VERSION: u8 = 1; const MODEL_VERSION_NAME: &str = "version"; +const MODEL_NAMESPACE: &str = "namespace"; struct ModelParameters { version: u8, + namespace: Option, } impl Default for ModelParameters { fn default() -> ModelParameters { - ModelParameters { version: DEFAULT_MODEL_VERSION } + ModelParameters { version: DEFAULT_MODEL_VERSION, namespace: Option::None } } } @@ -73,6 +76,29 @@ fn get_model_version( } } +/// Get the model namespace from the `Expr` parameter. +fn get_model_namespace( + db: &dyn SyntaxGroup, + arg_value: Expr, + diagnostics: &mut Vec, +) -> Option { + match arg_value { + Expr::ShortString(ss) => Some(ss.string_value(db).unwrap()), + Expr::String(s) => Some(s.string_value(db).unwrap()), + _ => { + diagnostics.push(PluginDiagnostic { + message: format!( + "The argument '{}' of dojo::model must be a string", + MODEL_NAMESPACE + ), + stable_ptr: arg_value.stable_ptr().untyped(), + severity: Severity::Error, + }); + Option::None + } + } +} + /// Get parameters of the dojo::model attribute. /// /// Note: dojo::model attribute has already been checked so there is one and only one attribute. @@ -114,6 +140,9 @@ fn get_model_parameters( MODEL_VERSION_NAME => { parameters.version = get_model_version(db, arg_value, diagnostics); } + MODEL_NAMESPACE => { + parameters.namespace = get_model_namespace(db, arg_value, diagnostics); + } _ => { diagnostics.push(PluginDiagnostic { message: format!( @@ -163,17 +192,44 @@ pub fn handle_model_struct( db: &dyn SyntaxGroup, aux_data: &mut DojoAuxData, struct_ast: ItemStruct, + package_id: String, ) -> (RewriteNode, Vec) { let mut diagnostics = vec![]; let parameters = get_model_parameters(db, struct_ast.clone(), &mut diagnostics); let model_name = struct_ast.name(db).as_syntax_node().get_text(db).trim().to_string(); + let model_namespace = match parameters.namespace { + Option::Some(x) => x, + Option::None => package_id, + }; + + if !is_namespace_valid(&model_namespace) { + return ( + RewriteNode::empty(), + vec![PluginDiagnostic { + stable_ptr: struct_ast.name(db).stable_ptr().0, + message: format!( + "The model namespace '{}' can only contain lower case characters (a-z) and \ + underscore (_)", + &model_namespace + ) + .to_string(), + severity: Severity::Error, + }], + ); + } + + let model_name_hash = compute_bytearray_hash(&model_name); + let model_namespace_hash = compute_bytearray_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(get_selector_from_name(model_name.as_str()).unwrap().to_string()), + RewriteNode::Text( + compute_model_selector_from_hash(model_namespace_hash, model_name_hash).to_string(), + ), ), }; @@ -242,7 +298,11 @@ pub fn handle_model_struct( members.iter().filter_map(|m| serialize_member(m, false)).collect::<_>(); let name = struct_ast.name(db).text(db); - aux_data.models.push(Model { name: name.to_string(), members: members.to_vec() }); + aux_data.models.push(Model { + name: name.to_string(), + namespace: model_namespace.clone(), + members: members.to_vec(), + }); ( RewriteNode::interpolate_patched( @@ -250,8 +310,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. @@ -292,6 +356,16 @@ impl $type_name$Model of dojo::model::Model<$type_name$> { Self::selector() } + #[inline(always)] + fn namespace() -> ByteArray { + \"$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(); @@ -360,7 +434,15 @@ mod $contract_name$ { fn version(self: @ContractState) -> u8 { dojo::model::Model::<$type_name$>::version() } + + fn namespace(self: @ContractState) -> ByteArray { + 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() } @@ -393,6 +475,11 @@ mod $contract_name$ { ("serialized_values".to_string(), RewriteNode::new_modified(serialized_values)), ("model_version".to_string(), model_version), ("model_selector".to_string(), model_selector), + ("model_namespace".to_string(), RewriteNode::Text(model_namespace.clone())), + ( + "model_namespace_hash".to_string(), + RewriteNode::Text(model_namespace_hash.to_string()), + ), ]), ), diagnostics, diff --git a/crates/dojo-lang/src/plugin.rs b/crates/dojo-lang/src/plugin.rs index fdd7d28419..d5872e3556 100644 --- a/crates/dojo-lang/src/plugin.rs +++ b/crates/dojo-lang/src/plugin.rs @@ -17,6 +17,7 @@ use cairo_lang_syntax::node::ids::SyntaxStablePtrId; use cairo_lang_syntax::node::{ast, Terminal, TypedSyntaxNode}; use dojo_types::system::Dependency; use dojo_world::manifest::Member; +use dojo_world::utils::split_full_world_element_name; use scarb::compiler::plugin::builtin::BuiltinStarkNetPlugin; use scarb::compiler::plugin::{CairoPlugin, CairoPluginInstance}; use scarb::core::{PackageId, PackageName, SourceId}; @@ -34,6 +35,7 @@ use crate::interface::DojoInterface; use crate::introspect::{handle_introspect_enum, handle_introspect_struct}; use crate::model::handle_model_struct; use crate::print::{handle_print_enum, handle_print_struct}; +use crate::utils::get_package_id; pub const DOJO_CONTRACT_ATTR: &str = "dojo::contract"; pub const DOJO_INTERFACE_ATTR: &str = "dojo::interface"; @@ -46,12 +48,14 @@ pub const DOJO_PACKED_ATTR: &str = "IntrospectPacked"; #[derive(Clone, Debug, PartialEq)] pub struct Model { pub name: String, + pub namespace: String, pub members: Vec, } #[derive(Debug, PartialEq, Eq)] pub struct SystemAuxData { pub name: SmolStr, + pub namespace: String, pub dependencies: Vec, } @@ -81,6 +85,7 @@ pub struct ComputedValuesAuxData { // Name of entrypoint to get computed value pub entrypoint: SmolStr, // Model to bind to + pub namespace: Option, pub model: Option, } @@ -103,9 +108,14 @@ pub const PACKAGE_NAME: &str = "dojo_plugin"; pub struct BuiltinDojoPlugin; impl BuiltinDojoPlugin { - fn handle_mod(&self, db: &dyn SyntaxGroup, module_ast: ast::ItemModule) -> PluginResult { + fn handle_mod( + &self, + db: &dyn SyntaxGroup, + module_ast: ast::ItemModule, + package_id: String, + ) -> PluginResult { if module_ast.has_attr(db, DOJO_CONTRACT_ATTR) { - return DojoContract::from_module(db, module_ast); + return DojoContract::from_module(db, &module_ast, package_id); } PluginResult::default() @@ -133,7 +143,12 @@ impl BuiltinDojoPlugin { } } - fn handle_fn(&self, db: &dyn SyntaxGroup, fn_ast: ast::FunctionWithBody) -> PluginResult { + fn handle_fn( + &self, + db: &dyn SyntaxGroup, + fn_ast: ast::FunctionWithBody, + package_id: String, + ) -> PluginResult { let attrs = fn_ast.attributes(db).query_attr(db, "computed"); if attrs.is_empty() { return PluginResult::default(); @@ -157,9 +172,19 @@ impl BuiltinDojoPlugin { let params = fn_decl.signature(db).parameters(db); let param_els = params.elements(db); let mut model = None; + let mut namespace = None; if args.len() == 1 { let model_name = args[0].text(db); - model = Some(model_name.clone()); + match split_full_world_element_name(&model_name, &package_id) { + Ok((ns, n)) => { + model = Some(n); + namespace = Some(ns); + } + Err(e) => { + return self.result_with_diagnostic(attr.args_stable_ptr.0, e.to_string()); + } + }; + let model_type_node = param_els[1].type_clause(db).ty(db); if let ast::Expr::Path(model_type_path) = model_type_node { let model_type = model_type_path @@ -169,7 +194,7 @@ impl BuiltinDojoPlugin { .unwrap() .as_syntax_node() .get_text(db); - if model_type != model_name { + if model_type != model_name.clone() { return self.result_with_diagnostic( model_type_path.stable_ptr().0, "Computed functions second parameter should be the model.".into(), @@ -197,6 +222,7 @@ impl BuiltinDojoPlugin { name: fn_name.clone(), content: "".into(), aux_data: Some(DynGeneratedFileAuxData::new(ComputedValuesAuxData { + namespace, model, entrypoint: fn_name, })), @@ -325,8 +351,25 @@ impl MacroPlugin for BuiltinDojoPlugin { item_ast: ast::ModuleItem, _metadata: &MacroPluginMetadata<'_>, ) -> PluginResult { + let package_id = match get_package_id(db) { + Option::Some(x) => x, + Option::None => { + return PluginResult { + code: Option::None, + diagnostics: vec![PluginDiagnostic { + stable_ptr: item_ast.stable_ptr().0, + message: "Unable to find the package ID. Be sure to have a 'package.name' \ + field in your Scarb.toml file." + .into(), + severity: Severity::Error, + }], + remove_original_item: false, + }; + } + }; + match item_ast { - ast::ModuleItem::Module(module_ast) => self.handle_mod(db, module_ast), + ast::ModuleItem::Module(module_ast) => self.handle_mod(db, module_ast, package_id), ast::ModuleItem::Trait(trait_ast) => self.handle_trait(db, trait_ast), ast::ModuleItem::Enum(enum_ast) => { let aux_data = DojoAuxData::default(); @@ -466,7 +509,7 @@ impl MacroPlugin for BuiltinDojoPlugin { match model_attrs.len().cmp(&1) { Ordering::Equal => { let (model_rewrite_nodes, model_diagnostics) = - handle_model_struct(db, &mut aux_data, struct_ast.clone()); + handle_model_struct(db, &mut aux_data, struct_ast.clone(), package_id); rewrite_nodes.push(model_rewrite_nodes); diagnostics.extend(model_diagnostics); } @@ -504,7 +547,7 @@ impl MacroPlugin for BuiltinDojoPlugin { remove_original_item: false, } } - ast::ModuleItem::FreeFunction(fn_ast) => self.handle_fn(db, fn_ast), + ast::ModuleItem::FreeFunction(fn_ast) => self.handle_fn(db, fn_ast, package_id), _ => PluginResult::default(), } } diff --git a/crates/dojo-lang/src/plugin_test_data/model b/crates/dojo-lang/src/plugin_test_data/model index 092bee2438..4069d28e2d 100644 --- a/crates/dojo-lang/src/plugin_test_data/model +++ b/crates/dojo-lang/src/plugin_test_data/model @@ -61,6 +61,27 @@ struct Modelv0 { v: Vec3, } +#[dojo::model(namespace: 'MyNamespace')] +struct ModelWithBadNamespaceFormat { + #[key] + id: felt252, + v: Vec3, +} + +#[dojo::model(namespace: 'my_namespace')] +struct ModelWithShortStringNamespace { + #[key] + id: felt252, + v: Vec3, +} + +#[dojo::model(namespace: "my_namespace")] +struct ModelWithStringNamespace { + #[key] + id: felt252, + v: Vec3, +} + #[dojo::model] struct Position { #[key] @@ -195,6 +216,27 @@ struct Modelv0 { v: Vec3, } +#[dojo::model(namespace: 'MyNamespace')] +struct ModelWithBadNamespaceFormat { + #[key] + id: felt252, + v: Vec3, +} + +#[dojo::model(namespace: 'my_namespace')] +struct ModelWithShortStringNamespace { + #[key] + id: felt252, + v: Vec3, +} + +#[dojo::model(namespace: "my_namespace")] +struct ModelWithStringNamespace { + #[key] + id: felt252, + v: Vec3, +} + #[dojo::model] struct Position { #[key] @@ -355,7 +397,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. @@ -395,6 +442,16 @@ impl BadModelMultipleVersionsModel of dojo::model::Model ByteArray { + "dojo_plugin" + } + + #[inline(always)] + fn namespace_selector() -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + #[inline(always)] fn keys(self: @BadModelMultipleVersions) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -463,7 +520,15 @@ mod bad_model_multiple_versions { fn version(self: @ContractState) -> u8 { dojo::model::Model::::version() } + + fn namespace(self: @ContractState) -> ByteArray { + 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() } @@ -531,7 +596,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, 537246025350462187868458942885902086202425585541495898150877285881426926523, 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. @@ -563,7 +633,7 @@ impl BadModelBadVersionTypeModel of dojo::model::Model { #[inline(always)] fn selector() -> felt252 { - 537246025350462187868458942885902086202425585541495898150877285881426926523 + 1257444965375069225632929782137899434201314657712945575000402601057577969467 } #[inline(always)] @@ -571,6 +641,16 @@ impl BadModelBadVersionTypeModel of dojo::model::Model { Self::selector() } + #[inline(always)] + fn namespace() -> ByteArray { + "dojo_plugin" + } + + #[inline(always)] + fn namespace_selector() -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + #[inline(always)] fn keys(self: @BadModelBadVersionType) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -639,7 +719,15 @@ mod bad_model_bad_version_type { fn version(self: @ContractState) -> u8 { dojo::model::Model::::version() } + + fn namespace(self: @ContractState) -> ByteArray { + 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() } @@ -707,7 +795,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, 510884764440804248641145470106421715520498065640762121627610646122289418442, 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. @@ -739,7 +832,7 @@ impl BadModelNoVersionValueModel of dojo::model::Model { #[inline(always)] fn selector() -> felt252 { - 510884764440804248641145470106421715520498065640762121627610646122289418442 + 3373097771824053354196231469173076752789704424742154674493295341772858104830 } #[inline(always)] @@ -747,6 +840,16 @@ impl BadModelNoVersionValueModel of dojo::model::Model { Self::selector() } + #[inline(always)] + fn namespace() -> ByteArray { + "dojo_plugin" + } + + #[inline(always)] + fn namespace_selector() -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + #[inline(always)] fn keys(self: @BadModelNoVersionValue) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -815,7 +918,15 @@ mod bad_model_no_version_value { fn version(self: @ContractState) -> u8 { dojo::model::Model::::version() } + + fn namespace(self: @ContractState) -> ByteArray { + 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() } @@ -883,7 +994,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, 609798817400410974332175542242790740792842310475593325422194044359199941027, 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. @@ -915,7 +1031,7 @@ impl BadModelUnexpectedArgWithValueModel of dojo::model::Model felt252 { - 609798817400410974332175542242790740792842310475593325422194044359199941027 + 3590405629214068034212593672218295377527112441964389853941077460616482660871 } #[inline(always)] @@ -923,6 +1039,16 @@ impl BadModelUnexpectedArgWithValueModel of dojo::model::Model ByteArray { + "dojo_plugin" + } + + #[inline(always)] + fn namespace_selector() -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + #[inline(always)] fn keys(self: @BadModelUnexpectedArgWithValue) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -991,7 +1117,15 @@ mod bad_model_unexpected_arg_with_value { fn version(self: @ContractState) -> u8 { dojo::model::Model::::version() } + + fn namespace(self: @ContractState) -> ByteArray { + 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() } @@ -1059,7 +1193,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, 949097735839867165379372628344008784789919991740118948112868710933218930849, 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. @@ -1091,7 +1230,7 @@ impl BadModelUnexpectedArgModel of dojo::model::Model { #[inline(always)] fn selector() -> felt252 { - 949097735839867165379372628344008784789919991740118948112868710933218930849 + 1096230073778795894347893795076822536130165745015118585791241737691598280119 } #[inline(always)] @@ -1099,6 +1238,16 @@ impl BadModelUnexpectedArgModel of dojo::model::Model { Self::selector() } + #[inline(always)] + fn namespace() -> ByteArray { + "dojo_plugin" + } + + #[inline(always)] + fn namespace_selector() -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + #[inline(always)] fn keys(self: @BadModelUnexpectedArg) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -1167,32 +1316,438 @@ mod bad_model_unexpected_arg { fn version(self: @ContractState) -> u8 { dojo::model::Model::::version() } + + fn namespace(self: @ContractState) -> ByteArray { + 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() + } + + fn packed_size(self: @ContractState) -> Option { + dojo::model::Model::::packed_size() + } + + fn layout(self: @ContractState) -> dojo::database::introspect::Layout { + dojo::model::Model::::layout() + } + + fn schema(self: @ContractState) -> dojo::database::introspect::Ty { + dojo::database::introspect::Introspect::::ty() + } + } + + #[abi(embed_v0)] + impl bad_model_unexpected_argImpl of Ibad_model_unexpected_arg{ + fn ensure_abi(self: @ContractState, model: BadModelUnexpectedArg) { + } + } +} + +impl BadModelNotSupportedVersionIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + dojo::database::introspect::Introspect::::size() + } + + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Struct( + array![ + dojo::database::introspect::FieldLayout { + selector: 578691550836206188651404750433984985630363913126316857592149308417275000080, + layout: dojo::database::introspect::Introspect::::layout() + } + ].span() + ) + } + + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Struct( + dojo::database::introspect::Struct { + name: 'BadModelNotSupportedVersion', + attrs: array![].span(), + children: array![ + dojo::database::introspect::Member { + name: 'id', + attrs: array!['key'].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'v', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::::ty() + } + + ].span() + } + ) + } +} + +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, + Self::selector(), + keys, + layout + ); + + // TODO: Generate method to deserialize from keys / values directly to avoid + // serializing to intermediate array. + let mut serialized = core::array::ArrayTrait::new(); + core::array::serialize_array_helper(keys, ref serialized); + core::array::serialize_array_helper(values, ref serialized); + let mut serialized = core::array::ArrayTrait::span(@serialized); + + let entity = core::serde::Serde::::deserialize(ref serialized); + + if core::option::OptionTrait::::is_none(@entity) { + panic!( + "Model `BadModelNotSupportedVersion`: deserialization failed. Ensure the length of the keys tuple is matching the number of #[key] fields in the model struct." + ); + } + + core::option::OptionTrait::::unwrap(entity) + } + + #[inline(always)] + fn name() -> ByteArray { + "BadModelNotSupportedVersion" + } + + #[inline(always)] + fn version() -> u8 { + 1 + } + + #[inline(always)] + fn selector() -> felt252 { + 2618259498257511987977711074037130039442899457131070784132500210658539158686 + } + + #[inline(always)] + fn instance_selector(self: @BadModelNotSupportedVersion) -> felt252 { + Self::selector() + } + + #[inline(always)] + fn namespace() -> ByteArray { + "dojo_plugin" + } + + #[inline(always)] + fn namespace_selector() -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + + #[inline(always)] + fn keys(self: @BadModelNotSupportedVersion) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::array::ArrayTrait::append(ref serialized, *self.id); + core::array::ArrayTrait::span(@serialized) + } + + #[inline(always)] + fn values(self: @BadModelNotSupportedVersion) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.v, ref serialized); + core::array::ArrayTrait::span(@serialized) + } + + #[inline(always)] + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Introspect::::layout() + } + + #[inline(always)] + fn instance_layout(self: @BadModelNotSupportedVersion) -> dojo::database::introspect::Layout { + Self::layout() + } + + #[inline(always)] + fn packed_size() -> Option { + let layout = Self::layout(); + + match layout { + dojo::database::introspect::Layout::Fixed(layout) => { + let mut span_layout = layout; + Option::Some(dojo::packing::calculate_packed_size(ref span_layout)) + }, + dojo::database::introspect::Layout::Struct(_) => Option::None, + dojo::database::introspect::Layout::Array(_) => Option::None, + dojo::database::introspect::Layout::Tuple(_) => Option::None, + dojo::database::introspect::Layout::Enum(_) => Option::None, + dojo::database::introspect::Layout::ByteArray => Option::None, + } + } +} + +#[starknet::interface] +trait Ibad_model_not_supported_version { + fn ensure_abi(self: @T, model: BadModelNotSupportedVersion); +} + +#[starknet::contract] +mod bad_model_not_supported_version { + use super::BadModelNotSupportedVersion; + use super::Ibad_model_not_supported_version; + + #[storage] + struct Storage {} + + #[abi(embed_v0)] + impl DojoModelImpl of dojo::model::IModel{ + fn selector(self: @ContractState) -> felt252 { + dojo::model::Model::::selector() + } + + fn name(self: @ContractState) -> ByteArray { + dojo::model::Model::::name() + } + + fn version(self: @ContractState) -> u8 { + dojo::model::Model::::version() + } + + fn namespace(self: @ContractState) -> ByteArray { + 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() + } + + fn packed_size(self: @ContractState) -> Option { + dojo::model::Model::::packed_size() + } + + fn layout(self: @ContractState) -> dojo::database::introspect::Layout { + dojo::model::Model::::layout() + } + + fn schema(self: @ContractState) -> dojo::database::introspect::Ty { + dojo::database::introspect::Introspect::::ty() + } + } + + #[abi(embed_v0)] + impl bad_model_not_supported_versionImpl of Ibad_model_not_supported_version{ + fn ensure_abi(self: @ContractState, model: BadModelNotSupportedVersion) { + } + } +} + +impl Modelv0Introspect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + dojo::database::introspect::Introspect::::size() + } + + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Struct( + array![ + dojo::database::introspect::FieldLayout { + selector: 578691550836206188651404750433984985630363913126316857592149308417275000080, + layout: dojo::database::introspect::Introspect::::layout() + } + ].span() + ) + } + + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Struct( + dojo::database::introspect::Struct { + name: 'Modelv0', + attrs: array![].span(), + children: array![ + dojo::database::introspect::Member { + name: 'id', + attrs: array!['key'].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'v', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::::ty() + } + + ].span() + } + ) + } +} + +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, + Self::selector(), + keys, + layout + ); + + // TODO: Generate method to deserialize from keys / values directly to avoid + // serializing to intermediate array. + let mut serialized = core::array::ArrayTrait::new(); + core::array::serialize_array_helper(keys, ref serialized); + core::array::serialize_array_helper(values, ref serialized); + let mut serialized = core::array::ArrayTrait::span(@serialized); + + let entity = core::serde::Serde::::deserialize(ref serialized); + + if core::option::OptionTrait::::is_none(@entity) { + panic!( + "Model `Modelv0`: deserialization failed. Ensure the length of the keys tuple is matching the number of #[key] fields in the model struct." + ); + } + + core::option::OptionTrait::::unwrap(entity) + } + + #[inline(always)] + fn name() -> ByteArray { + "Modelv0" + } + + #[inline(always)] + fn version() -> u8 { + 0 + } + + #[inline(always)] + fn selector() -> felt252 { + "Modelv0" + } + + #[inline(always)] + fn instance_selector(self: @Modelv0) -> felt252 { + Self::selector() + } + + #[inline(always)] + fn namespace() -> ByteArray { + "dojo_plugin" + } + + #[inline(always)] + fn namespace_selector() -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + + #[inline(always)] + fn keys(self: @Modelv0) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::array::ArrayTrait::append(ref serialized, *self.id); + core::array::ArrayTrait::span(@serialized) + } + + #[inline(always)] + fn values(self: @Modelv0) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.v, ref serialized); + core::array::ArrayTrait::span(@serialized) + } + + #[inline(always)] + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Introspect::::layout() + } + + #[inline(always)] + fn instance_layout(self: @Modelv0) -> dojo::database::introspect::Layout { + Self::layout() + } + + #[inline(always)] + fn packed_size() -> Option { + let layout = Self::layout(); + + match layout { + dojo::database::introspect::Layout::Fixed(layout) => { + let mut span_layout = layout; + Option::Some(dojo::packing::calculate_packed_size(ref span_layout)) + }, + dojo::database::introspect::Layout::Struct(_) => Option::None, + dojo::database::introspect::Layout::Array(_) => Option::None, + dojo::database::introspect::Layout::Tuple(_) => Option::None, + dojo::database::introspect::Layout::Enum(_) => Option::None, + dojo::database::introspect::Layout::ByteArray => Option::None, + } + } +} + +#[starknet::interface] +trait Imodelv_0 { + fn ensure_abi(self: @T, model: Modelv0); +} + +#[starknet::contract] +mod modelv_0 { + use super::Modelv0; + use super::Imodelv_0; + + #[storage] + struct Storage {} + + #[abi(embed_v0)] + impl DojoModelImpl of dojo::model::IModel{ + fn selector(self: @ContractState) -> felt252 { + dojo::model::Model::::selector() + } + + fn name(self: @ContractState) -> ByteArray { + dojo::model::Model::::name() + } + fn version(self: @ContractState) -> u8 { + dojo::model::Model::::version() + } + + fn namespace(self: @ContractState) -> ByteArray { + 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() + dojo::database::introspect::Introspect::::size() } fn packed_size(self: @ContractState) -> Option { - dojo::model::Model::::packed_size() + dojo::model::Model::::packed_size() } fn layout(self: @ContractState) -> dojo::database::introspect::Layout { - dojo::model::Model::::layout() + dojo::model::Model::::layout() } fn schema(self: @ContractState) -> dojo::database::introspect::Ty { - dojo::database::introspect::Introspect::::ty() + dojo::database::introspect::Introspect::::ty() } } #[abi(embed_v0)] - impl bad_model_unexpected_argImpl of Ibad_model_unexpected_arg{ - fn ensure_abi(self: @ContractState, model: BadModelUnexpectedArg) { + impl modelv_0Impl of Imodelv_0{ + fn ensure_abi(self: @ContractState, model: Modelv0) { } } } -impl BadModelNotSupportedVersionIntrospect<> of dojo::database::introspect::Introspect> { +impl ModelWithBadNamespaceFormatIntrospect<> of dojo::database::introspect::Introspect> { #[inline(always)] fn size() -> Option { dojo::database::introspect::Introspect::::size() @@ -1213,7 +1768,48 @@ impl BadModelNotSupportedVersionIntrospect<> of dojo::database::introspect::Intr fn ty() -> dojo::database::introspect::Ty { dojo::database::introspect::Ty::Struct( dojo::database::introspect::Struct { - name: 'BadModelNotSupportedVersion', + name: 'ModelWithBadNamespaceFormat', + attrs: array![].span(), + children: array![ + dojo::database::introspect::Member { + name: 'id', + attrs: array!['key'].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'v', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::::ty() + } + + ].span() + } + ) + } +} + +impl ModelWithShortStringNamespaceIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + dojo::database::introspect::Introspect::::size() + } + + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Struct( + array![ + dojo::database::introspect::FieldLayout { + selector: 578691550836206188651404750433984985630363913126316857592149308417275000080, + layout: dojo::database::introspect::Introspect::::layout() + } + ].span() + ) + } + + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Struct( + dojo::database::introspect::Struct { + name: 'ModelWithShortStringNamespace', attrs: array![].span(), children: array![ dojo::database::introspect::Member { @@ -1233,9 +1829,14 @@ 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, 1024306429832444281478160321067399481685861686361100808176928576017034183663, keys, layout); +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, + Self::selector(), + keys, + layout + ); // TODO: Generate method to deserialize from keys / values directly to avoid // serializing to intermediate array. @@ -1244,20 +1845,20 @@ impl BadModelNotSupportedVersionModel of dojo::model::Model::deserialize(ref serialized); + let entity = core::serde::Serde::::deserialize(ref serialized); - if core::option::OptionTrait::::is_none(@entity) { + if core::option::OptionTrait::::is_none(@entity) { panic!( - "Model `BadModelNotSupportedVersion`: deserialization failed. Ensure the length of the keys tuple is matching the number of #[key] fields in the model struct." + "Model `ModelWithShortStringNamespace`: deserialization failed. Ensure the length of the keys tuple is matching the number of #[key] fields in the model struct." ); } - core::option::OptionTrait::::unwrap(entity) + core::option::OptionTrait::::unwrap(entity) } #[inline(always)] fn name() -> ByteArray { - "BadModelNotSupportedVersion" + "ModelWithShortStringNamespace" } #[inline(always)] @@ -1267,23 +1868,33 @@ impl BadModelNotSupportedVersionModel of dojo::model::Model felt252 { - 1024306429832444281478160321067399481685861686361100808176928576017034183663 + 643350075018191729855964658181798951445581630505240307235771395728709379388 } #[inline(always)] - fn instance_selector(self: @BadModelNotSupportedVersion) -> felt252 { + fn instance_selector(self: @ModelWithShortStringNamespace) -> felt252 { Self::selector() } #[inline(always)] - fn keys(self: @BadModelNotSupportedVersion) -> Span { + fn namespace() -> ByteArray { + "my_namespace" + } + + #[inline(always)] + fn namespace_selector() -> felt252 { + 1685136890688416384941629523783652800960468745356230625531475538826800548713 + } + + #[inline(always)] + fn keys(self: @ModelWithShortStringNamespace) -> Span { let mut serialized = core::array::ArrayTrait::new(); core::array::ArrayTrait::append(ref serialized, *self.id); core::array::ArrayTrait::span(@serialized) } #[inline(always)] - fn values(self: @BadModelNotSupportedVersion) -> Span { + fn values(self: @ModelWithShortStringNamespace) -> Span { let mut serialized = core::array::ArrayTrait::new(); core::serde::Serde::serialize(self.v, ref serialized); core::array::ArrayTrait::span(@serialized) @@ -1291,11 +1902,11 @@ impl BadModelNotSupportedVersionModel of dojo::model::Model dojo::database::introspect::Layout { - dojo::database::introspect::Introspect::::layout() + dojo::database::introspect::Introspect::::layout() } #[inline(always)] - fn instance_layout(self: @BadModelNotSupportedVersion) -> dojo::database::introspect::Layout { + fn instance_layout(self: @ModelWithShortStringNamespace) -> dojo::database::introspect::Layout { Self::layout() } @@ -1318,14 +1929,14 @@ impl BadModelNotSupportedVersionModel of dojo::model::Model { - fn ensure_abi(self: @T, model: BadModelNotSupportedVersion); +trait Imodel_with_short_string_namespace { + fn ensure_abi(self: @T, model: ModelWithShortStringNamespace); } #[starknet::contract] -mod bad_model_not_supported_version { - use super::BadModelNotSupportedVersion; - use super::Ibad_model_not_supported_version; +mod model_with_short_string_namespace { + use super::ModelWithShortStringNamespace; + use super::Imodel_with_short_string_namespace; #[storage] struct Storage {} @@ -1333,42 +1944,50 @@ mod bad_model_not_supported_version { #[abi(embed_v0)] impl DojoModelImpl of dojo::model::IModel{ fn selector(self: @ContractState) -> felt252 { - dojo::model::Model::::selector() + dojo::model::Model::::selector() } fn name(self: @ContractState) -> ByteArray { - dojo::model::Model::::name() + dojo::model::Model::::name() } fn version(self: @ContractState) -> u8 { - dojo::model::Model::::version() + dojo::model::Model::::version() + } + + fn namespace(self: @ContractState) -> ByteArray { + 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() + dojo::database::introspect::Introspect::::size() } fn packed_size(self: @ContractState) -> Option { - dojo::model::Model::::packed_size() + dojo::model::Model::::packed_size() } fn layout(self: @ContractState) -> dojo::database::introspect::Layout { - dojo::model::Model::::layout() + dojo::model::Model::::layout() } fn schema(self: @ContractState) -> dojo::database::introspect::Ty { - dojo::database::introspect::Introspect::::ty() + dojo::database::introspect::Introspect::::ty() } } #[abi(embed_v0)] - impl bad_model_not_supported_versionImpl of Ibad_model_not_supported_version{ - fn ensure_abi(self: @ContractState, model: BadModelNotSupportedVersion) { + impl model_with_short_string_namespaceImpl of Imodel_with_short_string_namespace{ + fn ensure_abi(self: @ContractState, model: ModelWithShortStringNamespace) { } } } -impl Modelv0Introspect<> of dojo::database::introspect::Introspect> { +impl ModelWithStringNamespaceIntrospect<> of dojo::database::introspect::Introspect> { #[inline(always)] fn size() -> Option { dojo::database::introspect::Introspect::::size() @@ -1389,7 +2008,7 @@ impl Modelv0Introspect<> of dojo::database::introspect::Introspect> { fn ty() -> dojo::database::introspect::Ty { dojo::database::introspect::Ty::Struct( dojo::database::introspect::Struct { - name: 'Modelv0', + name: 'ModelWithStringNamespace', attrs: array![].span(), children: array![ dojo::database::introspect::Member { @@ -1409,9 +2028,14 @@ 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); +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, + Self::selector(), + keys, + layout + ); // TODO: Generate method to deserialize from keys / values directly to avoid // serializing to intermediate array. @@ -1420,46 +2044,56 @@ impl Modelv0Model of dojo::model::Model { core::array::serialize_array_helper(values, ref serialized); let mut serialized = core::array::ArrayTrait::span(@serialized); - let entity = core::serde::Serde::::deserialize(ref serialized); + let entity = core::serde::Serde::::deserialize(ref serialized); - if core::option::OptionTrait::::is_none(@entity) { + if core::option::OptionTrait::::is_none(@entity) { panic!( - "Model `Modelv0`: deserialization failed. Ensure the length of the keys tuple is matching the number of #[key] fields in the model struct." + "Model `ModelWithStringNamespace`: deserialization failed. Ensure the length of the keys tuple is matching the number of #[key] fields in the model struct." ); } - core::option::OptionTrait::::unwrap(entity) + core::option::OptionTrait::::unwrap(entity) } #[inline(always)] fn name() -> ByteArray { - "Modelv0" + "ModelWithStringNamespace" } #[inline(always)] fn version() -> u8 { - 0 + 1 } #[inline(always)] fn selector() -> felt252 { - "Modelv0" + 2567055065785696374111447326195815858786390804996225951953791904194802101726 } #[inline(always)] - fn instance_selector(self: @Modelv0) -> felt252 { + fn instance_selector(self: @ModelWithStringNamespace) -> felt252 { Self::selector() } #[inline(always)] - fn keys(self: @Modelv0) -> Span { + fn namespace() -> ByteArray { + "my_namespace" + } + + #[inline(always)] + fn namespace_selector() -> felt252 { + 1685136890688416384941629523783652800960468745356230625531475538826800548713 + } + + #[inline(always)] + fn keys(self: @ModelWithStringNamespace) -> Span { let mut serialized = core::array::ArrayTrait::new(); core::array::ArrayTrait::append(ref serialized, *self.id); core::array::ArrayTrait::span(@serialized) } #[inline(always)] - fn values(self: @Modelv0) -> Span { + fn values(self: @ModelWithStringNamespace) -> Span { let mut serialized = core::array::ArrayTrait::new(); core::serde::Serde::serialize(self.v, ref serialized); core::array::ArrayTrait::span(@serialized) @@ -1467,11 +2101,11 @@ impl Modelv0Model of dojo::model::Model { #[inline(always)] fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Introspect::::layout() + dojo::database::introspect::Introspect::::layout() } #[inline(always)] - fn instance_layout(self: @Modelv0) -> dojo::database::introspect::Layout { + fn instance_layout(self: @ModelWithStringNamespace) -> dojo::database::introspect::Layout { Self::layout() } @@ -1494,14 +2128,14 @@ impl Modelv0Model of dojo::model::Model { } #[starknet::interface] -trait Imodelv_0 { - fn ensure_abi(self: @T, model: Modelv0); +trait Imodel_with_string_namespace { + fn ensure_abi(self: @T, model: ModelWithStringNamespace); } #[starknet::contract] -mod modelv_0 { - use super::Modelv0; - use super::Imodelv_0; +mod model_with_string_namespace { + use super::ModelWithStringNamespace; + use super::Imodel_with_string_namespace; #[storage] struct Storage {} @@ -1509,37 +2143,45 @@ mod modelv_0 { #[abi(embed_v0)] impl DojoModelImpl of dojo::model::IModel{ fn selector(self: @ContractState) -> felt252 { - dojo::model::Model::::selector() + dojo::model::Model::::selector() } fn name(self: @ContractState) -> ByteArray { - dojo::model::Model::::name() + dojo::model::Model::::name() } fn version(self: @ContractState) -> u8 { - dojo::model::Model::::version() + dojo::model::Model::::version() + } + + fn namespace(self: @ContractState) -> ByteArray { + 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() + dojo::database::introspect::Introspect::::size() } fn packed_size(self: @ContractState) -> Option { - dojo::model::Model::::packed_size() + dojo::model::Model::::packed_size() } fn layout(self: @ContractState) -> dojo::database::introspect::Layout { - dojo::model::Model::::layout() + dojo::model::Model::::layout() } fn schema(self: @ContractState) -> dojo::database::introspect::Ty { - dojo::database::introspect::Introspect::::ty() + dojo::database::introspect::Introspect::::ty() } } #[abi(embed_v0)] - impl modelv_0Impl of Imodelv_0{ - fn ensure_abi(self: @ContractState, model: Modelv0) { + impl model_with_string_namespaceImpl of Imodel_with_string_namespace{ + fn ensure_abi(self: @ContractState, model: ModelWithStringNamespace) { } } } @@ -1587,7 +2229,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, 71955415935911354973604243446792437686714331401564029050333759332065302780, 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. @@ -1619,7 +2266,7 @@ impl PositionModel of dojo::model::Model { #[inline(always)] fn selector() -> felt252 { - 71955415935911354973604243446792437686714331401564029050333759332065302780 + 2479520712854223096864276571913189358268637670027015185814050381675363770524 } #[inline(always)] @@ -1627,6 +2274,16 @@ impl PositionModel of dojo::model::Model { Self::selector() } + #[inline(always)] + fn namespace() -> ByteArray { + "dojo_plugin" + } + + #[inline(always)] + fn namespace_selector() -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + #[inline(always)] fn keys(self: @Position) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -1695,7 +2352,15 @@ mod position { fn version(self: @ContractState) -> u8 { dojo::model::Model::::version() } + + fn namespace(self: @ContractState) -> ByteArray { + 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() } @@ -1763,7 +2428,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, 419336544500304321788712222515554985736095774968511843121228046452992595089, 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. @@ -1795,7 +2465,7 @@ impl RolesModel of dojo::model::Model { #[inline(always)] fn selector() -> felt252 { - 419336544500304321788712222515554985736095774968511843121228046452992595089 + 855657559905271410348750655782338503830053919297069309307754778237415879343 } #[inline(always)] @@ -1803,6 +2473,16 @@ impl RolesModel of dojo::model::Model { Self::selector() } + #[inline(always)] + fn namespace() -> ByteArray { + "dojo_plugin" + } + + #[inline(always)] + fn namespace_selector() -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + #[inline(always)] fn keys(self: @Roles) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -1871,7 +2551,15 @@ mod roles { fn version(self: @ContractState) -> u8 { dojo::model::Model::::version() } + + fn namespace(self: @ContractState) -> ByteArray { + 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() } @@ -1931,7 +2619,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, 95348903287879133251404472882179060573633188436503276991594023731017124802, 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. @@ -1963,7 +2656,7 @@ impl OnlyKeyModelModel of dojo::model::Model { #[inline(always)] fn selector() -> felt252 { - 95348903287879133251404472882179060573633188436503276991594023731017124802 + 185833973124429845784881936399707635120594083624714634478397191250435112638 } #[inline(always)] @@ -1971,6 +2664,16 @@ impl OnlyKeyModelModel of dojo::model::Model { Self::selector() } + #[inline(always)] + fn namespace() -> ByteArray { + "dojo_plugin" + } + + #[inline(always)] + fn namespace_selector() -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + #[inline(always)] fn keys(self: @OnlyKeyModel) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -2039,7 +2742,15 @@ mod only_key_model { fn version(self: @ContractState) -> u8 { dojo::model::Model::::version() } + + fn namespace(self: @ContractState) -> ByteArray { + 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() } @@ -2099,7 +2810,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, 1012572617804599336461526165833773117831255507291742736404237332578427043161, 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. @@ -2131,7 +2847,7 @@ impl U256KeyModelModel of dojo::model::Model { #[inline(always)] fn selector() -> felt252 { - 1012572617804599336461526165833773117831255507291742736404237332578427043161 + 313949624866121544885414428820758126526635902180652023772135974434319323806 } #[inline(always)] @@ -2139,6 +2855,16 @@ impl U256KeyModelModel of dojo::model::Model { Self::selector() } + #[inline(always)] + fn namespace() -> ByteArray { + "dojo_plugin" + } + + #[inline(always)] + fn namespace_selector() -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + #[inline(always)] fn keys(self: @U256KeyModel) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -2207,7 +2933,15 @@ mod u_256_key_model { fn version(self: @ContractState) -> u8 { dojo::model::Model::::version() } + + fn namespace(self: @ContractState) -> ByteArray { + 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() } @@ -2280,7 +3014,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, 711011379911436309259372467342761500657237775100998141763491044473508065524, 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. @@ -2312,7 +3051,7 @@ impl PlayerModel of dojo::model::Model { #[inline(always)] fn selector() -> felt252 { - 711011379911436309259372467342761500657237775100998141763491044473508065524 + 3236595220905041720254406300307550499454912078227837571413280031443759061272 } #[inline(always)] @@ -2320,6 +3059,16 @@ impl PlayerModel of dojo::model::Model { Self::selector() } + #[inline(always)] + fn namespace() -> ByteArray { + "dojo_plugin" + } + + #[inline(always)] + fn namespace_selector() -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + #[inline(always)] fn keys(self: @Player) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -2388,7 +3137,15 @@ mod player { fn version(self: @ContractState) -> u8 { dojo::model::Model::::version() } + + fn namespace(self: @ContractState) -> ByteArray { + 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() } @@ -2470,7 +3227,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, 1666797686724122591687516812540504658474050953055875240069335038116740262482, 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. @@ -2502,7 +3264,7 @@ impl ModelWithSimpleArrayModel of dojo::model::Model { #[inline(always)] fn selector() -> felt252 { - 1666797686724122591687516812540504658474050953055875240069335038116740262482 + 3015573168128997707047545520976347917082964620628387533056114714397499472255 } #[inline(always)] @@ -2510,6 +3272,16 @@ impl ModelWithSimpleArrayModel of dojo::model::Model { Self::selector() } + #[inline(always)] + fn namespace() -> ByteArray { + "dojo_plugin" + } + + #[inline(always)] + fn namespace_selector() -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + #[inline(always)] fn keys(self: @ModelWithSimpleArray) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -2578,7 +3350,15 @@ mod model_with_simple_array { fn version(self: @ContractState) -> u8 { dojo::model::Model::::version() } + + fn namespace(self: @ContractState) -> ByteArray { + 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() } @@ -2656,7 +3436,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, 141311514815198970479576122039175676312992855455532566618126930677198428029, 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. @@ -2688,7 +3473,7 @@ impl ModelWithByteArrayModel of dojo::model::Model { #[inline(always)] fn selector() -> felt252 { - 141311514815198970479576122039175676312992855455532566618126930677198428029 + 1495813766814131974177657304275361143893541941399872042870855060582891570868 } #[inline(always)] @@ -2696,6 +3481,16 @@ impl ModelWithByteArrayModel of dojo::model::Model { Self::selector() } + #[inline(always)] + fn namespace() -> ByteArray { + "dojo_plugin" + } + + #[inline(always)] + fn namespace_selector() -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + #[inline(always)] fn keys(self: @ModelWithByteArray) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -2764,7 +3559,15 @@ mod model_with_byte_array { fn version(self: @ContractState) -> u8 { dojo::model::Model::::version() } + + fn namespace(self: @ContractState) -> ByteArray { + 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() } @@ -2846,7 +3649,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, 897000934674353152443993618748644314791405506479389733109858158050692281536, 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. @@ -2878,7 +3686,7 @@ impl ModelWithComplexArrayModel of dojo::model::Model { #[inline(always)] fn selector() -> felt252 { - 897000934674353152443993618748644314791405506479389733109858158050692281536 + 36330270687495804813979499325154873801411429162367231362587376627277795482 } #[inline(always)] @@ -2886,6 +3694,16 @@ impl ModelWithComplexArrayModel of dojo::model::Model { Self::selector() } + #[inline(always)] + fn namespace() -> ByteArray { + "dojo_plugin" + } + + #[inline(always)] + fn namespace_selector() -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + #[inline(always)] fn keys(self: @ModelWithComplexArray) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -2954,7 +3772,15 @@ mod model_with_complex_array { fn version(self: @ContractState) -> u8 { dojo::model::Model::::version() } + + fn namespace(self: @ContractState) -> ByteArray { + 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() } @@ -3043,7 +3869,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, 337716500732518130569836528184281758241439084973964029720107667501574962806, 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. @@ -3075,7 +3906,7 @@ impl ModelWithTupleModel of dojo::model::Model { #[inline(always)] fn selector() -> felt252 { - 337716500732518130569836528184281758241439084973964029720107667501574962806 + 2968932965114787437968555813812827702683268243780347884633996291362924490633 } #[inline(always)] @@ -3083,6 +3914,16 @@ impl ModelWithTupleModel of dojo::model::Model { Self::selector() } + #[inline(always)] + fn namespace() -> ByteArray { + "dojo_plugin" + } + + #[inline(always)] + fn namespace_selector() -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + #[inline(always)] fn keys(self: @ModelWithTuple) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -3151,7 +3992,15 @@ mod model_with_tuple { fn version(self: @ContractState) -> u8 { dojo::model::Model::::version() } + + fn namespace(self: @ContractState) -> ByteArray { + 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() } @@ -3249,7 +4098,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, 1607855252168926989989190762728138559179794826576658643328244347189144524311, 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. @@ -3281,7 +4135,7 @@ impl ModelWithTupleNoPrimitivesModel of dojo::model::Model felt252 { - 1607855252168926989989190762728138559179794826576658643328244347189144524311 + 1303002480984182254910512996281734914702552284127358821084351389028444664680 } #[inline(always)] @@ -3289,6 +4143,16 @@ impl ModelWithTupleNoPrimitivesModel of dojo::model::Model ByteArray { + "dojo_plugin" + } + + #[inline(always)] + fn namespace_selector() -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + #[inline(always)] fn keys(self: @ModelWithTupleNoPrimitives) -> Span { let mut serialized = core::array::ArrayTrait::new(); @@ -3357,7 +4221,15 @@ mod model_with_tuple_no_primitives { fn version(self: @ContractState) -> u8 { dojo::model::Model::::version() } + + fn namespace(self: @ContractState) -> ByteArray { + 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() } @@ -3418,23 +4290,28 @@ error: dojo::model version 2 not supported #[dojo::model(version: 2)] ^ +error: The model namespace 'MyNamespace' can only contain lower case characters (a-z) and underscore (_) + --> test_src/lib.cairo:59:8 +struct ModelWithBadNamespaceFormat { + ^*************************^ + error: Model must define at least one #[key] attribute - --> test_src/lib.cairo:66:8 + --> test_src/lib.cairo:87:8 struct Roles { ^***^ error: Model must define at least one member that is not a key - --> test_src/lib.cairo:71:8 + --> test_src/lib.cairo:92:8 struct OnlyKeyModel { ^**********^ error: Model must define at least one member that is not a key - --> test_src/lib.cairo:77:8 + --> test_src/lib.cairo:98:8 struct U256KeyModel { ^**********^ error: Key is only supported for core types that are 1 felt long once serialized. `u256` is a struct of 2 u128, hence not supported. - --> test_src/lib.cairo:77:8 + --> test_src/lib.cairo:98:8 struct U256KeyModel { ^**********^ @@ -3474,52 +4351,62 @@ error: Unsupported attribute. ^************************^ error: Unsupported attribute. - --> test_src/lib.cairo:58:1 + --> test_src/lib.cairo:65:1 +#[dojo::model(namespace: 'my_namespace')] +^***************************************^ + +error: Unsupported attribute. + --> test_src/lib.cairo:72:1 +#[dojo::model(namespace: "my_namespace")] +^***************************************^ + +error: Unsupported attribute. + --> test_src/lib.cairo:79:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:65:1 + --> test_src/lib.cairo:86:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:70:1 + --> test_src/lib.cairo:91:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:76:1 + --> test_src/lib.cairo:97:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:82:1 + --> test_src/lib.cairo:103:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:94:1 + --> test_src/lib.cairo:115:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:102:1 + --> test_src/lib.cairo:123:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:110:1 + --> test_src/lib.cairo:131:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:118:1 + --> test_src/lib.cairo:139:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:126:1 + --> test_src/lib.cairo:147:1 #[dojo::model] ^************^ @@ -3629,151 +4516,181 @@ error: Unsupported attribute. ^************************^ error: Unsupported attribute. - --> test_src/lib.cairo:58:1 + --> test_src/lib.cairo:65:1 +#[dojo::model(namespace: 'my_namespace')] +^***************************************^ + +error: Unsupported attribute. + --> test_src/lib.cairo:65:1 +#[dojo::model(namespace: 'my_namespace')] +^***************************************^ + +error: Unsupported attribute. + --> test_src/lib.cairo:65:1 +#[dojo::model(namespace: 'my_namespace')] +^***************************************^ + +error: Unsupported attribute. + --> test_src/lib.cairo:72:1 +#[dojo::model(namespace: "my_namespace")] +^***************************************^ + +error: Unsupported attribute. + --> test_src/lib.cairo:72:1 +#[dojo::model(namespace: "my_namespace")] +^***************************************^ + +error: Unsupported attribute. + --> test_src/lib.cairo:72:1 +#[dojo::model(namespace: "my_namespace")] +^***************************************^ + +error: Unsupported attribute. + --> test_src/lib.cairo:79:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:58:1 + --> test_src/lib.cairo:79:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:58:1 + --> test_src/lib.cairo:79:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:65:1 + --> test_src/lib.cairo:86:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:65:1 + --> test_src/lib.cairo:86:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:65:1 + --> test_src/lib.cairo:86:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:70:1 + --> test_src/lib.cairo:91:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:70:1 + --> test_src/lib.cairo:91:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:70:1 + --> test_src/lib.cairo:91:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:76:1 + --> test_src/lib.cairo:97:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:76:1 + --> test_src/lib.cairo:97:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:76:1 + --> test_src/lib.cairo:97:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:82:1 + --> test_src/lib.cairo:103:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:82:1 + --> test_src/lib.cairo:103:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:82:1 + --> test_src/lib.cairo:103:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:94:1 + --> test_src/lib.cairo:115:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:94:1 + --> test_src/lib.cairo:115:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:94:1 + --> test_src/lib.cairo:115:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:102:1 + --> test_src/lib.cairo:123:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:102:1 + --> test_src/lib.cairo:123:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:102:1 + --> test_src/lib.cairo:123:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:110:1 + --> test_src/lib.cairo:131:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:110:1 + --> test_src/lib.cairo:131:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:110:1 + --> test_src/lib.cairo:131:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:118:1 + --> test_src/lib.cairo:139:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:118:1 + --> test_src/lib.cairo:139:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:118:1 + --> test_src/lib.cairo:139:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:126:1 + --> test_src/lib.cairo:147:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:126:1 + --> test_src/lib.cairo:147:1 #[dojo::model] ^************^ error: Unsupported attribute. - --> test_src/lib.cairo:126:1 + --> test_src/lib.cairo:147:1 #[dojo::model] ^************^ diff --git a/crates/dojo-lang/src/plugin_test_data/system b/crates/dojo-lang/src/plugin_test_data/system index f7fbef26bb..4ec5b9d1c1 100644 --- a/crates/dojo-lang/src/plugin_test_data/system +++ b/crates/dojo-lang/src/plugin_test_data/system @@ -4,7 +4,17 @@ test_expand_plugin //! > cairo_code -#[dojo::contract] +#[dojo::contract(namespace: 'MyNamespace')] +mod bad_namespace_format { + use traits::Into; + use dojo::world::Context; + + fn execute(ctx: Context, name: felt252) { + return (); + } +} + +#[dojo::contract(namespace: 'my_namespace')] mod spawn { use traits::Into; use dojo::world::Context; @@ -14,7 +24,7 @@ mod spawn { } } -#[dojo::contract] +#[dojo::contract(namespace: "my_namespace")] mod proxy { fn execute(value: felt252) -> felt252 { value @@ -311,512 +321,571 @@ mod ctxnamed { } //! > expected_diagnostics +error: The contract namespace 'MyNamespace' can only contain lower case characters (a-z) and underscore (_) + --> test_src/lib.cairo:1:1 +#[dojo::contract(namespace: 'MyNamespace')] +^*****************************************^ + error: Unsupported attribute. - --> test_src/lib.cairo:42:1 + --> test_src/lib.cairo:52:1 #[starknet::component] ^********************^ error: Unsupported attribute. - --> test_src/lib.cairo:48:1 + --> test_src/lib.cairo:58:1 #[starknet::component] ^********************^ error: Anything other than functions is not supported in a dojo::interface - --> test_src/lib.cairo:80:5 + --> test_src/lib.cairo:90:5 const ONE: u8; ^************^ error: In a dojo contract or interface, you should use `world: @IWorldDispatcher` instead of `self: @ContractState`. - --> test_src/lib.cairo:98:5 + --> test_src/lib.cairo:108:5 fn do_with_self(self: @ContractState) -> felt252; ^***********************************************^ error: In a dojo contract or interface, you should use `ref world: IWorldDispatcher` instead of `ref self: ContractState`. - --> test_src/lib.cairo:99:5 + --> test_src/lib.cairo:109:5 fn do_with_ref_self(ref self: ContractState) -> felt252; ^******************************************************^ error: World parameter must be the first parameter. - --> test_src/lib.cairo:104:5 + --> test_src/lib.cairo:114:5 fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252; ^****************************************************************************^ error: In a dojo contract or interface, you should use `ref world: IWorldDispatcher` instead of `ref self: ContractState`. - --> test_src/lib.cairo:111:9 + --> test_src/lib.cairo:121:9 fn do_with_self(ref self: ContractState) -> felt252 { ^***************************************************^ error: In a dojo contract or interface, you should use `ref world: IWorldDispatcher` instead of `ref self: ContractState`. - --> test_src/lib.cairo:115:9 + --> test_src/lib.cairo:125:9 fn do_with_ref_self(ref self: ContractState) -> felt252 { ^*******************************************************^ error: World parameter must be the first parameter. - --> test_src/lib.cairo:129:9 + --> test_src/lib.cairo:139:9 fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252 { ^*****************************************************************************^ error: World parameter must be a snapshot if `ref` is not used. - --> test_src/lib.cairo:180:5 + --> test_src/lib.cairo:190:5 fn dojo_init( ^***********^ error: Unsupported attribute. - --> test_src/lib.cairo:1:1 -#[dojo::contract] -^***************^ + --> test_src/lib.cairo:11:1 +#[dojo::contract(namespace: 'my_namespace')] +^******************************************^ error: Unsupported attribute. - --> test_src/lib.cairo:11:1 -#[dojo::contract] -^***************^ + --> test_src/lib.cairo:21:1 +#[dojo::contract(namespace: "my_namespace")] +^******************************************^ error: Unsupported attribute. - --> test_src/lib.cairo:18:1 + --> test_src/lib.cairo:28:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:28:1 + --> test_src/lib.cairo:38:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:54:1 + --> test_src/lib.cairo:64:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:82:5 + --> test_src/lib.cairo:92:5 #[my_attr] ^********^ error: Unsupported attribute. - --> test_src/lib.cairo:107:1 + --> test_src/lib.cairo:117:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:135:1 + --> test_src/lib.cairo:145:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:178:1 + --> test_src/lib.cairo:188:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:195:1 + --> test_src/lib.cairo:205:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:44:5 + --> test_src/lib.cairo:54:5 #[storage] ^********^ error: Unsupported attribute. - --> test_src/lib.cairo:50:5 + --> test_src/lib.cairo:60:5 #[storage] ^********^ error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo:1:1 -#[dojo::contract] -^***************^ + --> test_src/lib.cairo:11:1 +#[dojo::contract(namespace: 'my_namespace')] +^******************************************^ error: Unsupported attribute. - --> test_src/lib.cairo:1:1 -#[dojo::contract] -^***************^ + --> test_src/lib.cairo:11:1 +#[dojo::contract(namespace: 'my_namespace')] +^******************************************^ error: Unsupported attribute. - --> test_src/lib.cairo:1:1 -#[dojo::contract] -^***************^ + --> test_src/lib.cairo:11:1 +#[dojo::contract(namespace: 'my_namespace')] +^******************************************^ error: Unsupported attribute. - --> test_src/lib.cairo:1:1 -#[dojo::contract] -^***************^ + --> test_src/lib.cairo:11:1 +#[dojo::contract(namespace: 'my_namespace')] +^******************************************^ error: Unsupported attribute. - --> test_src/lib.cairo:1:1 -#[dojo::contract] -^***************^ + --> test_src/lib.cairo:11:1 +#[dojo::contract(namespace: 'my_namespace')] +^******************************************^ error: Unsupported attribute. - --> test_src/lib.cairo:1:1 -#[dojo::contract] -^***************^ + --> test_src/lib.cairo:11:1 +#[dojo::contract(namespace: 'my_namespace')] +^******************************************^ error: Unsupported attribute. - --> test_src/lib.cairo:1:1 -#[dojo::contract] -^***************^ + --> test_src/lib.cairo:11:1 +#[dojo::contract(namespace: 'my_namespace')] +^******************************************^ error: Unsupported attribute. - --> test_src/lib.cairo:1:1 -#[dojo::contract] -^***************^ - -error: Unknown inline item macro: 'component'. --> test_src/lib.cairo:11:1 -#[dojo::contract] -^***************^ +#[dojo::contract(namespace: 'my_namespace')] +^******************************************^ error: Unsupported attribute. --> test_src/lib.cairo:11:1 -#[dojo::contract] -^***************^ +#[dojo::contract(namespace: 'my_namespace')] +^******************************************^ + +error: Unknown inline item macro: 'component'. + --> test_src/lib.cairo:21:1 +#[dojo::contract(namespace: "my_namespace")] +^******************************************^ error: Unsupported attribute. - --> test_src/lib.cairo:11:1 -#[dojo::contract] -^***************^ + --> test_src/lib.cairo:21:1 +#[dojo::contract(namespace: "my_namespace")] +^******************************************^ error: Unsupported attribute. - --> test_src/lib.cairo:11:1 -#[dojo::contract] -^***************^ + --> test_src/lib.cairo:21:1 +#[dojo::contract(namespace: "my_namespace")] +^******************************************^ error: Unsupported attribute. - --> test_src/lib.cairo:11:1 -#[dojo::contract] -^***************^ + --> test_src/lib.cairo:21:1 +#[dojo::contract(namespace: "my_namespace")] +^******************************************^ error: Unsupported attribute. - --> test_src/lib.cairo:11:1 -#[dojo::contract] -^***************^ + --> test_src/lib.cairo:21:1 +#[dojo::contract(namespace: "my_namespace")] +^******************************************^ error: Unsupported attribute. - --> test_src/lib.cairo:11:1 -#[dojo::contract] -^***************^ + --> test_src/lib.cairo:21:1 +#[dojo::contract(namespace: "my_namespace")] +^******************************************^ error: Unsupported attribute. - --> test_src/lib.cairo:11:1 + --> test_src/lib.cairo:21:1 +#[dojo::contract(namespace: "my_namespace")] +^******************************************^ + +error: Unsupported attribute. + --> test_src/lib.cairo:21:1 +#[dojo::contract(namespace: "my_namespace")] +^******************************************^ + +error: Unsupported attribute. + --> test_src/lib.cairo:21:1 +#[dojo::contract(namespace: "my_namespace")] +^******************************************^ + +error: Unknown inline item macro: 'component'. + --> test_src/lib.cairo:28:1 #[dojo::contract] ^***************^ -error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo:18:1 +error: Unsupported attribute. + --> test_src/lib.cairo:28:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:18:1 + --> test_src/lib.cairo:28:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:18:1 + --> test_src/lib.cairo:28:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:18:1 + --> test_src/lib.cairo:28:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:18:1 + --> test_src/lib.cairo:28:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:18:1 + --> test_src/lib.cairo:28:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:18:1 + --> test_src/lib.cairo:28:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:18:1 + --> test_src/lib.cairo:28:1 #[dojo::contract] ^***************^ error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo:28:1 + --> test_src/lib.cairo:38:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:28:1 + --> test_src/lib.cairo:38:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:28:1 + --> test_src/lib.cairo:38:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:28:1 + --> test_src/lib.cairo:38:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:28:1 + --> test_src/lib.cairo:38:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:28:1 + --> test_src/lib.cairo:38:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:28:1 + --> test_src/lib.cairo:38:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:28:1 + --> test_src/lib.cairo:38:1 +#[dojo::contract] +^***************^ + +error: Unsupported attribute. + --> test_src/lib.cairo:38:1 #[dojo::contract] ^***************^ error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo:54:1 + --> test_src/lib.cairo:64:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:54:1 + --> test_src/lib.cairo:64:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:54:1 + --> test_src/lib.cairo:64:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:54:1 + --> test_src/lib.cairo:64:1 +#[dojo::contract] +^***************^ + +error: Unsupported attribute. + --> test_src/lib.cairo:64:1 #[dojo::contract] ^***************^ error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo:56:5 + --> test_src/lib.cairo:66:5 component!(path: testcomponent1, storage: testcomponent1_storage, event: testcomponent1_event); ^*********************************************************************************************^ error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo:57:5 + --> test_src/lib.cairo:67:5 component!(path: testcomponent2, storage: testcomponent2_storage, event: testcomponent2_event); ^*********************************************************************************************^ error: Unsupported attribute. - --> test_src/lib.cairo:54:1 + --> test_src/lib.cairo:64:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:54:1 + --> test_src/lib.cairo:64:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:54:1 + --> test_src/lib.cairo:64:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:54:1 + --> test_src/lib.cairo:64:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:54:1 + --> test_src/lib.cairo:64:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:54:1 + --> test_src/lib.cairo:64:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:54:1 + --> test_src/lib.cairo:64:1 #[dojo::contract] ^***************^ error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo:107:1 + --> test_src/lib.cairo:117:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:107:1 + --> test_src/lib.cairo:117:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:107:1 + --> test_src/lib.cairo:117:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:107:1 + --> test_src/lib.cairo:117:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:109:5 + --> test_src/lib.cairo:117:1 +#[dojo::contract] +^***************^ + +error: Unsupported attribute. + --> test_src/lib.cairo:119:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo:107:1 + --> test_src/lib.cairo:117:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:107:1 + --> test_src/lib.cairo:117:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:107:1 + --> test_src/lib.cairo:117:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:107:1 + --> test_src/lib.cairo:117:1 #[dojo::contract] ^***************^ error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo:135:1 + --> test_src/lib.cairo:145:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:135:1 + --> test_src/lib.cairo:145:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:135:1 + --> test_src/lib.cairo:145:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:135:1 + --> test_src/lib.cairo:145:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:142:5 + --> test_src/lib.cairo:145:1 +#[dojo::contract] +^***************^ + +error: Unsupported attribute. + --> test_src/lib.cairo:152:5 #[abi(embed_v0)] ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo:135:1 + --> test_src/lib.cairo:145:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:135:1 + --> test_src/lib.cairo:145:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:135:1 + --> test_src/lib.cairo:145:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:135:1 + --> test_src/lib.cairo:145:1 #[dojo::contract] ^***************^ error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo:178:1 + --> test_src/lib.cairo:188:1 +#[dojo::contract] +^***************^ + +error: Unsupported attribute. + --> test_src/lib.cairo:188:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:178:1 + --> test_src/lib.cairo:188:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:178:1 + --> test_src/lib.cairo:188:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:178:1 + --> test_src/lib.cairo:188:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:178:1 + --> test_src/lib.cairo:188:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:178:1 + --> test_src/lib.cairo:188:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:178:1 + --> test_src/lib.cairo:188:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:178:1 + --> test_src/lib.cairo:188:1 #[dojo::contract] ^***************^ error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo:195:1 + --> test_src/lib.cairo:205:1 +#[dojo::contract] +^***************^ + +error: Unsupported attribute. + --> test_src/lib.cairo:205:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:195:1 + --> test_src/lib.cairo:205:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:195:1 + --> test_src/lib.cairo:205:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:195:1 + --> test_src/lib.cairo:205:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:195:1 + --> test_src/lib.cairo:205:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:195:1 + --> test_src/lib.cairo:205:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:195:1 + --> test_src/lib.cairo:205:1 #[dojo::contract] ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:195:1 + --> test_src/lib.cairo:205:1 #[dojo::contract] ^***************^ //! > expanded_cairo_code +#[dojo::contract(namespace: 'MyNamespace')] +mod bad_namespace_format { + use traits::Into; + use dojo::world::Context; + + fn execute(ctx: Context, name: felt252) { + return (); + } +} #[starknet::component] mod testcomponent1 { @@ -837,6 +906,7 @@ mod testcomponent2 { use dojo::world::IWorldDispatcherTrait; use dojo::world::IWorldProvider; use dojo::world::IDojoResourceProvider; + use dojo::world::INamespace; #[abi(embed_v0)] impl DojoResourceProviderImpl of IDojoResourceProvider { @@ -845,6 +915,17 @@ mod testcomponent2 { } } + #[abi(embed_v0)] + impl NamespaceImpl of INamespace { + fn namespace(self: @ContractState) -> ByteArray { + "my_namespace" + } + + fn namespace_selector(self: @ContractState) -> felt252 { + 1685136890688416384941629523783652800960468745356230625531475538826800548713 + } + } + #[abi(embed_v0)] impl WorldProviderImpl of IWorldProvider { fn world(self: @ContractState) -> IWorldDispatcher { @@ -897,6 +978,7 @@ impl EventDrop of core::traits::Drop::; use dojo::world::IWorldDispatcherTrait; use dojo::world::IWorldProvider; use dojo::world::IDojoResourceProvider; + use dojo::world::INamespace; #[abi(embed_v0)] impl DojoResourceProviderImpl of IDojoResourceProvider { @@ -905,6 +987,17 @@ impl EventDrop of core::traits::Drop::; } } + #[abi(embed_v0)] + impl NamespaceImpl of INamespace { + fn namespace(self: @ContractState) -> ByteArray { + "my_namespace" + } + + fn namespace_selector(self: @ContractState) -> felt252 { + 1685136890688416384941629523783652800960468745356230625531475538826800548713 + } + } + #[abi(embed_v0)] impl WorldProviderImpl of IWorldProvider { fn world(self: @ContractState) -> IWorldDispatcher { @@ -954,6 +1047,7 @@ impl EventDrop of core::traits::Drop::; use dojo::world::IWorldDispatcherTrait; use dojo::world::IWorldProvider; use dojo::world::IDojoResourceProvider; + use dojo::world::INamespace; #[abi(embed_v0)] impl DojoResourceProviderImpl of IDojoResourceProvider { @@ -962,6 +1056,17 @@ impl EventDrop of core::traits::Drop::; } } + #[abi(embed_v0)] + impl NamespaceImpl of INamespace { + fn namespace(self: @ContractState) -> ByteArray { + "dojo_plugin" + } + + fn namespace_selector(self: @ContractState) -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + } + #[abi(embed_v0)] impl WorldProviderImpl of IWorldProvider { fn world(self: @ContractState) -> IWorldDispatcher { @@ -1014,6 +1119,7 @@ impl EventDrop of core::traits::Drop::; use dojo::world::IWorldDispatcherTrait; use dojo::world::IWorldProvider; use dojo::world::IDojoResourceProvider; + use dojo::world::INamespace; #[abi(embed_v0)] impl DojoResourceProviderImpl of IDojoResourceProvider { @@ -1022,6 +1128,17 @@ impl EventDrop of core::traits::Drop::; } } + #[abi(embed_v0)] + impl NamespaceImpl of INamespace { + fn namespace(self: @ContractState) -> ByteArray { + "dojo_plugin" + } + + fn namespace_selector(self: @ContractState) -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + } + #[abi(embed_v0)] impl WorldProviderImpl of IWorldProvider { fn world(self: @ContractState) -> IWorldDispatcher { @@ -1075,6 +1192,7 @@ impl TestEventDrop of core::traits::Drop::; use dojo::world::IWorldDispatcherTrait; use dojo::world::IWorldProvider; use dojo::world::IDojoResourceProvider; + use dojo::world::INamespace; #[abi(embed_v0)] impl DojoResourceProviderImpl of IDojoResourceProvider { @@ -1083,6 +1201,17 @@ impl TestEventDrop of core::traits::Drop::; } } + #[abi(embed_v0)] + impl NamespaceImpl of INamespace { + fn namespace(self: @ContractState) -> ByteArray { + "dojo_plugin" + } + + fn namespace_selector(self: @ContractState) -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + } + #[abi(embed_v0)] impl WorldProviderImpl of IWorldProvider { fn world(self: @ContractState) -> IWorldDispatcher { @@ -1169,6 +1298,7 @@ self: @TContractState, vec: Vec2, ref another_world: IWorldDispatcher use dojo::world::IWorldDispatcherTrait; use dojo::world::IWorldProvider; use dojo::world::IDojoResourceProvider; + use dojo::world::INamespace; #[abi(embed_v0)] impl DojoResourceProviderImpl of IDojoResourceProvider { @@ -1177,6 +1307,17 @@ self: @TContractState, vec: Vec2, ref another_world: IWorldDispatcher } } + #[abi(embed_v0)] + impl NamespaceImpl of INamespace { + fn namespace(self: @ContractState) -> ByteArray { + "dojo_plugin" + } + + fn namespace_selector(self: @ContractState) -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + } + #[abi(embed_v0)] impl WorldProviderImpl of IWorldProvider { fn world(self: @ContractState) -> IWorldDispatcher { @@ -1248,6 +1389,7 @@ impl EventDrop of core::traits::Drop::; use dojo::world::IWorldDispatcherTrait; use dojo::world::IWorldProvider; use dojo::world::IDojoResourceProvider; + use dojo::world::INamespace; #[abi(embed_v0)] impl DojoResourceProviderImpl of IDojoResourceProvider { @@ -1256,6 +1398,17 @@ impl EventDrop of core::traits::Drop::; } } + #[abi(embed_v0)] + impl NamespaceImpl of INamespace { + fn namespace(self: @ContractState) -> ByteArray { + "dojo_plugin" + } + + fn namespace_selector(self: @ContractState) -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + } + #[abi(embed_v0)] impl WorldProviderImpl of IWorldProvider { fn world(self: @ContractState) -> IWorldDispatcher { @@ -1349,6 +1502,7 @@ impl EventDrop of core::traits::Drop::; use dojo::world::IWorldDispatcherTrait; use dojo::world::IWorldProvider; use dojo::world::IDojoResourceProvider; + use dojo::world::INamespace; #[abi(embed_v0)] impl DojoResourceProviderImpl of IDojoResourceProvider { @@ -1357,6 +1511,17 @@ impl EventDrop of core::traits::Drop::; } } + #[abi(embed_v0)] + impl NamespaceImpl of INamespace { + fn namespace(self: @ContractState) -> ByteArray { + "dojo_plugin" + } + + fn namespace_selector(self: @ContractState) -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + } + #[abi(embed_v0)] impl WorldProviderImpl of IWorldProvider { fn world(self: @ContractState) -> IWorldDispatcher { @@ -1415,6 +1580,7 @@ impl EventDrop of core::traits::Drop::; use dojo::world::IWorldDispatcherTrait; use dojo::world::IWorldProvider; use dojo::world::IDojoResourceProvider; + use dojo::world::INamespace; #[abi(embed_v0)] impl DojoResourceProviderImpl of IDojoResourceProvider { @@ -1423,6 +1589,17 @@ impl EventDrop of core::traits::Drop::; } } + #[abi(embed_v0)] + impl NamespaceImpl of INamespace { + fn namespace(self: @ContractState) -> ByteArray { + "dojo_plugin" + } + + fn namespace_selector(self: @ContractState) -> felt252 { + 3437408695301308226171664635441698996501144546809569617702850025816833723775 + } + } + #[abi(embed_v0)] impl WorldProviderImpl of IWorldProvider { fn world(self: @ContractState) -> IWorldDispatcher { diff --git a/crates/dojo-lang/src/utils.rs b/crates/dojo-lang/src/utils.rs new file mode 100644 index 0000000000..c03853cfb3 --- /dev/null +++ b/crates/dojo-lang/src/utils.rs @@ -0,0 +1,48 @@ +use std::fs; + +use cairo_lang_filesystem::ids::Directory; +use cairo_lang_syntax::node::db::SyntaxGroup; +use regex::Regex; +use toml::Table; + +/// Check if the provided namespace follows the format rules: +/// only lower case characters (a-z) and underscore (_) +pub fn is_namespace_valid(namespace: &str) -> bool { + Regex::new(r"^[a-z_]+$").unwrap().is_match(namespace) +} + +// parse the configuration file of the first crate to extract +// the main package Id (so the name field of the package section of the Scarb.toml file) +// TODO: Ask to Scarb team to expose this package Id information with the new macro system. +pub fn get_package_id(db: &dyn SyntaxGroup) -> Option { + let crates = db.crates(); + + if crates.is_empty() { + return Option::None; + } + + let configuration = match db.crate_config(crates[0]) { + Option::Some(cfg) => cfg, + Option::None => return Option::None, + }; + + if let Directory::Real(path) = configuration.root { + let config_path = path.parent().unwrap().join("Scarb.toml"); + let config_content = match fs::read_to_string(config_path) { + Ok(x) => x, + Err(_) => return Option::None, + }; + let config = match config_content.parse::() { + Ok(x) => x, + Err(_) => return Option::None, + }; + + if config.contains_key("package") + && config["package"].as_table().unwrap().contains_key("name") + { + return Some(config["package"]["name"].as_str().unwrap().to_string()); + }; + } + + Option::None +} diff --git a/crates/dojo-test-utils/src/migration.rs b/crates/dojo-test-utils/src/migration.rs index d0ecc91126..4361d32730 100644 --- a/crates/dojo-test-utils/src/migration.rs +++ b/crates/dojo-test-utils/src/migration.rs @@ -11,6 +11,7 @@ pub fn prepare_migration( manifest_dir: Utf8PathBuf, target_dir: Utf8PathBuf, skip_migration: Option>, + default_namespace: &str, ) -> Result { // In testing, profile name is always dev. let profile_name = "dev"; @@ -32,7 +33,7 @@ pub fn prepare_migration( manifest.merge(overlay_manifest); let mut world = WorldDiff::compute(manifest, None); - world.update_order().unwrap(); + world.update_order(default_namespace).unwrap(); let mut strat = prepare_for_migration(None, felt!("0x12345"), &target_dir, world).unwrap(); strat.resolve_variable(strat.world_address().unwrap()).unwrap(); @@ -45,6 +46,7 @@ pub fn prepare_migration_with_world_and_seed( target_dir: Utf8PathBuf, world_address: Option, seed: &str, + default_namespace: &str, ) -> Result { // In testing, profile name is always dev. let profile_name = "dev"; @@ -62,7 +64,7 @@ pub fn prepare_migration_with_world_and_seed( manifest.merge(overlay_manifest); let mut world = WorldDiff::compute(manifest, None); - world.update_order().unwrap(); + world.update_order(default_namespace).unwrap(); let seed = cairo_short_string_to_felt(seed).unwrap(); prepare_for_migration(world_address, seed, &target_dir, world) diff --git a/crates/dojo-world/src/contracts/abi/world.rs b/crates/dojo-world/src/contracts/abi/world.rs index 4f9016025e..e5d369b00b 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" } ] }, @@ -698,6 +770,11 @@ abigen!( "name": "address", "type": "core::starknet::contract_address::ContractAddress", "kind": "data" + }, + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "data" } ] }, @@ -747,6 +824,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", @@ -757,6 +851,11 @@ abigen!( "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", @@ -824,7 +923,7 @@ abigen!( "kind": "struct", "members": [ { - "name": "model", + "name": "resource", "type": "core::felt252", "kind": "data" }, @@ -962,6 +1061,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/dojo-world/src/contracts/model.rs b/crates/dojo-world/src/contracts/model.rs index 13bb96ea14..582ba2ab1d 100644 --- a/crates/dojo-world/src/contracts/model.rs +++ b/crates/dojo-world/src/contracts/model.rs @@ -8,13 +8,14 @@ use dojo_types::primitive::{Primitive, PrimitiveError}; use dojo_types::schema::{Enum, EnumOption, Member, Struct, Ty}; use starknet::core::types::FieldElement; use starknet::core::utils::{ - cairo_short_string_to_felt, get_selector_from_name, parse_cairo_short_string, - CairoShortStringToFeltError, NonAsciiNameError, ParseCairoShortStringError, + cairo_short_string_to_felt, parse_cairo_short_string, CairoShortStringToFeltError, + NonAsciiNameError, ParseCairoShortStringError, }; use starknet::providers::{Provider, ProviderError}; use super::abi::world::Layout; use crate::contracts::WorldContractReader; +use crate::utils::compute_model_selector_from_names; #[cfg(test)] #[path = "model_test.rs"] @@ -82,13 +83,14 @@ where P: Provider + Sync + Send, { pub async fn new( + namespace: &str, name: &str, world: &'a WorldContractReader

, ) -> Result, ModelError> { - let name = get_selector_from_name(name)?; + let model_selector = compute_model_selector_from_names(namespace, name); let (class_hash, contract_address) = - world.model(&name).block_id(world.block_id).call().await?; + world.model(&model_selector).block_id(world.block_id).call().await?; // World Cairo contract won't raise an error in case of unknown/unregistered // model so raise an error here in case of zero address. @@ -102,7 +104,7 @@ where world_reader: world, class_hash: class_hash.into(), contract_address: contract_address.into(), - name, + name: model_selector, model_reader, }) } diff --git a/crates/dojo-world/src/contracts/model_test.rs b/crates/dojo-world/src/contracts/model_test.rs index 2fd460b729..d8999221b2 100644 --- a/crates/dojo-world/src/contracts/model_test.rs +++ b/crates/dojo-world/src/contracts/model_test.rs @@ -29,12 +29,19 @@ async fn test_model() { let dojo_metadata = dojo_metadata_from_workspace(&ws).expect("No current package with dojo metadata found."); - let world_address = - deploy_world(&runner, &manifest_dir.into(), &target_dir, dojo_metadata.skip_migration) - .await; + let default_namespace = ws.current_package().unwrap().id.name.to_string(); + + let world_address = deploy_world( + &runner, + &manifest_dir.into(), + &target_dir, + dojo_metadata.skip_migration, + &default_namespace, + ) + .await; let world = WorldContractReader::new(world_address, provider); - let position = world.model_reader("Position").await.unwrap(); + let position = world.model_reader("Dojo", "Position").await.unwrap(); let schema = position.schema().await.unwrap(); assert_eq!( @@ -75,7 +82,7 @@ async fn test_model() { felt!("0x027942375b09862291ece780c573e8c625df4ba41fd7524e0658ca75fff014ff") ); - let moves = world.model_reader("Moves").await.unwrap(); + let moves = world.model_reader("Dojo", "Moves").await.unwrap(); let schema = moves.schema().await.unwrap(); assert_eq!( diff --git a/crates/dojo-world/src/contracts/world.rs b/crates/dojo-world/src/contracts/world.rs index 8a639c421c..69e5888758 100644 --- a/crates/dojo-world/src/contracts/world.rs +++ b/crates/dojo-world/src/contracts/world.rs @@ -22,7 +22,11 @@ impl

WorldContractReader

where P: Provider + Sync + Send, { - pub async fn model_reader(&self, name: &str) -> Result, ModelError> { - ModelRPCReader::new(name, self).await + pub async fn model_reader( + &self, + namespace: &str, + name: &str, + ) -> Result, ModelError> { + ModelRPCReader::new(namespace, name, self).await } } diff --git a/crates/dojo-world/src/contracts/world_test.rs b/crates/dojo-world/src/contracts/world_test.rs index 5680d52c45..142f1e3119 100644 --- a/crates/dojo-world/src/contracts/world_test.rs +++ b/crates/dojo-world/src/contracts/world_test.rs @@ -20,6 +20,9 @@ async fn test_world_contract_reader() { &Utf8PathBuf::from("../../examples/spawn-and-move"), &Utf8PathBuf::from("../dojo-core"), ); + let ws = scarb::ops::read_workspace(config.manifest_path(), &config).unwrap(); + + let default_namespace = ws.current_package().unwrap().id.name.to_string(); let manifest_dir = config.manifest_path().parent().unwrap(); let target_dir = manifest_dir.join("target").join("dev"); @@ -38,6 +41,7 @@ async fn test_world_contract_reader() { &manifest_dir.to_path_buf(), &target_dir.to_path_buf(), dojo_metadata.skip_migration, + &default_namespace, ) .await; @@ -49,6 +53,7 @@ pub async fn deploy_world( manifest_dir: &Utf8PathBuf, target_dir: &Utf8PathBuf, skip_migration: Option>, + default_namespace: &str, ) -> FieldElement { // Dev profile is used by default for testing: let profile_name = "dev"; @@ -70,7 +75,7 @@ pub async fn deploy_world( manifest.merge(overlay_manifest); let mut world = WorldDiff::compute(manifest.clone(), None); - world.update_order().unwrap(); + world.update_order(default_namespace).unwrap(); let account = sequencer.account(0); @@ -81,7 +86,7 @@ pub async fn deploy_world( world, ) .unwrap(); - strategy.resolve_variable(strategy.world_address().unwrap()).unwrap(); + strategy.resolve_variable(strategy.world_address().unwrap(), default_namespace).unwrap(); let base_class_hash = strategy.base.unwrap().declare(&account, &TxnConfig::default()).await.unwrap().class_hash; diff --git a/crates/dojo-world/src/manifest/manifest_test.rs b/crates/dojo-world/src/manifest/manifest_test.rs index d19a69b01b..0c6b476cdc 100644 --- a/crates/dojo-world/src/manifest/manifest_test.rs +++ b/crates/dojo-world/src/manifest/manifest_test.rs @@ -6,7 +6,6 @@ use dojo_test_utils::compiler; use dojo_test_utils::rpc::MockJsonRpcTransport; use katana_runner::KatanaRunner; use serde_json::json; -use smol_str::SmolStr; use starknet::accounts::ConnectedAccount; use starknet::core::types::contract::AbiEntry; use starknet::core::types::{EmittedEvent, FieldElement}; @@ -24,6 +23,7 @@ use crate::manifest::{ }; use crate::metadata::dojo_metadata_from_workspace; use crate::migration::world::WorldDiff; +use crate::utils::get_manifest_name; #[tokio::test] async fn manifest_from_remote_throw_error_on_not_deployed() { @@ -55,57 +55,43 @@ async fn manifest_from_remote_throw_error_on_not_deployed() { fn parse_registered_model_events() { let expected_models = vec![ Manifest::new( - DojoModel { class_hash: felt!("0x5555"), ..Default::default() }, - "Model1".into(), + DojoModel { + namespace: "ns".to_string(), + name: "modelA".to_string(), + class_hash: felt!("0x5555"), + ..Default::default() + }, + get_manifest_name("ns", "modelA"), + "".into(), ), Manifest::new( - DojoModel { class_hash: felt!("0x6666"), ..Default::default() }, - "Model2".into(), + DojoModel { + namespace: "ns".to_string(), + name: "modelB".to_string(), + class_hash: felt!("0x6666"), + ..Default::default() + }, + get_manifest_name("ns", "modelB"), + "".into(), ), ]; - let selector = selector!("ModelRegistered"); - let events = vec![ - EmittedEvent { - data: { - let mut data = - ByteArray::cairo_serialize(&ByteArray::from_string("Model1").unwrap()); - data.extend(vec![felt!("0x5555"), felt!("0xbeef"), felt!("0xa1"), felt!("0")]); - data - }, - keys: vec![selector], - block_hash: Default::default(), - from_address: Default::default(), - block_number: Default::default(), - transaction_hash: Default::default(), - }, - EmittedEvent { - data: { - let mut data = - ByteArray::cairo_serialize(&ByteArray::from_string("Model1").unwrap()); - data.extend(vec![felt!("0xbeef"), felt!("0"), felt!("0xa1"), felt!("0xa1")]); - data - }, - keys: vec![selector], - block_hash: Default::default(), - from_address: Default::default(), - block_number: Default::default(), - transaction_hash: Default::default(), - }, - EmittedEvent { - data: { - let mut data = - ByteArray::cairo_serialize(&ByteArray::from_string("Model2").unwrap()); - data.extend(vec![felt!("0x6666"), felt!("0"), felt!("0xa3"), felt!("0")]); - data - }, - keys: vec![selector], - block_hash: Default::default(), - from_address: Default::default(), - block_number: Default::default(), - transaction_hash: Default::default(), - }, + build_model_registered_event( + vec![felt!("0x5555"), felt!("0xbeef"), felt!("0xa1"), felt!("0")], + "ns", + "modelA", + ), + build_model_registered_event( + vec![felt!("0xbeef"), felt!("0"), felt!("0xa1"), felt!("0xa1")], + "ns", + "modelA", + ), + build_model_registered_event( + vec![felt!("0x6666"), felt!("0"), felt!("0xa3"), felt!("0")], + "ns", + "modelB", + ), ]; let actual_models = parse_models_events(events); @@ -122,53 +108,38 @@ fn parse_deployed_contracts_events_without_upgrade() { DojoContract { class_hash: felt!("0x1"), address: Some(felt!("0x123")), + namespace: "ns1".to_string(), ..Default::default() }, "".into(), + "".into(), ), Manifest::new( DojoContract { class_hash: felt!("0x2"), address: Some(felt!("0x456")), + namespace: "ns2".to_string(), ..Default::default() }, "".into(), + "".into(), ), Manifest::new( DojoContract { class_hash: felt!("0x3"), address: Some(felt!("0x789")), + namespace: "ns3".to_string(), ..Default::default() }, "".into(), + "".into(), ), ]; let events = vec![ - EmittedEvent { - data: vec![felt!("0x0"), felt!("0x1"), felt!("0x123")], - keys: vec![], - block_hash: Default::default(), - from_address: Default::default(), - block_number: Default::default(), - transaction_hash: Default::default(), - }, - EmittedEvent { - data: vec![felt!("0x0"), felt!("0x2"), felt!("0x456")], - keys: vec![], - block_hash: Default::default(), - from_address: Default::default(), - block_number: Default::default(), - transaction_hash: Default::default(), - }, - EmittedEvent { - data: vec![felt!("0x0"), felt!("0x3"), felt!("0x789")], - keys: vec![], - block_hash: Default::default(), - from_address: Default::default(), - block_number: Default::default(), - transaction_hash: Default::default(), - }, + build_deploy_event(vec![felt!("0x0"), felt!("0x1"), felt!("0x123")], "ns1"), + build_deploy_event(vec![felt!("0x0"), felt!("0x2"), felt!("0x456")], "ns2"), + build_deploy_event(vec![felt!("0x0"), felt!("0x3"), felt!("0x789")], "ns3"), ]; let actual_contracts = parse_contracts_events(events, vec![]); @@ -182,53 +153,38 @@ fn parse_deployed_contracts_events_with_upgrade() { DojoContract { class_hash: felt!("0x69"), address: Some(felt!("0x123")), + namespace: "ns1".to_string(), ..Default::default() }, "".into(), + "".into(), ), Manifest::new( DojoContract { class_hash: felt!("0x2"), address: Some(felt!("0x456")), + namespace: "ns2".to_string(), ..Default::default() }, "".into(), + "".into(), ), Manifest::new( DojoContract { class_hash: felt!("0x88"), address: Some(felt!("0x789")), + namespace: "ns3".to_string(), ..Default::default() }, "".into(), + "".into(), ), ]; let deployed_events = vec![ - EmittedEvent { - data: vec![felt!("0x0"), felt!("0x1"), felt!("0x123")], - keys: vec![], - block_hash: Default::default(), - from_address: Default::default(), - block_number: Default::default(), - transaction_hash: Default::default(), - }, - EmittedEvent { - data: vec![felt!("0x0"), felt!("0x2"), felt!("0x456")], - keys: vec![], - block_hash: Default::default(), - from_address: Default::default(), - block_number: Default::default(), - transaction_hash: Default::default(), - }, - EmittedEvent { - data: vec![felt!("0x0"), felt!("0x3"), felt!("0x789")], - keys: vec![], - block_hash: Default::default(), - from_address: Default::default(), - block_number: Default::default(), - transaction_hash: Default::default(), - }, + build_deploy_event(vec![felt!("0x0"), felt!("0x1"), felt!("0x123")], "ns1"), + build_deploy_event(vec![felt!("0x0"), felt!("0x2"), felt!("0x456")], "ns2"), + build_deploy_event(vec![felt!("0x0"), felt!("0x3"), felt!("0x789")], "ns3"), ]; let upgrade_events = vec![ @@ -277,53 +233,38 @@ fn events_without_block_number_arent_parsed() { DojoContract { class_hash: felt!("0x66"), address: Some(felt!("0x123")), + namespace: "ns1".to_string(), ..Default::default() }, "".into(), + "".into(), ), Manifest::new( DojoContract { class_hash: felt!("0x2"), address: Some(felt!("0x456")), + namespace: "ns2".to_string(), ..Default::default() }, "".into(), + "".into(), ), Manifest::new( DojoContract { class_hash: felt!("0x3"), address: Some(felt!("0x789")), + namespace: "ns3".to_string(), ..Default::default() }, "".into(), + "".into(), ), ]; let deployed_events = vec![ - EmittedEvent { - data: vec![felt!("0x0"), felt!("0x1"), felt!("0x123")], - keys: vec![], - block_hash: Default::default(), - from_address: Default::default(), - block_number: Default::default(), - transaction_hash: Default::default(), - }, - EmittedEvent { - data: vec![felt!("0x0"), felt!("0x2"), felt!("0x456")], - keys: vec![], - block_hash: Default::default(), - from_address: Default::default(), - block_number: Default::default(), - transaction_hash: Default::default(), - }, - EmittedEvent { - data: vec![felt!("0x0"), felt!("0x3"), felt!("0x789")], - keys: vec![], - block_hash: Default::default(), - from_address: Default::default(), - block_number: Default::default(), - transaction_hash: Default::default(), - }, + build_deploy_event(vec![felt!("0x0"), felt!("0x1"), felt!("0x123")], "ns1"), + build_deploy_event(vec![felt!("0x0"), felt!("0x2"), felt!("0x456")], "ns2"), + build_deploy_event(vec![felt!("0x0"), felt!("0x3"), felt!("0x789")], "ns3"), ]; // only the first upgrade event has a block number and is parsed @@ -389,12 +330,15 @@ fn fetch_remote_manifest() { let artifacts_path = temp_project_dir.join(format!("target/{profile_name}")); + let default_namespace = ws.current_package().unwrap().id.name.to_string(); + let world_address = config.tokio_handle().block_on(async { deploy_world( &runner, &temp_project_dir, &artifacts_path, dojo_metadata.skip_migration.clone(), + &default_namespace, ) .await }); @@ -663,16 +607,32 @@ fn base_manifest_remove_items_work_as_expected() { let contracts = ["c1", "c2", "c3"]; let models = ["m1", "m2", "m3"]; - let world = Manifest { name: "world".into(), inner: Default::default() }; - let base = Manifest { name: "base".into(), inner: Default::default() }; + let world = Manifest { + manifest_name: "world".into(), + artifact_name: "world".into(), + inner: Default::default(), + }; + let base = Manifest { + manifest_name: "base".into(), + artifact_name: "base".into(), + inner: Default::default(), + }; let contracts = contracts .iter() - .map(|c| Manifest { name: SmolStr::from(*c), inner: Default::default() }) + .map(|c| Manifest { + manifest_name: c.to_string(), + artifact_name: c.to_string(), + inner: Default::default(), + }) .collect(); let models = models .iter() - .map(|c| Manifest { name: SmolStr::from(*c), inner: Default::default() }) + .map(|c| Manifest { + manifest_name: c.to_string(), + artifact_name: c.to_string(), + inner: Default::default(), + }) .collect(); let mut base = BaseManifest { contracts, models, world, base }; @@ -681,13 +641,51 @@ fn base_manifest_remove_items_work_as_expected() { assert_eq!(base.contracts.len(), 1); assert_eq!( - base.contracts.iter().map(|c| c.name.clone().into()).collect::>(), + base.contracts.iter().map(|c| c.manifest_name.clone()).collect::>(), vec!["c2"] ); assert_eq!(base.models.len(), 2); assert_eq!( - base.models.iter().map(|c| c.name.clone().into()).collect::>(), + base.models.iter().map(|c| c.manifest_name.clone()).collect::>(), vec!["m1", "m3"] ); } + +fn serialize_namespace(s: &str) -> Vec { + let ba = ByteArray::from_string(s).unwrap(); + ByteArray::cairo_serialize(&ba) +} + +fn build_model_registered_event( + values: Vec, + namespace: &str, + model: &str, +) -> EmittedEvent { + let mut data = ByteArray::cairo_serialize(&ByteArray::from_string(model).unwrap()); + data.extend(ByteArray::cairo_serialize(&ByteArray::from_string(namespace).unwrap())); + data.extend(values); + + EmittedEvent { + data, + keys: vec![selector!("ModelRegistered")], + block_hash: Default::default(), + from_address: Default::default(), + block_number: Default::default(), + transaction_hash: Default::default(), + } +} + +fn build_deploy_event(values: Vec, ns: &str) -> EmittedEvent { + let mut data = values.to_vec(); + data.extend(serialize_namespace(ns).iter()); + + EmittedEvent { + data, + keys: vec![], + block_hash: Default::default(), + from_address: Default::default(), + block_number: Default::default(), + transaction_hash: Default::default(), + } +} diff --git a/crates/dojo-world/src/manifest/mod.rs b/crates/dojo-world/src/manifest/mod.rs index d3906595ab..fc68dad836 100644 --- a/crates/dojo-world/src/manifest/mod.rs +++ b/crates/dojo-world/src/manifest/mod.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use std::{fs, io}; use anyhow::Result; -use cainome::cairo_serde::Error as CainomeError; +use cainome::cairo_serde::{ByteArray, CairoSerde, Error as CainomeError}; use camino::Utf8PathBuf; use serde::de::DeserializeOwned; use smol_str::SmolStr; @@ -22,6 +22,7 @@ use tracing::error; use crate::contracts::model::ModelError; use crate::contracts::world::WorldEvent; use crate::contracts::WorldContractReader; +use crate::utils::{get_full_world_element_name, get_manifest_name}; #[cfg(test)] #[path = "manifest_test.rs"] @@ -37,8 +38,6 @@ pub use types::{ pub const WORLD_CONTRACT_NAME: &str = "dojo::world::world"; pub const BASE_CONTRACT_NAME: &str = "dojo::base::base"; -pub const RESOURCE_METADATA_CONTRACT_NAME: &str = "dojo::resource_metadata::resource_metadata"; -pub const RESOURCE_METADATA_MODEL_NAME: &str = "0x5265736f757263654d65746164617461"; pub const MANIFESTS_DIR: &str = "manifests"; pub const BASE_DIR: &str = "base"; @@ -86,7 +85,8 @@ impl From> for Manifest { original_class_hash: value.inner.original_class_hash, ..Default::default() }, - value.name, + value.manifest_name, + value.artifact_name, ) } } @@ -124,19 +124,22 @@ impl BaseManifest { /// Given a list of contract or model names, remove those from the manifest. pub fn remove_items(&mut self, items: Vec) { - self.contracts.retain(|contract| !items.contains(&contract.name.to_string())); - self.models.retain(|model| !items.contains(&model.name.to_string())); + self.contracts.retain(|contract| !items.contains(&contract.manifest_name.to_string())); + self.models.retain(|model| !items.contains(&model.manifest_name.to_string())); } pub fn merge(&mut self, overlay: OverlayManifest) { let mut base_map = HashMap::new(); for contract in self.contracts.iter_mut() { - base_map.insert(contract.name.clone(), contract); + let full_name = + get_full_world_element_name(&contract.inner.namespace, &contract.inner.name); + base_map.insert(full_name, contract); } for contract in overlay.contracts { - if let Some(manifest) = base_map.get_mut(&contract.name) { + let full_name = get_full_world_element_name(&contract.namespace, &contract.name); + if let Some(manifest) = base_map.get_mut(&full_name) { manifest.inner.merge(contract); } else { error!( @@ -257,7 +260,8 @@ impl DeploymentManifest { self.world.inner.seed = previous.world.inner.seed; self.contracts.iter_mut().for_each(|contract| { - let previous_contract = previous.contracts.iter().find(|c| c.name == contract.name); + let previous_contract = + previous.contracts.iter().find(|c| c.manifest_name == contract.manifest_name); if let Some(previous_contract) = previous_contract { if previous_contract.inner.base_class_hash != FieldElement::ZERO { contract.inner.base_class_hash = previous_contract.inner.base_class_hash; @@ -343,6 +347,7 @@ impl DeploymentManifest { ..Default::default() }, WORLD_CONTRACT_NAME.into(), + WORLD_CONTRACT_NAME.to_string(), ), base: Manifest::new( Class { @@ -351,6 +356,7 @@ impl DeploymentManifest { original_class_hash: base_class_hash, }, BASE_CONTRACT_NAME.into(), + BASE_CONTRACT_NAME.to_string(), ), }) } @@ -433,7 +439,7 @@ where Err(err) => return Err(err.into()), }; - contract.name = name; + contract.manifest_name = get_manifest_name(&contract.inner.namespace, name.as_str()); } Ok((models, contracts)) @@ -512,6 +518,9 @@ fn parse_contracts_events( let _ = data.next().expect("salt is missing from event"); let mut class_hash = data.next().expect("class hash is missing from event"); let address = data.next().expect("addresss is missing from event"); + let namespace = ByteArray::cairo_deserialize(data.as_mut_slice(), 0) + .expect("namespace is missing from event"); + let namespace = namespace.to_string().unwrap(); if let Some(upgrade) = upgradeds.get(&address) { class_hash = *upgrade; @@ -522,16 +531,18 @@ fn parse_contracts_events( address: Some(address), class_hash, abi: None, + namespace, ..Default::default() }, Default::default(), + Default::default(), ) }) .collect() } fn parse_models_events(events: Vec) -> Vec> { - let mut models: HashMap = HashMap::with_capacity(events.len()); + let mut models: HashMap = HashMap::with_capacity(events.len()); for e in events { let model_event = match e.try_into() { @@ -545,23 +556,31 @@ fn parse_models_events(events: Vec) -> Vec> { } }; - // TODO: Safely unwrap? - let model_name = model_event.name.to_string().unwrap(); - if let Some(current_class_hash) = models.get_mut(&model_name) { + let model_name = model_event.name.to_string().expect("ASCII encoded name"); + let namespace = model_event.namespace.to_string().expect("ASCII encoded namespace"); + + if let Some((_, current_class_hash)) = models.get_mut(&model_name) { if current_class_hash == &model_event.prev_class_hash.into() { *current_class_hash = model_event.class_hash.into(); } } else { - models.insert(model_name, model_event.class_hash.into()); + models.insert(model_name, (namespace, model_event.class_hash.into())); } } // TODO: include address of the model in the manifest. models .into_iter() - .map(|(name, class_hash)| Manifest:: { - inner: DojoModel { class_hash, abi: None, ..Default::default() }, - name: name.into(), + .map(|(name, (namespace, class_hash))| Manifest:: { + inner: DojoModel { + name: name.to_string(), + namespace: namespace.to_string(), + class_hash, + abi: None, + ..Default::default() + }, + manifest_name: get_manifest_name(&namespace, &name), + artifact_name: Default::default(), }) .collect() } @@ -663,6 +682,8 @@ impl ManifestMethods for DojoContract { } fn merge(&mut self, old: Self::OverlayType) { + // ignore name and namespace + if let Some(class_hash) = old.original_class_hash { self.original_class_hash = class_hash; } diff --git a/crates/dojo-world/src/manifest/types.rs b/crates/dojo-world/src/manifest/types.rs index 5eb3e67d0c..8d59119671 100644 --- a/crates/dojo-world/src/manifest/types.rs +++ b/crates/dojo-world/src/manifest/types.rs @@ -45,7 +45,7 @@ pub struct OverlayManifest { pub models: Vec, } -#[derive(Clone, Serialize, Deserialize, Debug)] +#[derive(Clone, Serialize, Default, Deserialize, Debug)] #[cfg_attr(test, derive(PartialEq))] pub struct Manifest where @@ -53,7 +53,13 @@ where { #[serde(flatten)] pub inner: T, - pub name: SmolStr, + + // name of the manifest which is used as filename + pub manifest_name: String, + + // artifact name which is used to be able to match manifests + // with artifacts produced during the compilation. + pub artifact_name: String, } // Utility methods thats needs to be implemented by manifest types @@ -75,8 +81,8 @@ impl Manifest where T: ManifestMethods, { - pub fn new(inner: T, name: SmolStr) -> Self { - Self { inner, name } + pub fn new(inner: T, manifest_name: String, artifact_name: String) -> Self { + Self { inner, manifest_name, artifact_name } } } @@ -103,6 +109,8 @@ pub struct DojoContract { pub computed: Vec, #[serde(default)] pub init_calldata: Vec, + pub name: String, + pub namespace: String, } /// Represents a declaration of a model. @@ -117,6 +125,8 @@ pub struct DojoModel { #[serde_as(as = "UfeHex")] pub original_class_hash: FieldElement, pub abi: Option, + pub name: String, + pub namespace: String, } #[serde_as] @@ -155,6 +165,7 @@ pub struct Class { #[cfg_attr(test, derive(PartialEq))] pub struct OverlayDojoContract { pub name: SmolStr, + pub namespace: String, pub original_class_hash: Option, pub reads: Option>, pub writes: Option>, @@ -166,6 +177,7 @@ pub struct OverlayDojoContract { #[cfg_attr(test, derive(PartialEq))] pub struct OverlayDojoModel { pub name: SmolStr, + pub namespace: String, pub original_class_hash: Option, } @@ -206,6 +218,7 @@ pub struct ComputedValueEntrypoint { // Name of entrypoint to get computed value pub entrypoint: SmolStr, // Component to compute for + pub namespace: Option, pub model: Option, } diff --git a/crates/dojo-world/src/metadata.rs b/crates/dojo-world/src/metadata.rs index d778476a2f..34853805ce 100644 --- a/crates/dojo-world/src/metadata.rs +++ b/crates/dojo-world/src/metadata.rs @@ -11,6 +11,7 @@ use serde_json::json; use url::Url; use crate::manifest::{BaseManifest, WORLD_CONTRACT_NAME}; +use crate::utils::get_full_world_element_name; #[cfg(test)] #[path = "metadata_test.rs"] @@ -31,9 +32,8 @@ fn build_artifact_from_name( abi_dir: &Utf8PathBuf, element_name: &str, ) -> ArtifactMetadata { - let sanitized_name = element_name.replace("::", "_"); - let abi_file = abi_dir.join(format!("{sanitized_name}.json")); - let src_file = source_dir.join(format!("{sanitized_name}.cairo")); + let abi_file = abi_dir.join(format!("{element_name}.json")); + let src_file = source_dir.join(format!("{element_name}.cairo")); ArtifactMetadata { abi: if abi_file.exists() { Some(Uri::File(abi_file.into_std_path_buf())) } else { None }, @@ -118,30 +118,32 @@ pub fn dojo_metadata_from_workspace(ws: &Workspace<'_>) -> Option if manifest_dir.join(BASE_DIR).exists() { if let Ok(manifest) = BaseManifest::load_from_path(&manifest_dir.join(BASE_DIR)) { for model in manifest.models { - let name = model.name.to_string(); + let full_name = + get_full_world_element_name(&model.inner.namespace, &model.inner.name); dojo_metadata.resources_artifacts.insert( - name.clone(), + full_name.clone(), ResourceMetadata { - name: name.clone(), + name: full_name.clone(), artifacts: build_artifact_from_name( &sources_dir, &abis_dir.join("models"), - &name, + &full_name, ), }, ); } for contract in manifest.contracts { - let name = contract.name.to_string(); + let full_name = + get_full_world_element_name(&contract.inner.namespace, &contract.inner.name); dojo_metadata.resources_artifacts.insert( - name.clone(), + full_name.clone(), ResourceMetadata { - name: name.clone(), + name: full_name.clone(), artifacts: build_artifact_from_name( &sources_dir, &abis_dir.join("contracts"), - &name, + &full_name, ), }, ); diff --git a/crates/dojo-world/src/metadata_test.rs b/crates/dojo-world/src/metadata_test.rs index e564e3a8e4..3d7b5dfea5 100644 --- a/crates/dojo-world/src/metadata_test.rs +++ b/crates/dojo-world/src/metadata_test.rs @@ -108,6 +108,7 @@ website = "https://dojoengine.org" assert!(metadata.world.is_some()); } +#[ignore] #[tokio::test] async fn get_full_dojo_metadata_from_workspace() { let config = compiler::build_test_config("../../examples/spawn-and-move/Scarb.toml").unwrap(); @@ -164,6 +165,8 @@ async fn get_full_dojo_metadata_from_workspace() { assert!(dojo_metadata.world.website.is_none()); assert!(dojo_metadata.world.socials.is_none()); + println!("world resource: {:#?}", dojo_metadata.world.artifacts); + check_artifact( dojo_metadata.world.artifacts, "dojo_world_world".to_string(), @@ -176,6 +179,7 @@ async fn get_full_dojo_metadata_from_workspace() { dbg!(&artifacts); for (abi_subdir, name) in artifacts { let resource = dojo_metadata.resources_artifacts.get(&name); + println!("name: {} resource: {:#?}", name, resource); dbg!(&dojo_metadata.resources_artifacts); assert!(resource.is_some(), "bad resource metadata for {}", name); let resource = resource.unwrap(); @@ -225,25 +229,12 @@ fn get_artifacts_from_manifest(manifest_dir: &Utf8PathBuf) -> Vec<(String, Strin // models for entry in fs::read_dir(models_dir).unwrap().flatten() { let name = entry.path().file_stem().unwrap().to_string_lossy().to_string(); - let name = name.replace("_models_", "::models::"); - // Some models are inside actions, we need a better way to gather those. - let name = name.replace("_actions_", "::actions::"); - let name = name.replace("::actions_", "::actions::"); - - let name = name.replace("_others_", "::others::"); - let name = name.replace("::others_", "::others::"); - - let name = name.replace("_mock_token_", "::mock_token::"); - let name = name.replace("::mock_token_", "::mock_token::"); artifacts.push(("models".to_string(), name)); } // contracts for entry in fs::read_dir(contracts_dir).unwrap().flatten() { let name = entry.path().file_stem().unwrap().to_string_lossy().to_string(); - let name = name.replace("_actions_", "::actions::"); - let name = name.replace("_others_", "::others::"); - let name = name.replace("_mock_token_", "::mock_token::"); artifacts.push(("contracts".to_string(), name)); } diff --git a/crates/dojo-world/src/migration/class.rs b/crates/dojo-world/src/migration/class.rs index e5b29f16d9..a6c29d87be 100644 --- a/crates/dojo-world/src/migration/class.rs +++ b/crates/dojo-world/src/migration/class.rs @@ -9,7 +9,10 @@ use super::{Declarable, MigrationType, StateDiff}; /// Represents differences between a local and remote class. #[derive(Debug, Default, Clone)] pub struct ClassDiff { - pub name: String, + pub artifact_name: String, /* name used to identify the corresponding artifact produced by + * the compiler */ + pub name: String, // class name as defined in Cairo files + pub namespace: String, // namespace of the class as defined in Cairo files pub local_class_hash: FieldElement, pub original_class_hash: FieldElement, pub remote_class_hash: Option, diff --git a/crates/dojo-world/src/migration/contract.rs b/crates/dojo-world/src/migration/contract.rs index 59e6c929f9..d828cc41d2 100644 --- a/crates/dojo-world/src/migration/contract.rs +++ b/crates/dojo-world/src/migration/contract.rs @@ -11,7 +11,10 @@ pub type DeclareOutput = DeclareTransactionResult; /// Represents differences between a local and remote contract. #[derive(Debug, Default, Clone)] pub struct ContractDiff { - pub name: String, + pub artifact_name: String, /* name used to identify the corresponding artifact produced by + * the compiler */ + pub name: String, // contract name as defined in Cairo files + pub namespace: String, // namespace of the contract as defined in Cairo files pub local_class_hash: FieldElement, pub original_class_hash: FieldElement, pub base_class_hash: FieldElement, diff --git a/crates/dojo-world/src/migration/mod.rs b/crates/dojo-world/src/migration/mod.rs index 203b5d91de..c3db51a02f 100644 --- a/crates/dojo-world/src/migration/mod.rs +++ b/crates/dojo-world/src/migration/mod.rs @@ -51,7 +51,7 @@ pub struct UpgradeOutput { pub struct RegisterOutput { pub transaction_hash: FieldElement, pub declare_output: Vec, - pub registered_model_names: Vec, + pub registered_models: Vec<(String, String)>, } #[derive(Debug, Error)] diff --git a/crates/dojo-world/src/migration/strategy.rs b/crates/dojo-world/src/migration/strategy.rs index 2a1ce96155..e74bac9cd6 100644 --- a/crates/dojo-world/src/migration/strategy.rs +++ b/crates/dojo-world/src/migration/strategy.rs @@ -12,6 +12,7 @@ use super::class::{ClassDiff, ClassMigration}; use super::contract::{ContractDiff, ContractMigration}; use super::world::WorldDiff; use super::MigrationType; +use crate::utils::split_full_world_element_name; #[derive(Debug, Clone)] pub struct MigrationStrategy { @@ -60,13 +61,30 @@ impl MigrationStrategy { MigrationItemsInfo { new, update } } - pub fn resolve_variable(&mut self, world_address: FieldElement) -> Result<()> { + pub fn resolve_variable( + &mut self, + world_address: FieldElement, + default_namespace: &str, + ) -> Result<()> { let contracts_clone = self.contracts.clone(); + + let find_contract_from_dependency = |dependency: &str| -> Result { + let (dep_namespace, dep_name) = + split_full_world_element_name(dependency, default_namespace)?; + match contracts_clone + .iter() + .find(|c| c.diff.name == dep_name && c.diff.namespace == dep_namespace) + { + Some(c) => Ok(c.clone()), + None => Err(anyhow!("Unable to find the contract: {dependency}")), + } + }; + for contract in self.contracts.iter_mut() { for field in contract.diff.init_calldata.iter_mut() { if let Some(dependency) = field.strip_prefix("$contract_address:") { - let dependency_contract = - contracts_clone.iter().find(|c| c.diff.name == dependency).unwrap(); + let dependency_contract = find_contract_from_dependency(dependency)?; + let contract_address = get_contract_address( generate_salt(&dependency_contract.diff.name), dependency_contract.diff.base_class_hash, @@ -75,8 +93,8 @@ impl MigrationStrategy { ); *field = contract_address.to_string(); } else if let Some(dependency) = field.strip_prefix("$class_hash:") { - let dependency_contract = - contracts_clone.iter().find(|c| c.diff.name == dependency).unwrap(); + let dependency_contract = find_contract_from_dependency(dependency)?; + *field = dependency_contract.diff.local_class_hash.to_string(); } } @@ -182,7 +200,7 @@ fn evaluate_class_to_migrate( Ok(None) } _ => { - let path = find_artifact_path(class.name.as_str(), artifact_paths)?; + let path = find_artifact_path(&class.artifact_name, artifact_paths)?; Ok(Some(ClassMigration { diff: class.clone(), artifact_path: path.clone() })) } } @@ -201,7 +219,7 @@ fn evaluate_contracts_to_migrate( continue; } _ => { - let path = find_artifact_path(c.name.as_str(), artifact_paths)?; + let path = find_artifact_path(&c.artifact_name, artifact_paths)?; comps_to_migrate.push(ContractMigration { diff: c.clone(), artifact_path: path.clone(), @@ -224,7 +242,7 @@ fn evaluate_contract_to_migrate( || contract.remote_class_hash.is_none() || matches!(contract.remote_class_hash, Some(remote_hash) if remote_hash != contract.local_class_hash) { - let path = find_artifact_path(&contract.name, artifact_paths)?; + let path = find_artifact_path(&contract.artifact_name, artifact_paths)?; Ok(Some(ContractMigration { diff: contract.clone(), diff --git a/crates/dojo-world/src/migration/world.rs b/crates/dojo-world/src/migration/world.rs index 27adf6c69a..01b3a3ca95 100644 --- a/crates/dojo-world/src/migration/world.rs +++ b/crates/dojo-world/src/migration/world.rs @@ -3,7 +3,6 @@ use std::mem; use std::str::FromStr; use anyhow::{bail, Result}; -use convert_case::{Case, Casing}; use starknet_crypto::FieldElement; use topological_sort::TopologicalSort; @@ -13,6 +12,7 @@ use super::StateDiff; use crate::manifest::{ BaseManifest, DeploymentManifest, ManifestMethods, BASE_CONTRACT_NAME, WORLD_CONTRACT_NAME, }; +use crate::utils::split_full_world_element_name; #[cfg(test)] #[path = "world_test.rs"] @@ -33,23 +33,16 @@ impl WorldDiff { .models .iter() .map(|model| ClassDiff { - name: model.name.to_string(), + artifact_name: model.artifact_name.to_string(), + name: model.inner.name.to_string(), + namespace: model.inner.namespace.clone(), local_class_hash: *model.inner.class_hash(), original_class_hash: *model.inner.original_class_hash(), remote_class_hash: remote.as_ref().and_then(|m| { - // Remote models are detected from events, where only the struct - // name (pascal case) is emitted. - // Local models uses the fully qualified name of the model, - // always in snake_case from cairo compiler. - let model_name = model - .name - .split("::") - .last() - .unwrap_or(&model.name) - .from_case(Case::Snake) - .to_case(Case::Pascal); - - m.models.iter().find(|e| e.name == model_name).map(|s| *s.inner.class_hash()) + m.models + .iter() + .find(|e| e.manifest_name == model.manifest_name) + .map(|s| *s.inner.class_hash()) }), }) .collect::>(); @@ -68,7 +61,9 @@ impl WorldDiff { }; ContractDiff { - name: contract.name.to_string(), + artifact_name: contract.artifact_name.to_string(), + name: contract.inner.name.to_string(), + namespace: contract.inner.namespace.clone(), local_class_hash: *contract.inner.class_hash(), original_class_hash: *contract.inner.original_class_hash(), base_class_hash, @@ -84,14 +79,18 @@ impl WorldDiff { .collect::>(); let base = ClassDiff { + artifact_name: local.base.artifact_name.clone(), name: BASE_CONTRACT_NAME.into(), + namespace: "__DOJO__".to_string(), local_class_hash: *local.base.inner.class_hash(), original_class_hash: *local.base.inner.original_class_hash(), remote_class_hash: remote.as_ref().map(|m| *m.base.inner.class_hash()), }; let world = ContractDiff { + artifact_name: local.world.artifact_name.clone(), name: WORLD_CONTRACT_NAME.into(), + namespace: "__DOJO__".to_string(), local_class_hash: *local.world.inner.class_hash(), original_class_hash: *local.world.inner.original_class_hash(), base_class_hash: *local.base.inner.class_hash(), @@ -114,19 +113,23 @@ impl WorldDiff { count } - pub fn update_order(&mut self) -> Result<()> { - let mut ts = TopologicalSort::<&str>::new(); + pub fn update_order(&mut self, default_namespace: &str) -> Result<()> { + let mut ts = TopologicalSort::<(String, String)>::new(); // make the dependency graph by reading the constructor_calldata for contract in self.contracts.iter() { - let curr_name: &str = &contract.name; - ts.insert(curr_name); + let cur_full_name = (contract.namespace.clone(), contract.name.clone()); + ts.insert(cur_full_name.clone()); for field in &contract.init_calldata { if let Some(dependency) = field.strip_prefix("$contract_address:") { - ts.add_dependency(dependency, curr_name); + let full_dep_name = + split_full_world_element_name(dependency, default_namespace)?; + ts.add_dependency(full_dep_name, cur_full_name.clone()); } else if let Some(dependency) = field.strip_prefix("$class_hash:") { - ts.add_dependency(dependency, curr_name); + let full_dep_name = + split_full_world_element_name(dependency, default_namespace)?; + ts.add_dependency(full_dep_name, cur_full_name.clone()); } else { // verify its a field element match FieldElement::from_str(field) { @@ -157,8 +160,12 @@ impl WorldDiff { let mut new_contracts = vec![]; - for c_name in calculated_order { - let contract = match self.contracts.iter().find(|c| c.name == c_name) { + for (c_namespace, c_name) in calculated_order { + let contract = match self + .contracts + .iter() + .find(|c| c.namespace == c_namespace && c.name == c_name) + { Some(c) => c, None => bail!("Unidentified contract found in `init_calldata`"), }; diff --git a/crates/dojo-world/src/migration/world_test.rs b/crates/dojo-world/src/migration/world_test.rs index e84e1b2cec..903246c78b 100644 --- a/crates/dojo-world/src/migration/world_test.rs +++ b/crates/dojo-world/src/migration/world_test.rs @@ -8,21 +8,25 @@ fn no_diff_when_local_and_remote_are_equal() { let world_contract = Manifest::new( Class { class_hash: 66_u32.into(), ..Default::default() }, WORLD_CONTRACT_NAME.into(), + WORLD_CONTRACT_NAME.into(), ); let base_contract = Manifest::new( Class { class_hash: 77_u32.into(), ..Default::default() }, BASE_CONTRACT_NAME.into(), + BASE_CONTRACT_NAME.into(), ); let models = vec![Manifest::new( DojoModel { members: vec![], class_hash: 11_u32.into(), ..Default::default() }, + "dojo_mock_model".into(), "dojo_mock::models::model".into(), )]; let remote_models = vec![Manifest::new( DojoModel { members: vec![], class_hash: 11_u32.into(), ..Default::default() }, - "Model".into(), + "dojo_mock_model".into(), + "dojo_mock::models::model".into(), )]; let local = @@ -43,50 +47,86 @@ fn diff_when_local_and_remote_are_different() { let world_contract = Manifest::new( Class { class_hash: 66_u32.into(), ..Default::default() }, WORLD_CONTRACT_NAME.into(), + WORLD_CONTRACT_NAME.into(), ); let base_contract = Manifest::new( Class { class_hash: 77_u32.into(), ..Default::default() }, BASE_CONTRACT_NAME.into(), + BASE_CONTRACT_NAME.into(), ); let models = vec![ Manifest::new( - DojoModel { members: vec![], class_hash: felt!("0x11"), ..Default::default() }, + DojoModel { + name: "model".to_string(), + namespace: "dojo_mock".to_string(), + members: vec![], + class_hash: felt!("0x11"), + ..Default::default() + }, + "dojo_mock:model".into(), "dojo_mock::models::model".into(), ), Manifest::new( - DojoModel { members: vec![], class_hash: felt!("0x22"), ..Default::default() }, + DojoModel { + name: "model_2".to_string(), + namespace: "dojo_mock".to_string(), + members: vec![], + class_hash: felt!("0x22"), + ..Default::default() + }, + "dojo_mock:model_2".into(), "dojo_mock::models::model_2".into(), ), ]; let remote_models = vec![ Manifest::new( - DojoModel { members: vec![], class_hash: felt!("0x11"), ..Default::default() }, - "Model".into(), + DojoModel { + name: "model".to_string(), + namespace: "dojo_mock".to_string(), + members: vec![], + class_hash: felt!("0x11"), + ..Default::default() + }, + "dojo_mock:model".into(), + "dojo_mock::models::model".into(), ), Manifest::new( - DojoModel { members: vec![], class_hash: felt!("0x33"), ..Default::default() }, - "Model2".into(), + DojoModel { + name: "model_2".to_string(), + namespace: "dojo_mock".to_string(), + members: vec![], + class_hash: felt!("0x33"), + ..Default::default() + }, + "dojo_mock:model_2".into(), + "dojo_mock::models::model_2".into(), ), ]; let contracts = vec![ Manifest::new( DojoContract { + name: "my_contract".to_string(), + namespace: "dojo_mock".to_string(), class_hash: felt!("0x1111"), address: Some(felt!("0x2222")), ..DojoContract::default() }, + "dojo_mock:my_contract".into(), "dojo_mock::contracts::my_contract".into(), ), Manifest::new( DojoContract { + name: "my_contract_2".to_string(), + namespace: "dojo_mock".to_string(), class_hash: felt!("0x3333"), address: Some(felt!("4444")), ..DojoContract::default() }, + "dojo_mock:my_contract_2".into(), "dojo_mock::contracts::my_contract_2".into(), ), ]; @@ -102,27 +142,28 @@ fn diff_when_local_and_remote_are_different() { let diff = WorldDiff::compute(local, Some(remote)); assert_eq!(diff.count_diffs(), 3); - assert!(diff.models.iter().any(|m| m.name == "dojo_mock::models::model_2")); - assert!(diff.contracts.iter().any(|c| c.name == "dojo_mock::contracts::my_contract")); + assert!(diff.models.iter().any(|m| m.name == "model_2" && m.namespace == "dojo_mock")); + assert!(diff.contracts.iter().any(|c| c.name == "my_contract" && c.namespace == "dojo_mock")); } #[test] fn updating_order_as_expected() { let init_calldata = vec![ - ("c4", vec!["$contract_address:c1", "0x0"]), - ("c3", vec!["0x0"]), - ("c5", vec!["$contract_address:c4", "0x0"]), - ("c7", vec!["$contract_address:c4", "0x0"]), - ("c2", vec!["0x0"]), - ("c6", vec!["$contract_address:c4", "$contract_address:c3", "0x0"]), - ("c1", vec!["0x0"]), + ("ns", "c4", vec!["$contract_address:ns:c1", "0x0"]), + ("ns", "c3", vec!["0x0"]), + ("ns", "c5", vec!["$contract_address:ns:c4", "0x0"]), + ("ns", "c7", vec!["$contract_address:ns:c4", "0x0"]), + ("ns", "c2", vec!["0x0"]), + ("ns", "c6", vec!["$contract_address:ns:c4", "$contract_address:ns:c3", "0x0"]), + ("ns", "c1", vec!["0x0"]), ]; let mut contracts = vec![]; for calldata in init_calldata { contracts.push(ContractDiff { - init_calldata: calldata.1.iter().map(|c| c.to_string()).collect(), - name: calldata.0.to_string(), + init_calldata: calldata.2.iter().map(|c| c.to_string()).collect(), + name: calldata.1.to_string(), + namespace: calldata.0.to_string(), ..Default::default() }); } @@ -134,7 +175,7 @@ fn updating_order_as_expected() { models: vec![], }; - diff.update_order().unwrap(); + diff.update_order("ns").unwrap(); let expected_order = ["c1", "c2", "c3", "c4", "c5", "c6", "c7"]; for (i, contract) in diff.contracts.iter().enumerate() { @@ -145,20 +186,21 @@ fn updating_order_as_expected() { #[test] fn updating_order_when_cyclic_dependency_fail() { let init_calldata = vec![ - ("c4", vec!["$contract_address:c1", "$contract_address:c6", "0x0"]), - ("c3", vec!["0x0"]), - ("c5", vec!["$contract_address:c4", "0x0"]), - ("c7", vec!["$contract_address:c4", "0x0"]), - ("c2", vec!["0x0"]), - ("c6", vec!["$contract_address:c4", "$contract_address:c3", "0x0"]), - ("c1", vec!["0x0"]), + ("ns", "c4", vec!["$contract_address:ns:c1", "$contract_address:ns:c6", "0x0"]), + ("ns", "c3", vec!["0x0"]), + ("ns", "c5", vec!["$contract_address:ns:c4", "0x0"]), + ("ns", "c7", vec!["$contract_address:ns:c4", "0x0"]), + ("ns", "c2", vec!["0x0"]), + ("ns", "c6", vec!["$contract_address:ns:c4", "$contract_address:ns:c3", "0x0"]), + ("ns", "c1", vec!["0x0"]), ]; let mut contracts = vec![]; for calldata in init_calldata { contracts.push(ContractDiff { - init_calldata: calldata.1.iter().map(|c| c.to_string()).collect(), - name: calldata.0.to_string(), + init_calldata: calldata.2.iter().map(|c| c.to_string()).collect(), + namespace: calldata.0.to_string(), + name: calldata.1.to_string(), ..Default::default() }); } @@ -170,5 +212,5 @@ fn updating_order_when_cyclic_dependency_fail() { models: vec![], }; - assert!(diff.update_order().is_err_and(|e| e.to_string().contains("Cyclic"))); + assert!(diff.update_order("ns").is_err_and(|e| e.to_string().contains("Cyclic"))); } diff --git a/crates/dojo-world/src/utils.rs b/crates/dojo-world/src/utils.rs index 25e478bce0..e333eb7461 100644 --- a/crates/dojo-world/src/utils.rs +++ b/crates/dojo-world/src/utils.rs @@ -3,6 +3,9 @@ use std::pin::Pin; use std::task::{Context, Poll}; use std::time::Duration; +use anyhow::{anyhow, Result}; +use cainome::cairo_serde::{ByteArray, CairoSerde}; +use convert_case::{Case, Casing}; use futures::FutureExt; use starknet::accounts::{ AccountDeployment, AccountError, AccountFactory, AccountFactoryError, ConnectedAccount, @@ -14,6 +17,7 @@ use starknet::core::types::{ StarknetError, TransactionFinalityStatus, TransactionReceipt, TransactionStatus, }; use starknet::providers::{Provider, ProviderError}; +use starknet_crypto::poseidon_hash_many; use tokio::time::{Instant, Interval}; use crate::migration::TxnConfig; @@ -24,6 +28,9 @@ type GetTxReceiptResult = Result; type GetTxStatusFuture<'a> = Pin + Send + 'a>>; type GetTxReceiptFuture<'a> = Pin + Send + 'a>>; +pub const FULLNAME_SEPARATOR: char = ':'; +pub const MANIFEST_NAME_SEPARATOR: char = '-'; + #[derive(Debug, thiserror::Error)] pub enum TransactionWaitingError { #[error("request timed out")] @@ -418,6 +425,66 @@ where } } +/// The artifact name is used as key to access to some information about +/// compiled elements during the compilation. +/// An artifact name is built by concatenating the fully qualified module name +/// and the element name in snake case, separated by '::'. +pub fn get_artifact_name(module_name: &str, element_name: &str) -> String { + format!("{module_name}::{element_name}").to_case(Case::Snake) +} + +/// Build the full name of an element by concatenating its namespace and its name, +/// using a dedicated separator. +pub fn get_full_world_element_name(namespace: &str, element_name: &str) -> String { + format!("{}{FULLNAME_SEPARATOR}{}", namespace, element_name) +} + +/// Build the full name of an element by concatenating its namespace and its name, +/// using a specific separator. +pub fn get_manifest_name(namespace: &str, element_name: &str) -> String { + format!( + "{}{MANIFEST_NAME_SEPARATOR}{}", + namespace.to_case(Case::Snake), + element_name.to_case(Case::Snake) + ) +} + +/// Get the namespace and the name of a world element from its full name. +/// If no namespace is specified, use the default one. +pub fn split_full_world_element_name( + full_name: &str, + default_namespace: &str, +) -> Result<(String, String)> { + let parts: Vec<&str> = full_name.split(FULLNAME_SEPARATOR).collect(); + match parts.len() { + 1 => Ok((default_namespace.to_string(), full_name.to_string())), + 2 => Ok((parts[0].to_string(), parts[1].to_string())), + _ => Err(anyhow!( + "Unexpected full name. Expected format: {FULLNAME_SEPARATOR} or \ + " + )), + } +} + +pub fn compute_bytearray_hash(namespace: &str) -> FieldElement { + let ba = ByteArray::from_string(namespace).unwrap(); + poseidon_hash_many(&ByteArray::cairo_serialize(&ba)) +} + +pub fn compute_model_selector_from_names(namespace: &str, model_name: &str) -> FieldElement { + compute_model_selector_from_hash( + compute_bytearray_hash(namespace), + compute_bytearray_hash(model_name), + ) +} + +pub fn compute_model_selector_from_hash( + namespace_hash: FieldElement, + model_hash: FieldElement, +) -> FieldElement { + poseidon_hash_many(&[namespace_hash, model_hash]) +} + #[cfg(test)] mod tests { use assert_matches::assert_matches; diff --git a/crates/sozo/ops/Cargo.toml b/crates/sozo/ops/Cargo.toml index f4144ae66b..4008ffa63d 100644 --- a/crates/sozo/ops/Cargo.toml +++ b/crates/sozo/ops/Cargo.toml @@ -33,6 +33,7 @@ dojo-lang.workspace = true dojo-types.workspace = true dojo-world = { workspace = true, features = [ "contracts", "metadata", "migration" ] } futures.workspace = true +itertools.workspace = true notify = "6.0.1" notify-debouncer-mini = "0.3.0" rpassword.workspace = true diff --git a/crates/sozo/ops/src/auth.rs b/crates/sozo/ops/src/auth.rs index 9edb851b48..476c7cd6e3 100644 --- a/crates/sozo/ops/src/auth.rs +++ b/crates/sozo/ops/src/auth.rs @@ -5,11 +5,11 @@ use dojo_world::contracts::model::ModelError; use dojo_world::contracts::world::WorldContract; use dojo_world::contracts::{cairo_utils, WorldContractReader}; use dojo_world::migration::TxnConfig; -use dojo_world::utils::TransactionExt; +use dojo_world::utils::{compute_model_selector_from_names, TransactionExt}; use scarb_ui::Ui; use starknet::accounts::{Account, ConnectedAccount}; use starknet::core::types::{BlockId, BlockTag}; -use starknet::core::utils::{get_selector_from_name, parse_cairo_short_string}; +use starknet::core::utils::parse_cairo_short_string; use starknet_crypto::FieldElement; use crate::utils; @@ -23,7 +23,7 @@ pub enum ResourceType { #[derive(Debug, Clone, PartialEq)] pub struct ModelContract { pub model: FieldElement, - pub contract: String, + pub contract: String, // contract name or address } impl FromStr for ModelContract { @@ -108,9 +108,10 @@ where // Should we add the version into the `ModelContract` struct? Can we always know that? for mc in models_contracts { let model_name = parse_cairo_short_string(&mc.model)?; - let model_selector = get_selector_from_name(&model_name)?; + let namespace = "TODO".to_string(); + let model_selector = compute_model_selector_from_names(&namespace, &model_name); - match world_reader.model_reader(&model_name).await { + match world_reader.model_reader(&namespace, &model_name).await { Ok(_) => { let contract = utils::get_contract_address(world, mc.contract).await?; calls.push(world.grant_writer_getcall(&model_selector, &contract.into())); @@ -166,7 +167,8 @@ where // Should we add the version into the `ModelContract` struct? Can we always know // that? let model_name = parse_cairo_short_string(name)?; - get_selector_from_name(&model_name)? + let namespace = "TODO".to_string(); + compute_model_selector_from_names(&namespace, &model_name) } ResourceType::Contract(name_or_address) => { utils::get_contract_address(world, name_or_address.clone()).await? @@ -214,16 +216,17 @@ where // selector), we're not able to distinguish that. // Should we add the version into the `ModelContract` struct? Can we always know that? let model_name = parse_cairo_short_string(&mc.model)?; - let model_selector = get_selector_from_name(&model_name)?; + let namespace = "TODO".to_string(); + let model_selector = compute_model_selector_from_names(&namespace, &model_name); - match world_reader.model_reader(&model_name).await { + match world_reader.model_reader(&namespace, &model_name).await { Ok(_) => { let contract = utils::get_contract_address(world, mc.contract).await?; calls.push(world.revoke_writer_getcall(&model_selector, &contract.into())); } Err(ModelError::ModelNotFound) => { - ui.print(format!("Unknown model '{}' => IGNORED", model_name)); + ui.print(format!("Unknown model '{}::{}' => IGNORED", namespace, model_name)); } Err(err) => { @@ -272,7 +275,8 @@ where // Should we add the version into the `ModelContract` struct? Can we always know // that? let model_name = parse_cairo_short_string(name)?; - get_selector_from_name(&model_name)? + let namespace = "TODO".to_string(); + compute_model_selector_from_names(&namespace, &model_name) } ResourceType::Contract(name_or_address) => { utils::get_contract_address(world, name_or_address.clone()).await? diff --git a/crates/sozo/ops/src/events.rs b/crates/sozo/ops/src/events.rs index b567157201..9005db9d7f 100644 --- a/crates/sozo/ops/src/events.rs +++ b/crates/sozo/ops/src/events.rs @@ -2,6 +2,7 @@ use std::collections::{HashMap, VecDeque}; use std::fs; use anyhow::{anyhow, Result}; +use cainome::cairo_serde::{ByteArray, CairoSerde}; use cainome::parser::tokens::{CompositeInner, CompositeInnerKind, CoreBasic, Token}; use cainome::parser::AbiParser; use camino::Utf8PathBuf; @@ -212,6 +213,16 @@ fn process_inners( let formatted_value = match &inner.token { Token::CoreBasic(ref cb) => parse_core_basic(cb, &value, true)?, + Token::Composite(c) => { + if c.type_path.eq("core::byte_array::ByteArray") { + data.push_front(value); + let bytearray = ByteArray::cairo_deserialize(data.as_mut_slices().0, 0)?; + data.drain(0..ByteArray::cairo_serialized_size(&bytearray)); + ByteArray::to_string(&bytearray)? + } else { + return Err(anyhow!("Unhandled Composite token")); + } + } Token::Array(ref array) => { let length = value .to_string() diff --git a/crates/sozo/ops/src/migration/auto_auth.rs b/crates/sozo/ops/src/migration/auto_auth.rs index df213e144c..45832f46f9 100644 --- a/crates/sozo/ops/src/migration/auto_auth.rs +++ b/crates/sozo/ops/src/migration/auto_auth.rs @@ -2,6 +2,7 @@ use anyhow::Result; use dojo_world::contracts::{cairo_utils, WorldContract}; use dojo_world::manifest::BaseManifest; use dojo_world::migration::TxnConfig; +use dojo_world::utils::get_full_world_element_name; use scarb::core::Workspace; use scarb_ui::Ui; use starknet::accounts::ConnectedAccount; @@ -43,12 +44,16 @@ pub fn compute_models_contracts( // Find that contract from local_manifest based on its name. let contract = local_contracts .iter() - .find(|c| migrated_contract.name == c.name) + .find(|c| { + migrated_contract.namespace == c.inner.namespace + && migrated_contract.name == c.inner.name + }) .expect("we know this contract exists"); ui.print_sub(format!( "Authorizing {} for Models: {:?}", - contract.name, contract.inner.writes + get_full_world_element_name(&contract.inner.namespace, &contract.inner.name), + contract.inner.writes )); // Read all the models that its supposed to write and collect them in a Vec diff --git a/crates/sozo/ops/src/migration/migrate.rs b/crates/sozo/ops/src/migration/migrate.rs index 420c269237..4c3b85a90b 100644 --- a/crates/sozo/ops/src/migration/migrate.rs +++ b/crates/sozo/ops/src/migration/migrate.rs @@ -1,6 +1,7 @@ use std::path::Path; use anyhow::{anyhow, bail, Context, Result}; +use cainome::cairo_serde::ByteArray; use camino::Utf8PathBuf; use dojo_world::contracts::abi::world; use dojo_world::contracts::{cairo_utils, WorldContract}; @@ -17,8 +18,12 @@ use dojo_world::migration::world::WorldDiff; use dojo_world::migration::{ Declarable, Deployable, MigrationError, RegisterOutput, TxnConfig, Upgradable, }; -use dojo_world::utils::{TransactionExt, TransactionWaiter}; +use dojo_world::utils::{ + compute_model_selector_from_names, get_full_world_element_name, TransactionExt, + TransactionWaiter, +}; use futures::future; +use itertools::Itertools; use scarb::core::Workspace; use scarb_ui::Ui; use starknet::accounts::ConnectedAccount; @@ -214,11 +219,21 @@ where let world_address = strategy.world_address()?; + // register namespaces + let mut namespaces = + strategy.models.iter().map(|m| m.diff.namespace.to_string()).collect::>(); + namespaces.extend( + strategy.contracts.iter().map(|c| c.diff.namespace.to_string()).collect::>(), + ); + namespaces = namespaces.into_iter().unique().collect::>(); + + register_namespaces(&namespaces, world_address, &migrator, &ui, &txn_config).await?; + // Once Torii supports indexing arrays, we should declare and register the // ResourceMetadata model. match register_dojo_models(&strategy.models, world_address, &migrator, &ui, &txn_config).await { Ok(output) => { - migration_output.models = output.registered_model_names; + migration_output.models = output.registered_models; } Err(e) => { ui.anyhow(&e); @@ -333,11 +348,12 @@ where // models if !migration_output.models.is_empty() { - for model_name in migration_output.models { - if let Some(m) = dojo_metadata.resources_artifacts.get(&model_name) { + for (namespace, model_name) in migration_output.models { + let full_name = get_full_world_element_name(&namespace, &model_name); + if let Some(m) = dojo_metadata.resources_artifacts.get(&full_name) { ipfs.push(upload_on_ipfs_and_create_resource( &ui, - get_selector_from_name(&model_name).expect("ASCII model name"), + compute_model_selector_from_names(&namespace, &model_name), m.clone(), )); } @@ -349,7 +365,8 @@ where if !migrated_contracts.is_empty() { for contract in migrated_contracts { - if let Some(m) = dojo_metadata.resources_artifacts.get(&contract.name) { + let full_name = get_full_world_element_name(&contract.namespace, &contract.name); + if let Some(m) = dojo_metadata.resources_artifacts.get(&full_name) { ipfs.push(upload_on_ipfs_and_create_resource( &ui, contract.contract_address, @@ -392,10 +409,46 @@ where Ok(()) } +async fn register_namespaces( + namespaces: &[String], + world_address: FieldElement, + migrator: &A, + ui: &Ui, + txn_config: &TxnConfig, +) -> Result<()> +where + A: ConnectedAccount + Send + Sync, + ::Provider: Send, +{ + ui.print_header(format!("# Namespaces ({})", namespaces.len())); + + let world = WorldContract::new(world_address, migrator); + + let calls = namespaces + .iter() + .map(|ns| { + ui.print(italic_message(&ns).to_string()); + world.register_namespace_getcall(&ByteArray::from_string(ns).unwrap()) + }) + .collect::>(); + + let InvokeTransactionResult { transaction_hash } = + world.account.execute(calls).send_with_cfg(txn_config).await.map_err(|e| { + ui.verbose(format!("{e:?}")); + anyhow!("Failed to register namespace to World: {e}") + })?; + + TransactionWaiter::new(transaction_hash, migrator.provider()).await?; + + ui.print(format!("All namespaces are registered at: {transaction_hash:#x}\n")); + + Ok(()) +} + async fn register_dojo_models( models: &[ClassMigration], world_address: FieldElement, - migrator: A, + migrator: &A, ui: &Ui, txn_config: &TxnConfig, ) -> Result @@ -407,14 +460,14 @@ where return Ok(RegisterOutput { transaction_hash: FieldElement::ZERO, declare_output: vec![], - registered_model_names: vec![], + registered_models: vec![], }); } ui.print_header(format!("# Models ({})", models.len())); let mut declare_output = vec![]; - let mut registered_model_names = vec![]; + let mut registered_models = vec![]; for c in models.iter() { ui.print(italic_message(&c.diff.name).to_string()); @@ -449,7 +502,7 @@ where let calls = models .iter() .map(|c| { - registered_model_names.push(c.diff.name.clone()); + registered_models.push((c.diff.namespace.clone(), c.diff.name.clone())); world.register_model_getcall(&c.diff.local_class_hash.into()) }) .collect::>(); @@ -462,9 +515,9 @@ where TransactionWaiter::new(transaction_hash, migrator.provider()).await?; - ui.print(format!("All models are registered at: {transaction_hash:#x}")); + ui.print(format!("All models are registered at: {transaction_hash:#x}\n")); - Ok(RegisterOutput { transaction_hash, declare_output, registered_model_names }) + Ok(RegisterOutput { transaction_hash, declare_output, registered_models }) } async fn register_dojo_contracts( @@ -531,6 +584,7 @@ where } deploy_output.push(Some(ContractMigrationOutput { name: name.to_string(), + namespace: contract.diff.namespace.to_string(), contract_address: output.contract_address, base_class_hash: output.base_class_hash, })); @@ -800,7 +854,7 @@ pub async fn update_manifests_and_abis( let local = local_manifest .contracts .iter_mut() - .find(|c| c.name == output.name) + .find(|c| c.inner.namespace == output.namespace && c.inner.name == output.name) .expect("contract got migrated, means it should be present here"); local.inner.base_class_hash = output.base_class_hash; @@ -810,7 +864,7 @@ pub async fn update_manifests_and_abis( local_manifest.contracts.iter_mut().for_each(|contract| { if contract.inner.base_class_hash != FieldElement::ZERO { - let salt = generate_salt(&contract.name); + let salt = generate_salt(&contract.inner.name); contract.inner.address = Some(get_contract_address( salt, contract.inner.base_class_hash, diff --git a/crates/sozo/ops/src/migration/mod.rs b/crates/sozo/ops/src/migration/mod.rs index 21351004a2..8ed837fc58 100644 --- a/crates/sozo/ops/src/migration/mod.rs +++ b/crates/sozo/ops/src/migration/mod.rs @@ -12,9 +12,12 @@ use dojo_world::manifest::{ use dojo_world::migration::world::WorldDiff; use dojo_world::migration::{DeployOutput, TxnConfig, UpgradeOutput}; use scarb::core::Workspace; +use smol_str::ToSmolStr; use starknet::accounts::ConnectedAccount; use starknet::core::types::FieldElement; +use crate::utils::get_default_namespace_from_ws; + mod auto_auth; mod migrate; mod ui; @@ -36,13 +39,14 @@ pub struct MigrationOutput { // If false that means migration got partially completed. pub full: bool, - pub models: Vec, + pub models: Vec<(String, String)>, pub contracts: Vec>, } #[derive(Debug, Default, Clone)] pub struct ContractMigrationOutput { pub name: String, + pub namespace: String, pub contract_address: FieldElement, pub base_class_hash: FieldElement, } @@ -75,6 +79,8 @@ where let target_dir = ws.target_dir().path_existent().unwrap(); let target_dir = target_dir.join(ws.config().profile().as_str()); + let default_namespace = get_default_namespace_from_ws(ws); + // Load local and remote World manifests. let (local_manifest, remote_manifest) = utils::load_world_manifests(&profile_dir, &account, world_address, &ui, skip_manifests) @@ -90,7 +96,7 @@ where // Calculate diff between local and remote World manifests. ui.print_step(2, "🧰", "Evaluating Worlds diff..."); let mut diff = WorldDiff::compute(local_manifest.clone(), remote_manifest.clone()); - diff.update_order()?; + diff.update_order(&default_namespace)?; let total_diffs = diff.count_diffs(); ui.print_sub(format!("Total diffs found: {total_diffs}")); @@ -102,7 +108,7 @@ where let mut strategy = prepare_migration(&target_dir, diff, name, world_address, &ui)?; let world_address = strategy.world_address().expect("world address must exist"); - strategy.resolve_variable(world_address)?; + strategy.resolve_variable(world_address, &default_namespace)?; if dry_run { print_strategy(&ui, account.provider(), &strategy, world_address).await; @@ -150,19 +156,26 @@ where ) .await?; + // TODO: temporary deactivate auto-auth because it should be adapted + // with the new namespace feature. let account = Arc::new(account); let world = WorldContract::new(world_address, account.clone()); if let Some(migration_output) = migration_output { - match auto_authorize(ws, &world, &txn_config, &local_manifest, &migration_output).await - { - Ok(()) => { - ui.print_sub("Auto authorize completed successfully"); - } - Err(e) => { - ui.print_sub(format!("Failed to auto authorize with error: {e}")); - } - }; + // TODO + if false { + match auto_authorize(ws, &world, &txn_config, &local_manifest, &migration_output) + .await + { + Ok(()) => { + ui.print_sub("Auto authorize completed successfully"); + } + Err(e) => { + ui.print_sub(format!("Failed to auto authorize with error: {e}")); + } + }; + } + // if !ws.config().offline() { upload_metadata(ws, &account, migration_output.clone(), txn_config).await?; } @@ -232,8 +245,11 @@ fn overlay_dojo_contracts_from_path(path: &Utf8PathBuf) -> Result = toml::from_str(&fs::read_to_string(path)?)?; - let overlay_manifest = - OverlayDojoContract { name: manifest.name, ..Default::default() }; + let overlay_manifest = OverlayDojoContract { + name: manifest.inner.name.to_smolstr(), + namespace: manifest.inner.namespace, + ..Default::default() + }; elements.push(overlay_manifest); } else { continue; @@ -255,7 +271,11 @@ fn overlay_model_from_path(path: &Utf8PathBuf) -> Result> if path.is_file() { let manifest: Manifest = toml::from_str(&fs::read_to_string(path)?)?; - let overlay_manifest = OverlayDojoModel { name: manifest.name, ..Default::default() }; + let overlay_manifest = OverlayDojoModel { + name: manifest.inner.name.to_smolstr(), + namespace: manifest.inner.namespace, + ..Default::default() + }; elements.push(overlay_manifest); } else { continue; diff --git a/crates/sozo/ops/src/model.rs b/crates/sozo/ops/src/model.rs index 1bfe108e96..304ecf6ad7 100644 --- a/crates/sozo/ops/src/model.rs +++ b/crates/sozo/ops/src/model.rs @@ -11,6 +11,7 @@ use starknet::providers::JsonRpcClient; const INDENT: &str = " "; pub async fn model_class_hash( + namespace: String, name: String, world_address: FieldElement, provider: JsonRpcClient, @@ -18,7 +19,7 @@ pub async fn model_class_hash( let mut world_reader = WorldContractReader::new(world_address, &provider); world_reader.set_block(BlockId::Tag(BlockTag::Pending)); - let model = world_reader.model_reader(&name).await?; + let model = world_reader.model_reader(&namespace, &name).await?; println!("{:#x}", model.class_hash()); @@ -26,6 +27,7 @@ pub async fn model_class_hash( } pub async fn model_contract_address( + namespace: String, name: String, world_address: FieldElement, provider: JsonRpcClient, @@ -33,7 +35,7 @@ pub async fn model_contract_address( let mut world_reader = WorldContractReader::new(world_address, &provider); world_reader.set_block(BlockId::Tag(BlockTag::Pending)); - let model = world_reader.model_reader(&name).await?; + let model = world_reader.model_reader(&namespace, &name).await?; println!("{:#x}", model.contract_address()); @@ -41,6 +43,7 @@ pub async fn model_contract_address( } pub async fn model_layout( + namespace: String, name: String, world_address: FieldElement, provider: JsonRpcClient, @@ -48,7 +51,7 @@ pub async fn model_layout( let mut world_reader = WorldContractReader::new(world_address, &provider); world_reader.set_block(BlockId::Tag(BlockTag::Pending)); - let model = world_reader.model_reader(&name).await?; + let model = world_reader.model_reader(&namespace, &name).await?; let layout = match model.layout().await { Ok(x) => x, Err(_) => anyhow::bail!( @@ -64,6 +67,7 @@ pub async fn model_layout( } pub async fn model_schema( + namespace: String, name: String, world_address: FieldElement, provider: JsonRpcClient, @@ -72,7 +76,7 @@ pub async fn model_schema( let mut world_reader = WorldContractReader::new(world_address, &provider); world_reader.set_block(BlockId::Tag(BlockTag::Pending)); - let model = world_reader.model_reader(&name).await?; + let model = world_reader.model_reader(&namespace, &name).await?; let schema = model.schema().await?; if to_json { @@ -85,6 +89,7 @@ pub async fn model_schema( } pub async fn model_get( + namespace: String, name: String, keys: Vec, world_address: FieldElement, @@ -97,7 +102,7 @@ pub async fn model_get( let mut world_reader = WorldContractReader::new(world_address, &provider); world_reader.set_block(BlockId::Tag(BlockTag::Pending)); - let model = world_reader.model_reader(&name).await?; + let model = world_reader.model_reader(&namespace, &name).await?; let schema = model.schema().await?; let values = model.entity_storage(&keys).await?; diff --git a/crates/sozo/ops/src/register.rs b/crates/sozo/ops/src/register.rs index c1edf97264..4d05598531 100644 --- a/crates/sozo/ops/src/register.rs +++ b/crates/sozo/ops/src/register.rs @@ -5,7 +5,7 @@ use dojo_world::contracts::model::ModelReader; use dojo_world::contracts::{WorldContract, WorldContractReader}; use dojo_world::manifest::DeploymentManifest; use dojo_world::migration::TxnConfig; -use dojo_world::utils::TransactionExt; +use dojo_world::utils::{get_full_world_element_name, TransactionExt}; use scarb::core::Config; use starknet::accounts::ConnectedAccount; use starknet::providers::Provider; @@ -34,20 +34,22 @@ where } }; - let registered_models_names = manifest.models.iter().map(|m| m.name.as_str()); + let registered_models = + manifest.models.iter().map(|m| (m.inner.namespace.clone(), m.inner.name.clone())); let mut model_class_hashes = HashMap::new(); - for model_name in registered_models_names { - let read_model = world_reader.model_reader(model_name).await?; + for (namespace, model_name) in registered_models { + let read_model = world_reader.model_reader(&namespace, &model_name).await?; let class_hash = read_model.class_hash(); - model_class_hashes.insert(class_hash, model_name); + model_class_hashes.insert(class_hash, (namespace, model_name)); } let mut models_to_register = Vec::new(); for input_model in models { - if let Some(model_name) = model_class_hashes.get(&input_model) { + if let Some((namespace, model_name)) = model_class_hashes.get(&input_model) { config.ui().print(format!( "\"{}\" model already registered with the class hash \"{:#x}\"", - model_name, input_model + get_full_world_element_name(namespace, model_name), + input_model )); } else { models_to_register.push(input_model); diff --git a/crates/sozo/ops/src/tests/migration.rs b/crates/sozo/ops/src/tests/migration.rs index 1c070dbd48..ae33424349 100644 --- a/crates/sozo/ops/src/tests/migration.rs +++ b/crates/sozo/ops/src/tests/migration.rs @@ -27,7 +27,7 @@ use starknet_crypto::FieldElement; use super::setup; use crate::migration::{auto_authorize, execute_strategy, upload_metadata}; -use crate::utils::get_contract_address_from_reader; +use crate::utils::{get_contract_address_from_reader, get_default_namespace_from_ws}; #[tokio::test(flavor = "multi_thread")] async fn migrate_with_auto_mine() { @@ -218,8 +218,10 @@ async fn migrate_with_auto_authorize() { let config = setup::load_config(); let ws = setup::setup_ws(&config); + let default_namespace = get_default_namespace_from_ws(&ws); + let mut migration = setup::setup_migration(&config).unwrap(); - migration.resolve_variable(migration.world_address().unwrap()).unwrap(); + migration.resolve_variable(migration.world_address().unwrap(), &default_namespace).unwrap(); let manifest_base = config.manifest_path().parent().unwrap(); let mut manifest = @@ -256,7 +258,11 @@ async fn migrate_with_auto_authorize() { let contract_address = get_contract_address_from_reader(&world_reader, c.diff.name.clone()).await.unwrap(); - let contract = manifest.contracts.iter().find(|a| a.name == c.diff.name).unwrap(); + let contract = manifest + .contracts + .iter() + .find(|a| a.inner.namespace == c.diff.namespace && a.inner.name == c.diff.name) + .unwrap(); for model in &contract.inner.writes { let model_selector = get_selector_from_name(model).unwrap(); @@ -271,15 +277,19 @@ async fn migrate_with_auto_authorize() { #[tokio::test(flavor = "multi_thread")] async fn migration_with_mismatching_world_address_and_seed() { let config = setup::load_config(); + let ws = setup::setup_ws(&config); let base_dir = config.manifest_path().parent().unwrap().to_path_buf(); let target_dir = base_dir.join("target").join("dev"); + let default_namespace = get_default_namespace_from_ws(&ws); + let result = prepare_migration_with_world_and_seed( base_dir, target_dir, Some(felt!("0x1")), "sozo_test", + &default_namespace, ); assert!(result.is_err()); diff --git a/crates/sozo/ops/src/tests/setup.rs b/crates/sozo/ops/src/tests/setup.rs index 0606ca74a0..5230b5c247 100644 --- a/crates/sozo/ops/src/tests/setup.rs +++ b/crates/sozo/ops/src/tests/setup.rs @@ -15,6 +15,7 @@ use starknet::providers::JsonRpcClient; use starknet::signers::LocalWallet; use crate::migration; +use crate::utils::get_default_namespace_from_ws; /// Load the spawn-and-moves project configuration from a copy of the project /// into a temporary directory to avoid any race during multithreading testing. @@ -53,11 +54,21 @@ pub fn setup_ws(config: &Config) -> Workspace<'_> { /// /// A [`MigrationStrategy`] to execute to migrate the full spawn-and-moves project. pub fn setup_migration(config: &Config) -> Result { + let ws = setup_ws(config); + let manifest_path = config.manifest_path(); let base_dir = manifest_path.parent().unwrap(); let target_dir = format!("{}/target/dev", base_dir); - prepare_migration_with_world_and_seed(base_dir.into(), target_dir.into(), None, "sozo_test") + let default_namespace = get_default_namespace_from_ws(&ws); + + prepare_migration_with_world_and_seed( + base_dir.into(), + target_dir.into(), + None, + "sozo_test", + &default_namespace, + ) } /// Setups the project by migrating the full spawn-and-moves project. diff --git a/crates/sozo/ops/src/utils.rs b/crates/sozo/ops/src/utils.rs index 5fd777fc11..a2824487eb 100644 --- a/crates/sozo/ops/src/utils.rs +++ b/crates/sozo/ops/src/utils.rs @@ -2,6 +2,7 @@ use anyhow::{anyhow, Result}; use dojo_world::contracts::world::{WorldContract, WorldContractReader}; use dojo_world::migration::strategy::generate_salt; use dojo_world::utils::{execution_status_from_maybe_pending_receipt, TransactionWaiter}; +use scarb::core::Workspace; use scarb_ui::Ui; use starknet::accounts::ConnectedAccount; use starknet::core::types::{ @@ -136,3 +137,7 @@ pub fn parse_block_id(block_str: String) -> Result { } } } + +pub fn get_default_namespace_from_ws(ws: &Workspace<'_>) -> String { + ws.current_package().unwrap().id.name.to_string() +} diff --git a/crates/torii/client/src/client/mod.rs b/crates/torii/client/src/client/mod.rs index a87415bb95..1a40c79ba4 100644 --- a/crates/torii/client/src/client/mod.rs +++ b/crates/torii/client/src/client/mod.rs @@ -79,7 +79,8 @@ impl Client { // TODO: change this to querying the gRPC url instead let subbed_models = subbed_models.models_keys.read().clone(); for keys in subbed_models { - let model_reader = world_reader.model_reader(&keys.model).await?; + // TODO: handle namespace + let model_reader = world_reader.model_reader("TODO", &keys.model).await?; let values = model_reader.entity_storage(&keys.keys).await?; client_storage.set_model_storage( @@ -182,7 +183,8 @@ impl Client { }; if !self.subscribed_models.is_synced(keys) { - let model = self.world_reader.model_reader(&keys.model).await?; + // TODO: handle namespace + let model = self.world_reader.model_reader("TODO", &keys.model).await?; return Ok(Some(model.entity(&keys.keys).await?)); } @@ -278,7 +280,8 @@ impl Client { } async fn initiate_model(&self, model: &str, keys: Vec) -> Result<(), Error> { - let model_reader = self.world_reader.model_reader(model).await?; + // TODO: handle namespace + let model_reader = self.world_reader.model_reader("TODO", model).await?; let values = model_reader.entity_storage(&keys).await?; self.storage.set_model_storage( cairo_short_string_to_felt(model).map_err(ParseError::CairoShortStringToFelt)?, diff --git a/crates/torii/core/src/processors/register_model.rs b/crates/torii/core/src/processors/register_model.rs index b23afab5d3..38281a00e1 100644 --- a/crates/torii/core/src/processors/register_model.rs +++ b/crates/torii/core/src/processors/register_model.rs @@ -50,7 +50,8 @@ where let name = ByteArray::cairo_deserialize(&event.data, 0)?; let name = name.to_string()?; - let model = world.model_reader(&name).await?; + // TODO: handle namespace + let model = world.model_reader("TODO", &name).await?; let schema = model.schema().await?; let layout = model.layout().await?; diff --git a/crates/torii/core/src/sql_test.rs b/crates/torii/core/src/sql_test.rs index 09f4100caa..03702f67c6 100644 --- a/crates/torii/core/src/sql_test.rs +++ b/crates/torii/core/src/sql_test.rs @@ -10,6 +10,7 @@ use dojo_world::utils::TransactionWaiter; use katana_runner::KatanaRunner; use scarb::ops; use sozo_ops::migration::execute_strategy; +use sozo_ops::utils::get_default_namespace_from_ws; use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions}; use starknet::accounts::{Account, Call}; use starknet::core::types::{BlockId, BlockTag}; @@ -70,10 +71,16 @@ async fn test_load_from_remote() { let base_dir = manifest_path.parent().unwrap(); let target_dir = format!("{}/target/dev", base_dir); - let mut migration = - prepare_migration(base_dir.into(), target_dir.into(), dojo_metadata.skip_migration) - .unwrap(); - migration.resolve_variable(migration.world_address().unwrap()).unwrap(); + let default_namespace = get_default_namespace_from_ws(&ws); + + let mut migration = prepare_migration( + base_dir.into(), + target_dir.into(), + dojo_metadata.skip_migration, + &default_namespace, + ) + .unwrap(); + migration.resolve_variable(migration.world_address().unwrap(), &default_namespace).unwrap(); let sequencer = KatanaRunner::new().expect("Failed to start runner."); diff --git a/crates/torii/graphql/src/tests/mod.rs b/crates/torii/graphql/src/tests/mod.rs index ddfc8fa182..7805e924fb 100644 --- a/crates/torii/graphql/src/tests/mod.rs +++ b/crates/torii/graphql/src/tests/mod.rs @@ -3,7 +3,7 @@ use std::str::FromStr; use anyhow::Result; use async_graphql::dynamic::Schema; use camino::Utf8PathBuf; -use dojo_test_utils::compiler::{self, build_test_config}; +use dojo_test_utils::compiler; use dojo_test_utils::migration::prepare_migration; use dojo_test_utils::sequencer::{ get_default_test_starknet_config, SequencerConfig, TestSequencer, @@ -20,6 +20,7 @@ use scarb::ops; use serde::Deserialize; use serde_json::Value; use sozo_ops::migration::execute_strategy; +use sozo_ops::utils::get_default_namespace_from_ws; use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions}; use sqlx::SqlitePool; use starknet::accounts::{Account, Call}; @@ -290,9 +291,17 @@ pub async fn spinup_types_test() -> Result { dojo_metadata_from_workspace(&ws).expect("No current package with dojo metadata found."); let target_path = ws.target_dir().path_existent().unwrap().join(config.profile().to_string()); - let migration = - prepare_migration(source_project_dir, target_path, dojo_metadata.skip_migration).unwrap(); - let config = build_test_config("../types-test/Scarb.toml").unwrap(); + + let default_namespace = get_default_namespace_from_ws(&ws); + + let migration = prepare_migration( + source_project_dir, + target_path, + dojo_metadata.skip_migration, + &default_namespace, + ) + .unwrap(); + let db = Sql::new(pool.clone(), migration.world_address().unwrap()).await.unwrap(); let sequencer = @@ -314,8 +323,9 @@ pub async fn spinup_types_test() -> Result { .unwrap(); // Execute `create` and insert 11 records into storage + // TODO: `manifest_name` is probably not the correct field to use => handle namespace. let records_contract = - manifest.contracts.iter().find(|contract| contract.name.eq("records")).unwrap(); + manifest.contracts.iter().find(|contract| contract.manifest_name.eq("records")).unwrap(); let record_contract_address = records_contract.inner.address.unwrap(); let InvokeTransactionResult { transaction_hash } = account .execute(vec![Call { diff --git a/crates/torii/grpc/src/server/tests/entities_test.rs b/crates/torii/grpc/src/server/tests/entities_test.rs index 6d5cdbe9a1..c027d355ff 100644 --- a/crates/torii/grpc/src/server/tests/entities_test.rs +++ b/crates/torii/grpc/src/server/tests/entities_test.rs @@ -13,6 +13,7 @@ use dojo_world::migration::TxnConfig; use dojo_world::utils::TransactionWaiter; use scarb::ops; use sozo_ops::migration::execute_strategy; +use sozo_ops::utils::get_default_namespace_from_ws; use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions}; use starknet::accounts::{Account, Call}; use starknet::core::types::{BlockId, BlockTag}; @@ -49,9 +50,16 @@ async fn test_entities_queries() { let target_path = ws.target_dir().path_existent().unwrap().join(config.profile().to_string()); - let mut migration = - prepare_migration(source_project_dir, target_path, dojo_metadata.skip_migration).unwrap(); - migration.resolve_variable(migration.world_address().unwrap()).unwrap(); + let default_namespace = get_default_namespace_from_ws(&ws); + + let mut migration = prepare_migration( + source_project_dir, + target_path, + dojo_metadata.skip_migration, + &default_namespace, + ) + .unwrap(); + migration.resolve_variable(migration.world_address().unwrap(), &default_namespace).unwrap(); dbg!(&migration); diff --git a/crates/torii/types-test/Scarb.lock b/crates/torii/types-test/Scarb.lock index 0babbac9af..bf6a5a2123 100644 --- a/crates/torii/types-test/Scarb.lock +++ b/crates/torii/types-test/Scarb.lock @@ -15,7 +15,7 @@ source = "git+https://github.com/dojoengine/dojo?tag=v0.3.11#1e651b5d4d3b79b14a7 [[package]] name = "types_test" -version = "0.6.0" +version = "0.7.0" dependencies = [ "dojo", ] 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 2555ec3eda..25aff37fe4 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,6 @@ kind = "Class" -class_hash = "0x3f63cecdc4964acafb921ba2934c6507d1b3c344edb64c2762cf08053169ab9" -original_class_hash = "0x3f63cecdc4964acafb921ba2934c6507d1b3c344edb64c2762cf08053169ab9" +class_hash = "0x28c727264c1c1f6550cbaaa7f817039454899dd0bf32a94ff7c814515f67fb3" +original_class_hash = "0x28c727264c1c1f6550cbaaa7f817039454899dd0bf32a94ff7c814515f67fb3" abi = "manifests/dev/abis/base/dojo_world_world.json" -name = "dojo::world::world" +manifest_name = "dojo_world_world" +artifact_name = "dojo::world::world" diff --git a/examples/spawn-and-move/manifests/dev/abis/base/contracts/dojo_examples_actions_actions.json b/examples/spawn-and-move/manifests/dev/abis/base/contracts/dojo_examples-actions.json similarity index 90% rename from examples/spawn-and-move/manifests/dev/abis/base/contracts/dojo_examples_actions_actions.json rename to examples/spawn-and-move/manifests/dev/abis/base/contracts/dojo_examples-actions.json index 0882f7c56d..e6a678eb65 100644 --- a/examples/spawn-and-move/manifests/dev/abis/base/contracts/dojo_examples_actions_actions.json +++ b/examples/spawn-and-move/manifests/dev/abis/base/contracts/dojo_examples-actions.json @@ -21,6 +21,57 @@ } ] }, + { + "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": "function", + "name": "namespace_selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + } + ] + }, { "type": "impl", "name": "WorldProviderImpl", @@ -155,24 +206,6 @@ } ] }, - { - "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_examples::actions::IActions", diff --git a/examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples_mock_token_mock_token.json b/examples/spawn-and-move/manifests/dev/abis/base/contracts/dojo_examples-mock_token.json similarity index 73% rename from examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples_mock_token_mock_token.json rename to examples/spawn-and-move/manifests/dev/abis/base/contracts/dojo_examples-mock_token.json index f4bde33e6d..8fb9993e33 100644 --- a/examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples_mock_token_mock_token.json +++ b/examples/spawn-and-move/manifests/dev/abis/base/contracts/dojo_examples-mock_token.json @@ -21,6 +21,57 @@ } ] }, + { + "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": "function", + "name": "namespace_selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + } + ] + }, { "type": "impl", "name": "WorldProviderImpl", diff --git a/examples/spawn-and-move/manifests/release/abis/base/contracts/dojo_examples_others_others.json b/examples/spawn-and-move/manifests/dev/abis/base/contracts/dojo_examples-others.json similarity index 75% rename from examples/spawn-and-move/manifests/release/abis/base/contracts/dojo_examples_others_others.json rename to examples/spawn-and-move/manifests/dev/abis/base/contracts/dojo_examples-others.json index 36d8c3ef78..b793450353 100644 --- a/examples/spawn-and-move/manifests/release/abis/base/contracts/dojo_examples_others_others.json +++ b/examples/spawn-and-move/manifests/dev/abis/base/contracts/dojo_examples-others.json @@ -21,6 +21,57 @@ } ] }, + { + "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": "function", + "name": "namespace_selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + } + ] + }, { "type": "impl", "name": "WorldProviderImpl", diff --git a/examples/spawn-and-move/manifests/dev/abis/base/contracts/dojo_examples_others_others.json b/examples/spawn-and-move/manifests/dev/abis/base/contracts/dojo_examples_others_others.json deleted file mode 100644 index 36d8c3ef78..0000000000 --- a/examples/spawn-and-move/manifests/dev/abis/base/contracts/dojo_examples_others_others.json +++ /dev/null @@ -1,146 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoResourceProviderImpl", - "interface_name": "dojo::world::IDojoResourceProvider" - }, - { - "type": "interface", - "name": "dojo::world::IDojoResourceProvider", - "items": [ - { - "type": "function", - "name": "dojo_resource", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "WorldProviderImpl", - "interface_name": "dojo::world::IWorldProvider" - }, - { - "type": "struct", - "name": "dojo::world::IWorldDispatcher", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::IWorldProvider", - "items": [ - { - "type": "function", - "name": "world", - "inputs": [], - "outputs": [ - { - "type": "dojo::world::IWorldDispatcher" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "IDojoInitImpl", - "interface_name": "dojo_examples::others::others::IDojoInit" - }, - { - "type": "interface", - "name": "dojo_examples::others::others::IDojoInit", - "items": [ - { - "type": "function", - "name": "dojo_init", - "inputs": [ - { - "name": "actions_address", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "actions_class", - "type": "core::starknet::class_hash::ClassHash" - }, - { - "name": "value", - "type": "core::integer::u8" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "UpgradableImpl", - "interface_name": "dojo::components::upgradeable::IUpgradeable" - }, - { - "type": "interface", - "name": "dojo::components::upgradeable::IUpgradeable", - "items": [ - { - "type": "function", - "name": "upgrade", - "inputs": [ - { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "event", - "name": "dojo::components::upgradeable::upgradeable::Upgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::components::upgradeable::upgradeable::Event", - "kind": "enum", - "variants": [ - { - "name": "Upgraded", - "type": "dojo::components::upgradeable::upgradeable::Upgraded", - "kind": "nested" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::others::others::Event", - "kind": "enum", - "variants": [ - { - "name": "UpgradeableEvent", - "type": "dojo::components::upgradeable::upgradeable::Event", - "kind": "nested" - } - ] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/abis/base/dojo_world_world.json b/examples/spawn-and-move/manifests/dev/abis/base/dojo_world_world.json index c1a2447839..1eb99602ad 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" } ] }, @@ -692,6 +764,11 @@ "name": "address", "type": "core::starknet::contract_address::ContractAddress", "kind": "data" + }, + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "data" } ] }, @@ -741,6 +818,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", @@ -751,6 +845,11 @@ "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", @@ -818,7 +917,7 @@ "kind": "struct", "members": [ { - "name": "model", + "name": "resource", "type": "core::felt252", "kind": "data" }, @@ -956,6 +1055,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/release/abis/base/models/dojo_examples_others_others_contract_initialized.json b/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples-contract_initialized.json similarity index 94% rename from examples/spawn-and-move/manifests/release/abis/base/models/dojo_examples_others_others_contract_initialized.json rename to examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples-contract_initialized.json index 1dbbd313d8..b85b095e69 100644 --- a/examples/spawn-and-move/manifests/release/abis/base/models/dojo_examples_others_others_contract_initialized.json +++ b/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples-contract_initialized.json @@ -271,6 +271,28 @@ ], "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", diff --git a/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_message.json b/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples-message.json similarity index 94% rename from examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_message.json rename to examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples-message.json index ec760c99fb..7c763bee48 100644 --- a/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_message.json +++ b/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples-message.json @@ -271,6 +271,28 @@ ], "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", diff --git a/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_mock_token.json b/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples-mock_token.json similarity index 94% rename from examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_mock_token.json rename to examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples-mock_token.json index b2c1c340fa..f53b8cdb1e 100644 --- a/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_mock_token.json +++ b/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples-mock_token.json @@ -271,6 +271,28 @@ ], "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", diff --git a/examples/spawn-and-move/manifests/release/abis/base/models/dojo_examples_actions_actions_moved.json b/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples-moved.json similarity index 94% rename from examples/spawn-and-move/manifests/release/abis/base/models/dojo_examples_actions_actions_moved.json rename to examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples-moved.json index 89abdcfec5..48393eae33 100644 --- a/examples/spawn-and-move/manifests/release/abis/base/models/dojo_examples_actions_actions_moved.json +++ b/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples-moved.json @@ -271,6 +271,28 @@ ], "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", 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-moves.json similarity index 94% rename from examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_models_moves.json rename to examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples-moves.json index ee2cf17b26..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-moves.json @@ -271,6 +271,28 @@ ], "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", 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/base/models/dojo_examples-player_config.json similarity index 94% rename from examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_player_config.json rename to examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples-player_config.json index 8c33ebabc4..602ff624a7 100644 --- a/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_player_config.json +++ b/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples-player_config.json @@ -271,6 +271,28 @@ ], "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", diff --git a/examples/spawn-and-move/manifests/release/abis/base/models/dojo_examples_models_position.json b/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples-position.json similarity index 94% rename from examples/spawn-and-move/manifests/release/abis/base/models/dojo_examples_models_position.json rename to examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples-position.json index bceec42587..6396707e5e 100644 --- a/examples/spawn-and-move/manifests/release/abis/base/models/dojo_examples_models_position.json +++ b/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples-position.json @@ -271,6 +271,28 @@ ], "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", 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 deleted file mode 100644 index 89abdcfec5..0000000000 --- a/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_actions_actions_moved.json +++ /dev/null @@ -1,389 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::database::introspect::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::database::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::database::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::database::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::IModel", - "items": [ - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "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/base/models/dojo_examples_models_mock_token.json b/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_models_mock_token.json deleted file mode 100644 index b2c1c340fa..0000000000 --- a/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_models_mock_token.json +++ /dev/null @@ -1,363 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::database::introspect::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::database::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::database::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::database::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::IModel", - "items": [ - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "mock_tokenImpl", - "interface_name": "dojo_examples::models::Imock_token" - }, - { - "type": "struct", - "name": "dojo_examples::models::MockToken", - "members": [ - { - "name": "account", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "amount", - "type": "core::integer::u128" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::models::Imock_token", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::models::MockToken" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::models::mock_token::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file 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 deleted file mode 100644 index 8c33ebabc4..0000000000 --- a/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_models_player_config.json +++ /dev/null @@ -1,385 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::database::introspect::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::database::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::database::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::database::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::IModel", - "items": [ - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "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/contracts/dojo_examples_actions_actions.json b/examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples-actions.json similarity index 90% rename from examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples_actions_actions.json rename to examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples-actions.json index 0882f7c56d..e6a678eb65 100644 --- a/examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples_actions_actions.json +++ b/examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples-actions.json @@ -21,6 +21,57 @@ } ] }, + { + "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": "function", + "name": "namespace_selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + } + ] + }, { "type": "impl", "name": "WorldProviderImpl", @@ -155,24 +206,6 @@ } ] }, - { - "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_examples::actions::IActions", diff --git a/examples/spawn-and-move/manifests/dev/abis/base/contracts/dojo_examples_mock_token_mock_token.json b/examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples-mock_token.json similarity index 73% rename from examples/spawn-and-move/manifests/dev/abis/base/contracts/dojo_examples_mock_token_mock_token.json rename to examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples-mock_token.json index f4bde33e6d..8fb9993e33 100644 --- a/examples/spawn-and-move/manifests/dev/abis/base/contracts/dojo_examples_mock_token_mock_token.json +++ b/examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples-mock_token.json @@ -21,6 +21,57 @@ } ] }, + { + "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": "function", + "name": "namespace_selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + } + ] + }, { "type": "impl", "name": "WorldProviderImpl", diff --git a/examples/spawn-and-move/manifests/release/abis/deployments/contracts/dojo_examples_others_others.json b/examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples-others.json similarity index 75% rename from examples/spawn-and-move/manifests/release/abis/deployments/contracts/dojo_examples_others_others.json rename to examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples-others.json index 36d8c3ef78..b793450353 100644 --- a/examples/spawn-and-move/manifests/release/abis/deployments/contracts/dojo_examples_others_others.json +++ b/examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples-others.json @@ -21,6 +21,57 @@ } ] }, + { + "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": "function", + "name": "namespace_selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + } + ] + }, { "type": "impl", "name": "WorldProviderImpl", 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 deleted file mode 100644 index 36d8c3ef78..0000000000 --- a/examples/spawn-and-move/manifests/dev/abis/deployments/contracts/dojo_examples_others_others.json +++ /dev/null @@ -1,146 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoResourceProviderImpl", - "interface_name": "dojo::world::IDojoResourceProvider" - }, - { - "type": "interface", - "name": "dojo::world::IDojoResourceProvider", - "items": [ - { - "type": "function", - "name": "dojo_resource", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "WorldProviderImpl", - "interface_name": "dojo::world::IWorldProvider" - }, - { - "type": "struct", - "name": "dojo::world::IWorldDispatcher", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::IWorldProvider", - "items": [ - { - "type": "function", - "name": "world", - "inputs": [], - "outputs": [ - { - "type": "dojo::world::IWorldDispatcher" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "IDojoInitImpl", - "interface_name": "dojo_examples::others::others::IDojoInit" - }, - { - "type": "interface", - "name": "dojo_examples::others::others::IDojoInit", - "items": [ - { - "type": "function", - "name": "dojo_init", - "inputs": [ - { - "name": "actions_address", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "actions_class", - "type": "core::starknet::class_hash::ClassHash" - }, - { - "name": "value", - "type": "core::integer::u8" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "UpgradableImpl", - "interface_name": "dojo::components::upgradeable::IUpgradeable" - }, - { - "type": "interface", - "name": "dojo::components::upgradeable::IUpgradeable", - "items": [ - { - "type": "function", - "name": "upgrade", - "inputs": [ - { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "event", - "name": "dojo::components::upgradeable::upgradeable::Upgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::components::upgradeable::upgradeable::Event", - "kind": "enum", - "variants": [ - { - "name": "Upgraded", - "type": "dojo::components::upgradeable::upgradeable::Upgraded", - "kind": "nested" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::others::others::Event", - "kind": "enum", - "variants": [ - { - "name": "UpgradeableEvent", - "type": "dojo::components::upgradeable::upgradeable::Event", - "kind": "nested" - } - ] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/abis/deployments/dojo_world_world.json b/examples/spawn-and-move/manifests/dev/abis/deployments/dojo_world_world.json index c1a2447839..1eb99602ad 100644 --- a/examples/spawn-and-move/manifests/dev/abis/deployments/dojo_world_world.json +++ b/examples/spawn-and-move/manifests/dev/abis/deployments/dojo_world_world.json @@ -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" } ] }, @@ -692,6 +764,11 @@ "name": "address", "type": "core::starknet::contract_address::ContractAddress", "kind": "data" + }, + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "data" } ] }, @@ -741,6 +818,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", @@ -751,6 +845,11 @@ "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", @@ -818,7 +917,7 @@ "kind": "struct", "members": [ { - "name": "model", + "name": "resource", "type": "core::felt252", "kind": "data" }, @@ -956,6 +1055,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_others_others_contract_initialized.json b/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples-contract_initialized.json similarity index 94% rename from examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_others_others_contract_initialized.json rename to examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples-contract_initialized.json index 1dbbd313d8..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/deployments/models/dojo_examples-contract_initialized.json @@ -271,6 +271,28 @@ ], "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", diff --git a/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_models_message.json b/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples-message.json similarity index 94% rename from examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_models_message.json rename to examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples-message.json index ec760c99fb..7c763bee48 100644 --- a/examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_models_message.json +++ b/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples-message.json @@ -271,6 +271,28 @@ ], "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", diff --git a/examples/spawn-and-move/manifests/release/abis/base/models/dojo_examples_models_mock_token.json b/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples-mock_token.json similarity index 94% rename from examples/spawn-and-move/manifests/release/abis/base/models/dojo_examples_models_mock_token.json rename to examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples-mock_token.json index b2c1c340fa..f53b8cdb1e 100644 --- a/examples/spawn-and-move/manifests/release/abis/base/models/dojo_examples_models_mock_token.json +++ b/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples-mock_token.json @@ -271,6 +271,28 @@ ], "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", 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-moved.json similarity index 94% rename from examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_actions_actions_moved.json rename to examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples-moved.json index 89abdcfec5..48393eae33 100644 --- 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-moved.json @@ -271,6 +271,28 @@ ], "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", diff --git a/examples/spawn-and-move/manifests/release/abis/base/models/dojo_examples_models_moves.json b/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples-moves.json similarity index 94% rename from examples/spawn-and-move/manifests/release/abis/base/models/dojo_examples_models_moves.json rename to examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples-moves.json index ee2cf17b26..0ffb6d39fd 100644 --- a/examples/spawn-and-move/manifests/release/abis/base/models/dojo_examples_models_moves.json +++ b/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples-moves.json @@ -271,6 +271,28 @@ ], "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", diff --git a/examples/spawn-and-move/manifests/release/abis/base/models/dojo_examples_models_player_config.json b/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples-player_config.json similarity index 94% rename from examples/spawn-and-move/manifests/release/abis/base/models/dojo_examples_models_player_config.json rename to examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples-player_config.json index 8c33ebabc4..602ff624a7 100644 --- a/examples/spawn-and-move/manifests/release/abis/base/models/dojo_examples_models_player_config.json +++ b/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples-player_config.json @@ -271,6 +271,28 @@ ], "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", 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/deployments/models/dojo_examples-position.json similarity index 94% rename from examples/spawn-and-move/manifests/dev/abis/base/models/dojo_examples_models_position.json rename to examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples-position.json index bceec42587..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/deployments/models/dojo_examples-position.json @@ -271,6 +271,28 @@ ], "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", 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 deleted file mode 100644 index ee2cf17b26..0000000000 --- a/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_moves.json +++ /dev/null @@ -1,393 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::database::introspect::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::database::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::database::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::database::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::IModel", - "items": [ - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "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_position.json b/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_position.json deleted file mode 100644 index bceec42587..0000000000 --- a/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_models_position.json +++ /dev/null @@ -1,377 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::database::introspect::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::database::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::database::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::database::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::IModel", - "items": [ - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "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 deleted file mode 100644 index 1dbbd313d8..0000000000 --- a/examples/spawn-and-move/manifests/dev/abis/deployments/models/dojo_examples_others_others_contract_initialized.json +++ /dev/null @@ -1,367 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::database::introspect::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::database::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::database::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::database::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::IModel", - "items": [ - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "contract_initializedImpl", - "interface_name": "dojo_examples::others::others::Icontract_initialized" - }, - { - "type": "struct", - "name": "dojo_examples::others::others::ContractInitialized", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "contract_class", - "type": "core::starknet::class_hash::ClassHash" - }, - { - "name": "value", - "type": "core::integer::u8" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::others::others::Icontract_initialized", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::others::others::ContractInitialized" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::others::others::contract_initialized::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-actions.toml b/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-actions.toml new file mode 100644 index 0000000000..88ebf379dd --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-actions.toml @@ -0,0 +1,13 @@ +kind = "DojoContract" +class_hash = "0x5cdaf2380629aca3dd35ddaf5430c728e2c2a7c5b5cd8dd5bd2a434ab1812c6" +original_class_hash = "0x5cdaf2380629aca3dd35ddaf5430c728e2c2a7c5b5cd8dd5bd2a434ab1812c6" +base_class_hash = "0x0" +abi = "manifests/dev/abis/base/contracts/dojo_examples-actions.json" +reads = [] +writes = [] +computed = [] +init_calldata = [] +name = "actions" +namespace = "dojo_examples" +manifest_name = "dojo_examples-actions" +artifact_name = "dojo_examples::actions::actions" diff --git a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-mock_token.toml b/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-mock_token.toml new file mode 100644 index 0000000000..d6aa3136a2 --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-mock_token.toml @@ -0,0 +1,13 @@ +kind = "DojoContract" +class_hash = "0x7416f8bb5be2b448d8cb5ef6af84e2a9f63f54c68fd3b04537b6a56d3fdbbf9" +original_class_hash = "0x7416f8bb5be2b448d8cb5ef6af84e2a9f63f54c68fd3b04537b6a56d3fdbbf9" +base_class_hash = "0x0" +abi = "manifests/dev/abis/base/contracts/dojo_examples-mock_token.json" +reads = [] +writes = [] +computed = [] +init_calldata = [] +name = "mock_token" +namespace = "dojo_examples" +manifest_name = "dojo_examples-mock_token" +artifact_name = "dojo_examples::mock_token::mock_token" diff --git a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-others.toml b/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-others.toml new file mode 100644 index 0000000000..3a36851457 --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-others.toml @@ -0,0 +1,13 @@ +kind = "DojoContract" +class_hash = "0x3fc738cd153b59715c5c0f3ba57265d86f838610d8926b872b402b74ffaa983" +original_class_hash = "0x3fc738cd153b59715c5c0f3ba57265d86f838610d8926b872b402b74ffaa983" +base_class_hash = "0x0" +abi = "manifests/dev/abis/base/contracts/dojo_examples-others.json" +reads = [] +writes = [] +computed = [] +init_calldata = [] +name = "others" +namespace = "dojo_examples" +manifest_name = "dojo_examples-others" +artifact_name = "dojo_examples::others::others" 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 deleted file mode 100644 index 405be86d28..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples_actions_actions.toml +++ /dev/null @@ -1,10 +0,0 @@ -kind = "DojoContract" -class_hash = "0x69ba4e0f7a03ae24f85aad88bd1a6b4eab5395474bbb6717803ffeb5aa13b8d" -original_class_hash = "0x69ba4e0f7a03ae24f85aad88bd1a6b4eab5395474bbb6717803ffeb5aa13b8d" -base_class_hash = "0x0" -abi = "manifests/dev/abis/base/contracts/dojo_examples_actions_actions.json" -reads = [] -writes = [] -computed = [] -init_calldata = [] -name = "dojo_examples::actions::actions" diff --git a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples_mock_token_mock_token.toml b/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples_mock_token_mock_token.toml deleted file mode 100644 index 572af4068e..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples_mock_token_mock_token.toml +++ /dev/null @@ -1,10 +0,0 @@ -kind = "DojoContract" -class_hash = "0x5c32bc974f96f82ded691bb95bf26b2783f874fffb50fe84a331acb75ecf5b2" -original_class_hash = "0x5c32bc974f96f82ded691bb95bf26b2783f874fffb50fe84a331acb75ecf5b2" -base_class_hash = "0x0" -abi = "manifests/dev/abis/base/contracts/dojo_examples_mock_token_mock_token.json" -reads = [] -writes = [] -computed = [] -init_calldata = [] -name = "dojo_examples::mock_token::mock_token" diff --git a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples_others_others.toml b/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples_others_others.toml deleted file mode 100644 index 0526bc5473..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples_others_others.toml +++ /dev/null @@ -1,10 +0,0 @@ -kind = "DojoContract" -class_hash = "0x3ee016157303a7ce35a9fecdb5b8519159df620c5780527d61443636aaa3c3a" -original_class_hash = "0x3ee016157303a7ce35a9fecdb5b8519159df620c5780527d61443636aaa3c3a" -base_class_hash = "0x0" -abi = "manifests/dev/abis/base/contracts/dojo_examples_others_others.json" -reads = [] -writes = [] -computed = [] -init_calldata = [] -name = "dojo_examples::others::others" diff --git a/examples/spawn-and-move/manifests/dev/base/dojo_base_base.toml b/examples/spawn-and-move/manifests/dev/base/dojo_base_base.toml index 6c4b5de67e..b322f99931 100644 --- a/examples/spawn-and-move/manifests/dev/base/dojo_base_base.toml +++ b/examples/spawn-and-move/manifests/dev/base/dojo_base_base.toml @@ -1,4 +1,5 @@ kind = "Class" class_hash = "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46" original_class_hash = "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46" -name = "dojo::base::base" +manifest_name = "dojo_base_base" +artifact_name = "dojo::base::base" 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 2555ec3eda..25aff37fe4 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,6 @@ kind = "Class" -class_hash = "0x3f63cecdc4964acafb921ba2934c6507d1b3c344edb64c2762cf08053169ab9" -original_class_hash = "0x3f63cecdc4964acafb921ba2934c6507d1b3c344edb64c2762cf08053169ab9" +class_hash = "0x28c727264c1c1f6550cbaaa7f817039454899dd0bf32a94ff7c814515f67fb3" +original_class_hash = "0x28c727264c1c1f6550cbaaa7f817039454899dd0bf32a94ff7c814515f67fb3" abi = "manifests/dev/abis/base/dojo_world_world.json" -name = "dojo::world::world" +manifest_name = "dojo_world_world" +artifact_name = "dojo::world::world" diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-contract_initialized.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-contract_initialized.toml new file mode 100644 index 0000000000..e423a80fe1 --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-contract_initialized.toml @@ -0,0 +1,23 @@ +kind = "DojoModel" +class_hash = "0x422d29e9d76703627b6e17ec21f76ea51673181cca1db86fe3831e6b9520947" +original_class_hash = "0x422d29e9d76703627b6e17ec21f76ea51673181cca1db86fe3831e6b9520947" +abi = "manifests/dev/abis/base/models/dojo_examples-contract_initialized.json" +name = "ContractInitialized" +namespace = "dojo_examples" +manifest_name = "dojo_examples-contract_initialized" +artifact_name = "dojo_examples::others::others::contract_initialized" + +[[members]] +name = "contract_address" +type = "ContractAddress" +key = true + +[[members]] +name = "contract_class" +type = "ClassHash" +key = false + +[[members]] +name = "value" +type = "u8" +key = false diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-message.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-message.toml new file mode 100644 index 0000000000..b23e7ddf64 --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-message.toml @@ -0,0 +1,28 @@ +kind = "DojoModel" +class_hash = "0x15bb4dfdcfe3dae6ee09cd2912b87f341cb0049c448443c19dff53e1dd2b2e4" +original_class_hash = "0x15bb4dfdcfe3dae6ee09cd2912b87f341cb0049c448443c19dff53e1dd2b2e4" +abi = "manifests/dev/abis/base/models/dojo_examples-message.json" +name = "Message" +namespace = "dojo_examples" +manifest_name = "dojo_examples-message" +artifact_name = "dojo_examples::models::message" + +[[members]] +name = "identity" +type = "ContractAddress" +key = true + +[[members]] +name = "channel" +type = "felt252" +key = true + +[[members]] +name = "message" +type = "ByteArray" +key = false + +[[members]] +name = "salt" +type = "felt252" +key = true diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-mock_token.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-mock_token.toml new file mode 100644 index 0000000000..54d4c385ba --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-mock_token.toml @@ -0,0 +1,18 @@ +kind = "DojoModel" +class_hash = "0x7b8abdeec63fe60338f5fd160c747c5db5fd911013a1f9c2b15e88900fabc5b" +original_class_hash = "0x7b8abdeec63fe60338f5fd160c747c5db5fd911013a1f9c2b15e88900fabc5b" +abi = "manifests/dev/abis/base/models/dojo_examples-mock_token.json" +name = "MockToken" +namespace = "dojo_examples" +manifest_name = "dojo_examples-mock_token" +artifact_name = "dojo_examples::models::mock_token" + +[[members]] +name = "account" +type = "ContractAddress" +key = true + +[[members]] +name = "amount" +type = "u128" +key = false diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-moved.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-moved.toml new file mode 100644 index 0000000000..7afd3e5ce1 --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-moved.toml @@ -0,0 +1,18 @@ +kind = "DojoModel" +class_hash = "0x1ea2333b6b366988a726f8b95472b38a56506631d916b38a503b57f7dc2c16b" +original_class_hash = "0x1ea2333b6b366988a726f8b95472b38a56506631d916b38a503b57f7dc2c16b" +abi = "manifests/dev/abis/base/models/dojo_examples-moved.json" +name = "Moved" +namespace = "dojo_examples" +manifest_name = "dojo_examples-moved" +artifact_name = "dojo_examples::actions::actions::moved" + +[[members]] +name = "player" +type = "ContractAddress" +key = true + +[[members]] +name = "direction" +type = "Direction" +key = false diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-moves.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-moves.toml new file mode 100644 index 0000000000..259ea9007e --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-moves.toml @@ -0,0 +1,23 @@ +kind = "DojoModel" +class_hash = "0x276c8225a5addbfe3e6b38d8e288dc977bdce2e2401877c58783d75c61a9f21" +original_class_hash = "0x276c8225a5addbfe3e6b38d8e288dc977bdce2e2401877c58783d75c61a9f21" +abi = "manifests/dev/abis/base/models/dojo_examples-moves.json" +name = "Moves" +namespace = "dojo_examples" +manifest_name = "dojo_examples-moves" +artifact_name = "dojo_examples::models::moves" + +[[members]] +name = "player" +type = "ContractAddress" +key = true + +[[members]] +name = "remaining" +type = "u8" +key = false + +[[members]] +name = "last_direction" +type = "Direction" +key = false diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-player_config.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-player_config.toml new file mode 100644 index 0000000000..0209b64b10 --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-player_config.toml @@ -0,0 +1,28 @@ +kind = "DojoModel" +class_hash = "0x1adabc0c605f4cbbad71bbbb86b8da6b964d406103cc854787e627eb779e474" +original_class_hash = "0x1adabc0c605f4cbbad71bbbb86b8da6b964d406103cc854787e627eb779e474" +abi = "manifests/dev/abis/base/models/dojo_examples-player_config.json" +name = "PlayerConfig" +namespace = "dojo_examples" +manifest_name = "dojo_examples-player_config" +artifact_name = "dojo_examples::models::player_config" + +[[members]] +name = "player" +type = "ContractAddress" +key = true + +[[members]] +name = "name" +type = "ByteArray" +key = false + +[[members]] +name = "items" +type = "Array" +key = false + +[[members]] +name = "favorite_item" +type = "Option" +key = false diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-position.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-position.toml new file mode 100644 index 0000000000..9ab06792ba --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-position.toml @@ -0,0 +1,18 @@ +kind = "DojoModel" +class_hash = "0xdf544463099a54b4ff5b10473cd62cb56565641d7f6413fe7a499a240f2aac" +original_class_hash = "0xdf544463099a54b4ff5b10473cd62cb56565641d7f6413fe7a499a240f2aac" +abi = "manifests/dev/abis/base/models/dojo_examples-position.json" +name = "Position" +namespace = "dojo_examples" +manifest_name = "dojo_examples-position" +artifact_name = "dojo_examples::models::position" + +[[members]] +name = "player" +type = "ContractAddress" +key = true + +[[members]] +name = "vec" +type = "Vec2" +key = false 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 deleted file mode 100644 index 8b79f5c317..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_actions_actions_moved.toml +++ /dev/null @@ -1,15 +0,0 @@ -kind = "DojoModel" -class_hash = "0x4ef89963afe500337aaf757ad52394ea8e311077a825b3de5a5f32d3457997c" -original_class_hash = "0x4ef89963afe500337aaf757ad52394ea8e311077a825b3de5a5f32d3457997c" -abi = "manifests/dev/abis/base/models/dojo_examples_actions_actions_moved.json" -name = "dojo_examples::actions::actions::moved" - -[[members]] -name = "player" -type = "ContractAddress" -key = true - -[[members]] -name = "direction" -type = "Direction" -key = false diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_message.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_message.toml deleted file mode 100644 index 15ad89aace..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_message.toml +++ /dev/null @@ -1,25 +0,0 @@ -kind = "DojoModel" -class_hash = "0x33bdb1a470ea0ee7d77faa3c75151934b3b129c0bad7333ec6c2dad1b98ec5" -original_class_hash = "0x33bdb1a470ea0ee7d77faa3c75151934b3b129c0bad7333ec6c2dad1b98ec5" -abi = "manifests/dev/abis/base/models/dojo_examples_models_message.json" -name = "dojo_examples::models::message" - -[[members]] -name = "identity" -type = "ContractAddress" -key = true - -[[members]] -name = "channel" -type = "felt252" -key = true - -[[members]] -name = "message" -type = "ByteArray" -key = false - -[[members]] -name = "salt" -type = "felt252" -key = true diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_mock_token.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_mock_token.toml deleted file mode 100644 index 1bf036168c..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_mock_token.toml +++ /dev/null @@ -1,15 +0,0 @@ -kind = "DojoModel" -class_hash = "0x6a21c56878ba470ac7a51f336ca6a59781de38e1810d2d20866ab2b52138a6d" -original_class_hash = "0x6a21c56878ba470ac7a51f336ca6a59781de38e1810d2d20866ab2b52138a6d" -abi = "manifests/dev/abis/base/models/dojo_examples_models_mock_token.json" -name = "dojo_examples::models::mock_token" - -[[members]] -name = "account" -type = "ContractAddress" -key = true - -[[members]] -name = "amount" -type = "u128" -key = false 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 deleted file mode 100644 index 6241643aa4..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_moves.toml +++ /dev/null @@ -1,20 +0,0 @@ -kind = "DojoModel" -class_hash = "0x456d85286b34249fffa0a13d1ac490cc1f5b02eb1a1c92d820c59d6b0f2eaa8" -original_class_hash = "0x456d85286b34249fffa0a13d1ac490cc1f5b02eb1a1c92d820c59d6b0f2eaa8" -abi = "manifests/dev/abis/base/models/dojo_examples_models_moves.json" -name = "dojo_examples::models::moves" - -[[members]] -name = "player" -type = "ContractAddress" -key = true - -[[members]] -name = "remaining" -type = "u8" -key = false - -[[members]] -name = "last_direction" -type = "Direction" -key = false 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 deleted file mode 100644 index 459eb9ebdb..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_player_config.toml +++ /dev/null @@ -1,25 +0,0 @@ -kind = "DojoModel" -class_hash = "0x584d016a91d077c86ff1c014e0c4d735946d1084dd0d4c0a80cee6d04629e55" -original_class_hash = "0x584d016a91d077c86ff1c014e0c4d735946d1084dd0d4c0a80cee6d04629e55" -abi = "manifests/dev/abis/base/models/dojo_examples_models_player_config.json" -name = "dojo_examples::models::player_config" - -[[members]] -name = "player" -type = "ContractAddress" -key = true - -[[members]] -name = "name" -type = "ByteArray" -key = false - -[[members]] -name = "items" -type = "Array" -key = false - -[[members]] -name = "favorite_item" -type = "Option" -key = false 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 deleted file mode 100644 index d29abaa4e0..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_models_position.toml +++ /dev/null @@ -1,15 +0,0 @@ -kind = "DojoModel" -class_hash = "0x27942375b09862291ece780c573e8c625df4ba41fd7524e0658ca75fff014ff" -original_class_hash = "0x27942375b09862291ece780c573e8c625df4ba41fd7524e0658ca75fff014ff" -abi = "manifests/dev/abis/base/models/dojo_examples_models_position.json" -name = "dojo_examples::models::position" - -[[members]] -name = "player" -type = "ContractAddress" -key = true - -[[members]] -name = "vec" -type = "Vec2" -key = false 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 deleted file mode 100644 index e4b4f0fdc3..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_others_others_contract_initialized.toml +++ /dev/null @@ -1,20 +0,0 @@ -kind = "DojoModel" -class_hash = "0x4b29afc6db744bd87f7276869620348557c11b984e9f3fcb27c4d55efb0ab6c" -original_class_hash = "0x4b29afc6db744bd87f7276869620348557c11b984e9f3fcb27c4d55efb0ab6c" -abi = "manifests/dev/abis/base/models/dojo_examples_others_others_contract_initialized.json" -name = "dojo_examples::others::others::contract_initialized" - -[[members]] -name = "contract_address" -type = "ContractAddress" -key = true - -[[members]] -name = "contract_class" -type = "ClassHash" -key = false - -[[members]] -name = "value" -type = "u8" -key = false diff --git a/examples/spawn-and-move/manifests/dev/manifest.json b/examples/spawn-and-move/manifests/dev/manifest.json index 9f2e854a95..b407f692f8 100644 --- a/examples/spawn-and-move/manifests/dev/manifest.json +++ b/examples/spawn-and-move/manifests/dev/manifest.json @@ -1,8 +1,8 @@ { "world": { "kind": "WorldContract", - "class_hash": "0x3f63cecdc4964acafb921ba2934c6507d1b3c344edb64c2762cf08053169ab9", - "original_class_hash": "0x3f63cecdc4964acafb921ba2934c6507d1b3c344edb64c2762cf08053169ab9", + "class_hash": "0x28c727264c1c1f6550cbaaa7f817039454899dd0bf32a94ff7c814515f67fb3", + "original_class_hash": "0x28c727264c1c1f6550cbaaa7f817039454899dd0bf32a94ff7c814515f67fb3", "abi": [ { "type": "impl", @@ -199,6 +199,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", @@ -406,7 +418,7 @@ "name": "is_writer", "inputs": [ { - "name": "model", + "name": "resource", "type": "core::felt252" }, { @@ -426,7 +438,7 @@ "name": "grant_writer", "inputs": [ { - "name": "model", + "name": "resource", "type": "core::felt252" }, { @@ -442,7 +454,7 @@ "name": "revoke_writer", "inputs": [ { - "name": "model", + "name": "resource", "type": "core::felt252" }, { @@ -452,6 +464,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" } ] }, @@ -697,6 +769,11 @@ "name": "address", "type": "core::starknet::contract_address::ContractAddress", "kind": "data" + }, + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "data" } ] }, @@ -746,6 +823,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", @@ -756,6 +850,11 @@ "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", @@ -823,7 +922,7 @@ "kind": "struct", "members": [ { - "name": "model", + "name": "resource", "type": "core::felt252", "kind": "data" }, @@ -961,6 +1060,11 @@ "type": "dojo::world::world::MetadataUpdate", "kind": "nested" }, + { + "name": "NamespaceRegistered", + "type": "dojo::world::world::NamespaceRegistered", + "kind": "nested" + }, { "name": "ModelRegistered", "type": "dojo::world::world::ModelRegistered", @@ -999,29 +1103,31 @@ ] } ], - "address": "0x7efebb0c2d4cc285d48a97a7174def3be7fdd6b7bd29cca758fa2e17e03ef30", - "transaction_hash": "0x60316eb232789f4d8352c6afdc36b76d33362d72b43bf78183b43f196779a9d", + "address": "0x5ceb94c01aab2606c2ba56d37578b8451aca5e210c5776075ef8a52ee9c1acb", + "transaction_hash": "0x3ac07d801954d5dff176c85dd299e6ab1dcd913eb8316c3e667f469a73f9e1b", "block_number": 3, "seed": "dojo_examples", "metadata": { "profile_name": "dev", "rpc_url": "http://localhost:5050/" }, - "name": "dojo::world::world" + "manifest_name": "dojo_world_world", + "artifact_name": "dojo::world::world" }, "base": { "kind": "Class", "class_hash": "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46", "original_class_hash": "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46", "abi": null, - "name": "dojo::base::base" + "manifest_name": "dojo_base_base", + "artifact_name": "dojo::base::base" }, "contracts": [ { "kind": "DojoContract", - "address": "0x5c70a663d6b48d8e4c6aaa9572e3735a732ac3765700d470463e670587852af", - "class_hash": "0x69ba4e0f7a03ae24f85aad88bd1a6b4eab5395474bbb6717803ffeb5aa13b8d", - "original_class_hash": "0x69ba4e0f7a03ae24f85aad88bd1a6b4eab5395474bbb6717803ffeb5aa13b8d", + "address": "0x113dffcbd368f04d4ea4972693a5b5f47ed1b495aa5c4b28940193795b24ad0", + "class_hash": "0x5cdaf2380629aca3dd35ddaf5430c728e2c2a7c5b5cd8dd5bd2a434ab1812c6", + "original_class_hash": "0x5cdaf2380629aca3dd35ddaf5430c728e2c2a7c5b5cd8dd5bd2a434ab1812c6", "base_class_hash": "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46", "abi": [ { @@ -1046,6 +1152,57 @@ } ] }, + { + "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": "function", + "name": "namespace_selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + } + ] + }, { "type": "impl", "name": "WorldProviderImpl", @@ -1180,24 +1337,6 @@ } ] }, - { - "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_examples::actions::IActions", @@ -1325,19 +1464,19 @@ } ], "reads": [], - "writes": [ - "Moves", - "Position" - ], + "writes": [], "computed": [], "init_calldata": [], - "name": "dojo_examples::actions::actions" + "name": "actions", + "namespace": "dojo_examples", + "manifest_name": "dojo_examples-actions", + "artifact_name": "dojo_examples::actions::actions" }, { "kind": "DojoContract", - "address": "0x75961b2027c52948ecebfd347aa427436ea308d41997fa9b3c98380f7011d53", - "class_hash": "0x5c32bc974f96f82ded691bb95bf26b2783f874fffb50fe84a331acb75ecf5b2", - "original_class_hash": "0x5c32bc974f96f82ded691bb95bf26b2783f874fffb50fe84a331acb75ecf5b2", + "address": "0x7cfff5cd7759cb2d8c301ee20751c4cd6080605055f117c06dc46ee0f92356b", + "class_hash": "0x7416f8bb5be2b448d8cb5ef6af84e2a9f63f54c68fd3b04537b6a56d3fdbbf9", + "original_class_hash": "0x7416f8bb5be2b448d8cb5ef6af84e2a9f63f54c68fd3b04537b6a56d3fdbbf9", "base_class_hash": "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46", "abi": [ { @@ -1362,6 +1501,57 @@ } ] }, + { + "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": "function", + "name": "namespace_selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + } + ] + }, { "type": "impl", "name": "WorldProviderImpl", @@ -1476,13 +1666,16 @@ "writes": [], "computed": [], "init_calldata": [], - "name": "dojo_examples::mock_token::mock_token" + "name": "mock_token", + "namespace": "dojo_examples", + "manifest_name": "dojo_examples-mock_token", + "artifact_name": "dojo_examples::mock_token::mock_token" }, { "kind": "DojoContract", - "address": "0x3f51cd82daaf5907d2fd082ae3f45ae2ef96ab61677f46abc16e0a54d3392d1", - "class_hash": "0x3ee016157303a7ce35a9fecdb5b8519159df620c5780527d61443636aaa3c3a", - "original_class_hash": "0x3ee016157303a7ce35a9fecdb5b8519159df620c5780527d61443636aaa3c3a", + "address": "0x64c941606ade888af5eba4e1d6044718edf53b52faeb43ff9233f17f543e967", + "class_hash": "0x3fc738cd153b59715c5c0f3ba57265d86f838610d8926b872b402b74ffaa983", + "original_class_hash": "0x3fc738cd153b59715c5c0f3ba57265d86f838610d8926b872b402b74ffaa983", "base_class_hash": "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46", "abi": [ { @@ -1507,6 +1700,57 @@ } ] }, + { + "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": "function", + "name": "namespace_selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + } + ] + }, { "type": "impl", "name": "WorldProviderImpl", @@ -1634,11 +1878,14 @@ "writes": [], "computed": [], "init_calldata": [ - "$contract_address:dojo_examples::actions::actions", - "$class_hash:dojo_examples::actions::actions", + "$contract_address:dojo_examples:actions", + "$class_hash:dojo_examples:actions", "10" ], - "name": "dojo_examples::others::others" + "name": "others", + "namespace": "dojo_examples", + "manifest_name": "dojo_examples-others", + "artifact_name": "dojo_examples::others::others" } ], "models": [ @@ -1646,18 +1893,23 @@ "kind": "DojoModel", "members": [ { - "name": "player", + "name": "contract_address", "type": "ContractAddress", "key": true }, { - "name": "direction", - "type": "Direction", + "name": "contract_class", + "type": "ClassHash", + "key": false + }, + { + "name": "value", + "type": "u8", "key": false } ], - "class_hash": "0x4ef89963afe500337aaf757ad52394ea8e311077a825b3de5a5f32d3457997c", - "original_class_hash": "0x4ef89963afe500337aaf757ad52394ea8e311077a825b3de5a5f32d3457997c", + "class_hash": "0x422d29e9d76703627b6e17ec21f76ea51673181cca1db86fe3831e6b9520947", + "original_class_hash": "0x422d29e9d76703627b6e17ec21f76ea51673181cca1db86fe3831e6b9520947", "abi": [ { "type": "impl", @@ -1931,6 +2183,28 @@ ], "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", @@ -1979,52 +2253,30 @@ }, { "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": "()" - } - ] + "name": "contract_initializedImpl", + "interface_name": "dojo_examples::others::others::Icontract_initialized" }, { "type": "struct", - "name": "dojo_examples::actions::actions::Moved", + "name": "dojo_examples::others::others::ContractInitialized", "members": [ { - "name": "player", + "name": "contract_address", "type": "core::starknet::contract_address::ContractAddress" }, { - "name": "direction", - "type": "dojo_examples::models::Direction" + "name": "contract_class", + "type": "core::starknet::class_hash::ClassHash" + }, + { + "name": "value", + "type": "core::integer::u8" } ] }, { "type": "interface", - "name": "dojo_examples::actions::actions::Imoved", + "name": "dojo_examples::others::others::Icontract_initialized", "items": [ { "type": "function", @@ -2032,7 +2284,7 @@ "inputs": [ { "name": "model", - "type": "dojo_examples::actions::actions::Moved" + "type": "dojo_examples::others::others::ContractInitialized" } ], "outputs": [], @@ -2042,12 +2294,15 @@ }, { "type": "event", - "name": "dojo_examples::actions::actions::moved::Event", + "name": "dojo_examples::others::others::contract_initialized::Event", "kind": "enum", "variants": [] } ], - "name": "dojo_examples::actions::actions::moved" + "name": "ContractInitialized", + "namespace": "dojo_examples", + "manifest_name": "dojo_examples-contract_initialized", + "artifact_name": "dojo_examples::others::others::contract_initialized" }, { "kind": "DojoModel", @@ -2073,8 +2328,8 @@ "key": true } ], - "class_hash": "0x33bdb1a470ea0ee7d77faa3c75151934b3b129c0bad7333ec6c2dad1b98ec5", - "original_class_hash": "0x33bdb1a470ea0ee7d77faa3c75151934b3b129c0bad7333ec6c2dad1b98ec5", + "class_hash": "0x15bb4dfdcfe3dae6ee09cd2912b87f341cb0049c448443c19dff53e1dd2b2e4", + "original_class_hash": "0x15bb4dfdcfe3dae6ee09cd2912b87f341cb0049c448443c19dff53e1dd2b2e4", "abi": [ { "type": "impl", @@ -2348,6 +2603,28 @@ ], "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", @@ -2446,7 +2723,10 @@ "variants": [] } ], - "name": "dojo_examples::models::message" + "name": "Message", + "namespace": "dojo_examples", + "manifest_name": "dojo_examples-message", + "artifact_name": "dojo_examples::models::message" }, { "kind": "DojoModel", @@ -2462,8 +2742,8 @@ "key": false } ], - "class_hash": "0x6a21c56878ba470ac7a51f336ca6a59781de38e1810d2d20866ab2b52138a6d", - "original_class_hash": "0x6a21c56878ba470ac7a51f336ca6a59781de38e1810d2d20866ab2b52138a6d", + "class_hash": "0x7b8abdeec63fe60338f5fd160c747c5db5fd911013a1f9c2b15e88900fabc5b", + "original_class_hash": "0x7b8abdeec63fe60338f5fd160c747c5db5fd911013a1f9c2b15e88900fabc5b", "abi": [ { "type": "impl", @@ -2737,6 +3017,28 @@ ], "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", @@ -2827,29 +3129,27 @@ "variants": [] } ], - "name": "dojo_examples::models::mock_token" + "name": "MockToken", + "namespace": "dojo_examples", + "manifest_name": "dojo_examples-mock_token", + "artifact_name": "dojo_examples::models::mock_token" }, { "kind": "DojoModel", "members": [ - { - "name": "player", - "type": "ContractAddress", - "key": true - }, - { - "name": "remaining", - "type": "u8", - "key": false + { + "name": "player", + "type": "ContractAddress", + "key": true }, { - "name": "last_direction", + "name": "direction", "type": "Direction", "key": false } ], - "class_hash": "0x456d85286b34249fffa0a13d1ac490cc1f5b02eb1a1c92d820c59d6b0f2eaa8", - "original_class_hash": "0x456d85286b34249fffa0a13d1ac490cc1f5b02eb1a1c92d820c59d6b0f2eaa8", + "class_hash": "0x1ea2333b6b366988a726f8b95472b38a56506631d916b38a503b57f7dc2c16b", + "original_class_hash": "0x1ea2333b6b366988a726f8b95472b38a56506631d916b38a503b57f7dc2c16b", "abi": [ { "type": "impl", @@ -3123,6 +3423,28 @@ ], "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", @@ -3171,8 +3493,8 @@ }, { "type": "impl", - "name": "movesImpl", - "interface_name": "dojo_examples::models::Imoves" + "name": "movedImpl", + "interface_name": "dojo_examples::actions::actions::Imoved" }, { "type": "enum", @@ -3202,25 +3524,21 @@ }, { "type": "struct", - "name": "dojo_examples::models::Moves", + "name": "dojo_examples::actions::actions::Moved", "members": [ { "name": "player", "type": "core::starknet::contract_address::ContractAddress" }, { - "name": "remaining", - "type": "core::integer::u8" - }, - { - "name": "last_direction", + "name": "direction", "type": "dojo_examples::models::Direction" } ] }, { "type": "interface", - "name": "dojo_examples::models::Imoves", + "name": "dojo_examples::actions::actions::Imoved", "items": [ { "type": "function", @@ -3228,7 +3546,7 @@ "inputs": [ { "name": "model", - "type": "dojo_examples::models::Moves" + "type": "dojo_examples::actions::actions::Moved" } ], "outputs": [], @@ -3238,12 +3556,15 @@ }, { "type": "event", - "name": "dojo_examples::models::moves::Event", + "name": "dojo_examples::actions::actions::moved::Event", "kind": "enum", "variants": [] } ], - "name": "dojo_examples::models::moves" + "name": "Moved", + "namespace": "dojo_examples", + "manifest_name": "dojo_examples-moved", + "artifact_name": "dojo_examples::actions::actions::moved" }, { "kind": "DojoModel", @@ -3254,23 +3575,18 @@ "key": true }, { - "name": "name", - "type": "ByteArray", - "key": false - }, - { - "name": "items", - "type": "Array", + "name": "remaining", + "type": "u8", "key": false }, { - "name": "favorite_item", - "type": "Option", + "name": "last_direction", + "type": "Direction", "key": false } ], - "class_hash": "0x584d016a91d077c86ff1c014e0c4d735946d1084dd0d4c0a80cee6d04629e55", - "original_class_hash": "0x584d016a91d077c86ff1c014e0c4d735946d1084dd0d4c0a80cee6d04629e55", + "class_hash": "0x276c8225a5addbfe3e6b38d8e288dc977bdce2e2401877c58783d75c61a9f21", + "original_class_hash": "0x276c8225a5addbfe3e6b38d8e288dc977bdce2e2401877c58783d75c61a9f21", "abi": [ { "type": "impl", @@ -3544,6 +3860,28 @@ ], "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", @@ -3592,48 +3930,56 @@ }, { "type": "impl", - "name": "player_configImpl", - "interface_name": "dojo_examples::models::Iplayer_config" + "name": "movesImpl", + "interface_name": "dojo_examples::models::Imoves" }, { - "type": "struct", - "name": "dojo_examples::models::PlayerItem", - "members": [ + "type": "enum", + "name": "dojo_examples::models::Direction", + "variants": [ { - "name": "item_id", - "type": "core::integer::u32" + "name": "None", + "type": "()" }, { - "name": "quantity", - "type": "core::integer::u32" + "name": "Left", + "type": "()" + }, + { + "name": "Right", + "type": "()" + }, + { + "name": "Up", + "type": "()" + }, + { + "name": "Down", + "type": "()" } ] }, { "type": "struct", - "name": "dojo_examples::models::PlayerConfig", + "name": "dojo_examples::models::Moves", "members": [ { "name": "player", "type": "core::starknet::contract_address::ContractAddress" }, { - "name": "name", - "type": "core::byte_array::ByteArray" - }, - { - "name": "items", - "type": "core::array::Array::" + "name": "remaining", + "type": "core::integer::u8" }, { - "name": "favorite_item", - "type": "core::option::Option::" + "name": "last_direction", + "type": "dojo_examples::models::Direction" } ] }, { "type": "interface", - "name": "dojo_examples::models::Iplayer_config", + "name": "dojo_examples::models::Imoves", "items": [ { "type": "function", @@ -3641,7 +3987,7 @@ "inputs": [ { "name": "model", - "type": "dojo_examples::models::PlayerConfig" + "type": "dojo_examples::models::Moves" } ], "outputs": [], @@ -3651,12 +3997,15 @@ }, { "type": "event", - "name": "dojo_examples::models::player_config::Event", + "name": "dojo_examples::models::moves::Event", "kind": "enum", "variants": [] } ], - "name": "dojo_examples::models::player_config" + "name": "Moves", + "namespace": "dojo_examples", + "manifest_name": "dojo_examples-moves", + "artifact_name": "dojo_examples::models::moves" }, { "kind": "DojoModel", @@ -3667,13 +4016,23 @@ "key": true }, { - "name": "vec", - "type": "Vec2", + "name": "name", + "type": "ByteArray", + "key": false + }, + { + "name": "items", + "type": "Array", + "key": false + }, + { + "name": "favorite_item", + "type": "Option", "key": false } ], - "class_hash": "0x27942375b09862291ece780c573e8c625df4ba41fd7524e0658ca75fff014ff", - "original_class_hash": "0x27942375b09862291ece780c573e8c625df4ba41fd7524e0658ca75fff014ff", + "class_hash": "0x1adabc0c605f4cbbad71bbbb86b8da6b964d406103cc854787e627eb779e474", + "original_class_hash": "0x1adabc0c605f4cbbad71bbbb86b8da6b964d406103cc854787e627eb779e474", "abi": [ { "type": "impl", @@ -3947,6 +4306,28 @@ ], "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", @@ -3995,40 +4376,48 @@ }, { "type": "impl", - "name": "positionImpl", - "interface_name": "dojo_examples::models::Iposition" + "name": "player_configImpl", + "interface_name": "dojo_examples::models::Iplayer_config" }, { "type": "struct", - "name": "dojo_examples::models::Vec2", + "name": "dojo_examples::models::PlayerItem", "members": [ { - "name": "x", + "name": "item_id", "type": "core::integer::u32" }, { - "name": "y", + "name": "quantity", "type": "core::integer::u32" } ] }, { "type": "struct", - "name": "dojo_examples::models::Position", + "name": "dojo_examples::models::PlayerConfig", "members": [ { "name": "player", "type": "core::starknet::contract_address::ContractAddress" }, { - "name": "vec", - "type": "dojo_examples::models::Vec2" + "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::Iposition", + "name": "dojo_examples::models::Iplayer_config", "items": [ { "type": "function", @@ -4036,7 +4425,7 @@ "inputs": [ { "name": "model", - "type": "dojo_examples::models::Position" + "type": "dojo_examples::models::PlayerConfig" } ], "outputs": [], @@ -4046,34 +4435,32 @@ }, { "type": "event", - "name": "dojo_examples::models::position::Event", + "name": "dojo_examples::models::player_config::Event", "kind": "enum", "variants": [] } ], - "name": "dojo_examples::models::position" + "name": "PlayerConfig", + "namespace": "dojo_examples", + "manifest_name": "dojo_examples-player_config", + "artifact_name": "dojo_examples::models::player_config" }, { "kind": "DojoModel", "members": [ { - "name": "contract_address", + "name": "player", "type": "ContractAddress", "key": true }, { - "name": "contract_class", - "type": "ClassHash", - "key": false - }, - { - "name": "value", - "type": "u8", + "name": "vec", + "type": "Vec2", "key": false } ], - "class_hash": "0x4b29afc6db744bd87f7276869620348557c11b984e9f3fcb27c4d55efb0ab6c", - "original_class_hash": "0x4b29afc6db744bd87f7276869620348557c11b984e9f3fcb27c4d55efb0ab6c", + "class_hash": "0xdf544463099a54b4ff5b10473cd62cb56565641d7f6413fe7a499a240f2aac", + "original_class_hash": "0xdf544463099a54b4ff5b10473cd62cb56565641d7f6413fe7a499a240f2aac", "abi": [ { "type": "impl", @@ -4347,6 +4734,28 @@ ], "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", @@ -4395,30 +4804,40 @@ }, { "type": "impl", - "name": "contract_initializedImpl", - "interface_name": "dojo_examples::others::others::Icontract_initialized" + "name": "positionImpl", + "interface_name": "dojo_examples::models::Iposition" }, { "type": "struct", - "name": "dojo_examples::others::others::ContractInitialized", + "name": "dojo_examples::models::Vec2", "members": [ { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" + "name": "x", + "type": "core::integer::u32" }, { - "name": "contract_class", - "type": "core::starknet::class_hash::ClassHash" + "name": "y", + "type": "core::integer::u32" + } + ] + }, + { + "type": "struct", + "name": "dojo_examples::models::Position", + "members": [ + { + "name": "player", + "type": "core::starknet::contract_address::ContractAddress" }, { - "name": "value", - "type": "core::integer::u8" + "name": "vec", + "type": "dojo_examples::models::Vec2" } ] }, { "type": "interface", - "name": "dojo_examples::others::others::Icontract_initialized", + "name": "dojo_examples::models::Iposition", "items": [ { "type": "function", @@ -4426,7 +4845,7 @@ "inputs": [ { "name": "model", - "type": "dojo_examples::others::others::ContractInitialized" + "type": "dojo_examples::models::Position" } ], "outputs": [], @@ -4436,12 +4855,15 @@ }, { "type": "event", - "name": "dojo_examples::others::others::contract_initialized::Event", + "name": "dojo_examples::models::position::Event", "kind": "enum", "variants": [] } ], - "name": "dojo_examples::others::others::contract_initialized" + "name": "Position", + "namespace": "dojo_examples", + "manifest_name": "dojo_examples-position", + "artifact_name": "dojo_examples::models::position" } ] } \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/manifest.toml b/examples/spawn-and-move/manifests/dev/manifest.toml index ec501b9733..37a16318a9 100644 --- a/examples/spawn-and-move/manifests/dev/manifest.toml +++ b/examples/spawn-and-move/manifests/dev/manifest.toml @@ -1,13 +1,14 @@ [world] kind = "WorldContract" -class_hash = "0x3f63cecdc4964acafb921ba2934c6507d1b3c344edb64c2762cf08053169ab9" -original_class_hash = "0x3f63cecdc4964acafb921ba2934c6507d1b3c344edb64c2762cf08053169ab9" +class_hash = "0x28c727264c1c1f6550cbaaa7f817039454899dd0bf32a94ff7c814515f67fb3" +original_class_hash = "0x28c727264c1c1f6550cbaaa7f817039454899dd0bf32a94ff7c814515f67fb3" abi = "manifests/dev/abis/deployments/dojo_world_world.json" -address = "0x7efebb0c2d4cc285d48a97a7174def3be7fdd6b7bd29cca758fa2e17e03ef30" -transaction_hash = "0x60316eb232789f4d8352c6afdc36b76d33362d72b43bf78183b43f196779a9d" +address = "0x5ceb94c01aab2606c2ba56d37578b8451aca5e210c5776075ef8a52ee9c1acb" +transaction_hash = "0x3ac07d801954d5dff176c85dd299e6ab1dcd913eb8316c3e667f469a73f9e1b" block_number = 3 seed = "dojo_examples" -name = "dojo::world::world" +manifest_name = "dojo_world_world" +artifact_name = "dojo::world::world" [world.metadata] profile_name = "dev" @@ -17,77 +18,95 @@ rpc_url = "http://localhost:5050/" kind = "Class" class_hash = "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46" original_class_hash = "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46" -name = "dojo::base::base" +manifest_name = "dojo_base_base" +artifact_name = "dojo::base::base" [[contracts]] kind = "DojoContract" -address = "0x5c70a663d6b48d8e4c6aaa9572e3735a732ac3765700d470463e670587852af" -class_hash = "0x69ba4e0f7a03ae24f85aad88bd1a6b4eab5395474bbb6717803ffeb5aa13b8d" -original_class_hash = "0x69ba4e0f7a03ae24f85aad88bd1a6b4eab5395474bbb6717803ffeb5aa13b8d" +address = "0x113dffcbd368f04d4ea4972693a5b5f47ed1b495aa5c4b28940193795b24ad0" +class_hash = "0x5cdaf2380629aca3dd35ddaf5430c728e2c2a7c5b5cd8dd5bd2a434ab1812c6" +original_class_hash = "0x5cdaf2380629aca3dd35ddaf5430c728e2c2a7c5b5cd8dd5bd2a434ab1812c6" base_class_hash = "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46" -abi = "manifests/dev/abis/deployments/contracts/dojo_examples_actions_actions.json" +abi = "manifests/dev/abis/deployments/contracts/dojo_examples-actions.json" reads = [] -writes = [ - "Moves", - "Position", -] +writes = [] computed = [] init_calldata = [] -name = "dojo_examples::actions::actions" +name = "actions" +namespace = "dojo_examples" +manifest_name = "dojo_examples-actions" +artifact_name = "dojo_examples::actions::actions" [[contracts]] kind = "DojoContract" -address = "0x75961b2027c52948ecebfd347aa427436ea308d41997fa9b3c98380f7011d53" -class_hash = "0x5c32bc974f96f82ded691bb95bf26b2783f874fffb50fe84a331acb75ecf5b2" -original_class_hash = "0x5c32bc974f96f82ded691bb95bf26b2783f874fffb50fe84a331acb75ecf5b2" +address = "0x7cfff5cd7759cb2d8c301ee20751c4cd6080605055f117c06dc46ee0f92356b" +class_hash = "0x7416f8bb5be2b448d8cb5ef6af84e2a9f63f54c68fd3b04537b6a56d3fdbbf9" +original_class_hash = "0x7416f8bb5be2b448d8cb5ef6af84e2a9f63f54c68fd3b04537b6a56d3fdbbf9" base_class_hash = "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46" -abi = "manifests/dev/abis/deployments/contracts/dojo_examples_mock_token_mock_token.json" +abi = "manifests/dev/abis/deployments/contracts/dojo_examples-mock_token.json" reads = [] writes = [] computed = [] init_calldata = [] -name = "dojo_examples::mock_token::mock_token" +name = "mock_token" +namespace = "dojo_examples" +manifest_name = "dojo_examples-mock_token" +artifact_name = "dojo_examples::mock_token::mock_token" [[contracts]] kind = "DojoContract" -address = "0x3f51cd82daaf5907d2fd082ae3f45ae2ef96ab61677f46abc16e0a54d3392d1" -class_hash = "0x3ee016157303a7ce35a9fecdb5b8519159df620c5780527d61443636aaa3c3a" -original_class_hash = "0x3ee016157303a7ce35a9fecdb5b8519159df620c5780527d61443636aaa3c3a" +address = "0x64c941606ade888af5eba4e1d6044718edf53b52faeb43ff9233f17f543e967" +class_hash = "0x3fc738cd153b59715c5c0f3ba57265d86f838610d8926b872b402b74ffaa983" +original_class_hash = "0x3fc738cd153b59715c5c0f3ba57265d86f838610d8926b872b402b74ffaa983" base_class_hash = "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46" -abi = "manifests/dev/abis/deployments/contracts/dojo_examples_others_others.json" +abi = "manifests/dev/abis/deployments/contracts/dojo_examples-others.json" reads = [] writes = [] computed = [] init_calldata = [ - "$contract_address:dojo_examples::actions::actions", - "$class_hash:dojo_examples::actions::actions", + "$contract_address:dojo_examples:actions", + "$class_hash:dojo_examples:actions", "10", ] -name = "dojo_examples::others::others" +name = "others" +namespace = "dojo_examples" +manifest_name = "dojo_examples-others" +artifact_name = "dojo_examples::others::others" [[models]] kind = "DojoModel" -class_hash = "0x4ef89963afe500337aaf757ad52394ea8e311077a825b3de5a5f32d3457997c" -original_class_hash = "0x4ef89963afe500337aaf757ad52394ea8e311077a825b3de5a5f32d3457997c" -abi = "manifests/dev/abis/deployments/models/dojo_examples_actions_actions_moved.json" -name = "dojo_examples::actions::actions::moved" +class_hash = "0x422d29e9d76703627b6e17ec21f76ea51673181cca1db86fe3831e6b9520947" +original_class_hash = "0x422d29e9d76703627b6e17ec21f76ea51673181cca1db86fe3831e6b9520947" +abi = "manifests/dev/abis/deployments/models/dojo_examples-contract_initialized.json" +name = "ContractInitialized" +namespace = "dojo_examples" +manifest_name = "dojo_examples-contract_initialized" +artifact_name = "dojo_examples::others::others::contract_initialized" [[models.members]] -name = "player" +name = "contract_address" type = "ContractAddress" key = true [[models.members]] -name = "direction" -type = "Direction" +name = "contract_class" +type = "ClassHash" +key = false + +[[models.members]] +name = "value" +type = "u8" key = false [[models]] kind = "DojoModel" -class_hash = "0x33bdb1a470ea0ee7d77faa3c75151934b3b129c0bad7333ec6c2dad1b98ec5" -original_class_hash = "0x33bdb1a470ea0ee7d77faa3c75151934b3b129c0bad7333ec6c2dad1b98ec5" -abi = "manifests/dev/abis/deployments/models/dojo_examples_models_message.json" -name = "dojo_examples::models::message" +class_hash = "0x15bb4dfdcfe3dae6ee09cd2912b87f341cb0049c448443c19dff53e1dd2b2e4" +original_class_hash = "0x15bb4dfdcfe3dae6ee09cd2912b87f341cb0049c448443c19dff53e1dd2b2e4" +abi = "manifests/dev/abis/deployments/models/dojo_examples-message.json" +name = "Message" +namespace = "dojo_examples" +manifest_name = "dojo_examples-message" +artifact_name = "dojo_examples::models::message" [[models.members]] name = "identity" @@ -111,10 +130,13 @@ key = true [[models]] kind = "DojoModel" -class_hash = "0x6a21c56878ba470ac7a51f336ca6a59781de38e1810d2d20866ab2b52138a6d" -original_class_hash = "0x6a21c56878ba470ac7a51f336ca6a59781de38e1810d2d20866ab2b52138a6d" -abi = "manifests/dev/abis/deployments/models/dojo_examples_models_mock_token.json" -name = "dojo_examples::models::mock_token" +class_hash = "0x7b8abdeec63fe60338f5fd160c747c5db5fd911013a1f9c2b15e88900fabc5b" +original_class_hash = "0x7b8abdeec63fe60338f5fd160c747c5db5fd911013a1f9c2b15e88900fabc5b" +abi = "manifests/dev/abis/deployments/models/dojo_examples-mock_token.json" +name = "MockToken" +namespace = "dojo_examples" +manifest_name = "dojo_examples-mock_token" +artifact_name = "dojo_examples::models::mock_token" [[models.members]] name = "account" @@ -128,10 +150,33 @@ key = false [[models]] kind = "DojoModel" -class_hash = "0x456d85286b34249fffa0a13d1ac490cc1f5b02eb1a1c92d820c59d6b0f2eaa8" -original_class_hash = "0x456d85286b34249fffa0a13d1ac490cc1f5b02eb1a1c92d820c59d6b0f2eaa8" -abi = "manifests/dev/abis/deployments/models/dojo_examples_models_moves.json" -name = "dojo_examples::models::moves" +class_hash = "0x1ea2333b6b366988a726f8b95472b38a56506631d916b38a503b57f7dc2c16b" +original_class_hash = "0x1ea2333b6b366988a726f8b95472b38a56506631d916b38a503b57f7dc2c16b" +abi = "manifests/dev/abis/deployments/models/dojo_examples-moved.json" +name = "Moved" +namespace = "dojo_examples" +manifest_name = "dojo_examples-moved" +artifact_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 = "0x276c8225a5addbfe3e6b38d8e288dc977bdce2e2401877c58783d75c61a9f21" +original_class_hash = "0x276c8225a5addbfe3e6b38d8e288dc977bdce2e2401877c58783d75c61a9f21" +abi = "manifests/dev/abis/deployments/models/dojo_examples-moves.json" +name = "Moves" +namespace = "dojo_examples" +manifest_name = "dojo_examples-moves" +artifact_name = "dojo_examples::models::moves" [[models.members]] name = "player" @@ -150,10 +195,13 @@ key = false [[models]] kind = "DojoModel" -class_hash = "0x584d016a91d077c86ff1c014e0c4d735946d1084dd0d4c0a80cee6d04629e55" -original_class_hash = "0x584d016a91d077c86ff1c014e0c4d735946d1084dd0d4c0a80cee6d04629e55" -abi = "manifests/dev/abis/deployments/models/dojo_examples_models_player_config.json" -name = "dojo_examples::models::player_config" +class_hash = "0x1adabc0c605f4cbbad71bbbb86b8da6b964d406103cc854787e627eb779e474" +original_class_hash = "0x1adabc0c605f4cbbad71bbbb86b8da6b964d406103cc854787e627eb779e474" +abi = "manifests/dev/abis/deployments/models/dojo_examples-player_config.json" +name = "PlayerConfig" +namespace = "dojo_examples" +manifest_name = "dojo_examples-player_config" +artifact_name = "dojo_examples::models::player_config" [[models.members]] name = "player" @@ -177,10 +225,13 @@ key = false [[models]] kind = "DojoModel" -class_hash = "0x27942375b09862291ece780c573e8c625df4ba41fd7524e0658ca75fff014ff" -original_class_hash = "0x27942375b09862291ece780c573e8c625df4ba41fd7524e0658ca75fff014ff" -abi = "manifests/dev/abis/deployments/models/dojo_examples_models_position.json" -name = "dojo_examples::models::position" +class_hash = "0xdf544463099a54b4ff5b10473cd62cb56565641d7f6413fe7a499a240f2aac" +original_class_hash = "0xdf544463099a54b4ff5b10473cd62cb56565641d7f6413fe7a499a240f2aac" +abi = "manifests/dev/abis/deployments/models/dojo_examples-position.json" +name = "Position" +namespace = "dojo_examples" +manifest_name = "dojo_examples-position" +artifact_name = "dojo_examples::models::position" [[models.members]] name = "player" @@ -191,25 +242,3 @@ key = true name = "vec" type = "Vec2" key = false - -[[models]] -kind = "DojoModel" -class_hash = "0x4b29afc6db744bd87f7276869620348557c11b984e9f3fcb27c4d55efb0ab6c" -original_class_hash = "0x4b29afc6db744bd87f7276869620348557c11b984e9f3fcb27c4d55efb0ab6c" -abi = "manifests/dev/abis/deployments/models/dojo_examples_others_others_contract_initialized.json" -name = "dojo_examples::others::others::contract_initialized" - -[[models.members]] -name = "contract_address" -type = "ContractAddress" -key = true - -[[models.members]] -name = "contract_class" -type = "ClassHash" -key = false - -[[models.members]] -name = "value" -type = "u8" -key = false diff --git a/examples/spawn-and-move/manifests/dev/overlays/contracts/dojo_examples-others.toml b/examples/spawn-and-move/manifests/dev/overlays/contracts/dojo_examples-others.toml new file mode 100644 index 0000000000..331b0785e5 --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/overlays/contracts/dojo_examples-others.toml @@ -0,0 +1,5 @@ +init_calldata = ["$contract_address:dojo_examples:actions", "$class_hash:dojo_examples:actions", "10"] +name = "others" +namespace = "dojo_examples" +manifest_name = "dojo_examples_others" +artifact_name = "dojo_examples::others::others" diff --git a/examples/spawn-and-move/manifests/dev/overlays/contracts/dojo_examples_actions_actions.toml b/examples/spawn-and-move/manifests/dev/overlays/contracts/dojo_examples_actions_actions.toml deleted file mode 100644 index b21fc1adec..0000000000 --- a/examples/spawn-and-move/manifests/dev/overlays/contracts/dojo_examples_actions_actions.toml +++ /dev/null @@ -1,4 +0,0 @@ -name = "dojo_examples::actions::actions" -reads = [] -writes = ["Moves", "Position"] -init_calldata = [] diff --git a/examples/spawn-and-move/manifests/dev/overlays/contracts/dojo_examples_others_others.toml b/examples/spawn-and-move/manifests/dev/overlays/contracts/dojo_examples_others_others.toml deleted file mode 100644 index 129f942bd8..0000000000 --- a/examples/spawn-and-move/manifests/dev/overlays/contracts/dojo_examples_others_others.toml +++ /dev/null @@ -1,4 +0,0 @@ -name = "dojo_examples::others::others" -reads = [] -writes = [] -init_calldata = ["$contract_address:dojo_examples::actions::actions", "$class_hash:dojo_examples::actions::actions", "10"] diff --git a/examples/spawn-and-move/manifests/dev/overlays/dojo_base_base.toml b/examples/spawn-and-move/manifests/dev/overlays/dojo_base_base.toml deleted file mode 100644 index f706470d45..0000000000 --- a/examples/spawn-and-move/manifests/dev/overlays/dojo_base_base.toml +++ /dev/null @@ -1 +0,0 @@ -name = "dojo::base::base" diff --git a/examples/spawn-and-move/manifests/dev/overlays/dojo_world_world.toml b/examples/spawn-and-move/manifests/dev/overlays/dojo_world_world.toml deleted file mode 100644 index a3e686e3ef..0000000000 --- a/examples/spawn-and-move/manifests/dev/overlays/dojo_world_world.toml +++ /dev/null @@ -1 +0,0 @@ -name = "dojo::world::world" diff --git a/examples/spawn-and-move/manifests/dev/overlays/models/dojo_examples_actions_actions_moved.toml b/examples/spawn-and-move/manifests/dev/overlays/models/dojo_examples_actions_actions_moved.toml deleted file mode 100644 index 4958a7a15c..0000000000 --- a/examples/spawn-and-move/manifests/dev/overlays/models/dojo_examples_actions_actions_moved.toml +++ /dev/null @@ -1 +0,0 @@ -name = "dojo_examples::actions::actions::moved" diff --git a/examples/spawn-and-move/manifests/dev/overlays/models/dojo_examples_models_emote_message.toml b/examples/spawn-and-move/manifests/dev/overlays/models/dojo_examples_models_emote_message.toml deleted file mode 100644 index d60162cc72..0000000000 --- a/examples/spawn-and-move/manifests/dev/overlays/models/dojo_examples_models_emote_message.toml +++ /dev/null @@ -1 +0,0 @@ -name = "dojo_examples::models::emote_message" diff --git a/examples/spawn-and-move/manifests/dev/overlays/models/dojo_examples_models_moves.toml b/examples/spawn-and-move/manifests/dev/overlays/models/dojo_examples_models_moves.toml deleted file mode 100644 index dc8784e746..0000000000 --- a/examples/spawn-and-move/manifests/dev/overlays/models/dojo_examples_models_moves.toml +++ /dev/null @@ -1 +0,0 @@ -name = "dojo_examples::models::moves" diff --git a/examples/spawn-and-move/manifests/dev/overlays/models/dojo_examples_models_player_config.toml b/examples/spawn-and-move/manifests/dev/overlays/models/dojo_examples_models_player_config.toml deleted file mode 100644 index 6af8240b36..0000000000 --- a/examples/spawn-and-move/manifests/dev/overlays/models/dojo_examples_models_player_config.toml +++ /dev/null @@ -1 +0,0 @@ -name = "dojo_examples::models::player_config" diff --git a/examples/spawn-and-move/manifests/dev/overlays/models/dojo_examples_models_position.toml b/examples/spawn-and-move/manifests/dev/overlays/models/dojo_examples_models_position.toml deleted file mode 100644 index df38e71c32..0000000000 --- a/examples/spawn-and-move/manifests/dev/overlays/models/dojo_examples_models_position.toml +++ /dev/null @@ -1 +0,0 @@ -name = "dojo_examples::models::position" diff --git a/examples/spawn-and-move/manifests/dev/overlays/models/dojo_examples_others_others_contract_initialized.toml b/examples/spawn-and-move/manifests/dev/overlays/models/dojo_examples_others_others_contract_initialized.toml deleted file mode 100644 index f8f3053fe5..0000000000 --- a/examples/spawn-and-move/manifests/dev/overlays/models/dojo_examples_others_others_contract_initialized.toml +++ /dev/null @@ -1 +0,0 @@ -name = "dojo_examples::others::others::contract_initialized" diff --git a/examples/spawn-and-move/manifests/release/abis/base/contracts/dojo_examples_actions_actions.json b/examples/spawn-and-move/manifests/release/abis/base/contracts/dojo_examples_actions_actions.json deleted file mode 100644 index 21aed968a7..0000000000 --- a/examples/spawn-and-move/manifests/release/abis/base/contracts/dojo_examples_actions_actions.json +++ /dev/null @@ -1,290 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoResourceProviderImpl", - "interface_name": "dojo::world::IDojoResourceProvider" - }, - { - "type": "interface", - "name": "dojo::world::IDojoResourceProvider", - "items": [ - { - "type": "function", - "name": "dojo_resource", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "WorldProviderImpl", - "interface_name": "dojo::world::IWorldProvider" - }, - { - "type": "struct", - "name": "dojo::world::IWorldDispatcher", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::IWorldProvider", - "items": [ - { - "type": "function", - "name": "world", - "inputs": [], - "outputs": [ - { - "type": "dojo::world::IWorldDispatcher" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "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": "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_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/release/abis/base/contracts/dojo_examples_mock_token_mock_token.json b/examples/spawn-and-move/manifests/release/abis/base/contracts/dojo_examples_mock_token_mock_token.json deleted file mode 100644 index f4bde33e6d..0000000000 --- a/examples/spawn-and-move/manifests/release/abis/base/contracts/dojo_examples_mock_token_mock_token.json +++ /dev/null @@ -1,133 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoResourceProviderImpl", - "interface_name": "dojo::world::IDojoResourceProvider" - }, - { - "type": "interface", - "name": "dojo::world::IDojoResourceProvider", - "items": [ - { - "type": "function", - "name": "dojo_resource", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "WorldProviderImpl", - "interface_name": "dojo::world::IWorldProvider" - }, - { - "type": "struct", - "name": "dojo::world::IWorldDispatcher", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::IWorldProvider", - "items": [ - { - "type": "function", - "name": "world", - "inputs": [], - "outputs": [ - { - "type": "dojo::world::IWorldDispatcher" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "IDojoInitImpl", - "interface_name": "dojo_examples::mock_token::mock_token::IDojoInit" - }, - { - "type": "interface", - "name": "dojo_examples::mock_token::mock_token::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::mock_token::mock_token::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/release/abis/base/dojo_world_world.json b/examples/spawn-and-move/manifests/release/abis/base/dojo_world_world.json deleted file mode 100644 index c1a2447839..0000000000 --- a/examples/spawn-and-move/manifests/release/abis/base/dojo_world_world.json +++ /dev/null @@ -1,996 +0,0 @@ -[ - { - "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": "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": "model", - "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": "model", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "revoke_writer", - "inputs": [ - { - "name": "model", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "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" - }, - { - "name": "program_hash", - "type": "core::felt252" - } - ], - "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_differ_program_hash", - "inputs": [ - { - "name": "program_hash", - "type": "core::felt252" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "set_merger_program_hash", - "inputs": [ - { - "name": "program_hash", - "type": "core::felt252" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "get_differ_program_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "get_merger_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::ModelRegistered", - "kind": "struct", - "members": [ - { - "name": "name", - "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": "model", - "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::DifferProgramHashUpdate", - "kind": "struct", - "members": [ - { - "name": "program_hash", - "type": "core::felt252", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::config::component::Config::MergerProgramHashUpdate", - "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": "DifferProgramHashUpdate", - "type": "dojo::config::component::Config::DifferProgramHashUpdate", - "kind": "nested" - }, - { - "name": "MergerProgramHashUpdate", - "type": "dojo::config::component::Config::MergerProgramHashUpdate", - "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": "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/release/abis/base/models/dojo_examples_models_message.json b/examples/spawn-and-move/manifests/release/abis/base/models/dojo_examples_models_message.json deleted file mode 100644 index ec760c99fb..0000000000 --- a/examples/spawn-and-move/manifests/release/abis/base/models/dojo_examples_models_message.json +++ /dev/null @@ -1,371 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::database::introspect::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::database::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::database::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::database::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::IModel", - "items": [ - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "messageImpl", - "interface_name": "dojo_examples::models::Imessage" - }, - { - "type": "struct", - "name": "dojo_examples::models::Message", - "members": [ - { - "name": "identity", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "channel", - "type": "core::felt252" - }, - { - "name": "message", - "type": "core::byte_array::ByteArray" - }, - { - "name": "salt", - "type": "core::felt252" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::models::Imessage", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::models::Message" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::models::message::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/release/abis/deployments/contracts/dojo_examples_actions_actions.json b/examples/spawn-and-move/manifests/release/abis/deployments/contracts/dojo_examples_actions_actions.json deleted file mode 100644 index 21aed968a7..0000000000 --- a/examples/spawn-and-move/manifests/release/abis/deployments/contracts/dojo_examples_actions_actions.json +++ /dev/null @@ -1,290 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoResourceProviderImpl", - "interface_name": "dojo::world::IDojoResourceProvider" - }, - { - "type": "interface", - "name": "dojo::world::IDojoResourceProvider", - "items": [ - { - "type": "function", - "name": "dojo_resource", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "WorldProviderImpl", - "interface_name": "dojo::world::IWorldProvider" - }, - { - "type": "struct", - "name": "dojo::world::IWorldDispatcher", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::IWorldProvider", - "items": [ - { - "type": "function", - "name": "world", - "inputs": [], - "outputs": [ - { - "type": "dojo::world::IWorldDispatcher" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "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": "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_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/release/abis/deployments/dojo_world_world.json b/examples/spawn-and-move/manifests/release/abis/deployments/dojo_world_world.json deleted file mode 100644 index c1a2447839..0000000000 --- a/examples/spawn-and-move/manifests/release/abis/deployments/dojo_world_world.json +++ /dev/null @@ -1,996 +0,0 @@ -[ - { - "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": "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": "model", - "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": "model", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "revoke_writer", - "inputs": [ - { - "name": "model", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "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" - }, - { - "name": "program_hash", - "type": "core::felt252" - } - ], - "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_differ_program_hash", - "inputs": [ - { - "name": "program_hash", - "type": "core::felt252" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "set_merger_program_hash", - "inputs": [ - { - "name": "program_hash", - "type": "core::felt252" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "get_differ_program_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "get_merger_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::ModelRegistered", - "kind": "struct", - "members": [ - { - "name": "name", - "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": "model", - "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::DifferProgramHashUpdate", - "kind": "struct", - "members": [ - { - "name": "program_hash", - "type": "core::felt252", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::config::component::Config::MergerProgramHashUpdate", - "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": "DifferProgramHashUpdate", - "type": "dojo::config::component::Config::DifferProgramHashUpdate", - "kind": "nested" - }, - { - "name": "MergerProgramHashUpdate", - "type": "dojo::config::component::Config::MergerProgramHashUpdate", - "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": "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/release/abis/deployments/models/dojo_examples_actions_actions_moved.json b/examples/spawn-and-move/manifests/release/abis/deployments/models/dojo_examples_actions_actions_moved.json deleted file mode 100644 index 89abdcfec5..0000000000 --- a/examples/spawn-and-move/manifests/release/abis/deployments/models/dojo_examples_actions_actions_moved.json +++ /dev/null @@ -1,389 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::database::introspect::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::database::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::database::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::database::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::IModel", - "items": [ - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "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/release/abis/deployments/models/dojo_examples_models_emote_message.json b/examples/spawn-and-move/manifests/release/abis/deployments/models/dojo_examples_models_emote_message.json deleted file mode 100644 index 9c63d0fc5d..0000000000 --- a/examples/spawn-and-move/manifests/release/abis/deployments/models/dojo_examples_models_emote_message.json +++ /dev/null @@ -1,389 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::database::introspect::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::database::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::database::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::database::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::IModel", - "items": [ - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "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/release/abis/deployments/models/dojo_examples_models_message.json b/examples/spawn-and-move/manifests/release/abis/deployments/models/dojo_examples_models_message.json deleted file mode 100644 index ec760c99fb..0000000000 --- a/examples/spawn-and-move/manifests/release/abis/deployments/models/dojo_examples_models_message.json +++ /dev/null @@ -1,371 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::database::introspect::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::database::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::database::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::database::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::IModel", - "items": [ - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "messageImpl", - "interface_name": "dojo_examples::models::Imessage" - }, - { - "type": "struct", - "name": "dojo_examples::models::Message", - "members": [ - { - "name": "identity", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "channel", - "type": "core::felt252" - }, - { - "name": "message", - "type": "core::byte_array::ByteArray" - }, - { - "name": "salt", - "type": "core::felt252" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::models::Imessage", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::models::Message" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::models::message::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/release/abis/deployments/models/dojo_examples_models_moves.json b/examples/spawn-and-move/manifests/release/abis/deployments/models/dojo_examples_models_moves.json deleted file mode 100644 index ee2cf17b26..0000000000 --- a/examples/spawn-and-move/manifests/release/abis/deployments/models/dojo_examples_models_moves.json +++ /dev/null @@ -1,393 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::database::introspect::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::database::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::database::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::database::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::IModel", - "items": [ - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "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/release/abis/deployments/models/dojo_examples_models_player_config.json b/examples/spawn-and-move/manifests/release/abis/deployments/models/dojo_examples_models_player_config.json deleted file mode 100644 index 8c33ebabc4..0000000000 --- a/examples/spawn-and-move/manifests/release/abis/deployments/models/dojo_examples_models_player_config.json +++ /dev/null @@ -1,385 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::database::introspect::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::database::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::database::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::database::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::IModel", - "items": [ - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "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/release/abis/deployments/models/dojo_examples_models_position.json b/examples/spawn-and-move/manifests/release/abis/deployments/models/dojo_examples_models_position.json deleted file mode 100644 index bceec42587..0000000000 --- a/examples/spawn-and-move/manifests/release/abis/deployments/models/dojo_examples_models_position.json +++ /dev/null @@ -1,377 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::database::introspect::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::database::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::database::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::database::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::IModel", - "items": [ - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "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/release/abis/deployments/models/dojo_examples_others_others_contract_initialized.json b/examples/spawn-and-move/manifests/release/abis/deployments/models/dojo_examples_others_others_contract_initialized.json deleted file mode 100644 index 1dbbd313d8..0000000000 --- a/examples/spawn-and-move/manifests/release/abis/deployments/models/dojo_examples_others_others_contract_initialized.json +++ /dev/null @@ -1,367 +0,0 @@ -[ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::database::introspect::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::database::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::database::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::database::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::IModel", - "items": [ - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "contract_initializedImpl", - "interface_name": "dojo_examples::others::others::Icontract_initialized" - }, - { - "type": "struct", - "name": "dojo_examples::others::others::ContractInitialized", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "contract_class", - "type": "core::starknet::class_hash::ClassHash" - }, - { - "name": "value", - "type": "core::integer::u8" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::others::others::Icontract_initialized", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::others::others::ContractInitialized" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::others::others::contract_initialized::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples_actions_actions.toml b/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples_actions_actions.toml deleted file mode 100644 index bf0f86489b..0000000000 --- a/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples_actions_actions.toml +++ /dev/null @@ -1,10 +0,0 @@ -kind = "DojoContract" -class_hash = "0x6d905953360cf18e3393d128c6ced40b38fc83b033412c8541fd4aba59d2767" -original_class_hash = "0x6d905953360cf18e3393d128c6ced40b38fc83b033412c8541fd4aba59d2767" -base_class_hash = "0x0" -abi = "manifests/release/abis/base/contracts/dojo_examples_actions_actions.json" -reads = [] -writes = [] -computed = [] -init_calldata = [] -name = "dojo_examples::actions::actions" diff --git a/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples_mock_token_mock_token.toml b/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples_mock_token_mock_token.toml deleted file mode 100644 index 65fbfcc8ad..0000000000 --- a/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples_mock_token_mock_token.toml +++ /dev/null @@ -1,10 +0,0 @@ -kind = "DojoContract" -class_hash = "0x5c32bc974f96f82ded691bb95bf26b2783f874fffb50fe84a331acb75ecf5b2" -original_class_hash = "0x5c32bc974f96f82ded691bb95bf26b2783f874fffb50fe84a331acb75ecf5b2" -base_class_hash = "0x0" -abi = "manifests/release/abis/base/contracts/dojo_examples_mock_token_mock_token.json" -reads = [] -writes = [] -computed = [] -init_calldata = [] -name = "dojo_examples::mock_token::mock_token" diff --git a/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples_others_others.toml b/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples_others_others.toml deleted file mode 100644 index 66cb83c9d6..0000000000 --- a/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples_others_others.toml +++ /dev/null @@ -1,10 +0,0 @@ -kind = "DojoContract" -class_hash = "0x3ee016157303a7ce35a9fecdb5b8519159df620c5780527d61443636aaa3c3a" -original_class_hash = "0x3ee016157303a7ce35a9fecdb5b8519159df620c5780527d61443636aaa3c3a" -base_class_hash = "0x0" -abi = "manifests/release/abis/base/contracts/dojo_examples_others_others.json" -reads = [] -writes = [] -computed = [] -init_calldata = [] -name = "dojo_examples::others::others" diff --git a/examples/spawn-and-move/manifests/release/base/dojo_base_base.toml b/examples/spawn-and-move/manifests/release/base/dojo_base_base.toml deleted file mode 100644 index 6c4b5de67e..0000000000 --- a/examples/spawn-and-move/manifests/release/base/dojo_base_base.toml +++ /dev/null @@ -1,4 +0,0 @@ -kind = "Class" -class_hash = "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46" -original_class_hash = "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46" -name = "dojo::base::base" diff --git a/examples/spawn-and-move/manifests/release/base/dojo_world_world.toml b/examples/spawn-and-move/manifests/release/base/dojo_world_world.toml deleted file mode 100644 index e9badcfe4c..0000000000 --- a/examples/spawn-and-move/manifests/release/base/dojo_world_world.toml +++ /dev/null @@ -1,5 +0,0 @@ -kind = "Class" -class_hash = "0x3f63cecdc4964acafb921ba2934c6507d1b3c344edb64c2762cf08053169ab9" -original_class_hash = "0x3f63cecdc4964acafb921ba2934c6507d1b3c344edb64c2762cf08053169ab9" -abi = "manifests/release/abis/base/dojo_world_world.json" -name = "dojo::world::world" diff --git a/examples/spawn-and-move/manifests/release/base/models/dojo_examples_actions_actions_moved.toml b/examples/spawn-and-move/manifests/release/base/models/dojo_examples_actions_actions_moved.toml deleted file mode 100644 index 74c1e890a1..0000000000 --- a/examples/spawn-and-move/manifests/release/base/models/dojo_examples_actions_actions_moved.toml +++ /dev/null @@ -1,15 +0,0 @@ -kind = "DojoModel" -class_hash = "0x4ef89963afe500337aaf757ad52394ea8e311077a825b3de5a5f32d3457997c" -original_class_hash = "0x4ef89963afe500337aaf757ad52394ea8e311077a825b3de5a5f32d3457997c" -abi = "manifests/release/abis/base/models/dojo_examples_actions_actions_moved.json" -name = "dojo_examples::actions::actions::moved" - -[[members]] -name = "player" -type = "ContractAddress" -key = true - -[[members]] -name = "direction" -type = "Direction" -key = false diff --git a/examples/spawn-and-move/manifests/release/base/models/dojo_examples_models_message.toml b/examples/spawn-and-move/manifests/release/base/models/dojo_examples_models_message.toml deleted file mode 100644 index fdc87b27cb..0000000000 --- a/examples/spawn-and-move/manifests/release/base/models/dojo_examples_models_message.toml +++ /dev/null @@ -1,25 +0,0 @@ -kind = "DojoModel" -class_hash = "0x33bdb1a470ea0ee7d77faa3c75151934b3b129c0bad7333ec6c2dad1b98ec5" -original_class_hash = "0x33bdb1a470ea0ee7d77faa3c75151934b3b129c0bad7333ec6c2dad1b98ec5" -abi = "manifests/release/abis/base/models/dojo_examples_models_message.json" -name = "dojo_examples::models::message" - -[[members]] -name = "identity" -type = "ContractAddress" -key = true - -[[members]] -name = "channel" -type = "felt252" -key = true - -[[members]] -name = "message" -type = "ByteArray" -key = false - -[[members]] -name = "salt" -type = "felt252" -key = true diff --git a/examples/spawn-and-move/manifests/release/base/models/dojo_examples_models_mock_token.toml b/examples/spawn-and-move/manifests/release/base/models/dojo_examples_models_mock_token.toml deleted file mode 100644 index 3d0147bc11..0000000000 --- a/examples/spawn-and-move/manifests/release/base/models/dojo_examples_models_mock_token.toml +++ /dev/null @@ -1,15 +0,0 @@ -kind = "DojoModel" -class_hash = "0x6a21c56878ba470ac7a51f336ca6a59781de38e1810d2d20866ab2b52138a6d" -original_class_hash = "0x6a21c56878ba470ac7a51f336ca6a59781de38e1810d2d20866ab2b52138a6d" -abi = "manifests/release/abis/base/models/dojo_examples_models_mock_token.json" -name = "dojo_examples::models::mock_token" - -[[members]] -name = "account" -type = "ContractAddress" -key = true - -[[members]] -name = "amount" -type = "u128" -key = false diff --git a/examples/spawn-and-move/manifests/release/base/models/dojo_examples_models_moves.toml b/examples/spawn-and-move/manifests/release/base/models/dojo_examples_models_moves.toml deleted file mode 100644 index 8954550f5e..0000000000 --- a/examples/spawn-and-move/manifests/release/base/models/dojo_examples_models_moves.toml +++ /dev/null @@ -1,20 +0,0 @@ -kind = "DojoModel" -class_hash = "0x456d85286b34249fffa0a13d1ac490cc1f5b02eb1a1c92d820c59d6b0f2eaa8" -original_class_hash = "0x456d85286b34249fffa0a13d1ac490cc1f5b02eb1a1c92d820c59d6b0f2eaa8" -abi = "manifests/release/abis/base/models/dojo_examples_models_moves.json" -name = "dojo_examples::models::moves" - -[[members]] -name = "player" -type = "ContractAddress" -key = true - -[[members]] -name = "remaining" -type = "u8" -key = false - -[[members]] -name = "last_direction" -type = "Direction" -key = false diff --git a/examples/spawn-and-move/manifests/release/base/models/dojo_examples_models_player_config.toml b/examples/spawn-and-move/manifests/release/base/models/dojo_examples_models_player_config.toml deleted file mode 100644 index bbeae83193..0000000000 --- a/examples/spawn-and-move/manifests/release/base/models/dojo_examples_models_player_config.toml +++ /dev/null @@ -1,25 +0,0 @@ -kind = "DojoModel" -class_hash = "0x584d016a91d077c86ff1c014e0c4d735946d1084dd0d4c0a80cee6d04629e55" -original_class_hash = "0x584d016a91d077c86ff1c014e0c4d735946d1084dd0d4c0a80cee6d04629e55" -abi = "manifests/release/abis/base/models/dojo_examples_models_player_config.json" -name = "dojo_examples::models::player_config" - -[[members]] -name = "player" -type = "ContractAddress" -key = true - -[[members]] -name = "name" -type = "ByteArray" -key = false - -[[members]] -name = "items" -type = "Array" -key = false - -[[members]] -name = "favorite_item" -type = "Option" -key = false diff --git a/examples/spawn-and-move/manifests/release/base/models/dojo_examples_models_position.toml b/examples/spawn-and-move/manifests/release/base/models/dojo_examples_models_position.toml deleted file mode 100644 index 562adaba78..0000000000 --- a/examples/spawn-and-move/manifests/release/base/models/dojo_examples_models_position.toml +++ /dev/null @@ -1,15 +0,0 @@ -kind = "DojoModel" -class_hash = "0x27942375b09862291ece780c573e8c625df4ba41fd7524e0658ca75fff014ff" -original_class_hash = "0x27942375b09862291ece780c573e8c625df4ba41fd7524e0658ca75fff014ff" -abi = "manifests/release/abis/base/models/dojo_examples_models_position.json" -name = "dojo_examples::models::position" - -[[members]] -name = "player" -type = "ContractAddress" -key = true - -[[members]] -name = "vec" -type = "Vec2" -key = false diff --git a/examples/spawn-and-move/manifests/release/base/models/dojo_examples_others_others_contract_initialized.toml b/examples/spawn-and-move/manifests/release/base/models/dojo_examples_others_others_contract_initialized.toml deleted file mode 100644 index 51efb699ba..0000000000 --- a/examples/spawn-and-move/manifests/release/base/models/dojo_examples_others_others_contract_initialized.toml +++ /dev/null @@ -1,20 +0,0 @@ -kind = "DojoModel" -class_hash = "0x4b29afc6db744bd87f7276869620348557c11b984e9f3fcb27c4d55efb0ab6c" -original_class_hash = "0x4b29afc6db744bd87f7276869620348557c11b984e9f3fcb27c4d55efb0ab6c" -abi = "manifests/release/abis/base/models/dojo_examples_others_others_contract_initialized.json" -name = "dojo_examples::others::others::contract_initialized" - -[[members]] -name = "contract_address" -type = "ContractAddress" -key = true - -[[members]] -name = "contract_class" -type = "ClassHash" -key = false - -[[members]] -name = "value" -type = "u8" -key = false diff --git a/examples/spawn-and-move/manifests/release/manifest.json b/examples/spawn-and-move/manifests/release/manifest.json deleted file mode 100644 index 8ae464adc9..0000000000 --- a/examples/spawn-and-move/manifests/release/manifest.json +++ /dev/null @@ -1,3910 +0,0 @@ -{ - "world": { - "kind": "WorldContract", - "class_hash": "0x3f63cecdc4964acafb921ba2934c6507d1b3c344edb64c2762cf08053169ab9", - "original_class_hash": "0x3f63cecdc4964acafb921ba2934c6507d1b3c344edb64c2762cf08053169ab9", - "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": "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": "model", - "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": "model", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "revoke_writer", - "inputs": [ - { - "name": "model", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "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" - }, - { - "name": "program_hash", - "type": "core::felt252" - } - ], - "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_differ_program_hash", - "inputs": [ - { - "name": "program_hash", - "type": "core::felt252" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "set_merger_program_hash", - "inputs": [ - { - "name": "program_hash", - "type": "core::felt252" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "get_differ_program_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "get_merger_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::ModelRegistered", - "kind": "struct", - "members": [ - { - "name": "name", - "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": "model", - "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::DifferProgramHashUpdate", - "kind": "struct", - "members": [ - { - "name": "program_hash", - "type": "core::felt252", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::config::component::Config::MergerProgramHashUpdate", - "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": "DifferProgramHashUpdate", - "type": "dojo::config::component::Config::DifferProgramHashUpdate", - "kind": "nested" - }, - { - "name": "MergerProgramHashUpdate", - "type": "dojo::config::component::Config::MergerProgramHashUpdate", - "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": "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": "0x7efebb0c2d4cc285d48a97a7174def3be7fdd6b7bd29cca758fa2e17e03ef30", - "transaction_hash": "0x60316eb232789f4d8352c6afdc36b76d33362d72b43bf78183b43f196779a9d", - "block_number": 3, - "seed": "dojo_examples", - "metadata": { - "profile_name": "release", - "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": "0x5c70a663d6b48d8e4c6aaa9572e3735a732ac3765700d470463e670587852af", - "class_hash": "0x6d905953360cf18e3393d128c6ced40b38fc83b033412c8541fd4aba59d2767", - "original_class_hash": "0x6d905953360cf18e3393d128c6ced40b38fc83b033412c8541fd4aba59d2767", - "base_class_hash": "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46", - "abi": [ - { - "type": "impl", - "name": "DojoResourceProviderImpl", - "interface_name": "dojo::world::IDojoResourceProvider" - }, - { - "type": "interface", - "name": "dojo::world::IDojoResourceProvider", - "items": [ - { - "type": "function", - "name": "dojo_resource", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "WorldProviderImpl", - "interface_name": "dojo::world::IWorldProvider" - }, - { - "type": "struct", - "name": "dojo::world::IWorldDispatcher", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::IWorldProvider", - "items": [ - { - "type": "function", - "name": "world", - "inputs": [], - "outputs": [ - { - "type": "dojo::world::IWorldDispatcher" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "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": "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_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": "0x3f51cd82daaf5907d2fd082ae3f45ae2ef96ab61677f46abc16e0a54d3392d1", - "class_hash": "0x3ee016157303a7ce35a9fecdb5b8519159df620c5780527d61443636aaa3c3a", - "original_class_hash": "0x3ee016157303a7ce35a9fecdb5b8519159df620c5780527d61443636aaa3c3a", - "base_class_hash": "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46", - "abi": [ - { - "type": "impl", - "name": "DojoResourceProviderImpl", - "interface_name": "dojo::world::IDojoResourceProvider" - }, - { - "type": "interface", - "name": "dojo::world::IDojoResourceProvider", - "items": [ - { - "type": "function", - "name": "dojo_resource", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "WorldProviderImpl", - "interface_name": "dojo::world::IWorldProvider" - }, - { - "type": "struct", - "name": "dojo::world::IWorldDispatcher", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::IWorldProvider", - "items": [ - { - "type": "function", - "name": "world", - "inputs": [], - "outputs": [ - { - "type": "dojo::world::IWorldDispatcher" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "IDojoInitImpl", - "interface_name": "dojo_examples::others::others::IDojoInit" - }, - { - "type": "interface", - "name": "dojo_examples::others::others::IDojoInit", - "items": [ - { - "type": "function", - "name": "dojo_init", - "inputs": [ - { - "name": "actions_address", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "actions_class", - "type": "core::starknet::class_hash::ClassHash" - }, - { - "name": "value", - "type": "core::integer::u8" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "UpgradableImpl", - "interface_name": "dojo::components::upgradeable::IUpgradeable" - }, - { - "type": "interface", - "name": "dojo::components::upgradeable::IUpgradeable", - "items": [ - { - "type": "function", - "name": "upgrade", - "inputs": [ - { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "event", - "name": "dojo::components::upgradeable::upgradeable::Upgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::components::upgradeable::upgradeable::Event", - "kind": "enum", - "variants": [ - { - "name": "Upgraded", - "type": "dojo::components::upgradeable::upgradeable::Upgraded", - "kind": "nested" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::others::others::Event", - "kind": "enum", - "variants": [ - { - "name": "UpgradeableEvent", - "type": "dojo::components::upgradeable::upgradeable::Event", - "kind": "nested" - } - ] - } - ], - "reads": [], - "writes": [], - "computed": [], - "init_calldata": [ - "$class_hash:dojo_examples::actions::actions", - "$contract_address: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": "0x4ef89963afe500337aaf757ad52394ea8e311077a825b3de5a5f32d3457997c", - "original_class_hash": "0x4ef89963afe500337aaf757ad52394ea8e311077a825b3de5a5f32d3457997c", - "abi": [ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::database::introspect::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::database::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::database::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::database::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::IModel", - "items": [ - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "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": "channel", - "type": "felt252", - "key": true - }, - { - "name": "message", - "type": "ByteArray", - "key": false - }, - { - "name": "salt", - "type": "felt252", - "key": true - } - ], - "class_hash": "0x33bdb1a470ea0ee7d77faa3c75151934b3b129c0bad7333ec6c2dad1b98ec5", - "original_class_hash": "0x33bdb1a470ea0ee7d77faa3c75151934b3b129c0bad7333ec6c2dad1b98ec5", - "abi": [ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::database::introspect::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::database::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::database::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::database::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::IModel", - "items": [ - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "messageImpl", - "interface_name": "dojo_examples::models::Imessage" - }, - { - "type": "struct", - "name": "dojo_examples::models::Message", - "members": [ - { - "name": "identity", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "channel", - "type": "core::felt252" - }, - { - "name": "message", - "type": "core::byte_array::ByteArray" - }, - { - "name": "salt", - "type": "core::felt252" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::models::Imessage", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::models::Message" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::models::message::Event", - "kind": "enum", - "variants": [] - } - ], - "name": "dojo_examples::models::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": "0x456d85286b34249fffa0a13d1ac490cc1f5b02eb1a1c92d820c59d6b0f2eaa8", - "original_class_hash": "0x456d85286b34249fffa0a13d1ac490cc1f5b02eb1a1c92d820c59d6b0f2eaa8", - "abi": [ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::database::introspect::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::database::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::database::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::database::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::IModel", - "items": [ - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "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": "0x584d016a91d077c86ff1c014e0c4d735946d1084dd0d4c0a80cee6d04629e55", - "original_class_hash": "0x584d016a91d077c86ff1c014e0c4d735946d1084dd0d4c0a80cee6d04629e55", - "abi": [ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::database::introspect::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::database::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::database::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::database::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::IModel", - "items": [ - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "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": "0x27942375b09862291ece780c573e8c625df4ba41fd7524e0658ca75fff014ff", - "original_class_hash": "0x27942375b09862291ece780c573e8c625df4ba41fd7524e0658ca75fff014ff", - "abi": [ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::database::introspect::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::database::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::database::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::database::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::IModel", - "items": [ - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "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": "0x4b29afc6db744bd87f7276869620348557c11b984e9f3fcb27c4d55efb0ab6c", - "original_class_hash": "0x4b29afc6db744bd87f7276869620348557c11b984e9f3fcb27c4d55efb0ab6c", - "abi": [ - { - "type": "impl", - "name": "DojoModelImpl", - "interface_name": "dojo::model::IModel" - }, - { - "type": "struct", - "name": "core::byte_array::ByteArray", - "members": [ - { - "name": "data", - "type": "core::array::Array::" - }, - { - "name": "pending_word", - "type": "core::felt252" - }, - { - "name": "pending_word_len", - "type": "core::integer::u32" - } - ] - }, - { - "type": "enum", - "name": "core::option::Option::", - "variants": [ - { - "name": "Some", - "type": "core::integer::u32" - }, - { - "name": "None", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::database::introspect::Layout" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Layout", - "variants": [ - { - "name": "Fixed", - "type": "core::array::Span::" - }, - { - "name": "Struct", - "type": "core::array::Span::" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - }, - { - "name": "Enum", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Member", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "ty", - "type": "dojo::database::introspect::Ty" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Struct", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "dojo::database::introspect::Enum", - "members": [ - { - "name": "name", - "type": "core::felt252" - }, - { - "name": "attrs", - "type": "core::array::Span::" - }, - { - "name": "children", - "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "enum", - "name": "dojo::database::introspect::Ty", - "variants": [ - { - "name": "Primitive", - "type": "core::felt252" - }, - { - "name": "Struct", - "type": "dojo::database::introspect::Struct" - }, - { - "name": "Enum", - "type": "dojo::database::introspect::Enum" - }, - { - "name": "Tuple", - "type": "core::array::Span::" - }, - { - "name": "Array", - "type": "core::array::Span::" - }, - { - "name": "ByteArray", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::model::IModel", - "items": [ - { - "type": "function", - "name": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "version", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u8" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "contract_initializedImpl", - "interface_name": "dojo_examples::others::others::Icontract_initialized" - }, - { - "type": "struct", - "name": "dojo_examples::others::others::ContractInitialized", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "contract_class", - "type": "core::starknet::class_hash::ClassHash" - }, - { - "name": "value", - "type": "core::integer::u8" - } - ] - }, - { - "type": "interface", - "name": "dojo_examples::others::others::Icontract_initialized", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "dojo_examples::others::others::ContractInitialized" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "dojo_examples::others::others::contract_initialized::Event", - "kind": "enum", - "variants": [] - } - ], - "name": "dojo_examples::others::others::contract_initialized" - } - ] -} \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/release/manifest.toml b/examples/spawn-and-move/manifests/release/manifest.toml deleted file mode 100644 index 71ebf9944e..0000000000 --- a/examples/spawn-and-move/manifests/release/manifest.toml +++ /dev/null @@ -1,185 +0,0 @@ -[world] -kind = "WorldContract" -class_hash = "0x3f63cecdc4964acafb921ba2934c6507d1b3c344edb64c2762cf08053169ab9" -original_class_hash = "0x3f63cecdc4964acafb921ba2934c6507d1b3c344edb64c2762cf08053169ab9" -abi = "manifests/release/abis/deployments/dojo_world_world.json" -address = "0x7efebb0c2d4cc285d48a97a7174def3be7fdd6b7bd29cca758fa2e17e03ef30" -transaction_hash = "0x60316eb232789f4d8352c6afdc36b76d33362d72b43bf78183b43f196779a9d" -block_number = 3 -seed = "dojo_examples" -name = "dojo::world::world" - -[world.metadata] -profile_name = "release" -rpc_url = "http://localhost:5050/" - -[base] -kind = "Class" -class_hash = "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46" -original_class_hash = "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46" -name = "dojo::base::base" - -[[contracts]] -kind = "DojoContract" -address = "0x5c70a663d6b48d8e4c6aaa9572e3735a732ac3765700d470463e670587852af" -class_hash = "0x6d905953360cf18e3393d128c6ced40b38fc83b033412c8541fd4aba59d2767" -original_class_hash = "0x6d905953360cf18e3393d128c6ced40b38fc83b033412c8541fd4aba59d2767" -base_class_hash = "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46" -abi = "manifests/release/abis/deployments/contracts/dojo_examples_actions_actions.json" -reads = [] -writes = [ - "Moves", - "Position", -] -computed = [] -init_calldata = [] -name = "dojo_examples::actions::actions" - -[[contracts]] -kind = "DojoContract" -address = "0x3f51cd82daaf5907d2fd082ae3f45ae2ef96ab61677f46abc16e0a54d3392d1" -class_hash = "0x3ee016157303a7ce35a9fecdb5b8519159df620c5780527d61443636aaa3c3a" -original_class_hash = "0x3ee016157303a7ce35a9fecdb5b8519159df620c5780527d61443636aaa3c3a" -base_class_hash = "0x22f3e55b61d86c2ac5239fa3b3b8761f26b9a5c0b5f61ddbd5d756ced498b46" -abi = "manifests/release/abis/deployments/contracts/dojo_examples_others_others.json" -reads = [] -writes = [] -computed = [] -init_calldata = [ - "$class_hash:dojo_examples::actions::actions", - "$contract_address:dojo_examples::actions::actions", - "10", -] -name = "dojo_examples::others::others" - -[[models]] -kind = "DojoModel" -class_hash = "0x4ef89963afe500337aaf757ad52394ea8e311077a825b3de5a5f32d3457997c" -original_class_hash = "0x4ef89963afe500337aaf757ad52394ea8e311077a825b3de5a5f32d3457997c" -abi = "manifests/release/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 = "0x33bdb1a470ea0ee7d77faa3c75151934b3b129c0bad7333ec6c2dad1b98ec5" -original_class_hash = "0x33bdb1a470ea0ee7d77faa3c75151934b3b129c0bad7333ec6c2dad1b98ec5" -abi = "manifests/release/abis/deployments/models/dojo_examples_models_message.json" -name = "dojo_examples::models::message" - -[[models.members]] -name = "identity" -type = "ContractAddress" -key = true - -[[models.members]] -name = "channel" -type = "felt252" -key = true - -[[models.members]] -name = "message" -type = "ByteArray" -key = false - -[[models.members]] -name = "salt" -type = "felt252" -key = true - -[[models]] -kind = "DojoModel" -class_hash = "0x456d85286b34249fffa0a13d1ac490cc1f5b02eb1a1c92d820c59d6b0f2eaa8" -original_class_hash = "0x456d85286b34249fffa0a13d1ac490cc1f5b02eb1a1c92d820c59d6b0f2eaa8" -abi = "manifests/release/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 = "0x584d016a91d077c86ff1c014e0c4d735946d1084dd0d4c0a80cee6d04629e55" -original_class_hash = "0x584d016a91d077c86ff1c014e0c4d735946d1084dd0d4c0a80cee6d04629e55" -abi = "manifests/release/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 = "0x27942375b09862291ece780c573e8c625df4ba41fd7524e0658ca75fff014ff" -original_class_hash = "0x27942375b09862291ece780c573e8c625df4ba41fd7524e0658ca75fff014ff" -abi = "manifests/release/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 = "0x4b29afc6db744bd87f7276869620348557c11b984e9f3fcb27c4d55efb0ab6c" -original_class_hash = "0x4b29afc6db744bd87f7276869620348557c11b984e9f3fcb27c4d55efb0ab6c" -abi = "manifests/release/abis/deployments/models/dojo_examples_others_others_contract_initialized.json" -name = "dojo_examples::others::others::contract_initialized" - -[[models.members]] -name = "contract_address" -type = "ContractAddress" -key = true - -[[models.members]] -name = "contract_class" -type = "ClassHash" -key = false - -[[models.members]] -name = "value" -type = "u8" -key = false diff --git a/examples/spawn-and-move/manifests/release/overlays/contracts/dojo_examples_actions_actions.toml b/examples/spawn-and-move/manifests/release/overlays/contracts/dojo_examples_actions_actions.toml deleted file mode 100644 index 188130a013..0000000000 --- a/examples/spawn-and-move/manifests/release/overlays/contracts/dojo_examples_actions_actions.toml +++ /dev/null @@ -1,4 +0,0 @@ -init_calldata = [ ] -name = "dojo_examples::actions::actions" -reads = [ ] -writes = [ "Moves", "Position" ] diff --git a/examples/spawn-and-move/manifests/release/overlays/contracts/dojo_examples_others_others.toml b/examples/spawn-and-move/manifests/release/overlays/contracts/dojo_examples_others_others.toml deleted file mode 100644 index 82545bca81..0000000000 --- a/examples/spawn-and-move/manifests/release/overlays/contracts/dojo_examples_others_others.toml +++ /dev/null @@ -1,8 +0,0 @@ -init_calldata = [ - "$class_hash:dojo_examples::actions::actions", - "$contract_address:dojo_examples::actions::actions", - "10", -] -name = "dojo_examples::others::others" -reads = [ ] -writes = [ ] diff --git a/examples/spawn-and-move/manifests/release/overlays/dojo_base_base.toml b/examples/spawn-and-move/manifests/release/overlays/dojo_base_base.toml deleted file mode 100644 index f706470d45..0000000000 --- a/examples/spawn-and-move/manifests/release/overlays/dojo_base_base.toml +++ /dev/null @@ -1 +0,0 @@ -name = "dojo::base::base" diff --git a/examples/spawn-and-move/manifests/release/overlays/dojo_world_world.toml b/examples/spawn-and-move/manifests/release/overlays/dojo_world_world.toml deleted file mode 100644 index a3e686e3ef..0000000000 --- a/examples/spawn-and-move/manifests/release/overlays/dojo_world_world.toml +++ /dev/null @@ -1 +0,0 @@ -name = "dojo::world::world" diff --git a/examples/spawn-and-move/manifests/release/overlays/models/dojo_examples_actions_actions_moved.toml b/examples/spawn-and-move/manifests/release/overlays/models/dojo_examples_actions_actions_moved.toml deleted file mode 100644 index 4958a7a15c..0000000000 --- a/examples/spawn-and-move/manifests/release/overlays/models/dojo_examples_actions_actions_moved.toml +++ /dev/null @@ -1 +0,0 @@ -name = "dojo_examples::actions::actions::moved" diff --git a/examples/spawn-and-move/manifests/release/overlays/models/dojo_examples_models_message.toml b/examples/spawn-and-move/manifests/release/overlays/models/dojo_examples_models_message.toml deleted file mode 100644 index 5d9412cae2..0000000000 --- a/examples/spawn-and-move/manifests/release/overlays/models/dojo_examples_models_message.toml +++ /dev/null @@ -1 +0,0 @@ -name = "dojo_examples::models::message" diff --git a/examples/spawn-and-move/manifests/release/overlays/models/dojo_examples_models_mock_token.toml b/examples/spawn-and-move/manifests/release/overlays/models/dojo_examples_models_mock_token.toml deleted file mode 100644 index a5ba5684a6..0000000000 --- a/examples/spawn-and-move/manifests/release/overlays/models/dojo_examples_models_mock_token.toml +++ /dev/null @@ -1 +0,0 @@ -name = "dojo_examples::models::mock_token" diff --git a/examples/spawn-and-move/manifests/release/overlays/models/dojo_examples_models_moves.toml b/examples/spawn-and-move/manifests/release/overlays/models/dojo_examples_models_moves.toml deleted file mode 100644 index dc8784e746..0000000000 --- a/examples/spawn-and-move/manifests/release/overlays/models/dojo_examples_models_moves.toml +++ /dev/null @@ -1 +0,0 @@ -name = "dojo_examples::models::moves" diff --git a/examples/spawn-and-move/manifests/release/overlays/models/dojo_examples_models_player_config.toml b/examples/spawn-and-move/manifests/release/overlays/models/dojo_examples_models_player_config.toml deleted file mode 100644 index 6af8240b36..0000000000 --- a/examples/spawn-and-move/manifests/release/overlays/models/dojo_examples_models_player_config.toml +++ /dev/null @@ -1 +0,0 @@ -name = "dojo_examples::models::player_config" diff --git a/examples/spawn-and-move/manifests/release/overlays/models/dojo_examples_models_position.toml b/examples/spawn-and-move/manifests/release/overlays/models/dojo_examples_models_position.toml deleted file mode 100644 index df38e71c32..0000000000 --- a/examples/spawn-and-move/manifests/release/overlays/models/dojo_examples_models_position.toml +++ /dev/null @@ -1 +0,0 @@ -name = "dojo_examples::models::position" diff --git a/examples/spawn-and-move/manifests/release/overlays/models/dojo_examples_others_others_contract_initialized.toml b/examples/spawn-and-move/manifests/release/overlays/models/dojo_examples_others_others_contract_initialized.toml deleted file mode 100644 index f8f3053fe5..0000000000 --- a/examples/spawn-and-move/manifests/release/overlays/models/dojo_examples_others_others_contract_initialized.toml +++ /dev/null @@ -1 +0,0 @@ -name = "dojo_examples::others::others::contract_initialized" diff --git a/examples/spawn-and-move/src/actions.cairo b/examples/spawn-and-move/src/actions.cairo index 143696ed80..dbfc5cec40 100644 --- a/examples/spawn-and-move/src/actions.cairo +++ b/examples/spawn-and-move/src/actions.cairo @@ -125,7 +125,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