From f19b4facc0f00d2c8a2dc82f6abf48d85b117b71 Mon Sep 17 00:00:00 2001 From: glihm Date: Wed, 10 Jul 2024 16:04:40 -0600 Subject: [PATCH 01/15] fix: ensure models from dependencies inherite the current package namespace --- crates/dojo-lang/src/compiler.rs | 5 ++++- crates/dojo-lang/src/contract.rs | 4 ++-- crates/dojo-lang/src/model.rs | 7 ++----- crates/dojo-lang/src/plugin.rs | 28 ++++++++++++++++------------ crates/dojo-lang/src/utils.rs | 20 +++++++++++++------- 5 files changed, 37 insertions(+), 27 deletions(-) diff --git a/crates/dojo-lang/src/compiler.rs b/crates/dojo-lang/src/compiler.rs index faa07c22fa..eb4454cf0b 100644 --- a/crates/dojo-lang/src/compiler.rs +++ b/crates/dojo-lang/src/compiler.rs @@ -169,15 +169,18 @@ fn find_project_contracts( .map(|selector| selector.package().into()) .unique() .map(|package_name: SmolStr| { + debug!(target: LOG_TARGET, %package_name, "Looking for internal crates."); db.upcast_mut().intern_crate(CrateLongId::Real(package_name)) }) .collect::>(); + find_contracts(db, crate_ids.as_ref()) .into_iter() .filter(|decl| { external_contracts.iter().any(|selector| { let contract_path = decl.module_id().full_path(db.upcast()); - contract_path == selector.full_path() + // Snake case is used to ensure we match the `compile()` output. + contract_path == selector.full_path().to_case(Case::Snake) }) }) .collect::>() diff --git a/crates/dojo-lang/src/contract.rs b/crates/dojo-lang/src/contract.rs index bf07bbd2d3..1f5284d461 100644 --- a/crates/dojo-lang/src/contract.rs +++ b/crates/dojo-lang/src/contract.rs @@ -40,7 +40,7 @@ impl DojoContract { pub fn from_module( db: &dyn SyntaxGroup, module_ast: &ast::ItemModule, - package_id: String, + default_namespace: String, metadata: &MacroPluginMetadata<'_>, ) -> PluginResult { let name = module_ast.name(db).text(db); @@ -56,7 +56,7 @@ impl DojoContract { let contract_namespace = match parameters.namespace { Some(x) => x.to_string(), - None => package_id, + None => default_namespace, }; for (id, value) in [("name", &name.to_string()), ("namespace", &contract_namespace)] { diff --git a/crates/dojo-lang/src/model.rs b/crates/dojo-lang/src/model.rs index 18bdd3ed80..c04e6f3530 100644 --- a/crates/dojo-lang/src/model.rs +++ b/crates/dojo-lang/src/model.rs @@ -192,17 +192,14 @@ pub fn handle_model_struct( db: &dyn SyntaxGroup, aux_data: &mut DojoAuxData, struct_ast: ItemStruct, - package_id: String, + default_namespace: 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, - }; + let model_namespace = parameters.namespace.unwrap_or(default_namespace); for (id, value) in [("name", &model_name), ("namespace", &model_namespace)] { if !is_name_valid(value) { diff --git a/crates/dojo-lang/src/plugin.rs b/crates/dojo-lang/src/plugin.rs index a0f43e8c4a..9cf0b82520 100644 --- a/crates/dojo-lang/src/plugin.rs +++ b/crates/dojo-lang/src/plugin.rs @@ -35,7 +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; +use crate::utils::get_default_namespace; pub const DOJO_CONTRACT_ATTR: &str = "dojo::contract"; pub const DOJO_INTERFACE_ATTR: &str = "dojo::interface"; @@ -111,11 +111,11 @@ impl BuiltinDojoPlugin { &self, db: &dyn SyntaxGroup, module_ast: ast::ItemModule, - package_id: String, + default_namespace: String, metadata: &MacroPluginMetadata<'_>, ) -> PluginResult { if module_ast.has_attr(db, DOJO_CONTRACT_ATTR) { - return DojoContract::from_module(db, &module_ast, package_id, metadata); + return DojoContract::from_module(db, &module_ast, default_namespace, metadata); } PluginResult::default() @@ -150,7 +150,7 @@ impl BuiltinDojoPlugin { &self, db: &dyn SyntaxGroup, fn_ast: ast::FunctionWithBody, - package_id: String, + default_namespace: String, ) -> PluginResult { let attrs = fn_ast.attributes(db).query_attr(db, "computed"); if attrs.is_empty() { @@ -177,7 +177,7 @@ impl BuiltinDojoPlugin { let mut tag = None; if args.len() == 1 { let model_name = args[0].text(db); - tag = Some(naming::get_tag(&model_name, &package_id)); + tag = Some(naming::get_tag(&model_name, &default_namespace)); let model_type_node = param_els[1].type_clause(db).ty(db); if let ast::Expr::Path(model_type_path) = model_type_node { @@ -342,15 +342,15 @@ impl MacroPlugin for BuiltinDojoPlugin { item_ast: ast::ModuleItem, metadata: &MacroPluginMetadata<'_>, ) -> PluginResult { - let package_id = match get_package_id(db) { + let default_namespace = match get_default_namespace(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." + message: "Unable to find the default namespace. Be sure to have a \ + 'tool.dojo.world.namespace' field in your Scarb.toml file." .into(), severity: Severity::Error, }], @@ -361,7 +361,7 @@ impl MacroPlugin for BuiltinDojoPlugin { match item_ast { ast::ModuleItem::Module(module_ast) => { - self.handle_mod(db, module_ast, package_id, metadata) + self.handle_mod(db, module_ast, default_namespace, metadata) } ast::ModuleItem::Trait(trait_ast) => self.handle_trait(db, trait_ast, metadata), ast::ModuleItem::Enum(enum_ast) => { @@ -501,8 +501,12 @@ 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(), package_id); + let (model_rewrite_nodes, model_diagnostics) = handle_model_struct( + db, + &mut aux_data, + struct_ast.clone(), + default_namespace, + ); rewrite_nodes.push(model_rewrite_nodes); diagnostics.extend(model_diagnostics); } @@ -540,7 +544,7 @@ impl MacroPlugin for BuiltinDojoPlugin { remove_original_item: false, } } - ast::ModuleItem::FreeFunction(fn_ast) => self.handle_fn(db, fn_ast, package_id), + ast::ModuleItem::FreeFunction(fn_ast) => self.handle_fn(db, fn_ast, default_namespace), _ => PluginResult::default(), } } diff --git a/crates/dojo-lang/src/utils.rs b/crates/dojo-lang/src/utils.rs index d46f10a7b7..3b9a7d553c 100644 --- a/crates/dojo-lang/src/utils.rs +++ b/crates/dojo-lang/src/utils.rs @@ -10,16 +10,18 @@ pub fn is_name_valid(name: &str) -> bool { Regex::new(r"^[a-zA-Z0-9_]+$").unwrap().is_match(name) } -// 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 { +// Parses the configuration file of the first crate to extract the default namespace. +// TODO: Ask to Scarb team to expose this information with the new macro system. +pub fn get_default_namespace(db: &dyn SyntaxGroup) -> Option { let crates = db.crates(); if crates.is_empty() { return Option::None; } + // Crates[0] is always the root crate that triggered the build origin. + // In case of a library, crates[0] refers to the lib itself if compiled directly, + // or the crate using the library otherwise. let configuration = match db.crate_config(crates[0]) { Option::Some(cfg) => cfg, Option::None => return Option::None, @@ -36,10 +38,14 @@ pub fn get_package_id(db: &dyn SyntaxGroup) -> Option { Err(_) => return Option::None, }; - if config.contains_key("package") - && config["package"].as_table().unwrap().contains_key("name") + if config.contains_key("tool") + && config["tool"].as_table().unwrap().contains_key("dojo") + && config["tool"]["dojo"].as_table().unwrap().contains_key("world") + && config["tool"]["dojo"]["world"].as_table().unwrap().contains_key("namespace") { - return Some(config["package"]["name"].as_str().unwrap().to_string()); + return Some( + config["tool"]["dojo"]["world"]["namespace"].as_str().unwrap().to_string(), + ); }; } From 24b64950f42007e64c733ad04c5079a51a3fb253 Mon Sep 17 00:00:00 2001 From: glihm Date: Wed, 10 Jul 2024 20:13:23 -0600 Subject: [PATCH 02/15] feat: add new game-lib with workspace and adjust test --- bin/sozo/src/commands/build.rs | 8 +- bin/sozo/src/commands/clean.rs | 23 +- bin/sozo/src/commands/migrate.rs | 66 +- bin/sozo/tests/register_test.rs | 11 +- bin/sozo/tests/test_migrate.rs | 11 +- crates/dojo-bindgen/src/lib.rs | 25 +- .../src/plugins/typescript_v2/mod.rs | 21 +- .../dojo-lang/src/plugin_test_data/introspect | 2525 ++------- crates/dojo-lang/src/plugin_test_data/model | 4854 +---------------- crates/dojo-lang/src/plugin_test_data/print | 69 +- crates/dojo-lang/src/plugin_test_data/system | 1620 ++---- crates/dojo-lang/src/semantics/test_data/get | 105 + crates/dojo-lang/src/semantics/test_data/set | 40 + crates/dojo-test-utils/src/compiler.rs | 64 +- crates/dojo-world/src/contracts/model_test.rs | 10 +- crates/dojo-world/src/contracts/world_test.rs | 11 +- .../dojo-world/src/manifest/manifest_test.rs | 25 +- crates/sozo/ops/src/migration/mod.rs | 14 +- crates/sozo/ops/src/tests/setup.rs | 11 +- crates/torii/core/src/sql_test.rs | 131 +- crates/torii/graphql/src/tests/mod.rs | 70 +- .../grpc/src/server/tests/entities_test.rs | 10 +- examples/game-lib/Scarb.lock | 28 + examples/game-lib/Scarb.toml | 12 + examples/game-lib/armory/Scarb.lock | 21 + examples/game-lib/armory/Scarb.toml | 16 + .../manifests/dev/base/abis/dojo-base.json | 98 + .../manifests/dev/base/abis/dojo-world.json | 1105 ++++ .../abis/models/armory-ModelA-19290fb7.json | 407 ++ .../armory/manifests/dev/base/dojo-base.toml | 6 + .../armory/manifests/dev/base/dojo-world.toml | 6 + .../base/models/armory-ModelA-19290fb7.toml | 16 + examples/game-lib/armory/src/lib.cairo | 8 + examples/game-lib/bestiary/Scarb.toml | 16 + examples/game-lib/bestiary/src/lib.cairo | 9 + .../manifests/dev/base/abis/dojo-base.json | 98 + .../manifests/dev/base/abis/dojo-world.json | 1105 ++++ .../abis/models/armory-Flatbow-f269a4c3.json | 411 ++ .../models/bestiary-RiverSkale-1bce2040.json | 415 ++ .../manifests/dev/base/dojo-base.toml | 6 + .../manifests/dev/base/dojo-world.toml | 6 + .../base/models/armory-Flatbow-f269a4c3.toml | 21 + .../models/bestiary-RiverSkale-1bce2040.toml | 26 + examples/spawn-and-move/Scarb.lock | 16 + examples/spawn-and-move/Scarb.toml | 11 +- .../dojo_examples-actions-40b6994c.json | 6 +- ...on => dojo_examples-dungeon-6620e0e6.json} | 14 +- .../dojo_examples-Flatbow-3632af69.json | 411 ++ .../dojo_examples-RiverSkale-27fcbc29.json | 415 ++ .../dojo_examples-actions-40b6994c.toml | 4 +- .../dojo_examples-dungeon-6620e0e6.toml | 11 + .../dojo_examples-something-71cfad55.toml | 11 - .../dojo_examples-Flatbow-3632af69.toml | 21 + .../dojo_examples-RiverSkale-27fcbc29.toml | 26 + .../dojo_examples-actions-40b6994c.json | 12 + .../dojo_examples-dungeon-6620e0e6.json} | 14 +- .../dojo_examples-Flatbow-3632af69.json | 411 ++ .../models/dojo_examples-ModelA-689f21bc.json | 407 ++ .../dojo_examples-RiverSkale-27fcbc29.json | 415 ++ .../manifests/dev/deployment/manifest.json | 1438 ++++- .../manifests/dev/deployment/manifest.toml | 69 +- .../dojo_examples-actions-40b6994c.json | 6 +- .../dojo_examples-dungeon-6620e0e6.json | 224 + .../dojo_examples-Flatbow-3632af69.json | 411 ++ .../dojo_examples-RiverSkale-27fcbc29.json | 415 ++ .../dojo_examples-actions-40b6994c.toml | 4 +- .../dojo_examples-dungeon-6620e0e6.toml | 11 + .../dojo_examples-something-71cfad55.toml | 11 - .../dojo_examples-Flatbow-3632af69.toml | 21 + .../dojo_examples-RiverSkale-27fcbc29.toml | 26 + examples/spawn-and-move/src/actions.cairo | 28 +- examples/spawn-and-move/src/dungeon.cairo | 12 + examples/spawn-and-move/src/lib.cairo | 4 +- examples/spawn-and-move/src/something.cairo | 12 - 74 files changed, 9830 insertions(+), 8627 deletions(-) create mode 100644 examples/game-lib/Scarb.lock create mode 100644 examples/game-lib/Scarb.toml create mode 100644 examples/game-lib/armory/Scarb.lock create mode 100644 examples/game-lib/armory/Scarb.toml create mode 100644 examples/game-lib/armory/manifests/dev/base/abis/dojo-base.json create mode 100644 examples/game-lib/armory/manifests/dev/base/abis/dojo-world.json create mode 100644 examples/game-lib/armory/manifests/dev/base/abis/models/armory-ModelA-19290fb7.json create mode 100644 examples/game-lib/armory/manifests/dev/base/dojo-base.toml create mode 100644 examples/game-lib/armory/manifests/dev/base/dojo-world.toml create mode 100644 examples/game-lib/armory/manifests/dev/base/models/armory-ModelA-19290fb7.toml create mode 100644 examples/game-lib/armory/src/lib.cairo create mode 100644 examples/game-lib/bestiary/Scarb.toml create mode 100644 examples/game-lib/bestiary/src/lib.cairo create mode 100644 examples/game-lib/manifests/dev/base/abis/dojo-base.json create mode 100644 examples/game-lib/manifests/dev/base/abis/dojo-world.json create mode 100644 examples/game-lib/manifests/dev/base/abis/models/armory-Flatbow-f269a4c3.json create mode 100644 examples/game-lib/manifests/dev/base/abis/models/bestiary-RiverSkale-1bce2040.json create mode 100644 examples/game-lib/manifests/dev/base/dojo-base.toml create mode 100644 examples/game-lib/manifests/dev/base/dojo-world.toml create mode 100644 examples/game-lib/manifests/dev/base/models/armory-Flatbow-f269a4c3.toml create mode 100644 examples/game-lib/manifests/dev/base/models/bestiary-RiverSkale-1bce2040.toml rename examples/spawn-and-move/manifests/dev/base/abis/contracts/{dojo_examples-something-71cfad55.json => dojo_examples-dungeon-6620e0e6.json} (92%) create mode 100644 examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-Flatbow-3632af69.json create mode 100644 examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-RiverSkale-27fcbc29.json create mode 100644 examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-dungeon-6620e0e6.toml delete mode 100644 examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-something-71cfad55.toml create mode 100644 examples/spawn-and-move/manifests/dev/base/models/dojo_examples-Flatbow-3632af69.toml create mode 100644 examples/spawn-and-move/manifests/dev/base/models/dojo_examples-RiverSkale-27fcbc29.toml rename examples/spawn-and-move/manifests/{release/base/abis/contracts/dojo_examples-something-71cfad55.json => dev/deployment/abis/contracts/dojo_examples-dungeon-6620e0e6.json} (92%) create mode 100644 examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-Flatbow-3632af69.json create mode 100644 examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-ModelA-689f21bc.json create mode 100644 examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-RiverSkale-27fcbc29.json create mode 100644 examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-dungeon-6620e0e6.json create mode 100644 examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-Flatbow-3632af69.json create mode 100644 examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-RiverSkale-27fcbc29.json create mode 100644 examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-dungeon-6620e0e6.toml delete mode 100644 examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-something-71cfad55.toml create mode 100644 examples/spawn-and-move/manifests/release/base/models/dojo_examples-Flatbow-3632af69.toml create mode 100644 examples/spawn-and-move/manifests/release/base/models/dojo_examples-RiverSkale-27fcbc29.toml create mode 100644 examples/spawn-and-move/src/dungeon.cairo delete mode 100644 examples/spawn-and-move/src/something.cairo diff --git a/bin/sozo/src/commands/build.rs b/bin/sozo/src/commands/build.rs index 91a7ba15b3..20cc76c5c6 100644 --- a/bin/sozo/src/commands/build.rs +++ b/bin/sozo/src/commands/build.rs @@ -214,8 +214,7 @@ fn create_stats_table(mut contracts_statistics: Vec) -> Tabl #[cfg(test)] mod tests { - use camino::Utf8PathBuf; - use dojo_test_utils::compiler; + use dojo_test_utils::compiler::CompilerTestSetup; use prettytable::format::consts::FORMAT_NO_LINESEP_WITH_TITLE; use prettytable::{format, Cell, Row, Table}; use scarb::compiler::Profile; @@ -227,10 +226,9 @@ mod tests { // Uncomment once bindings support arrays. #[test] fn build_example_with_typescript_and_unity_bindings() { - let source_project_dir = Utf8PathBuf::from("../../examples/spawn-and-move/"); - let dojo_core_path = Utf8PathBuf::from("../../crates/dojo-core"); + let setup = CompilerTestSetup::from_examples("../../crates/dojo-core", "../../examples/"); - let config = compiler::copy_tmp_config(&source_project_dir, &dojo_core_path, Profile::DEV); + let config = setup.build_test_config("spawn-and-move", Profile::DEV); let build_args = BuildArgs { bindings_output: "generated".to_string(), diff --git a/bin/sozo/src/commands/clean.rs b/bin/sozo/src/commands/clean.rs index 79af666bdd..5bf8ea47a6 100644 --- a/bin/sozo/src/commands/clean.rs +++ b/bin/sozo/src/commands/clean.rs @@ -91,7 +91,7 @@ impl CleanArgs { // which are normally built by the `build.rs` of `dojo-test-utils`. #[cfg(test)] mod tests { - use dojo_test_utils::compiler; + use dojo_test_utils::compiler::CompilerTestSetup; use dojo_world::manifest::DEPLOYMENT_DIR; use dojo_world::metadata::ABIS_DIR; use scarb::compiler::Profile; @@ -100,16 +100,8 @@ mod tests { #[test] fn default_clean_works() { - let source_project = "../../examples/spawn-and-move"; - let dojo_core_path = "../../crates/dojo-core"; - - let config = compiler::copy_tmp_config( - &Utf8PathBuf::from(source_project), - &Utf8PathBuf::from(dojo_core_path), - Profile::DEV, - ); - - println!("path {:?}", config.manifest_path()); + let setup = CompilerTestSetup::from_examples("../../crates/dojo-core", "../../examples/"); + let config = setup.build_test_config("spawn-and-move", Profile::DEV); let temp_project_dir = config.manifest_path().parent().unwrap().to_path_buf(); @@ -180,14 +172,9 @@ mod tests { #[test] fn all_profile_clean_works() { - let source_project = "../../examples/spawn-and-move"; - let dojo_core_path = "../../crates/dojo-core"; + let setup = CompilerTestSetup::from_examples("../../crates/dojo-core", "../../examples/"); - let config = compiler::copy_tmp_config( - &Utf8PathBuf::from(source_project), - &Utf8PathBuf::from(dojo_core_path), - Profile::DEV, - ); + let config = setup.build_test_config("spawn-and-move", Profile::DEV); let temp_project_dir = config.manifest_path().parent().unwrap().to_path_buf(); diff --git a/bin/sozo/src/commands/migrate.rs b/bin/sozo/src/commands/migrate.rs index 746aceb033..6f64938cda 100644 --- a/bin/sozo/src/commands/migrate.rs +++ b/bin/sozo/src/commands/migrate.rs @@ -88,36 +88,42 @@ impl MigrateArgs { })?; match self.command { - MigrateCommand::Plan => config.tokio_handle().block_on(async { - trace!(name, "Planning migration."); - migration::migrate( - &ws, - world_address, - rpc_url, - account, - &name, - true, - TxnConfig::default(), - dojo_metadata.skip_migration, - ) - .await - }), - MigrateCommand::Apply { transaction } => config.tokio_handle().block_on(async { - trace!(name, "Applying migration."); - let txn_config: TxnConfig = transaction.into(); - - migration::migrate( - &ws, - world_address, - rpc_url, - account, - &name, - false, - txn_config, - dojo_metadata.skip_migration, - ) - .await - }), + MigrateCommand::Plan => config + .tokio_handle() + .block_on(async { + trace!(name, "Planning migration."); + migration::migrate( + &ws, + world_address, + rpc_url, + account, + &name, + true, + TxnConfig::default(), + dojo_metadata.skip_migration, + ) + .await + }) + .map(|_| ()), + MigrateCommand::Apply { transaction } => config + .tokio_handle() + .block_on(async { + trace!(name, "Applying migration."); + let txn_config: TxnConfig = transaction.into(); + + migration::migrate( + &ws, + world_address, + rpc_url, + account, + &name, + false, + txn_config, + dojo_metadata.skip_migration, + ) + .await + }) + .map(|_| ()), } } } diff --git a/bin/sozo/tests/register_test.rs b/bin/sozo/tests/register_test.rs index 560ae8f103..ce0f84d83f 100644 --- a/bin/sozo/tests/register_test.rs +++ b/bin/sozo/tests/register_test.rs @@ -1,7 +1,6 @@ mod utils; -use camino::Utf8PathBuf; -use dojo_test_utils::compiler; +use dojo_test_utils::compiler::CompilerTestSetup; use dojo_test_utils::migration::prepare_migration; use dojo_world::metadata::{dojo_metadata_from_workspace, get_default_namespace_from_ws}; use dojo_world::migration::TxnConfig; @@ -15,10 +14,8 @@ use utils::snapbox::get_snapbox; #[tokio::test(flavor = "multi_thread")] async fn reregister_models() { - let source_project_dir = Utf8PathBuf::from("../../examples/spawn-and-move/"); - let dojo_core_path = Utf8PathBuf::from("../../crates/dojo-core"); - - let config = compiler::copy_tmp_config(&source_project_dir, &dojo_core_path, Profile::DEV); + let setup = CompilerTestSetup::from_examples("../../crates/dojo-core", "../../examples/"); + let config = setup.build_test_config("spawn-and-move", Profile::DEV); let ws = ops::read_workspace(config.manifest_path(), &config) .unwrap_or_else(|op| panic!("Error building workspace: {op:?}")); @@ -31,7 +28,7 @@ async fn reregister_models() { let default_namespace = get_default_namespace_from_ws(&ws).unwrap(); let migration = prepare_migration( - source_project_dir.clone(), + config.manifest_path().parent().unwrap().into(), target_path, dojo_metadata.skip_migration, &default_namespace, diff --git a/bin/sozo/tests/test_migrate.rs b/bin/sozo/tests/test_migrate.rs index df39bfc51a..53474c9114 100644 --- a/bin/sozo/tests/test_migrate.rs +++ b/bin/sozo/tests/test_migrate.rs @@ -1,7 +1,6 @@ mod utils; -use camino::Utf8PathBuf; -use dojo_test_utils::compiler; +use dojo_test_utils::compiler::CompilerTestSetup; use katana_runner::KatanaRunner; use scarb::compiler::Profile; use starknet::accounts::Account; @@ -10,10 +9,8 @@ use utils::snapbox::get_snapbox; #[tokio::test(flavor = "multi_thread")] async fn migrate_dry_run() { - let source_project_dir = Utf8PathBuf::from("../../examples/spawn-and-move/"); - let dojo_core_path = Utf8PathBuf::from("../../crates/dojo-core"); - - let config = compiler::copy_tmp_config(&source_project_dir, &dojo_core_path, Profile::DEV); + let setup = CompilerTestSetup::from_examples("../../crates/dojo-core", "../../examples/"); + let config = setup.build_test_config("spawn-and-move", Profile::DEV); let sequencer = KatanaRunner::new().expect("Failed to start runner."); @@ -45,7 +42,7 @@ async fn migrate_dry_run() { assert!(output.contains("Migration Strategy")); assert!(output.contains("# Base Contract")); - assert!(output.contains("# Models (8)")); + assert!(output.contains("# Models (10)")); assert!(output.contains("# World")); assert!(output.contains("# Contracts (4)")); } diff --git a/crates/dojo-bindgen/src/lib.rs b/crates/dojo-bindgen/src/lib.rs index 06b2225ada..07b8fdede1 100644 --- a/crates/dojo-bindgen/src/lib.rs +++ b/crates/dojo-bindgen/src/lib.rs @@ -213,7 +213,7 @@ fn filter_model_tokens(tokens: &TokenizedAbi) -> TokenizedAbi { #[cfg(test)] mod tests { - use dojo_test_utils::compiler; + use dojo_test_utils::compiler::CompilerTestSetup; use dojo_world::metadata::dojo_metadata_from_workspace; use scarb::compiler::Profile; @@ -221,13 +221,8 @@ mod tests { #[test] fn gather_data_ok() { - let manifest_path = Utf8PathBuf::from("src/test_data/spawn-and-move/Scarb.toml"); - - let config = compiler::copy_tmp_config( - &Utf8PathBuf::from("../../examples/spawn-and-move"), - &Utf8PathBuf::from("../dojo-core"), - Profile::DEV, - ); + let setup = CompilerTestSetup::from_examples("../dojo-core", "../../examples/"); + let config = setup.build_test_config("spawn-and-move", Profile::DEV); let ws = scarb::ops::read_workspace(config.manifest_path(), &config).unwrap(); let dojo_metadata = dojo_metadata_from_workspace(&ws).expect( @@ -235,11 +230,15 @@ mod tests { workspaces.", ); - let data = - gather_dojo_data(&manifest_path, "dojo_example", "dev", dojo_metadata.skip_migration) - .unwrap(); - - assert_eq!(data.models.len(), 8); + let data = gather_dojo_data( + &config.manifest_path().to_path_buf(), + "dojo_example", + "dev", + dojo_metadata.skip_migration, + ) + .unwrap(); + + assert_eq!(data.models.len(), 10); assert_eq!(data.world.name, "dojo_example"); diff --git a/crates/dojo-bindgen/src/plugins/typescript_v2/mod.rs b/crates/dojo-bindgen/src/plugins/typescript_v2/mod.rs index a4b8c1076e..07d3ff6272 100644 --- a/crates/dojo-bindgen/src/plugins/typescript_v2/mod.rs +++ b/crates/dojo-bindgen/src/plugins/typescript_v2/mod.rs @@ -627,8 +627,7 @@ mod tests { use std::fs; use std::io::Read; - use camino::Utf8PathBuf; - use dojo_test_utils::compiler; + use dojo_test_utils::compiler::CompilerTestSetup; use dojo_world::metadata::dojo_metadata_from_workspace; use scarb::compiler::Profile; @@ -647,21 +646,21 @@ mod tests { let expected_output_without_header = expected_output.lines().skip(1).collect::>().join("\n"); - let manifest_path = Utf8PathBuf::from("src/test_data/spawn-and-move/Scarb.toml"); - let config = compiler::copy_tmp_config( - &Utf8PathBuf::from("../../examples/spawn-and-move"), - &Utf8PathBuf::from("../dojo-core"), - Profile::DEV, - ); + let setup = CompilerTestSetup::from_examples("../dojo-core", "../../examples/"); + let config = setup.build_test_config("spawn-and-move", Profile::DEV); let ws = scarb::ops::read_workspace(config.manifest_path(), &config).unwrap(); let dojo_metadata = dojo_metadata_from_workspace(&ws).expect( "No current package with dojo metadata found, bindgen is not yet support for \ workspaces.", ); - let data = - gather_dojo_data(&manifest_path, "dojo_examples", "dev", dojo_metadata.skip_migration) - .unwrap(); + let data = gather_dojo_data( + &config.manifest_path().to_path_buf(), + "dojo_examples", + "dev", + dojo_metadata.skip_migration, + ) + .unwrap(); let actual_output = TypeScriptV2Plugin::generate_code_content(&data); let actual_output_without_header = diff --git a/crates/dojo-lang/src/plugin_test_data/introspect b/crates/dojo-lang/src/plugin_test_data/introspect index 3582f86aad..2c59dfb0a8 100644 --- a/crates/dojo-lang/src/plugin_test_data/introspect +++ b/crates/dojo-lang/src/plugin_test_data/introspect @@ -526,52 +526,6 @@ impl Vec2Serde of core::serde::Serde:: { }) } } - -impl Vec2Introspect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::Some(2) - } - - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Struct( - array![ - dojo::database::introspect::FieldLayout { - selector: 512066735765477566404754172672287371265995314501343422459174036873487219331, - layout: dojo::database::introspect::Introspect::::layout() - }, -dojo::database::introspect::FieldLayout { - selector: 1591024729085637502504777720563487898377940395575083379770417352976841400819, - 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: 'Vec2', - attrs: array![].span(), - children: array![ - dojo::database::introspect::Member { - name: 'x', - attrs: array![].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'y', - attrs: array![].span(), - ty: dojo::database::introspect::Introspect::::ty() - } - - ].span() - } - ) - } -} impl PlainEnumSerde of core::serde::Serde:: { fn serialize(self: @PlainEnum, ref output: core::array::Array) { match self { @@ -592,43 +546,6 @@ impl PlainEnumSerde of core::serde::Serde:: { } impl PlainEnumCopy of core::traits::Copy::; impl PlainEnumDrop of core::traits::Drop::; - -impl PlainEnumIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::Some(1) - } - - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Enum( - array![ - dojo::database::introspect::FieldLayout { - selector: 0, - layout: dojo::database::introspect::Layout::Fixed(array![].span()) - }, -dojo::database::introspect::FieldLayout { - selector: 1, - layout: dojo::database::introspect::Layout::Fixed(array![].span()) - } - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Enum( - dojo::database::introspect::Enum { - name: 'PlainEnum', - attrs: array![].span(), - children: array![ - ('Left', dojo::database::introspect::Ty::Tuple(array![].span())), -('Right', dojo::database::introspect::Ty::Tuple(array![].span())) - - ].span() - } - ) - } -} impl EnumWithPrimitiveSerde of core::serde::Serde:: { fn serialize(self: @EnumWithPrimitive, ref output: core::array::Array) { match self { @@ -649,43 +566,6 @@ impl EnumWithPrimitiveSerde of core::serde::Serde:: { } impl EnumWithPrimitiveCopy of core::traits::Copy::; impl EnumWithPrimitiveDrop of core::traits::Drop::; - -impl EnumWithPrimitiveIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::Some(2) - } - - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Enum( - array![ - dojo::database::introspect::FieldLayout { - selector: 0, - layout: dojo::database::introspect::Introspect::::layout() - }, -dojo::database::introspect::FieldLayout { - selector: 1, - layout: dojo::database::introspect::Introspect::::layout() - } - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Enum( - dojo::database::introspect::Enum { - name: 'EnumWithPrimitive', - attrs: array![].span(), - children: array![ - ('Left', dojo::database::introspect::Introspect::::ty()), -('Right', dojo::database::introspect::Introspect::::ty()) - - ].span() - } - ) - } -} impl EnumWithStructSerde of core::serde::Serde:: { fn serialize(self: @EnumWithStruct, ref output: core::array::Array) { match self { @@ -706,52 +586,6 @@ impl EnumWithStructSerde of core::serde::Serde:: { } impl EnumWithStructCopy of core::traits::Copy::; impl EnumWithStructDrop of core::traits::Drop::; - -impl EnumWithStructIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - let sizes : Array> = array![ - dojo::database::introspect::Introspect::::size(), -Option::Some(1) - ]; - - if dojo::database::utils::any_none(@sizes) { - return Option::None; - } - Option::Some(dojo::database::utils::sum(sizes)) - - } - - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Enum( - array![ - dojo::database::introspect::FieldLayout { - selector: 0, - layout: dojo::database::introspect::Introspect::::layout() - }, -dojo::database::introspect::FieldLayout { - selector: 1, - layout: dojo::database::introspect::Introspect::::layout() - } - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Enum( - dojo::database::introspect::Enum { - name: 'EnumWithStruct', - attrs: array![].span(), - children: array![ - ('Left', dojo::database::introspect::Introspect::::ty()), -('Right', dojo::database::introspect::Introspect::::ty()) - - ].span() - } - ) - } -} impl EnumWithSimpleArraySerde of core::serde::Serde:: { fn serialize(self: @EnumWithSimpleArray, ref output: core::array::Array) { match self { @@ -772,51 +606,6 @@ impl EnumWithSimpleArraySerde of core::serde::Serde:: { } impl EnumWithSimpleArrayCopy of core::traits::Copy::; impl EnumWithSimpleArrayDrop of core::traits::Drop::; - -impl EnumWithSimpleArrayIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::None - } - - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Enum( - array![ - dojo::database::introspect::FieldLayout { - selector: 0, - layout: dojo::database::introspect::Introspect::>::layout() - }, -dojo::database::introspect::FieldLayout { - selector: 1, - layout: dojo::database::introspect::Introspect::>::layout() - } - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Enum( - dojo::database::introspect::Enum { - name: 'EnumWithSimpleArray', - attrs: array![].span(), - children: array![ - ('Left', dojo::database::introspect::Ty::Array( - array![ - dojo::database::introspect::Introspect::::ty() - ].span() - )), -('Right', dojo::database::introspect::Ty::Array( - array![ - dojo::database::introspect::Introspect::::ty() - ].span() - )) - - ].span() - } - ) - } -} impl EnumWithByteArraySerde of core::serde::Serde:: { fn serialize(self: @EnumWithByteArray, ref output: core::array::Array) { match self { @@ -837,43 +626,6 @@ impl EnumWithByteArraySerde of core::serde::Serde:: { } impl EnumWithByteArrayCopy of core::traits::Copy::; impl EnumWithByteArrayDrop of core::traits::Drop::; - -impl EnumWithByteArrayIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::None - } - - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Enum( - array![ - dojo::database::introspect::FieldLayout { - selector: 0, - layout: dojo::database::introspect::Introspect::::layout() - }, -dojo::database::introspect::FieldLayout { - selector: 1, - layout: dojo::database::introspect::Introspect::::layout() - } - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Enum( - dojo::database::introspect::Enum { - name: 'EnumWithByteArray', - attrs: array![].span(), - children: array![ - ('Left', dojo::database::introspect::Ty::ByteArray), -('Right', dojo::database::introspect::Ty::ByteArray) - - ].span() - } - ) - } -} impl EnumWithSimpleTupleSerde of core::serde::Serde:: { fn serialize(self: @EnumWithSimpleTuple, ref output: core::array::Array) { match self { @@ -894,63 +646,6 @@ impl EnumWithSimpleTupleSerde of core::serde::Serde:: { } impl EnumWithSimpleTupleCopy of core::traits::Copy::; impl EnumWithSimpleTupleDrop of core::traits::Drop::; - -impl EnumWithSimpleTupleIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::Some(4) - } - - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Enum( - array![ - dojo::database::introspect::FieldLayout { - selector: 0, - layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Introspect::::layout(), -dojo::database::introspect::Introspect::::layout() - ].span() - ) - }, -dojo::database::introspect::FieldLayout { - selector: 1, - layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Introspect::::layout(), -dojo::database::introspect::Introspect::::layout() - ].span() - ) - } - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Enum( - dojo::database::introspect::Enum { - name: 'EnumWithSimpleTuple', - attrs: array![].span(), - children: array![ - ('Left', dojo::database::introspect::Ty::Tuple( - array![ - dojo::database::introspect::Introspect::::ty(), -dojo::database::introspect::Introspect::::ty() - ].span() - )), -('Right', dojo::database::introspect::Ty::Tuple( - array![ - dojo::database::introspect::Introspect::::ty(), -dojo::database::introspect::Introspect::::ty() - ].span() - )) - - ].span() - } - ) - } -} impl EnumWithComplexTupleSerde of core::serde::Serde:: { fn serialize(self: @EnumWithComplexTuple, ref output: core::array::Array) { match self { @@ -971,72 +666,6 @@ impl EnumWithComplexTupleSerde of core::serde::Serde:: { } impl EnumWithComplexTupleCopy of core::traits::Copy::; impl EnumWithComplexTupleDrop of core::traits::Drop::; - -impl EnumWithComplexTupleIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - let sizes : Array> = array![ - dojo::database::introspect::Introspect::::size(), -Option::Some(2) - ]; - - if dojo::database::utils::any_none(@sizes) { - return Option::None; - } - Option::Some(dojo::database::utils::sum(sizes)) - - } - - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Enum( - array![ - dojo::database::introspect::FieldLayout { - selector: 0, - layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Introspect::::layout(), -dojo::database::introspect::Introspect::::layout() - ].span() - ) - }, -dojo::database::introspect::FieldLayout { - selector: 1, - layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Introspect::::layout(), -dojo::database::introspect::Introspect::::layout() - ].span() - ) - } - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Enum( - dojo::database::introspect::Enum { - name: 'EnumWithComplexTuple', - attrs: array![].span(), - children: array![ - ('Left', dojo::database::introspect::Ty::Tuple( - array![ - dojo::database::introspect::Introspect::::ty(), -dojo::database::introspect::Introspect::::ty() - ].span() - )), -('Right', dojo::database::introspect::Ty::Tuple( - array![ - dojo::database::introspect::Introspect::::ty(), -dojo::database::introspect::Introspect::::ty() - ].span() - )) - - ].span() - } - ) - } -} impl EnumWithPrimitiveSerde of core::serde::Serde:: { fn serialize(self: @EnumWithPrimitive, ref output: core::array::Array) { match self { @@ -1057,43 +686,6 @@ impl EnumWithPrimitiveSerde of core::serde::Serde:: { } impl EnumWithPrimitiveCopy of core::traits::Copy::; impl EnumWithPrimitiveDrop of core::traits::Drop::; - -impl EnumWithPrimitiveIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::Some(2) - } - - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Enum( - array![ - dojo::database::introspect::FieldLayout { - selector: 0, - layout: dojo::database::introspect::Introspect::::layout() - }, -dojo::database::introspect::FieldLayout { - selector: 1, - layout: dojo::database::introspect::Introspect::::layout() - } - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Enum( - dojo::database::introspect::Enum { - name: 'EnumWithPrimitive', - attrs: array![].span(), - children: array![ - ('Left', dojo::database::introspect::Introspect::::ty()), -('Right', dojo::database::introspect::Introspect::::ty()) - - ].span() - } - ) - } -} impl EnumCustomSerde of core::serde::Serde:: { fn serialize(self: @EnumCustom, ref output: core::array::Array) { match self { @@ -1114,52 +706,6 @@ impl EnumCustomSerde of core::serde::Serde:: { } impl EnumCustomCopy of core::traits::Copy::; impl EnumCustomDrop of core::traits::Drop::; - -impl EnumCustomIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - let sizes : Array> = array![ - dojo::database::introspect::Introspect::::size(), -Option::Some(1) - ]; - - if dojo::database::utils::any_none(@sizes) { - return Option::None; - } - Option::Some(dojo::database::utils::sum(sizes)) - - } - - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Enum( - array![ - dojo::database::introspect::FieldLayout { - selector: 0, - layout: dojo::database::introspect::Introspect::::layout() - }, -dojo::database::introspect::FieldLayout { - selector: 1, - layout: dojo::database::introspect::Introspect::::layout() - } - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Enum( - dojo::database::introspect::Enum { - name: 'EnumCustom', - attrs: array![].span(), - children: array![ - ('Left', dojo::database::introspect::Introspect::::ty()), -('Right', dojo::database::introspect::Introspect::::ty()) - - ].span() - } - ) - } -} impl EnumTupleMixSerde of core::serde::Serde:: { fn serialize(self: @EnumTupleMix, ref output: core::array::Array) { match self { @@ -1180,77 +726,6 @@ impl EnumTupleMixSerde of core::serde::Serde:: { } impl EnumTupleMixCopy of core::traits::Copy::; impl EnumTupleMixDrop of core::traits::Drop::; - -impl EnumTupleMixIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - let sizes : Array> = array![ - dojo::database::introspect::Introspect::::size(), -dojo::database::introspect::Introspect::::size(), -Option::Some(2) - ]; - - if dojo::database::utils::any_none(@sizes) { - return Option::None; - } - Option::Some(dojo::database::utils::sum(sizes)) - - } - - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Enum( - array![ - dojo::database::introspect::FieldLayout { - selector: 0, - layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Introspect::::layout(), -dojo::database::introspect::Introspect::::layout(), -dojo::database::introspect::Introspect::::layout() - ].span() - ) - }, -dojo::database::introspect::FieldLayout { - selector: 1, - layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Introspect::::layout(), -dojo::database::introspect::Introspect::::layout(), -dojo::database::introspect::Introspect::::layout() - ].span() - ) - } - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Enum( - dojo::database::introspect::Enum { - name: 'EnumTupleMix', - attrs: array![].span(), - children: array![ - ('Left', dojo::database::introspect::Ty::Tuple( - array![ - dojo::database::introspect::Introspect::::ty(), -dojo::database::introspect::Introspect::::ty(), -dojo::database::introspect::Introspect::::ty() - ].span() - )), -('Right', dojo::database::introspect::Ty::Tuple( - array![ - dojo::database::introspect::Introspect::::ty(), -dojo::database::introspect::Introspect::::ty(), -dojo::database::introspect::Introspect::::ty() - ].span() - )) - - ].span() - } - ) - } -} impl EnumWithDifferentVariantDataSerde of core::serde::Serde:: { fn serialize(self: @EnumWithDifferentVariantData, ref output: core::array::Array) { match self { @@ -1273,1670 +748,608 @@ impl EnumWithDifferentVariantDataSerde of core::serde::Serde::; impl EnumWithDifferentVariantDataDrop of core::traits::Drop::; - -impl EnumWithDifferentVariantDataIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::None - } - - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Enum( - array![ - dojo::database::introspect::FieldLayout { - selector: 0, - layout: dojo::database::introspect::Layout::Fixed(array![].span()) - }, -dojo::database::introspect::FieldLayout { - selector: 1, - layout: dojo::database::introspect::Introspect::::layout() - }, -dojo::database::introspect::FieldLayout { - selector: 2, - layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Introspect::::layout(), -dojo::database::introspect::Introspect::::layout() - ].span() - ) - } - ].span() - ) +impl StructWithPrimitivesCopy of core::traits::Copy::; +impl StructWithPrimitivesDrop of core::traits::Drop::; +impl StructWithStructCopy of core::traits::Copy::; +impl StructWithStructDrop of core::traits::Drop::; +impl StructWithSimpleArrayCopy of core::traits::Copy::; +impl StructWithSimpleArrayDrop of core::traits::Drop::; +impl StructWithByteArrayCopy of core::traits::Copy::; +impl StructWithByteArrayDrop of core::traits::Drop::; +impl StructWithComplexArrayCopy of core::traits::Copy::; +impl StructWithComplexArrayDrop of core::traits::Drop::; +impl StructWithSimpleTupleCopy of core::traits::Copy::; +impl StructWithSimpleTupleDrop of core::traits::Drop::; +impl StructWithComplexTupleCopy of core::traits::Copy::; +impl StructWithComplexTupleDrop of core::traits::Drop::; +impl StructWithNestedArraysCopy of core::traits::Copy::; +impl StructWithNestedArraysDrop of core::traits::Drop::; +impl StructWithNestedTuplesCopy of core::traits::Copy::; +impl StructWithNestedTuplesDrop of core::traits::Drop::; +impl StructWithNestedTuplesAndByteArrayCopy of core::traits::Copy::; +impl StructWithNestedTuplesAndByteArrayDrop of core::traits::Drop::; +impl StructWithNestedEverythingCopy of core::traits::Copy::; +impl StructWithNestedEverythingDrop of core::traits::Drop::; +impl GenericStructCopy> of core::traits::Copy::>; +impl GenericStructDrop> of core::traits::Drop::>; +impl GenericStructSerde, +core::traits::Destruct> of core::serde::Serde::> { + fn serialize(self: @GenericStruct, ref output: core::array::Array) { + core::serde::Serde::serialize(self.t, ref output) } - - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Enum( - dojo::database::introspect::Enum { - name: 'EnumWithDifferentVariantData', - attrs: array![].span(), - children: array![ - ('One', dojo::database::introspect::Ty::Tuple(array![].span())), -('Two', dojo::database::introspect::Introspect::::ty()), -('Three', dojo::database::introspect::Ty::Tuple( - array![ - dojo::database::introspect::Introspect::::ty(), -dojo::database::introspect::Introspect::::ty() - ].span() - )) - - ].span() - } - ) + fn deserialize(ref serialized: core::array::Span) -> core::option::Option> { + core::option::Option::Some(GenericStruct { + t: core::serde::Serde::deserialize(ref serialized)?, + }) } } -impl StructWithPrimitivesCopy of core::traits::Copy::; -impl StructWithPrimitivesDrop of core::traits::Drop::; - -impl StructWithPrimitivesIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::Some(2) +impl StructWithBadOptionCopy of core::traits::Copy::; +impl StructWithBadOptionDrop of core::traits::Drop::; +impl StructWithBadOptionSerde of core::serde::Serde:: { + fn serialize(self: @StructWithBadOption, ref output: core::array::Array) { + core::serde::Serde::serialize(self.x, ref output) } - - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Struct( - array![ - dojo::database::introspect::FieldLayout { - selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, - layout: dojo::database::introspect::Introspect::::layout() - }, -dojo::database::introspect::FieldLayout { - selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, - layout: dojo::database::introspect::Introspect::::layout() - } - ].span() - ) + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(StructWithBadOption { + x: core::serde::Serde::deserialize(ref serialized)?, + }) } - - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Struct( - dojo::database::introspect::Struct { - name: 'StructWithPrimitives', - attrs: array![].span(), - children: array![ - dojo::database::introspect::Member { - name: 'player', - attrs: array!['key'].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'before', - attrs: array![].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'after', - attrs: array![].span(), - ty: dojo::database::introspect::Introspect::::ty() +} +impl EnumWithBadOptionCopy of core::traits::Copy::; +impl EnumWithBadOptionDrop of core::traits::Drop::; +impl EnumWithBadOptionSerde of core::serde::Serde:: { + fn serialize(self: @EnumWithBadOption, ref output: core::array::Array) { + match self { + EnumWithBadOption::first(x) => { core::serde::Serde::serialize(@0, ref output); core::serde::Serde::serialize(x, ref output); }, } - - ].span() + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + let idx: felt252 = core::serde::Serde::deserialize(ref serialized)?; + core::option::Option::Some( + match idx { + 0 => EnumWithBadOption::first(core::serde::Serde::deserialize(ref serialized)?), + _ => { return core::option::Option::None; } } ) } } -impl StructWithStructCopy of core::traits::Copy::; -impl StructWithStructDrop of core::traits::Drop::; -impl StructWithStructIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - let sizes : Array> = array![ - dojo::database::introspect::Introspect::::size(), -Option::Some(1) - ]; - - if dojo::database::utils::any_none(@sizes) { - return Option::None; - } - Option::Some(dojo::database::utils::sum(sizes)) - - } +//! > expected_diagnostics +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:1:1 +use core::serde::Serde; +^*********************^ - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Struct( - array![ - dojo::database::introspect::FieldLayout { - selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, - layout: dojo::database::introspect::Introspect::::layout() - }, -dojo::database::introspect::FieldLayout { - selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, - layout: dojo::database::introspect::Introspect::::layout() - } - ].span() - ) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:3:1 +#[derive(Copy, Drop, Serde, Introspect)] +^**************************************^ - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Struct( - dojo::database::introspect::Struct { - name: 'StructWithStruct', - attrs: array![].span(), - children: array![ - dojo::database::introspect::Member { - name: 'player', - attrs: array!['key'].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'before', - attrs: array![].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'after', - attrs: array![].span(), - ty: dojo::database::introspect::Introspect::::ty() - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:9:1 +#[derive(Serde, Copy, Drop, Introspect)] +^**************************************^ - ].span() - } - ) - } -} -impl StructWithSimpleArrayCopy of core::traits::Copy::; -impl StructWithSimpleArrayDrop of core::traits::Drop::; +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:15:1 +#[derive(Serde, Copy, Drop, Introspect)] +^**************************************^ -impl StructWithSimpleArrayIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::None - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:21:1 +#[derive(Serde, Copy, Drop, Introspect)] +^**************************************^ - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Struct( - array![ - dojo::database::introspect::FieldLayout { - selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, - layout: dojo::database::introspect::Introspect::::layout() - }, -dojo::database::introspect::FieldLayout { - selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, - layout: dojo::database::introspect::Introspect::>::layout() - } - ].span() - ) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:27:1 +#[derive(Serde, Copy, Drop, Introspect)] +^**************************************^ - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Struct( - dojo::database::introspect::Struct { - name: 'StructWithSimpleArray', - attrs: array![].span(), - children: array![ - dojo::database::introspect::Member { - name: 'player', - attrs: array!['key'].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'before', - attrs: array![].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'after', - attrs: array![].span(), - ty: dojo::database::introspect::Ty::Array( - array![ - dojo::database::introspect::Introspect::::ty() - ].span() - ) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:33:1 +#[derive(Serde, Copy, Drop, Introspect)] +^**************************************^ - ].span() - } - ) - } -} -impl StructWithByteArrayCopy of core::traits::Copy::; -impl StructWithByteArrayDrop of core::traits::Drop::; +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:39:1 +#[derive(Serde, Copy, Drop, Introspect)] +^**************************************^ -impl StructWithByteArrayIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::None - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:45:1 +#[derive(Serde, Copy, Drop, Introspect)] +^**************************************^ - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Struct( - array![ - dojo::database::introspect::FieldLayout { - selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, - layout: dojo::database::introspect::Introspect::::layout() - }, -dojo::database::introspect::FieldLayout { - selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, - layout: dojo::database::introspect::Introspect::::layout() - } - ].span() - ) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:51:1 +#[derive(Serde, Copy, Drop, Introspect)] +^**************************************^ - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Struct( - dojo::database::introspect::Struct { - name: 'StructWithByteArray', - attrs: array![].span(), - children: array![ - dojo::database::introspect::Member { - name: 'player', - attrs: array!['key'].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'before', - attrs: array![].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'after', - attrs: array![].span(), - ty: dojo::database::introspect::Ty::ByteArray - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:57:1 +#[derive(Serde, Copy, Drop, Introspect)] +^**************************************^ - ].span() - } - ) - } -} -impl StructWithComplexArrayCopy of core::traits::Copy::; -impl StructWithComplexArrayDrop of core::traits::Drop::; +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:63:1 +#[derive(Serde, Copy, Drop, Introspect)] +^**************************************^ -impl StructWithComplexArrayIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::None - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:69:1 +#[derive(Serde, Copy, Drop, Introspect)] +^**************************************^ - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Struct( - array![ - dojo::database::introspect::FieldLayout { - selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, - layout: dojo::database::introspect::Introspect::::layout() - }, -dojo::database::introspect::FieldLayout { - selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, - layout: dojo::database::introspect::Introspect::>::layout() - } - ].span() - ) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:76:1 +#[derive(Copy, Drop, Introspect)] +^*******************************^ - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Struct( - dojo::database::introspect::Struct { - name: 'StructWithComplexArray', - attrs: array![].span(), - children: array![ - dojo::database::introspect::Member { - name: 'player', - attrs: array!['key'].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'before', - attrs: array![].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'after', - attrs: array![].span(), - ty: dojo::database::introspect::Ty::Array( - array![ - dojo::database::introspect::Introspect::::ty() - ].span() - ) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:84:1 +#[derive(Copy, Drop, Introspect)] +^*******************************^ - ].span() - } - ) - } -} -impl StructWithSimpleTupleCopy of core::traits::Copy::; -impl StructWithSimpleTupleDrop of core::traits::Drop::; +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:92:1 +#[derive(Copy, Drop, Introspect)] +^*******************************^ -impl StructWithSimpleTupleIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::Some(4) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:100:1 +#[derive(Copy, Drop, Introspect)] +^*******************************^ - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Struct( - array![ - dojo::database::introspect::FieldLayout { - selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, - layout: dojo::database::introspect::Introspect::::layout() - }, -dojo::database::introspect::FieldLayout { - selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, - layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Introspect::::layout(), -dojo::database::introspect::Introspect::::layout() - ].span() - ) - } - ].span() - ) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:108:1 +#[derive(Copy, Drop, Introspect)] +^*******************************^ - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Struct( - dojo::database::introspect::Struct { - name: 'StructWithSimpleTuple', - attrs: array![].span(), - children: array![ - dojo::database::introspect::Member { - name: 'player', - attrs: array!['key'].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'before', - attrs: array![].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'after', - attrs: array![].span(), - ty: dojo::database::introspect::Ty::Tuple( - array![ - dojo::database::introspect::Introspect::::ty(), -dojo::database::introspect::Introspect::::ty() - ].span() - ) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:116:1 +#[derive(Copy, Drop, Introspect)] +^*******************************^ - ].span() - } - ) - } -} -impl StructWithComplexTupleCopy of core::traits::Copy::; -impl StructWithComplexTupleDrop of core::traits::Drop::; +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:124:1 +#[derive(Copy, Drop, Introspect)] +^*******************************^ -impl StructWithComplexTupleIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - let sizes : Array> = array![ - dojo::database::introspect::Introspect::::size(), -dojo::database::introspect::Introspect::::size(), -Option::Some(2) - ]; - - if dojo::database::utils::any_none(@sizes) { - return Option::None; - } - Option::Some(dojo::database::utils::sum(sizes)) - - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:132:1 +#[derive(Copy, Drop, Introspect)] +^*******************************^ - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Struct( - array![ - dojo::database::introspect::FieldLayout { - selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, - layout: dojo::database::introspect::Introspect::::layout() - }, -dojo::database::introspect::FieldLayout { - selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, - layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Introspect::::layout(), -dojo::database::introspect::Introspect::::layout(), -dojo::database::introspect::Introspect::::layout() - ].span() - ) - } - ].span() - ) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:140:1 +#[derive(Copy, Drop, Introspect)] +^*******************************^ - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Struct( - dojo::database::introspect::Struct { - name: 'StructWithComplexTuple', - attrs: array![].span(), - children: array![ - dojo::database::introspect::Member { - name: 'player', - attrs: array!['key'].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'before', - attrs: array![].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'after', - attrs: array![].span(), - ty: dojo::database::introspect::Ty::Tuple( - array![ - dojo::database::introspect::Introspect::::ty(), -dojo::database::introspect::Introspect::::ty(), -dojo::database::introspect::Introspect::::ty() - ].span() - ) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:148:1 +#[derive(Copy, Drop, Introspect)] +^*******************************^ - ].span() - } - ) - } -} -impl StructWithNestedArraysCopy of core::traits::Copy::; -impl StructWithNestedArraysDrop of core::traits::Drop::; +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:156:1 +#[derive(Copy, Drop, Introspect)] +^*******************************^ -impl StructWithNestedArraysIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::None - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:164:1 +#[derive(Copy, Drop, Serde, Introspect)] +^**************************************^ - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Struct( - array![ - dojo::database::introspect::FieldLayout { - selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, - layout: dojo::database::introspect::Introspect::::layout() - }, -dojo::database::introspect::FieldLayout { - selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, - layout: dojo::database::introspect::Layout::Array( - array![ - dojo::database::introspect::Layout::Array( - array![ - dojo::database::introspect::Introspect::>::layout() - ].span() - ) - ].span() - ) - } - ].span() - ) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:169:1 +#[derive(Copy, Drop, Serde, Introspect)] +^**************************************^ - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Struct( - dojo::database::introspect::Struct { - name: 'StructWithNestedArrays', - attrs: array![].span(), - children: array![ - dojo::database::introspect::Member { - name: 'player', - attrs: array!['key'].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'before', - attrs: array![].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'after', - attrs: array![].span(), - ty: dojo::database::introspect::Ty::Array( - array![ - dojo::database::introspect::Ty::Array( - array![ - dojo::database::introspect::Ty::Array( - array![ - dojo::database::introspect::Introspect::::ty() - ].span() - ) - ].span() - ) - ].span() - ) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:174:1 +#[derive(Copy, Drop, Serde, Introspect)] +^**************************************^ - ].span() - } - ) - } -} -impl StructWithNestedTuplesCopy of core::traits::Copy::; -impl StructWithNestedTuplesDrop of core::traits::Drop::; +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:179:1 +#[derive(Introspect, IntrospectPacked)] +^*************************************^ -impl StructWithNestedTuplesIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - let sizes : Array> = array![ - dojo::database::introspect::Introspect::::size(), -dojo::database::introspect::Introspect::::size(), -Option::Some(3) - ]; - - if dojo::database::utils::any_none(@sizes) { - return Option::None; - } - Option::Some(dojo::database::utils::sum(sizes)) - - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:182:1 +#[derive(Introspect, IntrospectPacked)] +^*************************************^ - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Struct( - array![ - dojo::database::introspect::FieldLayout { - selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, - layout: dojo::database::introspect::Introspect::::layout() - }, -dojo::database::introspect::FieldLayout { - selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, - layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Introspect::::layout(), -dojo::database::introspect::Introspect::::layout() - ].span() - ), -dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Introspect::::layout(), -dojo::database::introspect::Introspect::::layout() - ].span() - ) - ].span() - ) - } - ].span() - ) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:185:1 +#[derive(Introspect)] +^*******************^ - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Struct( - dojo::database::introspect::Struct { - name: 'StructWithNestedTuples', - attrs: array![].span(), - children: array![ - dojo::database::introspect::Member { - name: 'player', - attrs: array!['key'].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'before', - attrs: array![].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'after', - attrs: array![].span(), - ty: dojo::database::introspect::Ty::Tuple( - array![ - dojo::database::introspect::Ty::Tuple( - array![ - dojo::database::introspect::Introspect::::ty(), -dojo::database::introspect::Introspect::::ty() - ].span() - ), -dojo::database::introspect::Ty::Tuple( - array![ - dojo::database::introspect::Introspect::::ty(), -dojo::database::introspect::Introspect::::ty() - ].span() - ) - ].span() - ) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:189:1 +#[derive(Introspect)] +^*******************^ - ].span() - } - ) - } -} -impl StructWithNestedTuplesAndByteArrayCopy of core::traits::Copy::; -impl StructWithNestedTuplesAndByteArrayDrop of core::traits::Drop::; +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:193:1 +#[derive(IntrospectPacked)] +^*************************^ -impl StructWithNestedTuplesAndByteArrayIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::None - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:198:1 +#[derive(IntrospectPacked)] +^*************************^ - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Struct( - array![ - dojo::database::introspect::FieldLayout { - selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, - layout: dojo::database::introspect::Introspect::::layout() - }, -dojo::database::introspect::FieldLayout { - selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, - layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Introspect::::layout(), -dojo::database::introspect::Introspect::::layout() - ].span() - ), -dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Introspect::::layout(), -dojo::database::introspect::Introspect::::layout() - ].span() - ) - ].span() - ) - } - ].span() - ) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:204:1 +#[derive(IntrospectPacked)] +^*************************^ - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Struct( - dojo::database::introspect::Struct { - name: 'StructWithNestedTuplesAndByteArray', - attrs: array![].span(), - children: array![ - dojo::database::introspect::Member { - name: 'player', - attrs: array!['key'].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'before', - attrs: array![].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'after', - attrs: array![].span(), - ty: dojo::database::introspect::Ty::Tuple( - array![ - dojo::database::introspect::Ty::Tuple( - array![ - dojo::database::introspect::Introspect::::ty(), -dojo::database::introspect::Introspect::::ty() - ].span() - ), -dojo::database::introspect::Ty::Tuple( - array![ - dojo::database::introspect::Introspect::::ty(), -dojo::database::introspect::Ty::ByteArray - ].span() - ) - ].span() - ) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:210:1 +#[derive(IntrospectPacked)] +^*************************^ - ].span() - } - ) - } -} -impl StructWithNestedEverythingCopy of core::traits::Copy::; -impl StructWithNestedEverythingDrop of core::traits::Drop::; +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:216:1 +#[derive(IntrospectPacked)] +^*************************^ -impl StructWithNestedEverythingIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::None - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:222:1 +#[derive(IntrospectPacked)] +^*************************^ - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Struct( - array![ - dojo::database::introspect::FieldLayout { - selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, - layout: dojo::database::introspect::Introspect::::layout() - }, -dojo::database::introspect::FieldLayout { - selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, - layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Introspect::::layout(), -dojo::database::introspect::Introspect::::layout() - ].span() - ), -dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Introspect::::layout(), -dojo::database::introspect::Introspect::::layout() - ].span() - ), -dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Layout::Array( - array![ - dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Introspect::::layout(), -dojo::database::introspect::Introspect::::layout() - ].span() - ) - ].span() - ), -dojo::database::introspect::Introspect::::layout() - ].span() - ), -dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Introspect::::layout() - ].span() - ) - ].span() - ) - } - ].span() - ) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:229:1 +#[derive(IntrospectPacked)] +^*************************^ - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Struct( - dojo::database::introspect::Struct { - name: 'StructWithNestedEverything', - attrs: array![].span(), - children: array![ - dojo::database::introspect::Member { - name: 'player', - attrs: array!['key'].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'before', - attrs: array![].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'after', - attrs: array![].span(), - ty: dojo::database::introspect::Ty::Tuple( - array![ - dojo::database::introspect::Ty::Tuple( - array![ - dojo::database::introspect::Introspect::::ty(), -dojo::database::introspect::Introspect::::ty() - ].span() - ), -dojo::database::introspect::Ty::Tuple( - array![ - dojo::database::introspect::Introspect::::ty(), -dojo::database::introspect::Introspect::::ty() - ].span() - ), -dojo::database::introspect::Ty::Tuple( - array![ - dojo::database::introspect::Ty::Array( - array![ - dojo::database::introspect::Ty::Tuple( - array![ - dojo::database::introspect::Introspect::::ty(), -dojo::database::introspect::Introspect::::ty() - ].span() - ) - ].span() - ), -dojo::database::introspect::Introspect::::ty() - ].span() - ), -dojo::database::introspect::Ty::Tuple( - array![ - dojo::database::introspect::Introspect::::ty() - ].span() - ) - ].span() - ) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:236:1 +#[derive(IntrospectPacked)] +^*************************^ - ].span() - } - ) - } -} -impl GenericStructCopy> of core::traits::Copy::>; -impl GenericStructDrop> of core::traits::Drop::>; -impl GenericStructSerde, +core::traits::Destruct> of core::serde::Serde::> { - fn serialize(self: @GenericStruct, ref output: core::array::Array) { - core::serde::Serde::serialize(self.t, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option> { - core::option::Option::Some(GenericStruct { - t: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:243:1 +#[derive(IntrospectPacked)] +^*************************^ -impl GenericStructIntrospect> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - dojo::database::introspect::Introspect::::size() - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:249:1 +#[derive(IntrospectPacked)] +^*************************^ - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Struct( - array![ - dojo::database::introspect::FieldLayout { - selector: 1246920879054256875300693562709339669009726288543267794550465531256469553289, - layout: dojo::database::introspect::Introspect::::layout() - } - ].span() - ) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:2:1 - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Struct( - dojo::database::introspect::Struct { - name: 'GenericStruct', - attrs: array![].span(), - children: array![ - dojo::database::introspect::Member { - name: 't', - attrs: array![].span(), - ty: dojo::database::introspect::Introspect::::ty() - } +^ - ].span() - } - ) - } -} -impl StructWithBadOptionCopy of core::traits::Copy::; -impl StructWithBadOptionDrop of core::traits::Drop::; -impl StructWithBadOptionSerde of core::serde::Serde:: { - fn serialize(self: @StructWithBadOption, ref output: core::array::Array) { - core::serde::Serde::serialize(self.x, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(StructWithBadOption { - x: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:2:1 -impl StructWithBadOptionIntrospect<> 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: 512066735765477566404754172672287371265995314501343422459174036873487219331, - layout: dojo::database::introspect::Introspect:: ->::layout() - } - ].span() - ) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:2:1 - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Struct( - dojo::database::introspect::Struct { - name: 'StructWithBadOption', - attrs: array![].span(), - children: array![ - dojo::database::introspect::Member { - name: 'x', - attrs: array![].span(), - ty: dojo::database::introspect::Introspect::>::ty() - } +^ - ].span() - } - ) - } -} -impl EnumWithBadOptionCopy of core::traits::Copy::; -impl EnumWithBadOptionDrop of core::traits::Drop::; -impl EnumWithBadOptionSerde of core::serde::Serde:: { - fn serialize(self: @EnumWithBadOption, ref output: core::array::Array) { - match self { - EnumWithBadOption::first(x) => { core::serde::Serde::serialize(@0, ref output); core::serde::Serde::serialize(x, ref output); }, - } - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - let idx: felt252 = core::serde::Serde::deserialize(ref serialized)?; - core::option::Option::Some( - match idx { - 0 => EnumWithBadOption::first(core::serde::Serde::deserialize(ref serialized)?), - _ => { return core::option::Option::None; } - } - ) - } -} +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:8:1 -impl EnumWithBadOptionIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - let sizes : Array> = array![ - dojo::database::introspect::Introspect::>::size(), -Option::Some(1) - ]; +^ - if dojo::database::utils::any_none(@sizes) { - return Option::None; - } - Option::Some(dojo::database::utils::sum(sizes)) - - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:8:1 - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Enum( - array![ - dojo::database::introspect::FieldLayout { - selector: 0, - layout: dojo::database::introspect::Introspect::>::layout() - } - ].span() - ) - } +^ - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Enum( - dojo::database::introspect::Enum { - name: 'EnumWithBadOption', - attrs: array![].span(), - children: array![ - ('first', dojo::database::introspect::Introspect::>::ty()) +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:8:1 - ].span() - } - ) - } -} +^ -impl EnumIncompatibleAttrsIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::None - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:14:1 - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Enum( - array![ - - ].span() - ) - } +^ - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Enum( - dojo::database::introspect::Enum { - name: 'EnumIncompatibleAttrs', - attrs: array![].span(), - children: array![ - +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:14:1 - ].span() - } - ) - } -} - -impl EnumIncompatibleAttrsIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::None - } +^ - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Fixed( - array![ - 8 - ].span() - ) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:14:1 - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Enum( - dojo::database::introspect::Enum { - name: 'EnumIncompatibleAttrs', - attrs: array![].span(), - children: array![ - +^ - ].span() - } - ) - } -} +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:20:1 -impl StructIncompatibleAttrsIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::None - } +^ - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Struct( - array![ - - ].span() - ) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:20:1 - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Struct( - dojo::database::introspect::Struct { - name: 'StructIncompatibleAttrs', - attrs: array![].span(), - children: array![ - +^ - ].span() - } - ) - } -} - -impl StructIncompatibleAttrsIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::None - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:20:1 - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Fixed( - array![ - - ].span() - ) - } +^ - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Struct( - dojo::database::introspect::Struct { - name: 'StructIncompatibleAttrs', - attrs: array![].span(), - children: array![ - +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:26:1 - ].span() - } - ) - } -} +^ -impl StructIncompatibleAttrs2Introspect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::None - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:26:1 - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Struct( - array![ - - ].span() - ) - } +^ - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Struct( - dojo::database::introspect::Struct { - name: 'StructIncompatibleAttrs2', - attrs: array![].span(), - children: array![ - +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:26:1 - ].span() - } - ) - } -} - -impl StructIncompatibleAttrs2Introspect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::None - } +^ - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Fixed( - array![ - - ].span() - ) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:32:1 - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Struct( - dojo::database::introspect::Struct { - name: 'StructIncompatibleAttrs2', - attrs: array![].span(), - children: array![ - +^ - ].span() - } - ) - } -} +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:32:1 -impl EnumIncompatibleAttrs2Introspect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::None - } +^ - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Enum( - array![ - - ].span() - ) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:32:1 - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Enum( - dojo::database::introspect::Enum { - name: 'EnumIncompatibleAttrs2', - attrs: array![].span(), - children: array![ - +^ - ].span() - } - ) - } -} - -impl EnumIncompatibleAttrs2Introspect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::None - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:38:1 - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Fixed( - array![ - 8 - ].span() - ) - } +^ - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Enum( - dojo::database::introspect::Enum { - name: 'EnumIncompatibleAttrs2', - attrs: array![].span(), - children: array![ - +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:38:1 - ].span() - } - ) - } -} +^ -impl StructPacked1Introspect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::Some(1) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:38:1 - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Fixed( - array![ - 8 - ].span() - ) - } +^ - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Struct( - dojo::database::introspect::Struct { - name: 'StructPacked1', - attrs: array![].span(), - children: array![ - dojo::database::introspect::Member { - name: 'x', - attrs: array![].span(), - ty: dojo::database::introspect::Introspect::::ty() - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:44:1 - ].span() - } - ) - } -} +^ -impl StructPacked2Introspect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::Some(3) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:44:1 - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Fixed( - array![ - 8,128,128 - ].span() - ) - } +^ - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Struct( - dojo::database::introspect::Struct { - name: 'StructPacked2', - attrs: array![].span(), - children: array![ - dojo::database::introspect::Member { - name: 'x', - attrs: array![].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'y', - attrs: array![].span(), - ty: dojo::database::introspect::Introspect::::ty() - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:44:1 - ].span() - } - ) - } -} +^ -impl StructPacked3Introspect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::Some(4) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:50:1 - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Fixed( - array![ - 128,128,8,32 - ].span() - ) - } +^ - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Struct( - dojo::database::introspect::Struct { - name: 'StructPacked3', - attrs: array![].span(), - children: array![ - dojo::database::introspect::Member { - name: 'x', - attrs: array![].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'y', - attrs: array![].span(), - ty: dojo::database::introspect::Ty::Tuple( - array![ - dojo::database::introspect::Introspect::::ty(), -dojo::database::introspect::Introspect::::ty() - ].span() - ) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:50:1 - ].span() - } - ) - } -} +^ -impl StructNotPackable1Introspect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::None - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:50:1 - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Fixed( - array![ - 8,ERROR - ].span() - ) - } +^ - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Struct( - dojo::database::introspect::Struct { - name: 'StructNotPackable1', - attrs: array![].span(), - children: array![ - dojo::database::introspect::Member { - name: 'x', - attrs: array![].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'y', - attrs: array![].span(), - ty: dojo::database::introspect::Ty::Array( - array![ - dojo::database::introspect::Introspect::::ty() - ].span() - ) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:56:1 - ].span() - } - ) - } -} +^ -impl StructPackableWithInnerPackedIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - let sizes : Array> = array![ - dojo::database::introspect::Introspect::::size(), -Option::Some(1) - ]; +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:56:1 - - Option::Some(dojo::database::utils::sum(sizes)) - - } +^ - fn layout() -> dojo::database::introspect::Layout { - let mut layouts = array![ - dojo::database::introspect::Layout::Fixed(array![8].span()), -dojo::database::introspect::Introspect::::layout() - ]; - let mut merged_layout = ArrayTrait::::new(); - - loop { - match ArrayTrait::pop_front(ref layouts) { - Option::Some(mut layout) => { - match layout { - dojo::database::introspect::Layout::Fixed(mut l) => { - loop { - match SpanTrait::pop_front(ref l) { - Option::Some(x) => merged_layout.append(*x), - Option::None(_) => { break; } - }; - }; - }, - _ => panic!("A packed model layout must contain Fixed layouts only."), - }; - }, - Option::None(_) => { break; } - }; - }; - - dojo::database::introspect::Layout::Fixed(merged_layout.span()) - - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:56:1 - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Struct( - dojo::database::introspect::Struct { - name: 'StructPackableWithInnerPacked', - attrs: array![].span(), - children: array![ - dojo::database::introspect::Member { - name: 'x', - attrs: array![].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'y', - attrs: array![].span(), - ty: dojo::database::introspect::Introspect::::ty() - } +^ - ].span() - } - ) - } -} +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:62:1 -impl EnumPacked1Introspect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::Some(1) - } +^ - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Fixed( - array![ - 8 - ].span() - ) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:62:1 - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Enum( - dojo::database::introspect::Enum { - name: 'EnumPacked1', - attrs: array![].span(), - children: array![ - ('a', dojo::database::introspect::Ty::Tuple(array![].span())), -('b', dojo::database::introspect::Ty::Tuple(array![].span())), -('c', dojo::database::introspect::Ty::Tuple(array![].span())) - - ].span() - } - ) - } -} +^ -impl EnumPacked2Introspect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::Some(2) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:62:1 - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Fixed( - array![ - 8,8 - ].span() - ) - } +^ - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Enum( - dojo::database::introspect::Enum { - name: 'EnumPacked2', - attrs: array![].span(), - children: array![ - ('a', dojo::database::introspect::Introspect::::ty()), -('b', dojo::database::introspect::Introspect::::ty()), -('c', dojo::database::introspect::Introspect::::ty()) - - ].span() - } - ) - } -} +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:68:1 -impl EnumPacked3Introspect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::Some(3) - } +^ - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Fixed( - array![ - 8,128,128 - ].span() - ) - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:68:1 - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Enum( - dojo::database::introspect::Enum { - name: 'EnumPacked3', - attrs: array![].span(), - children: array![ - ('a', dojo::database::introspect::Ty::Tuple( - array![ - dojo::database::introspect::Introspect::::ty(), -dojo::database::introspect::Introspect::::ty() - ].span() - )), -('b', dojo::database::introspect::Introspect::::ty()) - - ].span() - } - ) - } -} +^ -impl EnumPackableWithInnerPackedIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - let sizes : Array> = array![ - dojo::database::introspect::Introspect::::size(), -Option::Some(1) - ]; +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:68:1 - - Option::Some(dojo::database::utils::sum(sizes)) - - } +^ - fn layout() -> dojo::database::introspect::Layout { - let mut layouts = array![ - dojo::database::introspect::Layout::Fixed(array![8].span()), -dojo::database::introspect::Introspect::::layout() - ]; - let mut merged_layout = ArrayTrait::::new(); - - loop { - match ArrayTrait::pop_front(ref layouts) { - Option::Some(mut layout) => { - match layout { - dojo::database::introspect::Layout::Fixed(mut l) => { - loop { - match SpanTrait::pop_front(ref l) { - Option::Some(x) => merged_layout.append(*x), - Option::None(_) => { break; } - }; - }; - }, - _ => panic!("A packed model layout must contain Fixed layouts only."), - }; - }, - Option::None(_) => { break; } - }; - }; - - dojo::database::introspect::Layout::Fixed(merged_layout.span()) - - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:75:1 - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Enum( - dojo::database::introspect::Enum { - name: 'EnumPackableWithInnerPacked', - attrs: array![].span(), - children: array![ - ('a', dojo::database::introspect::Introspect::::ty()), -('b', dojo::database::introspect::Introspect::::ty()) - - ].span() - } - ) - } -} +^ -impl EnumNotPackable1Introspect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::None - } +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:75:1 - fn layout() -> dojo::database::introspect::Layout { - ERROR - } +^ - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Enum( - dojo::database::introspect::Enum { - name: 'EnumNotPackable1', - attrs: array![].span(), - children: array![ - ('a', dojo::database::introspect::Introspect::::ty()), -('b', dojo::database::introspect::Introspect::::ty()) - - ].span() - } - ) - } -} +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:83:1 -//! > expected_diagnostics -error: Option cannot be used with tuples. Prefer using a struct. - --> test_src/lib.cairo:171:6 - x: Option<(u8, u16)> - ^*****************^ +^ -error: Option cannot be used with tuples. Prefer using a struct. - --> test_src/lib.cairo:176:10 - first: Option<(u8, u16)>, - ^*****************^ +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:83:1 -error: Introspect and IntrospectPacked attributes cannot be used at a same time. - --> test_src/lib.cairo:180:6 -enum EnumIncompatibleAttrs {} - ^*******************^ +^ -error: Introspect and IntrospectPacked attributes cannot be used at a same time. - --> test_src/lib.cairo:183:8 -struct StructIncompatibleAttrs {} - ^*********************^ +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:91:1 -error: Introspect and IntrospectPacked attributes cannot be used at a same time. - --> test_src/lib.cairo:187:8 -struct StructIncompatibleAttrs2 {} - ^**********************^ +^ -error: Introspect and IntrospectPacked attributes cannot be used at a same time. - --> test_src/lib.cairo:191:6 -enum EnumIncompatibleAttrs2 {} - ^********************^ +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:91:1 -error: Array field cannot be packed. - --> test_src/lib.cairo:213:6 - y: Array - ^**********^ +^ -error: To be packed, all variants must have fixed layout of same size. - --> test_src/lib.cairo:250:6 -enum EnumNotPackable1 { - ^**************^ +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:99:1 + +^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:99:1 + +^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:107:1 + +^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:107:1 + +^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:115:1 + +^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:115:1 + +^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:123:1 + +^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:123:1 + +^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:131:1 + +^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:131:1 + +^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:139:1 + +^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:139:1 + +^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:147:1 + +^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:147:1 + +^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:155:1 + +^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:155:1 + +^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:163:1 + +^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:163:1 + +^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:163:1 + +^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:168:1 + +^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:168:1 + +^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:168:1 + +^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:173:1 + +^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:173:1 + +^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:173:1 + +^ diff --git a/crates/dojo-lang/src/plugin_test_data/model b/crates/dojo-lang/src/plugin_test_data/model index fd85ef4652..0eff60161f 100644 --- a/crates/dojo-lang/src/plugin_test_data/model +++ b/crates/dojo-lang/src/plugin_test_data/model @@ -313,4917 +313,113 @@ struct ModelWithTupleNoPrimitives { y: (u8, Vec3, u32) } -impl BadModelMultipleAttrIntrospect<> 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: 'BadModelMultipleAttr', - 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 BadModelMultipleVersionsIntrospect<> 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: 'BadModelMultipleVersions', - 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 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, - 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 `BadModelMultipleVersions`: 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 { - "BadModelMultipleVersions" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_plugin" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_plugin-BadModelMultipleVersions" - } - - #[inline(always)] - fn version() -> u8 { - 0 - } - - #[inline(always)] - fn selector() -> felt252 { - "BadModelMultipleVersions" - } - - #[inline(always)] - fn instance_selector(self: @BadModelMultipleVersions) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 3538888628466873673221842373412072042558277047191927145880480325050722136660 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 3437408695301308226171664635441698996501144546809569617702850025816833723775 - } - - #[inline(always)] - fn keys(self: @BadModelMultipleVersions) -> 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: @BadModelMultipleVersions) -> 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: @BadModelMultipleVersions) -> 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_multiple_versions { - fn ensure_abi(self: @T, model: BadModelMultipleVersions); -} - -#[starknet::contract] -mod bad_model_multiple_versions { - use super::BadModelMultipleVersions; - use super::Ibad_model_multiple_versions; - - #[storage] - struct Storage {} - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - dojo::model::Model::::name() - } - - fn namespace(self: @ContractState) -> ByteArray { - dojo::model::Model::::namespace() - } - - fn tag(self: @ContractState) -> ByteArray { - dojo::model::Model::::tag() - } - - fn version(self: @ContractState) -> u8 { - dojo::model::Model::::version() - } - - fn selector(self: @ContractState) -> felt252 { - dojo::model::Model::::selector() - } - - fn name_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::name_hash() - } - - fn namespace_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::namespace_hash() - } - - 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_multiple_versionsImpl of Ibad_model_multiple_versions{ - fn ensure_abi(self: @ContractState, model: BadModelMultipleVersions) { - } - } -} - -impl BadModelBadVersionTypeIntrospect<> 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: 'BadModelBadVersionType', - 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 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, - 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 `BadModelBadVersionType`: 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 { - "BadModelBadVersionType" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_plugin" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_plugin-BadModelBadVersionType" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 1257444965375069225632929782137899434201314657712945575000402601057577969467 - } - - #[inline(always)] - fn instance_selector(self: @BadModelBadVersionType) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 760683829940564015458541272487101565210915690045377810379189532484191344547 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 3437408695301308226171664635441698996501144546809569617702850025816833723775 - } - - #[inline(always)] - fn keys(self: @BadModelBadVersionType) -> 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: @BadModelBadVersionType) -> 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: @BadModelBadVersionType) -> 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_bad_version_type { - fn ensure_abi(self: @T, model: BadModelBadVersionType); -} - -#[starknet::contract] -mod bad_model_bad_version_type { - use super::BadModelBadVersionType; - use super::Ibad_model_bad_version_type; - - #[storage] - struct Storage {} - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - dojo::model::Model::::name() - } - - fn namespace(self: @ContractState) -> ByteArray { - dojo::model::Model::::namespace() - } - - fn tag(self: @ContractState) -> ByteArray { - dojo::model::Model::::tag() - } - - fn version(self: @ContractState) -> u8 { - dojo::model::Model::::version() - } - - fn selector(self: @ContractState) -> felt252 { - dojo::model::Model::::selector() - } - - fn name_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::name_hash() - } - - fn namespace_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::namespace_hash() - } - - 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_bad_version_typeImpl of Ibad_model_bad_version_type{ - fn ensure_abi(self: @ContractState, model: BadModelBadVersionType) { - } - } -} - -impl BadModelNoVersionValueIntrospect<> 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: 'BadModelNoVersionValue', - 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 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, - 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 `BadModelNoVersionValue`: 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 { - "BadModelNoVersionValue" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_plugin" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_plugin-BadModelNoVersionValue" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 3373097771824053354196231469173076752789704424742154674493295341772858104830 - } - - #[inline(always)] - fn instance_selector(self: @BadModelNoVersionValue) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 2459365230136118590954025890011480023818926626380754992635699340900694864996 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 3437408695301308226171664635441698996501144546809569617702850025816833723775 - } - - #[inline(always)] - fn keys(self: @BadModelNoVersionValue) -> 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: @BadModelNoVersionValue) -> 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: @BadModelNoVersionValue) -> 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_no_version_value { - fn ensure_abi(self: @T, model: BadModelNoVersionValue); -} - -#[starknet::contract] -mod bad_model_no_version_value { - use super::BadModelNoVersionValue; - use super::Ibad_model_no_version_value; - - #[storage] - struct Storage {} - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - dojo::model::Model::::name() - } - - fn namespace(self: @ContractState) -> ByteArray { - dojo::model::Model::::namespace() - } - - fn tag(self: @ContractState) -> ByteArray { - dojo::model::Model::::tag() - } - - fn version(self: @ContractState) -> u8 { - dojo::model::Model::::version() - } - - fn selector(self: @ContractState) -> felt252 { - dojo::model::Model::::selector() - } - - fn name_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::name_hash() - } - - fn namespace_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::namespace_hash() - } - - 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_no_version_valueImpl of Ibad_model_no_version_value{ - fn ensure_abi(self: @ContractState, model: BadModelNoVersionValue) { - } - } -} - -impl BadModelUnexpectedArgWithValueIntrospect<> 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: 'BadModelUnexpectedArgWithValue', - 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 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, - 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 `BadModelUnexpectedArgWithValue`: 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 { - "BadModelUnexpectedArgWithValue" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_plugin" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_plugin-BadModelUnexpectedArgWithValue" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 3590405629214068034212593672218295377527112441964389853941077460616482660871 - } - - #[inline(always)] - fn instance_selector(self: @BadModelUnexpectedArgWithValue) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 3586339245084542986020591057627093254376225984628310828088084183494435682971 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 3437408695301308226171664635441698996501144546809569617702850025816833723775 - } - - #[inline(always)] - fn keys(self: @BadModelUnexpectedArgWithValue) -> 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: @BadModelUnexpectedArgWithValue) -> 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: @BadModelUnexpectedArgWithValue) -> 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_unexpected_arg_with_value { - fn ensure_abi(self: @T, model: BadModelUnexpectedArgWithValue); -} - -#[starknet::contract] -mod bad_model_unexpected_arg_with_value { - use super::BadModelUnexpectedArgWithValue; - use super::Ibad_model_unexpected_arg_with_value; - - #[storage] - struct Storage {} - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - dojo::model::Model::::name() - } - - fn namespace(self: @ContractState) -> ByteArray { - dojo::model::Model::::namespace() - } - - fn tag(self: @ContractState) -> ByteArray { - dojo::model::Model::::tag() - } - - fn version(self: @ContractState) -> u8 { - dojo::model::Model::::version() - } - - fn selector(self: @ContractState) -> felt252 { - dojo::model::Model::::selector() - } - - fn name_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::name_hash() - } - - fn namespace_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::namespace_hash() - } - - 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_arg_with_valueImpl of Ibad_model_unexpected_arg_with_value{ - fn ensure_abi(self: @ContractState, model: BadModelUnexpectedArgWithValue) { - } - } -} - -impl BadModelUnexpectedArgIntrospect<> 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: 'BadModelUnexpectedArg', - 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 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, - 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 `BadModelUnexpectedArg`: 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 { - "BadModelUnexpectedArg" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_plugin" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_plugin-BadModelUnexpectedArg" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 1096230073778795894347893795076822536130165745015118585791241737691598280119 - } - - #[inline(always)] - fn instance_selector(self: @BadModelUnexpectedArg) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 246403407829267991441535935236143476032296881039254363860883767387993960270 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 3437408695301308226171664635441698996501144546809569617702850025816833723775 - } - - #[inline(always)] - fn keys(self: @BadModelUnexpectedArg) -> 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: @BadModelUnexpectedArg) -> 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: @BadModelUnexpectedArg) -> 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_unexpected_arg { - fn ensure_abi(self: @T, model: BadModelUnexpectedArg); -} - -#[starknet::contract] -mod bad_model_unexpected_arg { - use super::BadModelUnexpectedArg; - use super::Ibad_model_unexpected_arg; - - #[storage] - struct Storage {} - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - dojo::model::Model::::name() - } - - fn namespace(self: @ContractState) -> ByteArray { - dojo::model::Model::::namespace() - } - - fn tag(self: @ContractState) -> ByteArray { - dojo::model::Model::::tag() - } - - fn version(self: @ContractState) -> u8 { - dojo::model::Model::::version() - } - - fn selector(self: @ContractState) -> felt252 { - dojo::model::Model::::selector() - } - - fn name_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::name_hash() - } - - fn namespace_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::namespace_hash() - } - - 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 namespace() -> ByteArray { - "dojo_plugin" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_plugin-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 name_hash() -> felt252 { - 1812257929012908024237871796629728977392496349235879470060252299886369485820 - } - - #[inline(always)] - fn namespace_hash() -> 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 name(self: @ContractState) -> ByteArray { - dojo::model::Model::::name() - } - - fn namespace(self: @ContractState) -> ByteArray { - dojo::model::Model::::namespace() - } - - fn tag(self: @ContractState) -> ByteArray { - dojo::model::Model::::tag() - } - - fn version(self: @ContractState) -> u8 { - dojo::model::Model::::version() - } - - fn selector(self: @ContractState) -> felt252 { - dojo::model::Model::::selector() - } - - fn name_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::name_hash() - } - - fn namespace_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::namespace_hash() - } - - 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 namespace() -> ByteArray { - "dojo_plugin" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_plugin-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 name_hash() -> felt252 { - 2212879130471315306779111820244908968466545702031328551192231795237740448313 - } - - #[inline(always)] - fn namespace_hash() -> 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 name(self: @ContractState) -> ByteArray { - dojo::model::Model::::name() - } - - fn namespace(self: @ContractState) -> ByteArray { - dojo::model::Model::::namespace() - } - - fn tag(self: @ContractState) -> ByteArray { - dojo::model::Model::::tag() - } - - fn version(self: @ContractState) -> u8 { - dojo::model::Model::::version() - } - - fn selector(self: @ContractState) -> felt252 { - dojo::model::Model::::selector() - } - - fn name_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::name_hash() - } - - fn namespace_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::namespace_hash() - } - - 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 modelv_0Impl of Imodelv_0{ - fn ensure_abi(self: @ContractState, model: Modelv0) { - } - } -} - -impl ModelWithBadNamespaceFormatIntrospect<> 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: '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 ModelWithBadNamespaceFormatModel of dojo::model::Model { - fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::database::introspect::Layout) -> ModelWithBadNamespaceFormat { - 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 `ModelWithBadNamespaceFormat`: 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 { - "ModelWithBadNamespaceFormat" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "MyNamespace" - } - - #[inline(always)] - fn tag() -> ByteArray { - "MyNamespace-ModelWithBadNamespaceFormat" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 3498075185010572568869958326439183660947774785526793544998939163671395407352 - } - - #[inline(always)] - fn instance_selector(self: @ModelWithBadNamespaceFormat) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 513559242384681567568052881519197161166285694153303371154270254637843894159 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 2518247443458975119180817677753479732439290689944304814934908400279022945373 - } - - #[inline(always)] - fn keys(self: @ModelWithBadNamespaceFormat) -> 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: @ModelWithBadNamespaceFormat) -> 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: @ModelWithBadNamespaceFormat) -> 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 Imodel_with_bad_namespace_format { - fn ensure_abi(self: @T, model: ModelWithBadNamespaceFormat); -} - -#[starknet::contract] -mod model_with_bad_namespace_format { - use super::ModelWithBadNamespaceFormat; - use super::Imodel_with_bad_namespace_format; - - #[storage] - struct Storage {} - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - dojo::model::Model::::name() - } - - fn namespace(self: @ContractState) -> ByteArray { - dojo::model::Model::::namespace() - } - - fn tag(self: @ContractState) -> ByteArray { - dojo::model::Model::::tag() - } - - fn version(self: @ContractState) -> u8 { - dojo::model::Model::::version() - } - - fn selector(self: @ContractState) -> felt252 { - dojo::model::Model::::selector() - } - - fn name_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::name_hash() - } - - fn namespace_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::namespace_hash() - } - - 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 model_with_bad_namespace_formatImpl of Imodel_with_bad_namespace_format{ - fn ensure_abi(self: @ContractState, model: ModelWithBadNamespaceFormat) { - } - } -} - -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 { - 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 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. - 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 `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) - } - - #[inline(always)] - fn name() -> ByteArray { - "ModelWithShortStringNamespace" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "my_namespace" - } - - #[inline(always)] - fn tag() -> ByteArray { - "my_namespace-ModelWithShortStringNamespace" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 643350075018191729855964658181798951445581630505240307235771395728709379388 - } - - #[inline(always)] - fn instance_selector(self: @ModelWithShortStringNamespace) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 4646597166239297873853881466258165424425132957303541470648153031188639878 - } - - #[inline(always)] - fn namespace_hash() -> 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: @ModelWithShortStringNamespace) -> 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: @ModelWithShortStringNamespace) -> 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 Imodel_with_short_string_namespace { - fn ensure_abi(self: @T, model: ModelWithShortStringNamespace); -} - -#[starknet::contract] -mod model_with_short_string_namespace { - use super::ModelWithShortStringNamespace; - use super::Imodel_with_short_string_namespace; - - #[storage] - struct Storage {} - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - dojo::model::Model::::name() - } - - fn namespace(self: @ContractState) -> ByteArray { - dojo::model::Model::::namespace() - } - - fn tag(self: @ContractState) -> ByteArray { - dojo::model::Model::::tag() - } - - fn version(self: @ContractState) -> u8 { - dojo::model::Model::::version() - } - - fn selector(self: @ContractState) -> felt252 { - dojo::model::Model::::selector() - } - - fn name_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::name_hash() - } - - fn namespace_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::namespace_hash() - } - - 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 model_with_short_string_namespaceImpl of Imodel_with_short_string_namespace{ - fn ensure_abi(self: @ContractState, model: ModelWithShortStringNamespace) { - } - } -} - -impl ModelWithStringNamespaceIntrospect<> 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: 'ModelWithStringNamespace', - 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 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. - 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 `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) - } - - #[inline(always)] - fn name() -> ByteArray { - "ModelWithStringNamespace" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "my_namespace" - } - - #[inline(always)] - fn tag() -> ByteArray { - "my_namespace-ModelWithStringNamespace" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 2567055065785696374111447326195815858786390804996225951953791904194802101726 - } - - #[inline(always)] - fn instance_selector(self: @ModelWithStringNamespace) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 36187013840655350498900857372670392628596870210415176261336407419317644423 - } - - #[inline(always)] - fn namespace_hash() -> 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: @ModelWithStringNamespace) -> 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: @ModelWithStringNamespace) -> 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 Imodel_with_string_namespace { - fn ensure_abi(self: @T, model: ModelWithStringNamespace); -} - -#[starknet::contract] -mod model_with_string_namespace { - use super::ModelWithStringNamespace; - use super::Imodel_with_string_namespace; - - #[storage] - struct Storage {} - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - dojo::model::Model::::name() - } - - fn namespace(self: @ContractState) -> ByteArray { - dojo::model::Model::::namespace() - } - - fn tag(self: @ContractState) -> ByteArray { - dojo::model::Model::::tag() - } - - fn version(self: @ContractState) -> u8 { - dojo::model::Model::::version() - } - - fn selector(self: @ContractState) -> felt252 { - dojo::model::Model::::selector() - } - - fn name_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::name_hash() - } - - fn namespace_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::namespace_hash() - } - - 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 model_with_string_namespaceImpl of Imodel_with_string_namespace{ - fn ensure_abi(self: @ContractState, model: ModelWithStringNamespace) { - } - } -} - -impl PositionIntrospect<> 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: 'Position', - 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 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, - 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 `Position`: 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 { - "Position" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_plugin" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_plugin-Position" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 2479520712854223096864276571913189358268637670027015185814050381675363770524 - } - - #[inline(always)] - fn instance_selector(self: @Position) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 2899920299641094436341712346886623904698864491830316325765258522168980161362 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 3437408695301308226171664635441698996501144546809569617702850025816833723775 - } - - #[inline(always)] - fn keys(self: @Position) -> 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: @Position) -> 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: @Position) -> 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 Iposition { - fn ensure_abi(self: @T, model: Position); -} - -#[starknet::contract] -mod position { - use super::Position; - use super::Iposition; - - #[storage] - struct Storage {} - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - dojo::model::Model::::name() - } - - fn namespace(self: @ContractState) -> ByteArray { - dojo::model::Model::::namespace() - } - - fn tag(self: @ContractState) -> ByteArray { - dojo::model::Model::::tag() - } - - fn version(self: @ContractState) -> u8 { - dojo::model::Model::::version() - } - - fn selector(self: @ContractState) -> felt252 { - dojo::model::Model::::selector() - } - - fn name_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::name_hash() - } - - fn namespace_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::namespace_hash() - } - - 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 positionImpl of Iposition{ - fn ensure_abi(self: @ContractState, model: Position) { - } - } -} - -impl RolesIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::None - } - - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Struct( - array![ - dojo::database::introspect::FieldLayout { - selector: 387776731289756409274549987067854286905927440612427426920343953432870065647, - 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: 'Roles', - attrs: array![].span(), - children: array![ - dojo::database::introspect::Member { - name: 'role_ids', - attrs: array![].span(), - ty: dojo::database::introspect::Ty::Array( - array![ - dojo::database::introspect::Introspect::::ty() - ].span() - ) - } - - ].span() - } - ) - } -} - -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, - 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 `Roles`: 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 { - "Roles" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_plugin" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_plugin-Roles" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 855657559905271410348750655782338503830053919297069309307754778237415879343 - } - - #[inline(always)] - fn instance_selector(self: @Roles) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 2030971736961612564423689930729061756599290850089001157163423482274886199516 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 3437408695301308226171664635441698996501144546809569617702850025816833723775 - } - - #[inline(always)] - fn keys(self: @Roles) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn values(self: @Roles) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.role_ids, 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: @Roles) -> 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 Iroles { - fn ensure_abi(self: @T, model: Roles); -} - -#[starknet::contract] -mod roles { - use super::Roles; - use super::Iroles; - - #[storage] - struct Storage {} - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - dojo::model::Model::::name() - } - - fn namespace(self: @ContractState) -> ByteArray { - dojo::model::Model::::namespace() - } - - fn tag(self: @ContractState) -> ByteArray { - dojo::model::Model::::tag() - } - - fn version(self: @ContractState) -> u8 { - dojo::model::Model::::version() - } - - fn selector(self: @ContractState) -> felt252 { - dojo::model::Model::::selector() - } - - fn name_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::name_hash() - } - - fn namespace_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::namespace_hash() - } - - 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 rolesImpl of Iroles{ - fn ensure_abi(self: @ContractState, model: Roles) { - } - } -} - -impl OnlyKeyModelIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::None - } - - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Struct( - array![ - - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Struct( - dojo::database::introspect::Struct { - name: 'OnlyKeyModel', - attrs: array![].span(), - children: array![ - dojo::database::introspect::Member { - name: 'id', - attrs: array!['key'].span(), - ty: dojo::database::introspect::Introspect::::ty() - } - - ].span() - } - ) - } -} - -impl OnlyKeyModelModel of dojo::model::Model { - fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::database::introspect::Layout) -> OnlyKeyModel { - 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 `OnlyKeyModel`: 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 { - "OnlyKeyModel" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_plugin" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_plugin-OnlyKeyModel" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 185833973124429845784881936399707635120594083624714634478397191250435112638 - } - - #[inline(always)] - fn instance_selector(self: @OnlyKeyModel) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 1001826121797570811408809643478760373535949956555931325019299477987282578617 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 3437408695301308226171664635441698996501144546809569617702850025816833723775 - } - - #[inline(always)] - fn keys(self: @OnlyKeyModel) -> 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: @OnlyKeyModel) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Introspect::::layout() - } - - #[inline(always)] - fn instance_layout(self: @OnlyKeyModel) -> 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 Ionly_key_model { - fn ensure_abi(self: @T, model: OnlyKeyModel); -} - -#[starknet::contract] -mod only_key_model { - use super::OnlyKeyModel; - use super::Ionly_key_model; - - #[storage] - struct Storage {} - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - dojo::model::Model::::name() - } - - fn namespace(self: @ContractState) -> ByteArray { - dojo::model::Model::::namespace() - } - - fn tag(self: @ContractState) -> ByteArray { - dojo::model::Model::::tag() - } - - fn version(self: @ContractState) -> u8 { - dojo::model::Model::::version() - } - - fn selector(self: @ContractState) -> felt252 { - dojo::model::Model::::selector() - } - - fn name_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::name_hash() - } - - fn namespace_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::namespace_hash() - } - - 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 only_key_modelImpl of Ionly_key_model{ - fn ensure_abi(self: @ContractState, model: OnlyKeyModel) { - } - } -} - -impl U256KeyModelIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::None - } - - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Struct( - array![ - - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Struct( - dojo::database::introspect::Struct { - name: 'U256KeyModel', - attrs: array![].span(), - children: array![ - dojo::database::introspect::Member { - name: 'id', - attrs: array!['key'].span(), - ty: dojo::database::introspect::Introspect::::ty() - } - - ].span() - } - ) - } -} - -impl U256KeyModelModel of dojo::model::Model { - fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::database::introspect::Layout) -> U256KeyModel { - 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 `U256KeyModel`: 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 { - "U256KeyModel" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_plugin" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_plugin-U256KeyModel" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 313949624866121544885414428820758126526635902180652023772135974434319323806 - } - - #[inline(always)] - fn instance_selector(self: @U256KeyModel) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 1848733002266458148515852001373055968326209639346734967305014900020806934517 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 3437408695301308226171664635441698996501144546809569617702850025816833723775 - } - - #[inline(always)] - fn keys(self: @U256KeyModel) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.id, ref serialized); - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn values(self: @U256KeyModel) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Introspect::::layout() - } - - #[inline(always)] - fn instance_layout(self: @U256KeyModel) -> 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 Iu_256_key_model { - fn ensure_abi(self: @T, model: U256KeyModel); -} - -#[starknet::contract] -mod u_256_key_model { - use super::U256KeyModel; - use super::Iu_256_key_model; - - #[storage] - struct Storage {} - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - dojo::model::Model::::name() - } - - fn namespace(self: @ContractState) -> ByteArray { - dojo::model::Model::::namespace() - } - - fn tag(self: @ContractState) -> ByteArray { - dojo::model::Model::::tag() - } - - fn version(self: @ContractState) -> u8 { - dojo::model::Model::::version() - } - - fn selector(self: @ContractState) -> felt252 { - dojo::model::Model::::selector() - } - - fn name_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::name_hash() - } - - fn namespace_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::namespace_hash() - } - - 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 u_256_key_modelImpl of Iu_256_key_model{ - fn ensure_abi(self: @ContractState, model: U256KeyModel) { - } - } -} - -impl PlayerIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::Some(1) - } - - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Struct( - array![ - dojo::database::introspect::FieldLayout { - selector: 1528802474226268325865027367859591458315299653151958663884057507666229546336, - 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: 'Player', - attrs: array![].span(), - children: array![ - dojo::database::introspect::Member { - name: 'game', - attrs: array!['key'].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'player', - attrs: array!['key'].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'name', - attrs: array![].span(), - ty: dojo::database::introspect::Introspect::::ty() - } - - ].span() - } - ) - } -} - -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, - 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 `Player`: 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 { - "Player" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_plugin" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_plugin-Player" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 3236595220905041720254406300307550499454912078227837571413280031443759061272 - } - - #[inline(always)] - fn instance_selector(self: @Player) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 1073075359926275415180704315933677548333097210683379121732618306925003101845 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 3437408695301308226171664635441698996501144546809569617702850025816833723775 - } - - #[inline(always)] - fn keys(self: @Player) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, *self.game);core::serde::Serde::serialize(self.player, ref serialized); - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn values(self: @Player) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::array::ArrayTrait::append(ref serialized, *self.name); - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Introspect::::layout() - } - - #[inline(always)] - fn instance_layout(self: @Player) -> 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 Iplayer { - fn ensure_abi(self: @T, model: Player); -} - -#[starknet::contract] -mod player { - use super::Player; - use super::Iplayer; - - #[storage] - struct Storage {} - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - dojo::model::Model::::name() - } - - fn namespace(self: @ContractState) -> ByteArray { - dojo::model::Model::::namespace() - } - - fn tag(self: @ContractState) -> ByteArray { - dojo::model::Model::::tag() - } - - fn version(self: @ContractState) -> u8 { - dojo::model::Model::::version() - } - - fn selector(self: @ContractState) -> felt252 { - dojo::model::Model::::selector() - } - - fn name_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::name_hash() - } - - fn namespace_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::namespace_hash() - } - - 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 playerImpl of Iplayer{ - fn ensure_abi(self: @ContractState, model: Player) { - } - } -} - -impl ModelWithSimpleArrayIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::None - } - - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Struct( - array![ - dojo::database::introspect::FieldLayout { - selector: 512066735765477566404754172672287371265995314501343422459174036873487219331, - layout: dojo::database::introspect::Introspect::::layout() - }, -dojo::database::introspect::FieldLayout { - selector: 1591024729085637502504777720563487898377940395575083379770417352976841400819, - 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: 'ModelWithSimpleArray', - attrs: array![].span(), - children: array![ - dojo::database::introspect::Member { - name: 'player', - attrs: array!['key'].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'x', - attrs: array![].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'y', - attrs: array![].span(), - ty: dojo::database::introspect::Ty::Array( - array![ - dojo::database::introspect::Introspect::::ty() - ].span() - ) - } - - ].span() - } - ) - } -} - -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, - 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 `ModelWithSimpleArray`: 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 { - "ModelWithSimpleArray" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_plugin" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_plugin-ModelWithSimpleArray" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 3015573168128997707047545520976347917082964620628387533056114714397499472255 - } - - #[inline(always)] - fn instance_selector(self: @ModelWithSimpleArray) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 173141902001925402715103859951360389436088950156916962046507357841237663931 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 3437408695301308226171664635441698996501144546809569617702850025816833723775 - } - - #[inline(always)] - fn keys(self: @ModelWithSimpleArray) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.player, ref serialized); - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn values(self: @ModelWithSimpleArray) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.x, ref serialized);core::serde::Serde::serialize(self.y, 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: @ModelWithSimpleArray) -> 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 Imodel_with_simple_array { - fn ensure_abi(self: @T, model: ModelWithSimpleArray); -} - -#[starknet::contract] -mod model_with_simple_array { - use super::ModelWithSimpleArray; - use super::Imodel_with_simple_array; - - #[storage] - struct Storage {} - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - dojo::model::Model::::name() - } - - fn namespace(self: @ContractState) -> ByteArray { - dojo::model::Model::::namespace() - } - - fn tag(self: @ContractState) -> ByteArray { - dojo::model::Model::::tag() - } - - fn version(self: @ContractState) -> u8 { - dojo::model::Model::::version() - } - - fn selector(self: @ContractState) -> felt252 { - dojo::model::Model::::selector() - } - - fn name_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::name_hash() - } - - fn namespace_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::namespace_hash() - } - - 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 model_with_simple_arrayImpl of Imodel_with_simple_array{ - fn ensure_abi(self: @ContractState, model: ModelWithSimpleArray) { - } - } -} - -impl ModelWithByteArrayIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::None - } - - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Struct( - array![ - dojo::database::introspect::FieldLayout { - selector: 512066735765477566404754172672287371265995314501343422459174036873487219331, - layout: dojo::database::introspect::Introspect::::layout() - }, -dojo::database::introspect::FieldLayout { - selector: 1591024729085637502504777720563487898377940395575083379770417352976841400819, - 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: 'ModelWithByteArray', - attrs: array![].span(), - children: array![ - dojo::database::introspect::Member { - name: 'player', - attrs: array!['key'].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'x', - attrs: array![].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'y', - attrs: array![].span(), - ty: dojo::database::introspect::Ty::ByteArray - } - - ].span() - } - ) - } -} - -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, - 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 `ModelWithByteArray`: 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 { - "ModelWithByteArray" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_plugin" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_plugin-ModelWithByteArray" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 1495813766814131974177657304275361143893541941399872042870855060582891570868 - } - - #[inline(always)] - fn instance_selector(self: @ModelWithByteArray) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 2176409715042145900636260236501596599545103472111273072320531220776338338674 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 3437408695301308226171664635441698996501144546809569617702850025816833723775 - } - - #[inline(always)] - fn keys(self: @ModelWithByteArray) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.player, ref serialized); - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn values(self: @ModelWithByteArray) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.x, ref serialized);core::serde::Serde::serialize(self.y, 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: @ModelWithByteArray) -> 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 Imodel_with_byte_array { - fn ensure_abi(self: @T, model: ModelWithByteArray); -} - -#[starknet::contract] -mod model_with_byte_array { - use super::ModelWithByteArray; - use super::Imodel_with_byte_array; - - #[storage] - struct Storage {} - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - dojo::model::Model::::name() - } - - fn namespace(self: @ContractState) -> ByteArray { - dojo::model::Model::::namespace() - } - - fn tag(self: @ContractState) -> ByteArray { - dojo::model::Model::::tag() - } - - fn version(self: @ContractState) -> u8 { - dojo::model::Model::::version() - } - - fn selector(self: @ContractState) -> felt252 { - dojo::model::Model::::selector() - } - - fn name_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::name_hash() - } - - fn namespace_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::namespace_hash() - } - - 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 model_with_byte_arrayImpl of Imodel_with_byte_array{ - fn ensure_abi(self: @ContractState, model: ModelWithByteArray) { - } - } -} - -impl ModelWithComplexArrayIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::None - } - - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Struct( - array![ - dojo::database::introspect::FieldLayout { - selector: 512066735765477566404754172672287371265995314501343422459174036873487219331, - layout: dojo::database::introspect::Introspect::::layout() - }, -dojo::database::introspect::FieldLayout { - selector: 1591024729085637502504777720563487898377940395575083379770417352976841400819, - 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: 'ModelWithComplexArray', - attrs: array![].span(), - children: array![ - dojo::database::introspect::Member { - name: 'player', - attrs: array!['key'].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'x', - attrs: array![].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'y', - attrs: array![].span(), - ty: dojo::database::introspect::Ty::Array( - array![ - dojo::database::introspect::Introspect::::ty() - ].span() - ) - } - - ].span() - } - ) - } -} - -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, - 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 `ModelWithComplexArray`: 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 { - "ModelWithComplexArray" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_plugin" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_plugin-ModelWithComplexArray" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 36330270687495804813979499325154873801411429162367231362587376627277795482 - } - - #[inline(always)] - fn instance_selector(self: @ModelWithComplexArray) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 2866472224509756243720005045848892642397514372569303051745174230372637769655 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 3437408695301308226171664635441698996501144546809569617702850025816833723775 - } - - #[inline(always)] - fn keys(self: @ModelWithComplexArray) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.player, ref serialized); - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn values(self: @ModelWithComplexArray) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.x, ref serialized);core::serde::Serde::serialize(self.y, 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: @ModelWithComplexArray) -> 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 Imodel_with_complex_array { - fn ensure_abi(self: @T, model: ModelWithComplexArray); -} - -#[starknet::contract] -mod model_with_complex_array { - use super::ModelWithComplexArray; - use super::Imodel_with_complex_array; - - #[storage] - struct Storage {} - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - dojo::model::Model::::name() - } - - fn namespace(self: @ContractState) -> ByteArray { - dojo::model::Model::::namespace() - } - - fn tag(self: @ContractState) -> ByteArray { - dojo::model::Model::::tag() - } - - fn version(self: @ContractState) -> u8 { - dojo::model::Model::::version() - } - - fn selector(self: @ContractState) -> felt252 { - dojo::model::Model::::selector() - } - - fn name_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::name_hash() - } - - fn namespace_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::namespace_hash() - } - - 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 model_with_complex_arrayImpl of Imodel_with_complex_array{ - fn ensure_abi(self: @ContractState, model: ModelWithComplexArray) { - } - } -} - -impl ModelWithTupleIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - Option::Some(4) - } - - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Struct( - array![ - dojo::database::introspect::FieldLayout { - selector: 512066735765477566404754172672287371265995314501343422459174036873487219331, - layout: dojo::database::introspect::Introspect::::layout() - }, -dojo::database::introspect::FieldLayout { - selector: 1591024729085637502504777720563487898377940395575083379770417352976841400819, - layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Introspect::::layout(), -dojo::database::introspect::Introspect::::layout(), -dojo::database::introspect::Introspect::::layout() - ].span() - ) - } - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Struct( - dojo::database::introspect::Struct { - name: 'ModelWithTuple', - attrs: array![].span(), - children: array![ - dojo::database::introspect::Member { - name: 'player', - attrs: array!['key'].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'x', - attrs: array![].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'y', - attrs: array![].span(), - ty: dojo::database::introspect::Ty::Tuple( - array![ - dojo::database::introspect::Introspect::::ty(), -dojo::database::introspect::Introspect::::ty(), -dojo::database::introspect::Introspect::::ty() - ].span() - ) - } - - ].span() - } - ) - } -} - -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, - 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 `ModelWithTuple`: 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 { - "ModelWithTuple" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_plugin" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_plugin-ModelWithTuple" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 2968932965114787437968555813812827702683268243780347884633996291362924490633 - } - - #[inline(always)] - fn instance_selector(self: @ModelWithTuple) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 3222351670132870101782632958288197874250493316621507272653773018669253981260 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 3437408695301308226171664635441698996501144546809569617702850025816833723775 - } - - #[inline(always)] - fn keys(self: @ModelWithTuple) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.player, ref serialized); - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn values(self: @ModelWithTuple) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.x, ref serialized);core::serde::Serde::serialize(self.y, 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: @ModelWithTuple) -> 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 Imodel_with_tuple { - fn ensure_abi(self: @T, model: ModelWithTuple); -} - -#[starknet::contract] -mod model_with_tuple { - use super::ModelWithTuple; - use super::Imodel_with_tuple; - - #[storage] - struct Storage {} - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - dojo::model::Model::::name() - } - - fn namespace(self: @ContractState) -> ByteArray { - dojo::model::Model::::namespace() - } - - fn tag(self: @ContractState) -> ByteArray { - dojo::model::Model::::tag() - } - - fn version(self: @ContractState) -> u8 { - dojo::model::Model::::version() - } - - fn selector(self: @ContractState) -> felt252 { - dojo::model::Model::::selector() - } - - fn name_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::name_hash() - } - - fn namespace_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::namespace_hash() - } - - 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 model_with_tupleImpl of Imodel_with_tuple{ - fn ensure_abi(self: @ContractState, model: ModelWithTuple) { - } - } -} - -impl ModelWithTupleNoPrimitivesIntrospect<> of dojo::database::introspect::Introspect> { - #[inline(always)] - fn size() -> Option { - let sizes : Array> = array![ - dojo::database::introspect::Introspect::::size(), -Option::Some(3) - ]; - - if dojo::database::utils::any_none(@sizes) { - return Option::None; - } - Option::Some(dojo::database::utils::sum(sizes)) - - } - - fn layout() -> dojo::database::introspect::Layout { - dojo::database::introspect::Layout::Struct( - array![ - dojo::database::introspect::FieldLayout { - selector: 512066735765477566404754172672287371265995314501343422459174036873487219331, - layout: dojo::database::introspect::Introspect::::layout() - }, -dojo::database::introspect::FieldLayout { - selector: 1591024729085637502504777720563487898377940395575083379770417352976841400819, - layout: dojo::database::introspect::Layout::Tuple( - array![ - dojo::database::introspect::Introspect::::layout(), -dojo::database::introspect::Introspect::::layout(), -dojo::database::introspect::Introspect::::layout() - ].span() - ) - } - ].span() - ) - } - - #[inline(always)] - fn ty() -> dojo::database::introspect::Ty { - dojo::database::introspect::Ty::Struct( - dojo::database::introspect::Struct { - name: 'ModelWithTupleNoPrimitives', - attrs: array![].span(), - children: array![ - dojo::database::introspect::Member { - name: 'player', - attrs: array!['key'].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'x', - attrs: array![].span(), - ty: dojo::database::introspect::Introspect::::ty() - }, -dojo::database::introspect::Member { - name: 'y', - attrs: array![].span(), - ty: dojo::database::introspect::Ty::Tuple( - array![ - dojo::database::introspect::Introspect::::ty(), -dojo::database::introspect::Introspect::::ty(), -dojo::database::introspect::Introspect::::ty() - ].span() - ) - } - - ].span() - } - ) - } -} - -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, - 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 `ModelWithTupleNoPrimitives`: 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 { - "ModelWithTupleNoPrimitives" - } - - #[inline(always)] - fn namespace() -> ByteArray { - "dojo_plugin" - } - - #[inline(always)] - fn tag() -> ByteArray { - "dojo_plugin-ModelWithTupleNoPrimitives" - } - - #[inline(always)] - fn version() -> u8 { - 1 - } - - #[inline(always)] - fn selector() -> felt252 { - 1303002480984182254910512996281734914702552284127358821084351389028444664680 - } - - #[inline(always)] - fn instance_selector(self: @ModelWithTupleNoPrimitives) -> felt252 { - Self::selector() - } - - #[inline(always)] - fn name_hash() -> felt252 { - 157059227407493660591195028728750607977045261142495925435047270200565107096 - } - - #[inline(always)] - fn namespace_hash() -> felt252 { - 3437408695301308226171664635441698996501144546809569617702850025816833723775 - } - - #[inline(always)] - fn keys(self: @ModelWithTupleNoPrimitives) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.player, ref serialized); - core::array::ArrayTrait::span(@serialized) - } - - #[inline(always)] - fn values(self: @ModelWithTupleNoPrimitives) -> Span { - let mut serialized = core::array::ArrayTrait::new(); - core::serde::Serde::serialize(self.x, ref serialized);core::serde::Serde::serialize(self.y, 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: @ModelWithTupleNoPrimitives) -> 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 Imodel_with_tuple_no_primitives { - fn ensure_abi(self: @T, model: ModelWithTupleNoPrimitives); -} - -#[starknet::contract] -mod model_with_tuple_no_primitives { - use super::ModelWithTupleNoPrimitives; - use super::Imodel_with_tuple_no_primitives; - - #[storage] - struct Storage {} - - #[abi(embed_v0)] - impl DojoModelImpl of dojo::model::IModel{ - fn name(self: @ContractState) -> ByteArray { - dojo::model::Model::::name() - } - - fn namespace(self: @ContractState) -> ByteArray { - dojo::model::Model::::namespace() - } - - fn tag(self: @ContractState) -> ByteArray { - dojo::model::Model::::tag() - } - - fn version(self: @ContractState) -> u8 { - dojo::model::Model::::version() - } - - fn selector(self: @ContractState) -> felt252 { - dojo::model::Model::::selector() - } - - fn name_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::name_hash() - } - - fn namespace_hash(self: @ContractState) -> felt252 { - dojo::model::Model::::namespace_hash() - } - - 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 model_with_tuple_no_primitivesImpl of Imodel_with_tuple_no_primitives{ - fn ensure_abi(self: @ContractState, model: ModelWithTupleNoPrimitives) { - } - } -} - -//! > expected_diagnostics -error: A Dojo model must have zero or one dojo::model attribute. - --> test_src/lib.cairo:1:1 -#[dojo::model(version: 0)] -^************************^ - -error: Too many 'version' attributes for dojo::model - --> test_src/lib.cairo:9:1 -#[dojo::model(version: 0, version: 0)] -^************************************^ - -error: The argument 'version' of dojo::model must be an integer - --> test_src/lib.cairo:16:24 -#[dojo::model(version: hello)] - ^***^ - -error: Unexpected argument 'version' for dojo::model - --> test_src/lib.cairo:23:15 -#[dojo::model(version)] - ^*****^ - -error: Unexpected argument 'my_arg' for dojo::model - --> test_src/lib.cairo:30:15 -#[dojo::model(my_arg: 1)] - ^*******^ - -error: Unexpected argument 'my_arg' for dojo::model - --> test_src/lib.cairo:37:15 -#[dojo::model(my_arg)] - ^****^ - -error: dojo::model version 2 not supported - --> test_src/lib.cairo:44:24 -#[dojo::model(version: 2)] - ^ - -error: Model must define at least one #[key] attribute - --> 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:92:8 -struct OnlyKeyModel { - ^**********^ - -error: Model must define at least one member that is not a key - --> 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:98:8 -struct U256KeyModel { - ^**********^ - -error: Unsupported attribute. - --> test_src/lib.cairo:9:1 -#[dojo::model(version: 0, version: 0)] -^************************************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:16:1 -#[dojo::model(version: hello)] -^****************************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:23:1 -#[dojo::model(version)] -^*********************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:30:1 -#[dojo::model(my_arg: 1)] -^***********************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:37:1 -#[dojo::model(my_arg)] -^********************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:44:1 -#[dojo::model(version: 2)] -^************************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:51:1 +//! > expected_diagnostics +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:1:1 #[dojo::model(version: 0)] ^************************^ -error: Unsupported attribute. - --> test_src/lib.cairo:58:1 -#[dojo::model(namespace: 'MyNamespace')] -^**************************************^ - -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:79:1 -#[dojo::model] -^************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:86:1 -#[dojo::model] -^************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:91:1 -#[dojo::model] -^************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:97:1 -#[dojo::model] -^************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:103:1 -#[dojo::model] -^************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:115:1 -#[dojo::model] -^************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:123:1 -#[dojo::model] -^************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:131:1 -#[dojo::model] -^************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:139:1 -#[dojo::model] -^************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:147:1 -#[dojo::model] -^************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:9:1 -#[dojo::model(version: 0, version: 0)] -^************************************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:9:1 -#[dojo::model(version: 0, version: 0)] -^************************************^ - -error: Unsupported attribute. +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. --> test_src/lib.cairo:9:1 #[dojo::model(version: 0, version: 0)] ^************************************^ -error: Unsupported attribute. - --> test_src/lib.cairo:16:1 -#[dojo::model(version: hello)] -^****************************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:16:1 -#[dojo::model(version: hello)] -^****************************^ - -error: Unsupported attribute. +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. --> test_src/lib.cairo:16:1 #[dojo::model(version: hello)] ^****************************^ -error: Unsupported attribute. - --> test_src/lib.cairo:23:1 -#[dojo::model(version)] -^*********************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:23:1 -#[dojo::model(version)] -^*********************^ - -error: Unsupported attribute. +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. --> test_src/lib.cairo:23:1 #[dojo::model(version)] ^*********************^ -error: Unsupported attribute. - --> test_src/lib.cairo:30:1 -#[dojo::model(my_arg: 1)] -^***********************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:30:1 -#[dojo::model(my_arg: 1)] -^***********************^ - -error: Unsupported attribute. +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. --> test_src/lib.cairo:30:1 #[dojo::model(my_arg: 1)] ^***********************^ -error: Unsupported attribute. - --> test_src/lib.cairo:37:1 -#[dojo::model(my_arg)] -^********************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:37:1 -#[dojo::model(my_arg)] -^********************^ - -error: Unsupported attribute. +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. --> test_src/lib.cairo:37:1 #[dojo::model(my_arg)] ^********************^ -error: Unsupported attribute. - --> test_src/lib.cairo:44:1 -#[dojo::model(version: 2)] -^************************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:44:1 -#[dojo::model(version: 2)] -^************************^ - -error: Unsupported attribute. +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. --> test_src/lib.cairo:44:1 #[dojo::model(version: 2)] ^************************^ -error: Unsupported attribute. - --> test_src/lib.cairo:51:1 -#[dojo::model(version: 0)] -^************************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:51:1 -#[dojo::model(version: 0)] -^************************^ - -error: Unsupported attribute. +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. --> test_src/lib.cairo:51:1 #[dojo::model(version: 0)] ^************************^ -error: Unsupported attribute. - --> test_src/lib.cairo:58:1 -#[dojo::model(namespace: 'MyNamespace')] -^**************************************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:58:1 -#[dojo::model(namespace: 'MyNamespace')] -^**************************************^ - -error: Unsupported attribute. +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. --> test_src/lib.cairo:58:1 #[dojo::model(namespace: 'MyNamespace')] ^**************************************^ -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. +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. --> 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. +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. --> 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:79:1 -#[dojo::model] -^************^ - -error: Unsupported attribute. +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. --> test_src/lib.cairo:79:1 #[dojo::model] ^************^ -error: Unsupported attribute. - --> test_src/lib.cairo:86:1 -#[dojo::model] -^************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:86:1 -#[dojo::model] -^************^ - -error: Unsupported attribute. +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. --> test_src/lib.cairo:86:1 #[dojo::model] ^************^ -error: Unsupported attribute. - --> test_src/lib.cairo:91:1 -#[dojo::model] -^************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:91:1 -#[dojo::model] -^************^ - -error: Unsupported attribute. +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. --> test_src/lib.cairo:91:1 #[dojo::model] ^************^ -error: Unsupported attribute. - --> test_src/lib.cairo:97:1 -#[dojo::model] -^************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:97:1 -#[dojo::model] -^************^ - -error: Unsupported attribute. +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. --> test_src/lib.cairo:97:1 #[dojo::model] ^************^ -error: Unsupported attribute. - --> test_src/lib.cairo:103:1 -#[dojo::model] -^************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:103:1 -#[dojo::model] -^************^ - -error: Unsupported attribute. +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. --> test_src/lib.cairo:103:1 #[dojo::model] ^************^ -error: Unsupported attribute. - --> test_src/lib.cairo:115:1 -#[dojo::model] -^************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:115:1 +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:112:1 #[dojo::model] ^************^ -error: Unsupported attribute. +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. --> test_src/lib.cairo:115:1 #[dojo::model] ^************^ -error: Unsupported attribute. +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. --> test_src/lib.cairo:123:1 #[dojo::model] ^************^ -error: Unsupported attribute. - --> test_src/lib.cairo:123:1 -#[dojo::model] -^************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:123:1 -#[dojo::model] -^************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:131:1 -#[dojo::model] -^************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:131:1 -#[dojo::model] -^************^ - -error: Unsupported attribute. +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. --> test_src/lib.cairo:131:1 #[dojo::model] ^************^ -error: Unsupported attribute. +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. --> test_src/lib.cairo:139:1 #[dojo::model] ^************^ -error: Unsupported attribute. - --> test_src/lib.cairo:139:1 -#[dojo::model] -^************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:139:1 -#[dojo::model] -^************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:147:1 -#[dojo::model] -^************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:147:1 -#[dojo::model] -^************^ - -error: Unsupported attribute. +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. --> test_src/lib.cairo:147:1 #[dojo::model] ^************^ diff --git a/crates/dojo-lang/src/plugin_test_data/print b/crates/dojo-lang/src/plugin_test_data/print index 0698716613..0ed58b1d50 100644 --- a/crates/dojo-lang/src/plugin_test_data/print +++ b/crates/dojo-lang/src/plugin_test_data/print @@ -76,59 +76,58 @@ enum Enemy { OtherPlayer: ContractAddress, } -#[cfg(test)] -impl PositionStructPrintImpl of core::debug::PrintTrait { - fn print(self: Position) { - core::debug::PrintTrait::print('id'); core::debug::PrintTrait::print(self.id); -core::debug::PrintTrait::print('x'); core::debug::PrintTrait::print(self.x); -core::debug::PrintTrait::print('y'); core::debug::PrintTrait::print(self.y); - } -} - -#[cfg(test)] -impl RolesStructPrintImpl of core::debug::PrintTrait { - fn print(self: Roles) { - core::debug::PrintTrait::print('role_ids'); core::debug::PrintTrait::print(self.role_ids); - } -} - -#[cfg(test)] -impl PlayerStructPrintImpl of core::debug::PrintTrait { - fn print(self: Player) { - core::debug::PrintTrait::print('game'); core::debug::PrintTrait::print(self.game); -core::debug::PrintTrait::print('player'); core::debug::PrintTrait::print(self.player); -core::debug::PrintTrait::print('name'); core::debug::PrintTrait::print(self.name); - } -} +//! > expected_diagnostics +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:1:1 +use serde::Serde; +^***************^ -#[cfg(test)] -impl EnemyEnumPrintImpl of core::debug::PrintTrait { - fn print(self: Enemy) { - match self { - Enemy::Unknown => { core::debug::PrintTrait::print('Unknown'); }, -Enemy::Bot(v) => { core::debug::PrintTrait::print('Bot'); core::debug::PrintTrait::print(v); }, -Enemy::OtherPlayer(v) => { core::debug::PrintTrait::print('OtherPlayer'); core::debug::PrintTrait::print(v); } - } - } -} +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:2:1 +use debug::PrintTrait; +^********************^ -//! > expected_diagnostics error: Unknown derive `Print` - a plugin might be missing. --> test_src/lib.cairo:4:10 #[derive(Print)] ^***^ +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:4:1 +#[derive(Print)] +^**************^ + error: Unknown derive `Print` - a plugin might be missing. --> test_src/lib.cairo:12:10 #[derive(Print)] ^***^ +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:12:1 +#[derive(Print)] +^**************^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:17:1 +use starknet::ContractAddress; +^****************************^ + error: Unknown derive `Print` - a plugin might be missing. --> test_src/lib.cairo:19:10 #[derive(Print)] ^***^ +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:19:1 +#[derive(Print)] +^**************^ + error: Unknown derive `Print` - a plugin might be missing. --> test_src/lib.cairo:28:10 #[derive(Print)] ^***^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:28:1 +#[derive(Print)] +^**************^ diff --git a/crates/dojo-lang/src/plugin_test_data/system b/crates/dojo-lang/src/plugin_test_data/system index 9c832941be..8c306419d8 100644 --- a/crates/dojo-lang/src/plugin_test_data/system +++ b/crates/dojo-lang/src/plugin_test_data/system @@ -355,415 +355,275 @@ mod ctxnamed { } //! > expected_diagnostics -error: The contract namespace 'My@Namespace' can only contain characters (a-z/A-Z), numbers (0-9) and underscore (_) +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. --> test_src/lib.cairo:1:1 #[dojo::contract(namespace: "My@Namespace")] ^******************************************^ -error: Unsupported attribute. - --> test_src/lib.cairo:52:1 -#[starknet::component] -^********************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:58:1 -#[starknet::component] -^********************^ - -error: Anything other than functions is not supported in a dojo::interface - --> test_src/lib.cairo:90:5 - const ONE: u8; - ^************^ - -error: World parameter must be the first parameter. - --> test_src/lib.cairo:111:5 - fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252; - ^***********************************************************************************^ - -error: World parameter must be the first parameter. - --> test_src/lib.cairo:112:5 - fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; - ^*********************************************************************************************^ - -error: You cannot use `self` and `world` parameters together. - --> test_src/lib.cairo:113:5 - fn do_with_self_and_world_inv(world: @IWorldDispatcher, self: @ContractState) -> felt252; - ^***************************************************************************************^ - -error: You cannot use `self` and `world` parameters together. - --> test_src/lib.cairo:114:5 - fn do_with_ref_self_and_world_inv( - ^********************************^ - -error: World parameter must be the first parameter. - --> test_src/lib.cairo:121:5 - fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252; - ^****************************************************************************^ - -error: World parameter must be the first parameter. - --> test_src/lib.cairo:128:9 - fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252 { - ^************************************************************************************^ - -error: World parameter must be the first parameter. - --> test_src/lib.cairo:132:9 - fn do_with_ref_self_and_world( - ^****************************^ - -error: You cannot use `self` and `world` parameters together. - --> test_src/lib.cairo:138:9 - fn do_with_self_and_world_inv(world: @IWorldDispatcher, self: @ContractState) -> felt252 { - ^****************************************************************************************^ - -error: You cannot use `self` and `world` parameters together. - --> test_src/lib.cairo:142:9 - fn do_with_ref_self_and_world_inv( - ^********************************^ - -error: World parameter must be the first parameter. - --> test_src/lib.cairo:158:9 - fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252 { - ^*****************************************************************************^ - -error: You cannot use `world` and `#[generate_trait]` together. Use `self` instead. - --> test_src/lib.cairo:165:9 - fn bad_func_using_generate(world: @IWorldDispatcher) -> felt252 { - ^***************************************************************^ - -error: World parameter must be a snapshot if `ref` is not used. - --> test_src/lib.cairo:224:5 - fn dojo_init( - ^***********^ - -error: Unsupported attribute. +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. --> test_src/lib.cairo:11:1 #[dojo::contract(namespace: 'my_namespace')] ^******************************************^ -error: Unsupported attribute. +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. --> test_src/lib.cairo:21:1 #[dojo::contract(namespace: "my_namespace")] ^******************************************^ -error: Unsupported attribute. +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. --> test_src/lib.cairo:28:1 #[dojo::contract] ^***************^ -error: Unsupported attribute. +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. --> test_src/lib.cairo:38:1 #[dojo::contract] ^***************^ +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:52:1 +#[starknet::component] +^********************^ + +error: Unsupported attribute. + --> test_src/lib.cairo:52:1 +#[starknet::component] +^********************^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:58:1 +#[starknet::component] +^********************^ + error: Unsupported attribute. + --> test_src/lib.cairo:58:1 +#[starknet::component] +^********************^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. --> test_src/lib.cairo:64:1 #[dojo::contract] ^***************^ +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:85:1 +#[dojo::interface] +^****************^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:88:1 +#[dojo::interface] +^****************^ + error: Unsupported attribute. + --> test_src/lib.cairo:92:5 + #[my_attr] + ^********^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:96:1 +#[dojo::interface] +^****************^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:109:1 +#[dojo::interface] +^****************^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. --> test_src/lib.cairo:124:1 #[dojo::contract] ^***************^ -error: Unsupported attribute. +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. --> test_src/lib.cairo:171:1 #[dojo::contract] ^***************^ -error: Unsupported attribute. +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. --> test_src/lib.cairo:222:1 #[dojo::contract] ^***************^ -error: Unsupported attribute. +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. --> test_src/lib.cairo:239:1 #[dojo::contract] ^***************^ -error: Unsupported attribute. - --> test_src/lib.cairo:54:5 - #[storage] - ^********^ +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:3:5 + use traits::Into; + ^***************^ -error: Unsupported attribute. - --> test_src/lib.cairo:60:5 - #[storage] - ^********^ +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:4:5 + use dojo::world::Context; + ^***********************^ -error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo:11:1 -#[dojo::contract(namespace: 'my_namespace')] -^******************************************^ +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:6:5 + fn execute(ctx: Context, name: felt252) { + ^***************************************^ -error: Unsupported attribute. - --> test_src/lib.cairo:11:1 -#[dojo::contract(namespace: 'my_namespace')] -^******************************************^ +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:13:5 + use traits::Into; + ^***************^ -error: Unsupported attribute. - --> test_src/lib.cairo:11:1 -#[dojo::contract(namespace: 'my_namespace')] -^******************************************^ +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:14:5 + use dojo::world::Context; + ^***********************^ -error: Unsupported attribute. - --> test_src/lib.cairo:11:1 -#[dojo::contract(namespace: 'my_namespace')] -^******************************************^ +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:16:5 + fn execute(ctx: Context, name: felt252) { + ^***************************************^ -error: Unsupported attribute. - --> test_src/lib.cairo:11:1 -#[dojo::contract(namespace: 'my_namespace')] -^******************************************^ +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:23:5 + fn execute(value: felt252) -> felt252 { + ^*************************************^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:30:5 + use traits::Into; + ^***************^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:31:5 + use dojo::world::Context; + ^***********************^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:33:5 + fn execute(ctx2: Context, name: felt252) { + ^****************************************^ error: Unknown derive `starknet::Event` - a plugin might be missing. - --> test_src/lib.cairo:11:1 -#[dojo::contract(namespace: 'my_namespace')] -^******************************************^ + --> test_src/lib.cairo:41:20 + #[derive(Drop, starknet::Event)] + ^*************^ -error: Unsupported attribute. - --> test_src/lib.cairo:11:1 -#[dojo::contract(namespace: 'my_namespace')] -^******************************************^ +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:40:5 + #[event] + ^******^ error: Unsupported attribute. - --> test_src/lib.cairo:11:1 -#[dojo::contract(namespace: 'my_namespace')] -^******************************************^ + --> test_src/lib.cairo:40:5 + #[event] + ^******^ -error: Unsupported attribute. - --> test_src/lib.cairo:11:1 -#[dojo::contract(namespace: 'my_namespace')] -^******************************************^ +error: Unknown derive `starknet::Event` - a plugin might be missing. + --> test_src/lib.cairo:46:20 + #[derive(Drop, starknet::Event)] + ^*************^ -error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo:21:1 -#[dojo::contract(namespace: "my_namespace")] -^******************************************^ +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:46:5 + #[derive(Drop, starknet::Event)] + ^******************************^ -error: Unsupported attribute. - --> test_src/lib.cairo:21:1 -#[dojo::contract(namespace: "my_namespace")] -^******************************************^ +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:40:1 + #[event] +^**********^ -error: Unsupported attribute. - --> test_src/lib.cairo:21:1 -#[dojo::contract(namespace: "my_namespace")] -^******************************************^ +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:45:1 -error: Unsupported attribute. - --> test_src/lib.cairo:21:1 -#[dojo::contract(namespace: "my_namespace")] -^******************************************^ +^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:54:5 + #[storage] + ^********^ error: Unsupported attribute. - --> test_src/lib.cairo:21:1 -#[dojo::contract(namespace: "my_namespace")] -^******************************************^ + --> test_src/lib.cairo:54:5 + #[storage] + ^********^ -error: Unknown derive `starknet::Event` - a plugin might be missing. - --> test_src/lib.cairo:21:1 -#[dojo::contract(namespace: "my_namespace")] -^******************************************^ +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:60:5 + #[storage] + ^********^ error: Unsupported attribute. - --> test_src/lib.cairo:21:1 -#[dojo::contract(namespace: "my_namespace")] -^******************************************^ + --> test_src/lib.cairo:60:5 + #[storage] + ^********^ -error: Unsupported attribute. - --> test_src/lib.cairo:21:1 -#[dojo::contract(namespace: "my_namespace")] -^******************************************^ +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:66:5 + component!(path: testcomponent1, storage: testcomponent1_storage, event: testcomponent1_event); + ^*********************************************************************************************^ -error: Unsupported attribute. - --> test_src/lib.cairo:21:1 -#[dojo::contract(namespace: "my_namespace")] -^******************************************^ +error: Unknown inline item macro: 'component'. + --> test_src/lib.cairo:66:5 + component!(path: testcomponent1, storage: testcomponent1_storage, event: testcomponent1_event); + ^*********************************************************************************************^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:67:5 + component!(path: testcomponent2, storage: testcomponent2_storage, event: testcomponent2_event); + ^*********************************************************************************************^ error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo:28:1 -#[dojo::contract] -^***************^ + --> test_src/lib.cairo:67:5 + component!(path: testcomponent2, storage: testcomponent2_storage, event: testcomponent2_event); + ^*********************************************************************************************^ -error: Unsupported attribute. - --> test_src/lib.cairo:28:1 -#[dojo::contract] -^***************^ +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:69:5 + #[storage] + ^********^ error: Unsupported attribute. - --> test_src/lib.cairo:28:1 -#[dojo::contract] -^***************^ + --> test_src/lib.cairo:69:5 + #[storage] + ^********^ error: Unsupported attribute. - --> test_src/lib.cairo:28:1 -#[dojo::contract] -^***************^ + --> test_src/lib.cairo:71:9 + #[substorage(v0)] + ^***************^ error: Unsupported attribute. - --> test_src/lib.cairo:28:1 -#[dojo::contract] -^***************^ + --> test_src/lib.cairo:73:9 + #[substorage(v0)] + ^***************^ error: Unknown derive `starknet::Event` - a plugin might be missing. - --> test_src/lib.cairo:28:1 -#[dojo::contract] -^***************^ + --> test_src/lib.cairo:78:20 + #[derive(Drop, starknet::Event)] + ^*************^ -error: Unsupported attribute. - --> test_src/lib.cairo:28:1 -#[dojo::contract] -^***************^ +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:77:5 + #[event] + ^******^ error: Unsupported attribute. - --> test_src/lib.cairo:28:1 -#[dojo::contract] -^***************^ + --> test_src/lib.cairo:77:5 + #[event] + ^******^ error: Unsupported attribute. - --> test_src/lib.cairo:28:1 -#[dojo::contract] -^***************^ + --> test_src/lib.cairo:80:9 + #[flat] + ^*****^ -error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo:38:1 -#[dojo::contract] -^***************^ +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:76:1 -error: Unsupported attribute. - --> test_src/lib.cairo:38:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:38:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:38:1 -#[dojo::contract] -^***************^ - -error: Unknown derive `starknet::Event` - a plugin might be missing. - --> test_src/lib.cairo:38:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:38:1 -#[dojo::contract] -^***************^ - -error: Unknown derive `starknet::Event` - a plugin might be missing. - --> test_src/lib.cairo:46:20 - #[derive(Drop, starknet::Event)] - ^*************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:38:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> 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:64:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:64:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> 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:66:5 - component!(path: testcomponent1, storage: testcomponent1_storage, event: testcomponent1_event); - ^*********************************************************************************************^ - -error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo:67:5 - component!(path: testcomponent2, storage: testcomponent2_storage, event: testcomponent2_event); - ^*********************************************************************************************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:64:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:64:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:64:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:64:1 -#[dojo::contract] -^***************^ - -error: Unknown derive `starknet::Event` - a plugin might be missing. - --> test_src/lib.cairo:64:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:64:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> 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:124:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:124:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:124:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:124:1 -#[dojo::contract] -^***************^ +^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:126:5 + #[abi(embed_v0)] + ^**************^ error: Unsupported attribute. --> test_src/lib.cairo:126:5 @@ -771,174 +631,54 @@ error: Unsupported attribute. ^**************^ error: Generated trait must have generic args matching the impl's generic params. + --> test_src/lib.cairo:164:29 + impl InternalImplBad of InternalUtils { + ^**************************^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. --> test_src/lib.cairo:163:5 #[generate_trait] ^***************^ -error: Unsupported attribute. - --> test_src/lib.cairo:124:1 -#[dojo::contract] -^***************^ - -error: Unknown derive `starknet::Event` - a plugin might be missing. - --> test_src/lib.cairo:124:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:124:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:124:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:124:1 -#[dojo::contract] -^***************^ - -error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo:171:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:171:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:171:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:171:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:178:5 - #[abi(embed_v0)] - ^**************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:171:1 -#[dojo::contract] -^***************^ - -error: Unknown derive `starknet::Event` - a plugin might be missing. - --> test_src/lib.cairo:171:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:171:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:171:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:171:1 -#[dojo::contract] -^***************^ - -error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo:222:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:222:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:222:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:222:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:222:1 -#[dojo::contract] -^***************^ - -error: Unknown derive `starknet::Event` - a plugin might be missing. - --> test_src/lib.cairo:222:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:222:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:222:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:222:1 -#[dojo::contract] -^***************^ - -error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo:239:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:239:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:239:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:239:1 -#[dojo::contract] -^***************^ - -error: Unsupported attribute. - --> test_src/lib.cairo:239:1 -#[dojo::contract] -^***************^ +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:163:5 + #[generate_trait] + ^***************^ -error: Unknown derive `starknet::Event` - a plugin might be missing. - --> test_src/lib.cairo:239:1 -#[dojo::contract] -^***************^ +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:173:5 + #[derive(Drop)] + ^*************^ -error: Unsupported attribute. - --> test_src/lib.cairo:239:1 -#[dojo::contract] -^***************^ +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:178:5 + #[abi(embed_v0)] + ^**************^ error: Unsupported attribute. - --> test_src/lib.cairo:239:1 -#[dojo::contract] -^***************^ + --> test_src/lib.cairo:178:5 + #[abi(embed_v0)] + ^**************^ -error: Unsupported attribute. - --> test_src/lib.cairo:239:1 -#[dojo::contract] -^***************^ +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:213:5 + #[generate_trait] + ^***************^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:173:1 + #[derive(Drop)] +^*****************^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:213:5 + #[generate_trait] + ^***************^ + +error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> test_src/lib.cairo:224:5 + fn dojo_init( + ^***********^ //! > expanded_cairo_code #[dojo::contract(namespace: "My@Namespace")] @@ -951,585 +691,212 @@ mod bad_namespace_format { } } -#[starknet::component] -mod testcomponent1 { - #[storage] - struct Storage {} -} - -#[starknet::component] -mod testcomponent2 { - #[storage] - struct Storage {} -} - - #[starknet::contract] - mod spawn { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "spawn" - } - - fn namespace(self: @ContractState) -> ByteArray { - "my_namespace" - } - - fn tag(self: @ContractState) -> ByteArray { - "my_namespace-spawn" - } - - fn name_hash(self: @ContractState) -> felt252 { - 2776321589048333240377325502911505147617911439383944762363370901236132332849 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1685136890688416384941629523783652800960468745356230625531475538826800548713 - } - - fn selector(self: @ContractState) -> felt252 { - 927765609926166707747357189894656840364326580388522007560729768978560453318 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - use traits::Into; +#[dojo::contract(namespace: 'my_namespace')] +mod spawn { + use traits::Into; use dojo::world::Context; fn execute(ctx: Context, name: felt252) { return (); } +} - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } - - #[storage] - struct Storage { - world_dispatcher: IWorldDispatcher, - #[substorage(v0)] - upgradeable: dojo::components::upgradeable::upgradeable::Storage, - } -impl EventDrop of core::traits::Drop::; - - } - - #[starknet::contract] - mod proxy { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "proxy" - } - - fn namespace(self: @ContractState) -> ByteArray { - "my_namespace" - } - - fn tag(self: @ContractState) -> ByteArray { - "my_namespace-proxy" - } - - fn name_hash(self: @ContractState) -> felt252 { - 379211399603323842291430789821178524592027629543381998047225121027704003915 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 1685136890688416384941629523783652800960468745356230625531475538826800548713 - } - - fn selector(self: @ContractState) -> felt252 { - 1517897915978631541665409557725081861100844369870047691780983681552158397188 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - fn execute(value: felt252) -> felt252 { +#[dojo::contract(namespace: "my_namespace")] +mod proxy { + fn execute(value: felt252) -> felt252 { value } +} - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } - - #[storage] - struct Storage { - world_dispatcher: IWorldDispatcher, - #[substorage(v0)] - upgradeable: dojo::components::upgradeable::upgradeable::Storage, - } -impl EventDrop of core::traits::Drop::; - - } - - #[starknet::contract] - mod ctxnamed { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "ctxnamed" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_plugin" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_plugin-ctxnamed" - } - - fn name_hash(self: @ContractState) -> felt252 { - 1120614286815912604239420768209466007446460277061516527925636408561239543041 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3437408695301308226171664635441698996501144546809569617702850025816833723775 - } - - fn selector(self: @ContractState) -> felt252 { - 623565658600000333752908975824209395490663664165083881849022643225286426420 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - use traits::Into; +#[dojo::contract] +mod ctxnamed { + use traits::Into; use dojo::world::Context; fn execute(ctx2: Context, name: felt252) { return (); } +} + +#[dojo::contract] +mod withevent { + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + TestEvent: TestEvent, + } - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } - - #[storage] - struct Storage { - world_dispatcher: IWorldDispatcher, - #[substorage(v0)] - upgradeable: dojo::components::upgradeable::upgradeable::Storage, - } -impl EventDrop of core::traits::Drop::; - - } - - #[starknet::contract] - mod withevent { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "withevent" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_plugin" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_plugin-withevent" - } - - fn name_hash(self: @ContractState) -> felt252 { - 2196275886623691942883456540767114081898043897719876113518403014973431884540 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3437408695301308226171664635441698996501144546809569617702850025816833723775 - } - - fn selector(self: @ContractState) -> felt252 { - 2582359560254878564957629514448262994748633755439313237356383717683931939594 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - TestEvent: TestEvent - } - #[derive(Drop, starknet::Event)] struct TestEvent { address: ContractAddress, } - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[storage] - struct Storage { - world_dispatcher: IWorldDispatcher, - #[substorage(v0)] - upgradeable: dojo::components::upgradeable::upgradeable::Storage, - } impl EventDrop of core::traits::Drop::; impl TestEventDrop of core::traits::Drop::; - - } - - #[starknet::contract] - mod withcomponent { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "withcomponent" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_plugin" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_plugin-withcomponent" - } - - fn name_hash(self: @ContractState) -> felt252 { - 999850881662666048155666650426666132968026605763740651763663703103974774091 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3437408695301308226171664635441698996501144546809569617702850025816833723775 - } - - fn selector(self: @ContractState) -> felt252 { - 1893210824839004090894033724660704927789166883140571787032524912616670830055 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - #[storage] - struct Storage { - world_dispatcher: IWorldDispatcher, - #[substorage(v0)] - upgradeable: dojo::components::upgradeable::upgradeable::Storage, - #[substorage(v0)] +} + +#[starknet::component] +mod testcomponent1 { + #[storage] + struct Storage {} +} + +#[starknet::component] +mod testcomponent2 { + #[storage] + struct Storage {} +} + +#[dojo::contract] +mod withcomponent { + + #[storage] + struct Storage { + #[substorage(v0)] testcomponent1_storage: testcomponent1::Storage, #[substorage(v0)] - testcomponent2_storage: testcomponent2::Storage - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - #[flat] + testcomponent2_storage: testcomponent2::Storage, + } + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + #[flat] testcomponent1_event: testcomponent1::Event, - testcomponent2_event: testcomponent2::Event - } - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } + testcomponent2_event: testcomponent2::Event, + } impl EventDrop of core::traits::Drop::; - - } - - #[starknet::interface] - trait IEmptyTrait {} - - #[starknet::interface] - trait IFaultyTrait { - fn do_with_attrs(self: @TContractState, p1: u8) -> u16; - } - - #[starknet::interface] - trait INominalTrait { - fn do_no_param(self: @TContractState) -> felt252;fn do_no_param_but_world(self: @TContractState) -> felt252;fn do_no_param_but_world_ref(ref self: TContractState) -> felt252;fn do_params_no_world(self: @TContractState, p1: felt252, p2: u8) -> felt252;fn do_params_and_world(self: @TContractState, p2: u8) -> felt252;fn do_params_and_world_ref(ref self: TContractState, p2: u8) -> felt252;fn do_with_self(self: @ContractState) -> felt252;fn do_with_ref_self(ref self: ContractState) -> felt252; - } - - #[starknet::interface] - trait IFaultyTrait { - fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252;fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252;fn do_with_self_and_world_inv(self: @TContractState, self: @ContractState) -> felt252;fn do_with_ref_self_and_world_inv(ref self: TContractState, ref self: ContractState -) -> felt252;fn do_with_several_world_dispatchers(self: @TContractState, vec: Vec2, ref another_world: IWorldDispatcher -) -> felt252;fn do_with_world_not_named_world(self: @TContractState, another_world: @IWorldDispatcher) -> felt252;fn do_with_world_not_first(self: @TContractState, vec: Vec2, ref world: IWorldDispatcher) -> felt252; - } - - #[starknet::contract] - mod MyFaultyContract { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "MyFaultyContract" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_plugin" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_plugin-MyFaultyContract" - } - - fn name_hash(self: @ContractState) -> felt252 { - 3439743807865759203015037013733809315384408083697880336790137144257764256358 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3437408695301308226171664635441698996501144546809569617702850025816833723775 - } - - fn selector(self: @ContractState) -> felt252 { - 1974917320104648462406919942169147060276288716394308386802867612090262110929 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - #[abi(embed_v0)] - impl TestFaultyImpl of IFaultyTrait {fn do_with_self_and_world(self: @ContractState) -> felt252 { 'land' -}fn do_with_ref_self_and_world( ref self: ContractState) -> felt252 { 'land' -}fn do_with_self_and_world_inv(self: @ContractState, self: @ContractState) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_with_ref_self_and_world_inv(ref self: ContractState, ref self: ContractState -) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_with_several_world_dispatchers(self: @ContractState, vec: Vec2, ref another_world: IWorldDispatcher -) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_with_world_not_named_world(self: @ContractState, another_world: @IWorldDispatcher) -> felt252 { 'land' -}fn do_with_world_not_first(self: @ContractState, vec: Vec2) -> felt252 { 'land' -}} +} +#[dojo::interface] +trait IEmptyTrait; + +#[dojo::interface] +trait IFaultyTrait { + const ONE: u8; + + #[my_attr] + fn do_with_attrs(p1: u8) -> u16; +} + +#[dojo::interface] +trait INominalTrait { + fn do_no_param() -> felt252; + fn do_no_param_but_world(world: @IWorldDispatcher) -> felt252; + fn do_no_param_but_world_ref(ref world: IWorldDispatcher) -> felt252; + fn do_params_no_world(p1: felt252, p2: u8) -> felt252; + fn do_params_and_world(world: @IWorldDispatcher, p2: u8) -> felt252; + fn do_params_and_world_ref(ref world: IWorldDispatcher, p2: u8) -> felt252; + + fn do_with_self(self: @ContractState) -> felt252; + fn do_with_ref_self(ref self: ContractState) -> felt252; +} + +#[dojo::interface] +trait IFaultyTrait { + fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252; + fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; + fn do_with_self_and_world_inv(world: @IWorldDispatcher, self: @ContractState) -> felt252; + fn do_with_ref_self_and_world_inv( + ref world: IWorldDispatcher, ref self: ContractState + ) -> felt252; + fn do_with_several_world_dispatchers( + world: @IWorldDispatcher, vec: Vec2, ref another_world: IWorldDispatcher + ) -> felt252; + fn do_with_world_not_named_world(another_world: @IWorldDispatcher) -> felt252; + fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252; +} + +#[dojo::contract] +mod MyFaultyContract { + #[abi(embed_v0)] + impl TestFaultyImpl of IFaultyTrait { + fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252 { + 'land' + } + + fn do_with_ref_self_and_world( + ref self: ContractState, ref world: IWorldDispatcher + ) -> felt252 { + 'land' + } + + fn do_with_self_and_world_inv(world: @IWorldDispatcher, self: @ContractState) -> felt252 { + 'land' + } + + fn do_with_ref_self_and_world_inv( + ref world: IWorldDispatcher, ref self: ContractState + ) -> felt252 { + 'land' + } + + fn do_with_several_world_dispatchers( + world: @IWorldDispatcher, vec: Vec2, ref another_world: IWorldDispatcher + ) -> felt252 { + 'land' + } + + fn do_with_world_not_named_world(another_world: @IWorldDispatcher) -> felt252 { + 'land' + } + + fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252 { + 'land' + } + } + #[generate_trait] - impl InternalImplBad of InternalUtils {fn bad_func_using_generate(self: @ContractState) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}} - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } - - #[storage] - struct Storage { - world_dispatcher: IWorldDispatcher, - #[substorage(v0)] - upgradeable: dojo::components::upgradeable::upgradeable::Storage, - } - trait InternalUtils{fn bad_func_using_generate(self: @ContractState) -> felt252; + impl InternalImplBad of InternalUtils { + fn bad_func_using_generate(world: @IWorldDispatcher) -> felt252 { + 'land' + } + } + trait InternalUtils{ + fn bad_func_using_generate(world: @IWorldDispatcher) -> felt252; + } } -impl EventDrop of core::traits::Drop::; - - } - - #[starknet::contract] - mod MyNominalContract { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "MyNominalContract" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_plugin" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_plugin-MyNominalContract" - } - - fn name_hash(self: @ContractState) -> felt252 { - 1172628497499445169993220559087829230676589931723677494032285307738203070578 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3437408695301308226171664635441698996501144546809569617702850025816833723775 - } - - fn selector(self: @ContractState) -> felt252 { - 71500767592493013583062359997839280192942880614138784688801482747283680564 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - #[derive(Drop)] + +#[dojo::contract] +mod MyNominalContract { + #[derive(Drop)] struct Action { damage: u8 } #[abi(embed_v0)] - impl TestNominalImpl of INominalTrait {fn do_no_param(self: @ContractState) -> felt252 { 'land' -}fn do_no_param_but_world(self: @ContractState) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_no_param_but_world_ref(ref self: ContractState) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_params_no_world(self: @ContractState, p1: felt252, p2: u8) -> felt252 { 'land' -}fn do_params_and_world(self: @ContractState, p2: u8) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_params_and_world_ref(ref self: ContractState, p2: u8) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_with_self(self: @ContractState) -> felt252 { 'land' -}fn do_with_ref_self(ref self: ContractState) -> felt252 { 'land' -}} + impl TestNominalImpl of INominalTrait { + fn do_no_param() -> felt252 { + 'land' + } + + fn do_no_param_but_world(world: @IWorldDispatcher) -> felt252 { + 'land' + } + + fn do_no_param_but_world_ref(ref world: IWorldDispatcher) -> felt252 { + 'land' + } + + fn do_params_no_world(p1: felt252, p2: u8) -> felt252 { + 'land' + } + + fn do_params_and_world(world: @IWorldDispatcher, p2: u8) -> felt252 { + 'land' + } + + fn do_params_and_world_ref(ref world: IWorldDispatcher, p2: u8) -> felt252 { + 'land' + } + + fn do_with_self(self: @ContractState) -> felt252 { + 'land' + } + + fn do_with_ref_self(ref self: ContractState) -> felt252 { + 'land' + } + } + #[generate_trait] impl ImplInternalNoContractState of InternalNoContractState { fn func1(world: IWorldDispatcher) -> felt252 { @@ -1537,187 +904,28 @@ impl EventDrop of core::traits::Drop::; 42 } } - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } - - #[storage] - struct Storage { - world_dispatcher: IWorldDispatcher, - #[substorage(v0)] - upgradeable: dojo::components::upgradeable::upgradeable::Storage, - } impl ActionDrop of core::traits::Drop::; trait InternalNoContractState { fn func1(world: IWorldDispatcher) -> felt252; } -impl EventDrop of core::traits::Drop::; - - } - - #[starknet::contract] - mod init_test { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "init_test" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_plugin" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_plugin-init_test" - } - - fn name_hash(self: @ContractState) -> felt252 { - 1673722391095039242574232979635399085098867563460816803458086922970092209409 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3437408695301308226171664635441698996501144546809569617702850025816833723775 - } - - fn selector(self: @ContractState) -> felt252 { - 2312260519337406018659809228867734996705610542881011325166202975638859071009 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -) {let world = self.world_dispatcher.read();assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); emit!( +} + +#[dojo::contract] +mod init_test { + fn dojo_init( + world: IWorldDispatcher, + actions_address: ContractAddress, + actions_class: ClassHash, + value: u8 + ) { + emit!( world, ContractInitialized { contract_address: actions_address, contract_class: actions_class, value } ); + } } -} - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } - - #[storage] - struct Storage { - world_dispatcher: IWorldDispatcher, - #[substorage(v0)] - upgradeable: dojo::components::upgradeable::upgradeable::Storage, - } -impl EventDrop of core::traits::Drop::; - - } - - #[starknet::contract] - mod no_init_test { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "no_init_test" - } - - fn namespace(self: @ContractState) -> ByteArray { - "dojo_plugin" - } - - fn tag(self: @ContractState) -> ByteArray { - "dojo_plugin-no_init_test" - } - - fn name_hash(self: @ContractState) -> felt252 { - 2188407785440294979090510634648735461326850740369373015349552249835679156474 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3437408695301308226171664635441698996501144546809569617702850025816833723775 - } - - fn selector(self: @ContractState) -> felt252 { - 1995220858231254863157765882916485903598645700674102689896181167500490584020 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } - - #[storage] - struct Storage { - world_dispatcher: IWorldDispatcher, - #[substorage(v0)] - upgradeable: dojo::components::upgradeable::upgradeable::Storage, - } -impl EventDrop of core::traits::Drop::; - - } + +#[dojo::contract] +mod no_init_test {} diff --git a/crates/dojo-lang/src/semantics/test_data/get b/crates/dojo-lang/src/semantics/test_data/get index 5f90c0d359..355d7f40c1 100644 --- a/crates/dojo-lang/src/semantics/test_data/get +++ b/crates/dojo-lang/src/semantics/test_data/get @@ -29,6 +29,41 @@ Missing( ) //! > semantic_diagnostics +error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> lib.cairo:1:1 +use array::ArrayTrait; +^********************^ + +error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> lib.cairo:2:1 +use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; +^*********************************************************^ + +error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> lib.cairo:4:1 +#[derive(Copy, Drop, Serde, Introspect)] +^**************************************^ + +error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> lib.cairo:10:1 +fn test_func() { let key: felt252 = 0xb0b; +^****************************************^ + +error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> lib.cairo:3:1 + +^ + +error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> lib.cairo:3:1 + +^ + +error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> lib.cairo:3:1 + +^ + error: Plugin diagnostic: Invalid arguments. Expected "get!(world, keys, (models,))" --> lib.cairo:12:1 get!() @@ -77,6 +112,41 @@ Missing( ) //! > semantic_diagnostics +error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> lib.cairo:1:1 +use array::ArrayTrait; +^********************^ + +error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> lib.cairo:2:1 +use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; +^*********************************************************^ + +error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> lib.cairo:4:1 +#[derive(Copy, Drop, Serde, Introspect)] +^**************************************^ + +error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> lib.cairo:10:1 +fn test_func() { let key: felt252 = 0xb0b; +^****************************************^ + +error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> lib.cairo:3:1 + +^ + +error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> lib.cairo:3:1 + +^ + +error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> lib.cairo:3:1 + +^ + error: Plugin diagnostic: Invalid arguments. Expected "get!(world, keys, (models,))" --> lib.cairo:12:1 get!(world) @@ -251,6 +321,41 @@ Block( ) //! > semantic_diagnostics +error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> lib.cairo:1:1 +use array::ArrayTrait; +^********************^ + +error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> lib.cairo:2:1 +use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; +^*********************************************************^ + +error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> lib.cairo:4:1 +#[derive(Copy, Drop, Serde, Introspect)] +^**************************************^ + +error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> lib.cairo:10:1 +fn test_func() { let key: felt252 = 0xb0b; +^****************************************^ + +error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> lib.cairo:3:1 + +^ + +error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> lib.cairo:3:1 + +^ + +error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> lib.cairo:3:1 + +^ + error: Trait has no implementation in context: dojo::model::Model::. --> lib.cairo:12:1 get!(world, key, (Health)) diff --git a/crates/dojo-lang/src/semantics/test_data/set b/crates/dojo-lang/src/semantics/test_data/set index d41133d396..e9b415c178 100644 --- a/crates/dojo-lang/src/semantics/test_data/set +++ b/crates/dojo-lang/src/semantics/test_data/set @@ -18,6 +18,11 @@ Missing( ) //! > semantic_diagnostics +error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> lib.cairo:1:1 +fn test_func() { { +^*****************^ + error: Plugin diagnostic: Invalid arguments. Expected "(world, (models,))" --> lib.cairo:2:6 set!() @@ -45,6 +50,11 @@ Missing( ) //! > semantic_diagnostics +error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> lib.cairo:1:1 +fn test_func() { { +^*****************^ + error: Plugin diagnostic: Invalid arguments. Expected "(world, (models,))" --> lib.cairo:2:6 set!(world) @@ -224,11 +234,41 @@ Block( ) //! > semantic_diagnostics +error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> lib.cairo:1:1 +use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; +^*********************************************************^ + error: Plugin diagnostic: Unknown derive `Model` - a plugin might be missing. --> lib.cairo:3:29 #[derive(Copy, Drop, Serde, Model)] ^***^ +error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> lib.cairo:3:1 +#[derive(Copy, Drop, Serde, Model)] +^*********************************^ + +error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> lib.cairo:9:1 +fn test_func() { let key: felt252 = 0xb0b; +^****************************************^ + +error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> lib.cairo:2:1 + +^ + +error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> lib.cairo:2:1 + +^ + +error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. + --> lib.cairo:2:1 + +^ + warning[E0001]: Unused variable. Consider ignoring by prefixing with `_`. --> lib.cairo:9:22 fn test_func() { let key: felt252 = 0xb0b; diff --git a/crates/dojo-test-utils/src/compiler.rs b/crates/dojo-test-utils/src/compiler.rs index 91352fe6f5..c91d44fb13 100644 --- a/crates/dojo-test-utils/src/compiler.rs +++ b/crates/dojo-test-utils/src/compiler.rs @@ -1,3 +1,4 @@ +use std::collections::HashMap; use std::fs::File; use std::io::Read; use std::path::PathBuf; @@ -15,6 +16,58 @@ use scarb::ops::{CompileOpts, FeaturesOpts, FeaturesSelector}; use scarb_ui::Verbosity; use toml::{Table, Value}; +#[derive(Debug)] +pub struct CompilerTestSetup { + pub dir: Utf8PathBuf, + pub dojo_core: Utf8PathBuf, + pub manifests: HashMap, +} + +impl CompilerTestSetup { + pub fn from_examples(dojo_core: &str, example_path: &str) -> CompilerTestSetup { + let example_path = Utf8PathBuf::from(example_path); + + let packages: Vec = + vec![example_path.join("spawn-and-move"), example_path.join("game-lib")]; + + let package_refs: Vec<&str> = packages.iter().map(|p| p.as_str()).collect(); + + Self::from_paths(dojo_core, &package_refs) + } + + pub fn from_paths(dojo_core: &str, packages: &[&str]) -> CompilerTestSetup { + let dojo_core = Utf8PathBuf::from(dojo_core); + let packages: Vec = packages.iter().map(Utf8PathBuf::from).collect(); + + let tmp_dir = Utf8PathBuf::from( + assert_fs::TempDir::new().unwrap().to_path_buf().to_string_lossy().to_string(), + ); + + let mut manifests = HashMap::new(); + + for package_source in &packages { + let package_name = package_source.file_name().unwrap(); + let package_tmp = tmp_dir.join(package_name); + fs::create_dir_all(&package_tmp).unwrap(); + + let package_manifest = package_tmp.join("Scarb.toml"); + + manifests.insert(package_name.to_string(), package_manifest); + + copy_project_temp(package_source, &package_tmp, &dojo_core, &[]).unwrap(); + } + + CompilerTestSetup { dir: tmp_dir, dojo_core, manifests } + } + + pub fn build_test_config(&self, package_name: &str, profile: Profile) -> Config { + let manifest = self.manifests.get(package_name).unwrap(); + + build_test_config(manifest.as_ref(), profile) + .unwrap_or_else(|c| panic!("Error loading config: {c:?}")) + } +} + /// Copies a project into a temporary directory and loads a config from the copied project. /// /// # Returns @@ -120,11 +173,11 @@ pub fn copy_project_temp( if path.is_dir() { let dir_name = match entry.file_name().into_string() { Ok(name) => name, - Err(_) => continue, // Skip directories/files with non-UTF8 names + Err(_) => continue, // Skip non UTF8 dirs. }; if ignore_dirs.contains(&dir_name.as_str()) { - continue; // Skip ignored directories + continue; } copy_project_temp( @@ -149,7 +202,11 @@ pub fn copy_project_temp( let mut table = contents.parse::().expect("Failed to parse Scab.toml"); - let dojo = table["dependencies"]["dojo"].as_table_mut().unwrap(); + let dojo = if table.contains_key("workspace") { + table["workspace"]["dependencies"]["dojo"].as_table_mut().unwrap() + } else { + table["dependencies"]["dojo"].as_table_mut().unwrap() + }; if dojo.contains_key("path") { dojo["path"] = Value::String( @@ -176,6 +233,7 @@ pub fn copy_project_temp( /// # Arguments /// /// * `path` - The path to the Scarb.toml file to build the config for. +/// * `profile` - The profile to use for the config. pub fn build_test_config(path: &str, profile: Profile) -> anyhow::Result { let mut compilers = CompilerRepository::empty(); compilers.add(Box::new(DojoCompiler)).unwrap(); diff --git a/crates/dojo-world/src/contracts/model_test.rs b/crates/dojo-world/src/contracts/model_test.rs index 3277deb1ef..1ccf2a0833 100644 --- a/crates/dojo-world/src/contracts/model_test.rs +++ b/crates/dojo-world/src/contracts/model_test.rs @@ -1,5 +1,4 @@ -use camino::Utf8PathBuf; -use dojo_test_utils::compiler; +use dojo_test_utils::compiler::CompilerTestSetup; use dojo_types::primitive::Primitive; use dojo_types::schema::{Enum, EnumOption, Member, Struct, Ty}; use katana_runner::KatanaRunner; @@ -18,11 +17,8 @@ async fn test_model() { let account = runner.account(0); let provider = account.provider(); - let config = compiler::copy_tmp_config( - &Utf8PathBuf::from("../../examples/spawn-and-move"), - &Utf8PathBuf::from("../dojo-core"), - Profile::DEV, - ); + let setup = CompilerTestSetup::from_examples("../dojo-core", "../../examples/"); + let config = setup.build_test_config("spawn-and-move", Profile::DEV); let manifest_dir = config.manifest_path().parent().unwrap(); let target_dir = manifest_dir.join("target").join("dev"); diff --git a/crates/dojo-world/src/contracts/world_test.rs b/crates/dojo-world/src/contracts/world_test.rs index 387ab779f6..b81584b97a 100644 --- a/crates/dojo-world/src/contracts/world_test.rs +++ b/crates/dojo-world/src/contracts/world_test.rs @@ -1,7 +1,7 @@ use std::time::Duration; use camino::Utf8PathBuf; -use dojo_test_utils::compiler; +use dojo_test_utils::compiler::CompilerTestSetup; use katana_runner::KatanaRunner; use scarb::compiler::Profile; use starknet::accounts::{Account, ConnectedAccount}; @@ -18,11 +18,10 @@ use crate::utils::TransactionExt; #[tokio::test(flavor = "multi_thread")] async fn test_world_contract_reader() { let runner = KatanaRunner::new().expect("Fail to set runner"); - let config = compiler::copy_tmp_config( - &Utf8PathBuf::from("../../examples/spawn-and-move"), - &Utf8PathBuf::from("../dojo-core"), - Profile::DEV, - ); + + let setup = CompilerTestSetup::from_examples("../dojo-core", "../../examples/"); + let config = setup.build_test_config("spawn-and-move", Profile::DEV); + let ws = scarb::ops::read_workspace(config.manifest_path(), &config).unwrap(); let default_namespace = ws.current_package().unwrap().id.name.to_string(); diff --git a/crates/dojo-world/src/manifest/manifest_test.rs b/crates/dojo-world/src/manifest/manifest_test.rs index d6a0aa4e11..f59b85063a 100644 --- a/crates/dojo-world/src/manifest/manifest_test.rs +++ b/crates/dojo-world/src/manifest/manifest_test.rs @@ -2,7 +2,7 @@ use std::io::Write; use cainome::cairo_serde::{ByteArray, CairoSerde}; use camino::Utf8PathBuf; -use dojo_test_utils::compiler; +use dojo_test_utils::compiler::CompilerTestSetup; use dojo_test_utils::rpc::MockJsonRpcTransport; use katana_runner::KatanaRunner; use scarb::compiler::Profile; @@ -304,18 +304,15 @@ fn fetch_remote_manifest() { let account = runner.account(0); let provider = account.provider(); - let source_project = "../../examples/spawn-and-move/Scarb.toml"; - let dojo_core_path = "../dojo-core"; - let profile_name = "dev"; - - // Build a completely new project in it's own directory. - let (temp_project_dir, config, _) = - compiler::copy_build_project_temp(source_project, dojo_core_path, true, Profile::DEV); + let setup = CompilerTestSetup::from_examples("../dojo-core", "../../examples/"); + let config = setup.build_test_config("spawn-and-move", Profile::DEV); + let profile_name = Profile::DEV.to_string(); let ws = scarb::ops::read_workspace(config.manifest_path(), &config).unwrap(); let dojo_metadata = dojo_metadata_from_workspace(&ws).expect("No current package with dojo metadata found."); + let temp_project_dir = config.manifest_path().parent().unwrap(); let artifacts_path = temp_project_dir.join(format!("target/{profile_name}")); let default_namespace = ws.current_package().unwrap().id.name.to_string(); @@ -323,8 +320,8 @@ fn fetch_remote_manifest() { let world_address = config.tokio_handle().block_on(async { deploy_world( &runner, - &temp_project_dir, - &artifacts_path, + &temp_project_dir.to_path_buf(), + &artifacts_path.to_path_buf(), dojo_metadata.skip_migration.clone(), &default_namespace, ) @@ -332,7 +329,7 @@ fn fetch_remote_manifest() { }); let mut local_manifest = BaseManifest::load_from_path( - &temp_project_dir.join(MANIFESTS_DIR).join(profile_name).join(BASE_DIR), + &temp_project_dir.join(MANIFESTS_DIR).join(&profile_name).join(BASE_DIR), ) .unwrap(); @@ -340,7 +337,7 @@ fn fetch_remote_manifest() { local_manifest.remove_tags(skip_manifests); } - let overlay_dir = temp_project_dir.join(OVERLAYS_DIR).join(profile_name); + let overlay_dir = temp_project_dir.join(OVERLAYS_DIR).join(&profile_name); if overlay_dir.exists() { let overlay_manifest = OverlayManifest::load_from_path(&overlay_dir, &local_manifest).unwrap(); @@ -352,10 +349,10 @@ fn fetch_remote_manifest() { DeploymentManifest::load_from_remote(provider, world_address).await.unwrap() }); - assert_eq!(local_manifest.models.len(), 8); + assert_eq!(local_manifest.models.len(), 10); assert_eq!(local_manifest.contracts.len(), 4); - assert_eq!(remote_manifest.models.len(), 8); + assert_eq!(remote_manifest.models.len(), 10); assert_eq!(remote_manifest.contracts.len(), 4); // compute diff from local and remote manifest diff --git a/crates/sozo/ops/src/migration/mod.rs b/crates/sozo/ops/src/migration/mod.rs index 107e6bef03..fc420d8b76 100644 --- a/crates/sozo/ops/src/migration/mod.rs +++ b/crates/sozo/ops/src/migration/mod.rs @@ -54,7 +54,7 @@ pub async fn migrate( dry_run: bool, txn_config: TxnConfig, skip_manifests: Option>, -) -> Result<()> +) -> Result> where A: ConnectedAccount + Sync + Send, A::Provider: Send, @@ -116,7 +116,7 @@ where if total_diffs == 0 { ui.print("\n✨ No changes to be made. Remote World is already up to date!"); - return Ok(()); + return Ok(None); } let mut strategy = prepare_migration(&target_dir, diff, name, world_address, &ui)?; @@ -137,6 +137,8 @@ where name, ) .await?; + + Ok(None) } else { // Migrate according to the diff. let migration_output = match apply_diff(ws, &account, txn_config, &mut strategy).await { @@ -171,13 +173,13 @@ where let account = Arc::new(account); let world = WorldContract::new(world_address, account.clone()); - if let Some(migration_output) = migration_output { + if let Some(migration_output) = &migration_output { match auto_authorize( ws, &world, &txn_config, &local_manifest, - &migration_output, + migration_output, &default_namespace, ) .await @@ -195,9 +197,9 @@ where upload_metadata(ws, &account, migration_output.clone(), txn_config).await?; } } - }; - Ok(()) + Ok(migration_output) + } } fn get_world_address( diff --git a/crates/sozo/ops/src/tests/setup.rs b/crates/sozo/ops/src/tests/setup.rs index 664ff5e858..06d8f8a779 100644 --- a/crates/sozo/ops/src/tests/setup.rs +++ b/crates/sozo/ops/src/tests/setup.rs @@ -1,6 +1,5 @@ use anyhow::Result; -use camino::Utf8PathBuf; -use dojo_test_utils::compiler; +use dojo_test_utils::compiler::CompilerTestSetup; use dojo_test_utils::migration::prepare_migration_with_world_and_seed; use dojo_world::contracts::world::WorldContract; use dojo_world::metadata::get_default_namespace_from_ws; @@ -28,12 +27,8 @@ use crate::migration; /// /// A [`Config`] object loaded from the spawn-and-moves Scarb.toml file. pub fn load_config() -> Config { - // To avoid race conditions with other tests, all the project files - // are copied to ensure safe parallel execution. - let source_project_dir = Utf8PathBuf::from("../../../examples/spawn-and-move/"); - let dojo_core_path = Utf8PathBuf::from("../../dojo-core"); - - compiler::copy_tmp_config(&source_project_dir, &dojo_core_path, Profile::DEV) + let setup = CompilerTestSetup::from_examples("../../dojo-core", "../../../examples/"); + setup.build_test_config("spawn-and-move", Profile::DEV) } /// Setups the workspace for the spawn-and-moves project. diff --git a/crates/torii/core/src/sql_test.rs b/crates/torii/core/src/sql_test.rs index 480a06e6ce..757e63e367 100644 --- a/crates/torii/core/src/sql_test.rs +++ b/crates/torii/core/src/sql_test.rs @@ -1,23 +1,18 @@ use std::str::FromStr; -use camino::Utf8PathBuf; -use dojo_test_utils::compiler; -use dojo_test_utils::migration::prepare_migration; +use dojo_test_utils::compiler::CompilerTestSetup; use dojo_world::contracts::naming::compute_selector_from_names; use dojo_world::contracts::world::WorldContractReader; -use dojo_world::metadata::{dojo_metadata_from_workspace, get_default_namespace_from_ws}; use dojo_world::migration::TxnConfig; use dojo_world::utils::{TransactionExt, TransactionWaiter}; use katana_runner::KatanaRunner; use scarb::compiler::Profile; -use scarb::ops; -use sozo_ops::migration::execute_strategy; +use sozo_ops::migration; use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions}; -use starknet::accounts::{Account, Call}; -use starknet::core::types::{BlockId, BlockTag, Felt}; +use starknet::accounts::{Account, Call, ConnectedAccount}; +use starknet::core::types::Felt; use starknet::core::utils::get_selector_from_name; -use starknet::providers::jsonrpc::HttpTransport; -use starknet::providers::{JsonRpcClient, Provider}; +use starknet::providers::Provider; use starknet_crypto::poseidon_hash_many; use tokio::sync::broadcast; @@ -64,50 +59,31 @@ async fn test_load_from_remote() { SqliteConnectOptions::from_str("sqlite::memory:").unwrap().create_if_missing(true); let pool = SqlitePoolOptions::new().max_connections(5).connect_with(options).await.unwrap(); sqlx::migrate!("../migrations").run(&pool).await.unwrap(); - let source_project_dir = Utf8PathBuf::from("../../../examples/spawn-and-move/"); - let dojo_core_path = Utf8PathBuf::from("../../dojo-core"); - let config = compiler::copy_tmp_config(&source_project_dir, &dojo_core_path, Profile::DEV); - let ws = scarb::ops::read_workspace(config.manifest_path(), &config).unwrap(); - let dojo_metadata = - dojo_metadata_from_workspace(&ws).expect("No current package with dojo metadata found."); + let setup = CompilerTestSetup::from_examples("../../dojo-core", "../../../examples/"); + let config = setup.build_test_config("spawn-and-move", Profile::DEV); - let manifest_path = config.manifest_path(); - let base_dir = manifest_path.parent().unwrap(); - let target_dir = format!("{}/target/dev", base_dir); + let ws = scarb::ops::read_workspace(config.manifest_path(), &config).unwrap(); - let default_namespace = get_default_namespace_from_ws(&ws).unwrap(); + let sequencer = KatanaRunner::new().expect("Failed to start runner."); + let account = sequencer.account(0); - let mut migration = prepare_migration( - base_dir.into(), - target_dir.into(), - dojo_metadata.skip_migration, - &default_namespace, + let migration_output = migration::migrate( + &ws, + None, + sequencer.url().to_string(), + &account, + "dojo_examples", + false, + TxnConfig::init_wait(), + None, ) + .await + .unwrap() .unwrap(); - migration.resolve_variable(migration.world_address().unwrap()).unwrap(); - - let sequencer = KatanaRunner::new().expect("Failed to start runner."); - - let provider = JsonRpcClient::new(HttpTransport::new(sequencer.url())); - - let world = WorldContractReader::new(migration.world_address().unwrap(), &provider); - - let mut account = sequencer.account(0); - account.set_block_id(BlockId::Tag(BlockTag::Pending)); - - let ws = ops::read_workspace(config.manifest_path(), &config) - .unwrap_or_else(|op| panic!("Error building workspace: {op:?}")); - - let migration_output = - execute_strategy(&ws, &migration, &account, TxnConfig::init_wait()).await.unwrap(); - - let world_address = migration_output.world_address; - - assert!(migration.world_address().unwrap() == world_address); // spawn - let tx = account + let tx = &account .execute_v1(vec![Call { to: migration_output .contracts @@ -123,14 +99,16 @@ async fn test_load_from_remote() { .await .unwrap(); - TransactionWaiter::new(tx.transaction_hash, &provider).await.unwrap(); + TransactionWaiter::new(tx.transaction_hash, &account.provider()).await.unwrap(); + let world_address = migration_output.world_address; + let world = WorldContractReader::new(world_address, account.provider()); let mut db = Sql::new(pool.clone(), world_address).await.unwrap(); - let _ = bootstrap_engine(world, db.clone(), &provider).await; + let _ = bootstrap_engine(world, db.clone(), account.provider()).await; let _block_timestamp = 1710754478_u64; let models = sqlx::query("SELECT * FROM models").fetch_all(&pool).await.unwrap(); - assert_eq!(models.len(), 8); + assert_eq!(models.len(), 10); let (id, name, namespace, packed_size, unpacked_size): (String, String, String, u8, u8) = sqlx::query_as( @@ -203,49 +181,28 @@ async fn test_load_from_remote_del() { let pool = SqlitePoolOptions::new().max_connections(5).connect_with(options).await.unwrap(); sqlx::migrate!("../migrations").run(&pool).await.unwrap(); - let source_project_dir = Utf8PathBuf::from("../../../examples/spawn-and-move/"); - let dojo_core_path = Utf8PathBuf::from("../../dojo-core"); + let setup = CompilerTestSetup::from_examples("../../dojo-core", "../../../examples/"); + let config = setup.build_test_config("spawn-and-move", Profile::DEV); - let config = compiler::copy_tmp_config(&source_project_dir, &dojo_core_path, Profile::DEV); let ws = scarb::ops::read_workspace(config.manifest_path(), &config).unwrap(); - let dojo_metadata = - dojo_metadata_from_workspace(&ws).expect("No current package with dojo metadata found."); - let manifest_path = config.manifest_path(); - let base_dir = manifest_path.parent().unwrap(); - let target_dir = format!("{}/target/dev", base_dir); - - let default_namespace = get_default_namespace_from_ws(&ws).unwrap(); + let sequencer = KatanaRunner::new().expect("Failed to start runner."); + let account = sequencer.account(0); - let mut migration = prepare_migration( - base_dir.into(), - target_dir.into(), - dojo_metadata.skip_migration, - &default_namespace, + let migration_output = migration::migrate( + &ws, + None, + sequencer.url().to_string(), + &account, + "dojo_examples", + false, + TxnConfig::init_wait(), + None, ) + .await + .unwrap() .unwrap(); - migration.resolve_variable(migration.world_address().unwrap()).unwrap(); - - let sequencer = KatanaRunner::new().expect("Failed to start runner."); - - let provider = JsonRpcClient::new(HttpTransport::new(sequencer.url())); - - let world = WorldContractReader::new(migration.world_address().unwrap(), &provider); - - let mut account = sequencer.account(0); - account.set_block_id(BlockId::Tag(BlockTag::Pending)); - - let ws = ops::read_workspace(config.manifest_path(), &config) - .unwrap_or_else(|op| panic!("Error building workspace: {op:?}")); - - let migration_output = - execute_strategy(&ws, &migration, &account, TxnConfig::init_wait()).await.unwrap(); - - let world_address = migration_output.world_address; - - assert!(migration.world_address().unwrap() == world_address); - // spawn account .execute_v1(vec![Call { @@ -303,8 +260,10 @@ async fn test_load_from_remote_del() { tokio::time::sleep(tokio::time::Duration::from_secs(1)).await; + let world_address = migration_output.world_address; let mut db = Sql::new(pool.clone(), world_address).await.unwrap(); - let _ = bootstrap_engine(world, db.clone(), &provider).await; + let world = WorldContractReader::new(world_address, account.provider()); + let _ = bootstrap_engine(world, db.clone(), account.provider()).await; assert_eq!(count_table("dojo_examples-PlayerConfig", &pool).await, 0); assert_eq!(count_table("dojo_examples-PlayerConfig$favorite_item", &pool).await, 0); diff --git a/crates/torii/graphql/src/tests/mod.rs b/crates/torii/graphql/src/tests/mod.rs index 8bfba50696..c6ccd3c7e6 100644 --- a/crates/torii/graphql/src/tests/mod.rs +++ b/crates/torii/graphql/src/tests/mod.rs @@ -2,29 +2,23 @@ use std::str::FromStr; use anyhow::Result; use async_graphql::dynamic::Schema; -use camino::Utf8PathBuf; -use dojo_test_utils::compiler; -use dojo_test_utils::migration::prepare_migration; +use dojo_test_utils::compiler::CompilerTestSetup; use dojo_types::primitive::Primitive; use dojo_types::schema::{Enum, EnumOption, Member, Struct, Ty}; use dojo_world::contracts::abi::model::Layout; use dojo_world::contracts::WorldContractReader; -use dojo_world::metadata::{dojo_metadata_from_workspace, get_default_namespace_from_ws}; use dojo_world::migration::TxnConfig; use dojo_world::utils::TransactionWaiter; use katana_runner::KatanaRunner; use scarb::compiler::Profile; -use scarb::ops; use serde::Deserialize; use serde_json::Value; -use sozo_ops::migration::execute_strategy; +use sozo_ops::migration; use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions}; use sqlx::SqlitePool; -use starknet::accounts::{Account, Call}; +use starknet::accounts::{Account, Call, ConnectedAccount}; use starknet::core::types::{Felt, InvokeTransactionResult}; use starknet::macros::selector; -use starknet::providers::jsonrpc::HttpTransport; -use starknet::providers::JsonRpcClient; use tokio::sync::broadcast; use tokio_stream::StreamExt; use torii_core::engine::{Engine, EngineConfig, Processors}; @@ -279,44 +273,30 @@ pub async fn spinup_types_test() -> Result { let pool = SqlitePoolOptions::new().max_connections(5).connect_with(options).await.unwrap(); sqlx::migrate!("../migrations").run(&pool).await.unwrap(); - let source_project_dir = Utf8PathBuf::from("../types-test"); - let dojo_core_path = Utf8PathBuf::from("../../dojo-core"); + let setup = CompilerTestSetup::from_paths("../../dojo-core", &["../types-test"]); + let config = setup.build_test_config("types-test", Profile::DEV); - let config = compiler::copy_tmp_config(&source_project_dir, &dojo_core_path, Profile::DEV); - - let ws = ops::read_workspace(config.manifest_path(), &config) - .unwrap_or_else(|op| panic!("Error building workspace: {op:?}")); - let dojo_metadata = - 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 default_namespace = get_default_namespace_from_ws(&ws).unwrap(); - - let mut migration = prepare_migration( - source_project_dir, - target_path, - dojo_metadata.skip_migration, - &default_namespace, - ) - .unwrap(); - - migration.resolve_variable(migration.world.clone().unwrap().contract_address).unwrap(); - - let db = Sql::new(pool.clone(), migration.world_address().unwrap()).await.unwrap(); + let ws = scarb::ops::read_workspace(config.manifest_path(), &config).unwrap(); let sequencer = KatanaRunner::new().expect("Failed to start runner."); - let account = sequencer.account(0); - let provider = JsonRpcClient::new(HttpTransport::new(sequencer.url())); - - let world = WorldContractReader::new(migration.world_address().unwrap(), &provider); - - let output = execute_strategy(&ws, &migration, &account, TxnConfig::init_wait()).await.unwrap(); + let migration_output = migration::migrate( + &ws, + None, + sequencer.url().to_string(), + &account, + "types_test", + false, + TxnConfig::init_wait(), + None, + ) + .await + .unwrap() + .unwrap(); // Execute `create` and insert 11 records into storage - let records_contract = output + let records_contract = migration_output .contracts .iter() .find(|contract| contract.as_ref().unwrap().tag.eq("types_test-records")) @@ -334,7 +314,7 @@ pub async fn spinup_types_test() -> Result { .await .unwrap(); - TransactionWaiter::new(transaction_hash, &provider).await?; + TransactionWaiter::new(transaction_hash, &account.provider()).await?; // Execute `delete` and delete Record with id 20 let InvokeTransactionResult { transaction_hash } = account @@ -347,13 +327,17 @@ pub async fn spinup_types_test() -> Result { .await .unwrap(); - TransactionWaiter::new(transaction_hash, &provider).await?; + TransactionWaiter::new(transaction_hash, &account.provider()).await?; + + let world = WorldContractReader::new(migration_output.world_address, account.provider()); + + let db = Sql::new(pool.clone(), migration_output.world_address).await.unwrap(); let (shutdown_tx, _) = broadcast::channel(1); let mut engine = Engine::new( world, db, - &provider, + account.provider(), Processors { event: vec![ Box::new(RegisterModelProcessor), diff --git a/crates/torii/grpc/src/server/tests/entities_test.rs b/crates/torii/grpc/src/server/tests/entities_test.rs index 205fda416e..0060694703 100644 --- a/crates/torii/grpc/src/server/tests/entities_test.rs +++ b/crates/torii/grpc/src/server/tests/entities_test.rs @@ -1,8 +1,7 @@ use std::str::FromStr; use std::sync::Arc; -use camino::Utf8PathBuf; -use dojo_test_utils::compiler; +use dojo_test_utils::compiler::CompilerTestSetup; use dojo_test_utils::migration::prepare_migration; use dojo_world::contracts::WorldContractReader; use dojo_world::metadata::{dojo_metadata_from_workspace, get_default_namespace_from_ws}; @@ -37,11 +36,8 @@ async fn test_entities_queries() { let pool = SqlitePoolOptions::new().max_connections(5).connect_with(options).await.unwrap(); sqlx::migrate!("../migrations").run(&pool).await.unwrap(); - let source_project_dir = Utf8PathBuf::from("../../../examples/spawn-and-move"); - let dojo_core_path = Utf8PathBuf::from("../../dojo-core"); - - let config = compiler::copy_tmp_config(&source_project_dir, &dojo_core_path, Profile::DEV); - println!("config path {:?}", config.manifest_path()); + let setup = CompilerTestSetup::from_examples("../../dojo-core", "../../../examples/"); + let config = setup.build_test_config("spawn-and-move", Profile::DEV); let ws = ops::read_workspace(config.manifest_path(), &config) .unwrap_or_else(|op| panic!("Error building workspace: {op:?}")); diff --git a/examples/game-lib/Scarb.lock b/examples/game-lib/Scarb.lock new file mode 100644 index 0000000000..7890aa7ddd --- /dev/null +++ b/examples/game-lib/Scarb.lock @@ -0,0 +1,28 @@ +# Code generated by scarb DO NOT EDIT. +version = 1 + +[[package]] +name = "armory" +version = "0.1.0" +dependencies = [ + "dojo", +] + +[[package]] +name = "bestiary" +version = "0.1.0" +dependencies = [ + "dojo", +] + +[[package]] +name = "dojo" +version = "0.7.3" +dependencies = [ + "dojo_plugin", +] + +[[package]] +name = "dojo_plugin" +version = "0.7.2" +source = "git+https://github.com/dojoengine/dojo?tag=v0.7.3#e8539d5b199efbd51c89c75da32f6592de5d9262" diff --git a/examples/game-lib/Scarb.toml b/examples/game-lib/Scarb.toml new file mode 100644 index 0000000000..268b6a52f2 --- /dev/null +++ b/examples/game-lib/Scarb.toml @@ -0,0 +1,12 @@ +[workspace] +members = [ + "armory", + "bestiary" +] + +[workspace.package] +version = "0.1.0" +description = "Example game library for Dojo" + +[workspace.dependencies] +dojo = { path = "../../crates/dojo-core/" } diff --git a/examples/game-lib/armory/Scarb.lock b/examples/game-lib/armory/Scarb.lock new file mode 100644 index 0000000000..39069b13fb --- /dev/null +++ b/examples/game-lib/armory/Scarb.lock @@ -0,0 +1,21 @@ +# Code generated by scarb DO NOT EDIT. +version = 1 + +[[package]] +name = "armory" +version = "0.7.3" +dependencies = [ + "dojo", +] + +[[package]] +name = "dojo" +version = "0.7.3" +dependencies = [ + "dojo_plugin", +] + +[[package]] +name = "dojo_plugin" +version = "0.7.2" +source = "git+https://github.com/dojoengine/dojo?tag=v0.7.3#e8539d5b199efbd51c89c75da32f6592de5d9262" diff --git a/examples/game-lib/armory/Scarb.toml b/examples/game-lib/armory/Scarb.toml new file mode 100644 index 0000000000..68d819791f --- /dev/null +++ b/examples/game-lib/armory/Scarb.toml @@ -0,0 +1,16 @@ +[package] +name = "armory" +version = "0.1.0" +description = "An armory of epic weapons." + +[dependencies] +dojo.workspace = true + +[lib] + +[[target.dojo]] + +[tool.dojo.world] +name = "armory" +seed = "armory" +namespace = "armory" diff --git a/examples/game-lib/armory/manifests/dev/base/abis/dojo-base.json b/examples/game-lib/armory/manifests/dev/base/abis/dojo-base.json new file mode 100644 index 0000000000..ee9ceaac66 --- /dev/null +++ b/examples/game-lib/armory/manifests/dev/base/abis/dojo-base.json @@ -0,0 +1,98 @@ +[ + { + "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": "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": "constructor", + "name": "constructor", + "inputs": [] + }, + { + "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::base::base::Event", + "kind": "enum", + "variants": [ + { + "name": "UpgradeableEvent", + "type": "dojo::components::upgradeable::upgradeable::Event", + "kind": "flat" + } + ] + } +] \ No newline at end of file diff --git a/examples/game-lib/armory/manifests/dev/base/abis/dojo-world.json b/examples/game-lib/armory/manifests/dev/base/abis/dojo-world.json new file mode 100644 index 0000000000..0e5e96210e --- /dev/null +++ b/examples/game-lib/armory/manifests/dev/base/abis/dojo-world.json @@ -0,0 +1,1105 @@ +[ + { + "type": "impl", + "name": "World", + "interface_name": "dojo::world::IWorld" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "struct", + "name": "dojo::resource_metadata::ResourceMetadata", + "members": [ + { + "name": "resource_id", + "type": "core::felt252" + }, + { + "name": "metadata_uri", + "type": "core::byte_array::ByteArray" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "enum", + "name": "core::bool", + "variants": [ + { + "name": "False", + "type": "()" + }, + { + "name": "True", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::world::IWorld", + "items": [ + { + "type": "function", + "name": "metadata", + "inputs": [ + { + "name": "resource_id", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "dojo::resource_metadata::ResourceMetadata" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "set_metadata", + "inputs": [ + { + "name": "metadata", + "type": "dojo::resource_metadata::ResourceMetadata" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "model", + "inputs": [ + { + "name": "selector", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "(core::starknet::class_hash::ClassHash, core::starknet::contract_address::ContractAddress)" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "register_model", + "inputs": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "register_namespace", + "inputs": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "deploy_contract", + "inputs": [ + { + "name": "salt", + "type": "core::felt252" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + }, + { + "name": "init_calldata", + "type": "core::array::Span::" + } + ], + "outputs": [ + { + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "upgrade_contract", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [ + { + "type": "core::starknet::class_hash::ClassHash" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "uuid", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u32" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "emit", + "inputs": [ + { + "name": "keys", + "type": "core::array::Array::" + }, + { + "name": "values", + "type": "core::array::Span::" + } + ], + "outputs": [], + "state_mutability": "view" + }, + { + "type": "function", + "name": "entity", + "inputs": [ + { + "name": "model", + "type": "core::felt252" + }, + { + "name": "keys", + "type": "core::array::Span::" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ], + "outputs": [ + { + "type": "core::array::Span::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "set_entity", + "inputs": [ + { + "name": "model", + "type": "core::felt252" + }, + { + "name": "keys", + "type": "core::array::Span::" + }, + { + "name": "values", + "type": "core::array::Span::" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "delete_entity", + "inputs": [ + { + "name": "model", + "type": "core::felt252" + }, + { + "name": "keys", + "type": "core::array::Span::" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "base", + "inputs": [], + "outputs": [ + { + "type": "core::starknet::class_hash::ClassHash" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "is_owner", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "resource", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "grant_owner", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "resource", + "type": "core::felt252" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "revoke_owner", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "resource", + "type": "core::felt252" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "is_writer", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "grant_writer", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "revoke_writer", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "can_write_resource", + "inputs": [ + { + "name": "resource_id", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "can_write_model", + "inputs": [ + { + "name": "model_id", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "can_write_namespace", + "inputs": [ + { + "name": "namespace_id", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "UpgradeableWorld", + "interface_name": "dojo::world::IUpgradeableWorld" + }, + { + "type": "interface", + "name": "dojo::world::IUpgradeableWorld", + "items": [ + { + "type": "function", + "name": "upgrade", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "impl", + "name": "UpgradeableState", + "interface_name": "dojo::interfaces::IUpgradeableState" + }, + { + "type": "struct", + "name": "dojo::interfaces::StorageUpdate", + "members": [ + { + "name": "key", + "type": "core::felt252" + }, + { + "name": "value", + "type": "core::felt252" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::interfaces::ProgramOutput", + "members": [ + { + "name": "prev_state_root", + "type": "core::felt252" + }, + { + "name": "new_state_root", + "type": "core::felt252" + }, + { + "name": "block_number", + "type": "core::felt252" + }, + { + "name": "block_hash", + "type": "core::felt252" + }, + { + "name": "config_hash", + "type": "core::felt252" + }, + { + "name": "world_da_hash", + "type": "core::felt252" + }, + { + "name": "message_to_starknet_segment", + "type": "core::array::Span::" + }, + { + "name": "message_to_appchain_segment", + "type": "core::array::Span::" + } + ] + }, + { + "type": "interface", + "name": "dojo::interfaces::IUpgradeableState", + "items": [ + { + "type": "function", + "name": "upgrade_state", + "inputs": [ + { + "name": "new_state", + "type": "core::array::Span::" + }, + { + "name": "program_output", + "type": "dojo::interfaces::ProgramOutput" + }, + { + "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" + }, + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "data" + }, + { + "name": "name", + "type": "core::byte_array::ByteArray", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::ContractUpgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::WorldUpgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::MetadataUpdate", + "kind": "struct", + "members": [ + { + "name": "resource", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "uri", + "type": "core::byte_array::ByteArray", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::NamespaceRegistered", + "kind": "struct", + "members": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "data" + }, + { + "name": "hash", + "type": "core::felt252", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::ModelRegistered", + "kind": "struct", + "members": [ + { + "name": "name", + "type": "core::byte_array::ByteArray", + "kind": "data" + }, + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "data" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "prev_class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "prev_address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::StoreSetRecord", + "kind": "struct", + "members": [ + { + "name": "table", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "keys", + "type": "core::array::Span::", + "kind": "data" + }, + { + "name": "values", + "type": "core::array::Span::", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::StoreDelRecord", + "kind": "struct", + "members": [ + { + "name": "table", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "keys", + "type": "core::array::Span::", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::WriterUpdated", + "kind": "struct", + "members": [ + { + "name": "resource", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "value", + "type": "core::bool", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::OwnerUpdated", + "kind": "struct", + "members": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "resource", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "value", + "type": "core::bool", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::config::component::Config::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": "NamespaceRegistered", + "type": "dojo::world::world::NamespaceRegistered", + "kind": "nested" + }, + { + "name": "ModelRegistered", + "type": "dojo::world::world::ModelRegistered", + "kind": "nested" + }, + { + "name": "StoreSetRecord", + "type": "dojo::world::world::StoreSetRecord", + "kind": "nested" + }, + { + "name": "StoreDelRecord", + "type": "dojo::world::world::StoreDelRecord", + "kind": "nested" + }, + { + "name": "WriterUpdated", + "type": "dojo::world::world::WriterUpdated", + "kind": "nested" + }, + { + "name": "OwnerUpdated", + "type": "dojo::world::world::OwnerUpdated", + "kind": "nested" + }, + { + "name": "ConfigEvent", + "type": "dojo::config::component::Config::Event", + "kind": "nested" + }, + { + "name": "StateUpdated", + "type": "dojo::world::world::StateUpdated", + "kind": "nested" + } + ] + } +] \ No newline at end of file diff --git a/examples/game-lib/armory/manifests/dev/base/abis/models/armory-ModelA-19290fb7.json b/examples/game-lib/armory/manifests/dev/base/abis/models/armory-ModelA-19290fb7.json new file mode 100644 index 0000000000..497f653b51 --- /dev/null +++ b/examples/game-lib/armory/manifests/dev/base/abis/models/armory-ModelA-19290fb7.json @@ -0,0 +1,407 @@ +[ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::IModel" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::database::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::database::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::database::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::IModel", + "items": [ + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "tag", + "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": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "model_aImpl", + "interface_name": "armory::Imodel_a" + }, + { + "type": "struct", + "name": "armory::ModelA", + "members": [ + { + "name": "player", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "data", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "armory::Imodel_a", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "armory::ModelA" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "armory::model_a::Event", + "kind": "enum", + "variants": [] + } +] \ No newline at end of file diff --git a/examples/game-lib/armory/manifests/dev/base/dojo-base.toml b/examples/game-lib/armory/manifests/dev/base/dojo-base.toml new file mode 100644 index 0000000000..aa92e94fac --- /dev/null +++ b/examples/game-lib/armory/manifests/dev/base/dojo-base.toml @@ -0,0 +1,6 @@ +kind = "Class" +class_hash = "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4" +original_class_hash = "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4" +abi = "manifests/dev/base/abis/dojo-base.json" +tag = "dojo-base" +manifest_name = "dojo-base" diff --git a/examples/game-lib/armory/manifests/dev/base/dojo-world.toml b/examples/game-lib/armory/manifests/dev/base/dojo-world.toml new file mode 100644 index 0000000000..83a7a20228 --- /dev/null +++ b/examples/game-lib/armory/manifests/dev/base/dojo-world.toml @@ -0,0 +1,6 @@ +kind = "Class" +class_hash = "0x210dd8e484e5555dc74a4a600b17878fc108911719b04139309acc874160c51" +original_class_hash = "0x210dd8e484e5555dc74a4a600b17878fc108911719b04139309acc874160c51" +abi = "manifests/dev/base/abis/dojo-world.json" +tag = "dojo-world" +manifest_name = "dojo-world" diff --git a/examples/game-lib/armory/manifests/dev/base/models/armory-ModelA-19290fb7.toml b/examples/game-lib/armory/manifests/dev/base/models/armory-ModelA-19290fb7.toml new file mode 100644 index 0000000000..d43f6c1286 --- /dev/null +++ b/examples/game-lib/armory/manifests/dev/base/models/armory-ModelA-19290fb7.toml @@ -0,0 +1,16 @@ +kind = "DojoModel" +class_hash = "0xc9cbc616fe628f80bb6d80181100c50e2053c811bcd1ae148bdaebc472a602" +original_class_hash = "0xc9cbc616fe628f80bb6d80181100c50e2053c811bcd1ae148bdaebc472a602" +abi = "manifests/dev/base/abis/models/armory-ModelA-19290fb7.json" +tag = "armory-ModelA" +manifest_name = "armory-ModelA-19290fb7" + +[[members]] +name = "player" +type = "starknet::ContractAddress" +key = true + +[[members]] +name = "data" +type = "u32" +key = false diff --git a/examples/game-lib/armory/src/lib.cairo b/examples/game-lib/armory/src/lib.cairo new file mode 100644 index 0000000000..ab37e3d807 --- /dev/null +++ b/examples/game-lib/armory/src/lib.cairo @@ -0,0 +1,8 @@ +#[derive(Drop, Serde)] +#[dojo::model] +struct Flatbow { + #[key] + id: u32, + atk_speek: u32, + range: u32, +} diff --git a/examples/game-lib/bestiary/Scarb.toml b/examples/game-lib/bestiary/Scarb.toml new file mode 100644 index 0000000000..fdfc5bf310 --- /dev/null +++ b/examples/game-lib/bestiary/Scarb.toml @@ -0,0 +1,16 @@ +[package] +name = "bestiary" +version = "0.1.0" +description = "Some scary foes to fight." + +[dependencies] +dojo.workspace = true + +[lib] + +[[target.dojo]] + +[tool.dojo.world] +name = "bestiary" +seed = "bestiary" +namespace = "bestiary" diff --git a/examples/game-lib/bestiary/src/lib.cairo b/examples/game-lib/bestiary/src/lib.cairo new file mode 100644 index 0000000000..09b862ee30 --- /dev/null +++ b/examples/game-lib/bestiary/src/lib.cairo @@ -0,0 +1,9 @@ +#[derive(Drop, Serde)] +#[dojo::model] +struct RiverSkale { + #[key] + id: u32, + health: u32, + armor: u32, + attack: u32, +} diff --git a/examples/game-lib/manifests/dev/base/abis/dojo-base.json b/examples/game-lib/manifests/dev/base/abis/dojo-base.json new file mode 100644 index 0000000000..ee9ceaac66 --- /dev/null +++ b/examples/game-lib/manifests/dev/base/abis/dojo-base.json @@ -0,0 +1,98 @@ +[ + { + "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": "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": "constructor", + "name": "constructor", + "inputs": [] + }, + { + "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::base::base::Event", + "kind": "enum", + "variants": [ + { + "name": "UpgradeableEvent", + "type": "dojo::components::upgradeable::upgradeable::Event", + "kind": "flat" + } + ] + } +] \ No newline at end of file diff --git a/examples/game-lib/manifests/dev/base/abis/dojo-world.json b/examples/game-lib/manifests/dev/base/abis/dojo-world.json new file mode 100644 index 0000000000..0e5e96210e --- /dev/null +++ b/examples/game-lib/manifests/dev/base/abis/dojo-world.json @@ -0,0 +1,1105 @@ +[ + { + "type": "impl", + "name": "World", + "interface_name": "dojo::world::IWorld" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "struct", + "name": "dojo::resource_metadata::ResourceMetadata", + "members": [ + { + "name": "resource_id", + "type": "core::felt252" + }, + { + "name": "metadata_uri", + "type": "core::byte_array::ByteArray" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "enum", + "name": "core::bool", + "variants": [ + { + "name": "False", + "type": "()" + }, + { + "name": "True", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::world::IWorld", + "items": [ + { + "type": "function", + "name": "metadata", + "inputs": [ + { + "name": "resource_id", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "dojo::resource_metadata::ResourceMetadata" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "set_metadata", + "inputs": [ + { + "name": "metadata", + "type": "dojo::resource_metadata::ResourceMetadata" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "model", + "inputs": [ + { + "name": "selector", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "(core::starknet::class_hash::ClassHash, core::starknet::contract_address::ContractAddress)" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "register_model", + "inputs": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "register_namespace", + "inputs": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "deploy_contract", + "inputs": [ + { + "name": "salt", + "type": "core::felt252" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + }, + { + "name": "init_calldata", + "type": "core::array::Span::" + } + ], + "outputs": [ + { + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "upgrade_contract", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [ + { + "type": "core::starknet::class_hash::ClassHash" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "uuid", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u32" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "emit", + "inputs": [ + { + "name": "keys", + "type": "core::array::Array::" + }, + { + "name": "values", + "type": "core::array::Span::" + } + ], + "outputs": [], + "state_mutability": "view" + }, + { + "type": "function", + "name": "entity", + "inputs": [ + { + "name": "model", + "type": "core::felt252" + }, + { + "name": "keys", + "type": "core::array::Span::" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ], + "outputs": [ + { + "type": "core::array::Span::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "set_entity", + "inputs": [ + { + "name": "model", + "type": "core::felt252" + }, + { + "name": "keys", + "type": "core::array::Span::" + }, + { + "name": "values", + "type": "core::array::Span::" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "delete_entity", + "inputs": [ + { + "name": "model", + "type": "core::felt252" + }, + { + "name": "keys", + "type": "core::array::Span::" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "base", + "inputs": [], + "outputs": [ + { + "type": "core::starknet::class_hash::ClassHash" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "is_owner", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "resource", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "grant_owner", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "resource", + "type": "core::felt252" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "revoke_owner", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "resource", + "type": "core::felt252" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "is_writer", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "grant_writer", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "revoke_writer", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "can_write_resource", + "inputs": [ + { + "name": "resource_id", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "can_write_model", + "inputs": [ + { + "name": "model_id", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "can_write_namespace", + "inputs": [ + { + "name": "namespace_id", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "UpgradeableWorld", + "interface_name": "dojo::world::IUpgradeableWorld" + }, + { + "type": "interface", + "name": "dojo::world::IUpgradeableWorld", + "items": [ + { + "type": "function", + "name": "upgrade", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "impl", + "name": "UpgradeableState", + "interface_name": "dojo::interfaces::IUpgradeableState" + }, + { + "type": "struct", + "name": "dojo::interfaces::StorageUpdate", + "members": [ + { + "name": "key", + "type": "core::felt252" + }, + { + "name": "value", + "type": "core::felt252" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::interfaces::ProgramOutput", + "members": [ + { + "name": "prev_state_root", + "type": "core::felt252" + }, + { + "name": "new_state_root", + "type": "core::felt252" + }, + { + "name": "block_number", + "type": "core::felt252" + }, + { + "name": "block_hash", + "type": "core::felt252" + }, + { + "name": "config_hash", + "type": "core::felt252" + }, + { + "name": "world_da_hash", + "type": "core::felt252" + }, + { + "name": "message_to_starknet_segment", + "type": "core::array::Span::" + }, + { + "name": "message_to_appchain_segment", + "type": "core::array::Span::" + } + ] + }, + { + "type": "interface", + "name": "dojo::interfaces::IUpgradeableState", + "items": [ + { + "type": "function", + "name": "upgrade_state", + "inputs": [ + { + "name": "new_state", + "type": "core::array::Span::" + }, + { + "name": "program_output", + "type": "dojo::interfaces::ProgramOutput" + }, + { + "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" + }, + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "data" + }, + { + "name": "name", + "type": "core::byte_array::ByteArray", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::ContractUpgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::WorldUpgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::MetadataUpdate", + "kind": "struct", + "members": [ + { + "name": "resource", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "uri", + "type": "core::byte_array::ByteArray", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::NamespaceRegistered", + "kind": "struct", + "members": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "data" + }, + { + "name": "hash", + "type": "core::felt252", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::ModelRegistered", + "kind": "struct", + "members": [ + { + "name": "name", + "type": "core::byte_array::ByteArray", + "kind": "data" + }, + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "data" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "prev_class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "prev_address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::StoreSetRecord", + "kind": "struct", + "members": [ + { + "name": "table", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "keys", + "type": "core::array::Span::", + "kind": "data" + }, + { + "name": "values", + "type": "core::array::Span::", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::StoreDelRecord", + "kind": "struct", + "members": [ + { + "name": "table", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "keys", + "type": "core::array::Span::", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::WriterUpdated", + "kind": "struct", + "members": [ + { + "name": "resource", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "value", + "type": "core::bool", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::OwnerUpdated", + "kind": "struct", + "members": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "resource", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "value", + "type": "core::bool", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::config::component::Config::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": "NamespaceRegistered", + "type": "dojo::world::world::NamespaceRegistered", + "kind": "nested" + }, + { + "name": "ModelRegistered", + "type": "dojo::world::world::ModelRegistered", + "kind": "nested" + }, + { + "name": "StoreSetRecord", + "type": "dojo::world::world::StoreSetRecord", + "kind": "nested" + }, + { + "name": "StoreDelRecord", + "type": "dojo::world::world::StoreDelRecord", + "kind": "nested" + }, + { + "name": "WriterUpdated", + "type": "dojo::world::world::WriterUpdated", + "kind": "nested" + }, + { + "name": "OwnerUpdated", + "type": "dojo::world::world::OwnerUpdated", + "kind": "nested" + }, + { + "name": "ConfigEvent", + "type": "dojo::config::component::Config::Event", + "kind": "nested" + }, + { + "name": "StateUpdated", + "type": "dojo::world::world::StateUpdated", + "kind": "nested" + } + ] + } +] \ No newline at end of file diff --git a/examples/game-lib/manifests/dev/base/abis/models/armory-Flatbow-f269a4c3.json b/examples/game-lib/manifests/dev/base/abis/models/armory-Flatbow-f269a4c3.json new file mode 100644 index 0000000000..50d5861a0a --- /dev/null +++ b/examples/game-lib/manifests/dev/base/abis/models/armory-Flatbow-f269a4c3.json @@ -0,0 +1,411 @@ +[ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::IModel" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::database::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::database::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::database::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::IModel", + "items": [ + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "tag", + "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": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "flatbowImpl", + "interface_name": "armory::Iflatbow" + }, + { + "type": "struct", + "name": "armory::Flatbow", + "members": [ + { + "name": "id", + "type": "core::integer::u32" + }, + { + "name": "atk_speek", + "type": "core::integer::u32" + }, + { + "name": "range", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "armory::Iflatbow", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "armory::Flatbow" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "armory::flatbow::Event", + "kind": "enum", + "variants": [] + } +] \ No newline at end of file diff --git a/examples/game-lib/manifests/dev/base/abis/models/bestiary-RiverSkale-1bce2040.json b/examples/game-lib/manifests/dev/base/abis/models/bestiary-RiverSkale-1bce2040.json new file mode 100644 index 0000000000..4d4a41214e --- /dev/null +++ b/examples/game-lib/manifests/dev/base/abis/models/bestiary-RiverSkale-1bce2040.json @@ -0,0 +1,415 @@ +[ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::IModel" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::database::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::database::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::database::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::IModel", + "items": [ + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "tag", + "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": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "river_skaleImpl", + "interface_name": "bestiary::Iriver_skale" + }, + { + "type": "struct", + "name": "bestiary::RiverSkale", + "members": [ + { + "name": "id", + "type": "core::integer::u32" + }, + { + "name": "health", + "type": "core::integer::u32" + }, + { + "name": "armor", + "type": "core::integer::u32" + }, + { + "name": "attack", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "bestiary::Iriver_skale", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "bestiary::RiverSkale" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "bestiary::river_skale::Event", + "kind": "enum", + "variants": [] + } +] \ No newline at end of file diff --git a/examples/game-lib/manifests/dev/base/dojo-base.toml b/examples/game-lib/manifests/dev/base/dojo-base.toml new file mode 100644 index 0000000000..aa92e94fac --- /dev/null +++ b/examples/game-lib/manifests/dev/base/dojo-base.toml @@ -0,0 +1,6 @@ +kind = "Class" +class_hash = "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4" +original_class_hash = "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4" +abi = "manifests/dev/base/abis/dojo-base.json" +tag = "dojo-base" +manifest_name = "dojo-base" diff --git a/examples/game-lib/manifests/dev/base/dojo-world.toml b/examples/game-lib/manifests/dev/base/dojo-world.toml new file mode 100644 index 0000000000..83a7a20228 --- /dev/null +++ b/examples/game-lib/manifests/dev/base/dojo-world.toml @@ -0,0 +1,6 @@ +kind = "Class" +class_hash = "0x210dd8e484e5555dc74a4a600b17878fc108911719b04139309acc874160c51" +original_class_hash = "0x210dd8e484e5555dc74a4a600b17878fc108911719b04139309acc874160c51" +abi = "manifests/dev/base/abis/dojo-world.json" +tag = "dojo-world" +manifest_name = "dojo-world" diff --git a/examples/game-lib/manifests/dev/base/models/armory-Flatbow-f269a4c3.toml b/examples/game-lib/manifests/dev/base/models/armory-Flatbow-f269a4c3.toml new file mode 100644 index 0000000000..d379e49e24 --- /dev/null +++ b/examples/game-lib/manifests/dev/base/models/armory-Flatbow-f269a4c3.toml @@ -0,0 +1,21 @@ +kind = "DojoModel" +class_hash = "0x3a448f0a99ccf65cc1d2c888ba5fafb4a2f85c4e70d2e022147e5b1fe7ce1bf" +original_class_hash = "0x3a448f0a99ccf65cc1d2c888ba5fafb4a2f85c4e70d2e022147e5b1fe7ce1bf" +abi = "manifests/dev/base/abis/models/armory-Flatbow-f269a4c3.json" +tag = "armory-Flatbow" +manifest_name = "armory-Flatbow-f269a4c3" + +[[members]] +name = "id" +type = "u32" +key = true + +[[members]] +name = "atk_speek" +type = "u32" +key = false + +[[members]] +name = "range" +type = "u32" +key = false diff --git a/examples/game-lib/manifests/dev/base/models/bestiary-RiverSkale-1bce2040.toml b/examples/game-lib/manifests/dev/base/models/bestiary-RiverSkale-1bce2040.toml new file mode 100644 index 0000000000..89737084f9 --- /dev/null +++ b/examples/game-lib/manifests/dev/base/models/bestiary-RiverSkale-1bce2040.toml @@ -0,0 +1,26 @@ +kind = "DojoModel" +class_hash = "0x9efdf4d850ee4e4f837ff4f4b472739589a3aed34d22d1efa18ee743480ef7" +original_class_hash = "0x9efdf4d850ee4e4f837ff4f4b472739589a3aed34d22d1efa18ee743480ef7" +abi = "manifests/dev/base/abis/models/bestiary-RiverSkale-1bce2040.json" +tag = "bestiary-RiverSkale" +manifest_name = "bestiary-RiverSkale-1bce2040" + +[[members]] +name = "id" +type = "u32" +key = true + +[[members]] +name = "health" +type = "u32" +key = false + +[[members]] +name = "armor" +type = "u32" +key = false + +[[members]] +name = "attack" +type = "u32" +key = false diff --git a/examples/spawn-and-move/Scarb.lock b/examples/spawn-and-move/Scarb.lock index 9fd20e2292..2fc5c9b2d6 100644 --- a/examples/spawn-and-move/Scarb.lock +++ b/examples/spawn-and-move/Scarb.lock @@ -1,6 +1,20 @@ # Code generated by scarb DO NOT EDIT. version = 1 +[[package]] +name = "armory" +version = "0.1.0" +dependencies = [ + "dojo", +] + +[[package]] +name = "bestiary" +version = "0.1.0" +dependencies = [ + "dojo", +] + [[package]] name = "dojo" version = "0.7.3" @@ -12,6 +26,8 @@ dependencies = [ name = "dojo_examples" version = "0.7.3" dependencies = [ + "armory", + "bestiary", "dojo", ] diff --git a/examples/spawn-and-move/Scarb.toml b/examples/spawn-and-move/Scarb.toml index c5c1f0a06c..2b9b087c2e 100644 --- a/examples/spawn-and-move/Scarb.toml +++ b/examples/spawn-and-move/Scarb.toml @@ -11,13 +11,18 @@ sierra-replace-ids = true [dependencies] dojo = { path = "../../crates/dojo-core" } +armory = { path = "../game-lib/armory" } +bestiary = { path = "../game-lib/bestiary" } [[target.dojo]] -build-external-contracts = [ ] +build-external-contracts = [ + "armory::Flatbow", + "bestiary::RiverSkale", +] [features] -default = ["something"] -something = [] +default = ["dungeon"] +dungeon = [] # `dev` profile diff --git a/examples/spawn-and-move/manifests/dev/base/abis/contracts/dojo_examples-actions-40b6994c.json b/examples/spawn-and-move/manifests/dev/base/abis/contracts/dojo_examples-actions-40b6994c.json index a8654af001..1e5a2ea426 100644 --- a/examples/spawn-and-move/manifests/dev/base/abis/contracts/dojo_examples-actions-40b6994c.json +++ b/examples/spawn-and-move/manifests/dev/base/abis/contracts/dojo_examples-actions-40b6994c.json @@ -299,15 +299,15 @@ }, { "type": "function", - "name": "call_something", + "name": "enter_dungeon", "inputs": [ { - "name": "something_address", + "name": "dungeon_address", "type": "core::starknet::contract_address::ContractAddress" } ], "outputs": [], - "state_mutability": "view" + "state_mutability": "external" } ] }, diff --git a/examples/spawn-and-move/manifests/dev/base/abis/contracts/dojo_examples-something-71cfad55.json b/examples/spawn-and-move/manifests/dev/base/abis/contracts/dojo_examples-dungeon-6620e0e6.json similarity index 92% rename from examples/spawn-and-move/manifests/dev/base/abis/contracts/dojo_examples-something-71cfad55.json rename to examples/spawn-and-move/manifests/dev/base/abis/contracts/dojo_examples-dungeon-6620e0e6.json index fc1c520022..b48fc407a5 100644 --- a/examples/spawn-and-move/manifests/dev/base/abis/contracts/dojo_examples-something-71cfad55.json +++ b/examples/spawn-and-move/manifests/dev/base/abis/contracts/dojo_examples-dungeon-6620e0e6.json @@ -128,16 +128,16 @@ }, { "type": "impl", - "name": "ISomethingImpl", - "interface_name": "dojo_examples::something::ISomething" + "name": "IDungeonImpl", + "interface_name": "dojo_examples::dungeon::IDungeon" }, { "type": "interface", - "name": "dojo_examples::something::ISomething", + "name": "dojo_examples::dungeon::IDungeon", "items": [ { "type": "function", - "name": "something", + "name": "enter", "inputs": [], "outputs": [], "state_mutability": "view" @@ -147,11 +147,11 @@ { "type": "impl", "name": "IDojoInitImpl", - "interface_name": "dojo_examples::something::something::IDojoInit" + "interface_name": "dojo_examples::dungeon::dungeon::IDojoInit" }, { "type": "interface", - "name": "dojo_examples::something::something::IDojoInit", + "name": "dojo_examples::dungeon::dungeon::IDojoInit", "items": [ { "type": "function", @@ -211,7 +211,7 @@ }, { "type": "event", - "name": "dojo_examples::something::something::Event", + "name": "dojo_examples::dungeon::dungeon::Event", "kind": "enum", "variants": [ { diff --git a/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-Flatbow-3632af69.json b/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-Flatbow-3632af69.json new file mode 100644 index 0000000000..50d5861a0a --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-Flatbow-3632af69.json @@ -0,0 +1,411 @@ +[ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::IModel" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::database::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::database::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::database::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::IModel", + "items": [ + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "tag", + "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": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "flatbowImpl", + "interface_name": "armory::Iflatbow" + }, + { + "type": "struct", + "name": "armory::Flatbow", + "members": [ + { + "name": "id", + "type": "core::integer::u32" + }, + { + "name": "atk_speek", + "type": "core::integer::u32" + }, + { + "name": "range", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "armory::Iflatbow", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "armory::Flatbow" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "armory::flatbow::Event", + "kind": "enum", + "variants": [] + } +] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-RiverSkale-27fcbc29.json b/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-RiverSkale-27fcbc29.json new file mode 100644 index 0000000000..4d4a41214e --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-RiverSkale-27fcbc29.json @@ -0,0 +1,415 @@ +[ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::IModel" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::database::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::database::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::database::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::IModel", + "items": [ + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "tag", + "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": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "river_skaleImpl", + "interface_name": "bestiary::Iriver_skale" + }, + { + "type": "struct", + "name": "bestiary::RiverSkale", + "members": [ + { + "name": "id", + "type": "core::integer::u32" + }, + { + "name": "health", + "type": "core::integer::u32" + }, + { + "name": "armor", + "type": "core::integer::u32" + }, + { + "name": "attack", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "bestiary::Iriver_skale", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "bestiary::RiverSkale" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "bestiary::river_skale::Event", + "kind": "enum", + "variants": [] + } +] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-actions-40b6994c.toml b/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-actions-40b6994c.toml index 9bd796836c..c22cd90a7e 100644 --- a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-actions-40b6994c.toml +++ b/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-actions-40b6994c.toml @@ -1,6 +1,6 @@ kind = "DojoContract" -class_hash = "0x1843e2e8c174c087de5ebaf04eee196eb0526b6345ad5ac3a6055d4e0dd1363" -original_class_hash = "0x1843e2e8c174c087de5ebaf04eee196eb0526b6345ad5ac3a6055d4e0dd1363" +class_hash = "0x5693c8ae37b78934041173e9a1abd868e09b89d27fb2fc53702b69e48bfa94f" +original_class_hash = "0x5693c8ae37b78934041173e9a1abd868e09b89d27fb2fc53702b69e48bfa94f" base_class_hash = "0x0" abi = "manifests/dev/base/abis/contracts/dojo_examples-actions-40b6994c.json" reads = [] diff --git a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-dungeon-6620e0e6.toml b/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-dungeon-6620e0e6.toml new file mode 100644 index 0000000000..c0574da07c --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-dungeon-6620e0e6.toml @@ -0,0 +1,11 @@ +kind = "DojoContract" +class_hash = "0x14b3096b82a761f63dd47277c2b5ac18925dea43586418483939a2f1f57f674" +original_class_hash = "0x14b3096b82a761f63dd47277c2b5ac18925dea43586418483939a2f1f57f674" +base_class_hash = "0x0" +abi = "manifests/dev/base/abis/contracts/dojo_examples-dungeon-6620e0e6.json" +reads = [] +writes = [] +computed = [] +init_calldata = [] +tag = "dojo_examples-dungeon" +manifest_name = "dojo_examples-dungeon-6620e0e6" diff --git a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-something-71cfad55.toml b/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-something-71cfad55.toml deleted file mode 100644 index f088c8a356..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-something-71cfad55.toml +++ /dev/null @@ -1,11 +0,0 @@ -kind = "DojoContract" -class_hash = "0x2633dd37ecb3e273b309a3339da5dc820f2b77d4da474d7215952a1b60950dc" -original_class_hash = "0x2633dd37ecb3e273b309a3339da5dc820f2b77d4da474d7215952a1b60950dc" -base_class_hash = "0x0" -abi = "manifests/dev/base/abis/contracts/dojo_examples-something-71cfad55.json" -reads = [] -writes = [] -computed = [] -init_calldata = [] -tag = "dojo_examples-something" -manifest_name = "dojo_examples-something-71cfad55" diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-Flatbow-3632af69.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-Flatbow-3632af69.toml new file mode 100644 index 0000000000..036b378ddd --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-Flatbow-3632af69.toml @@ -0,0 +1,21 @@ +kind = "DojoModel" +class_hash = "0x452abb4fc0af6e0e08e6f652ce77d7330000d4e4bec995005785c7d3f12ea1a" +original_class_hash = "0x452abb4fc0af6e0e08e6f652ce77d7330000d4e4bec995005785c7d3f12ea1a" +abi = "manifests/dev/base/abis/models/dojo_examples-Flatbow-3632af69.json" +tag = "dojo_examples-Flatbow" +manifest_name = "dojo_examples-Flatbow-3632af69" + +[[members]] +name = "id" +type = "u32" +key = true + +[[members]] +name = "atk_speek" +type = "u32" +key = false + +[[members]] +name = "range" +type = "u32" +key = false diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-RiverSkale-27fcbc29.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-RiverSkale-27fcbc29.toml new file mode 100644 index 0000000000..b128e42cf7 --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-RiverSkale-27fcbc29.toml @@ -0,0 +1,26 @@ +kind = "DojoModel" +class_hash = "0x645afa3c2890d1b0d1176e20c703225ad7dfa4a16b67417bcd4fad97eac1ebb" +original_class_hash = "0x645afa3c2890d1b0d1176e20c703225ad7dfa4a16b67417bcd4fad97eac1ebb" +abi = "manifests/dev/base/abis/models/dojo_examples-RiverSkale-27fcbc29.json" +tag = "dojo_examples-RiverSkale" +manifest_name = "dojo_examples-RiverSkale-27fcbc29" + +[[members]] +name = "id" +type = "u32" +key = true + +[[members]] +name = "health" +type = "u32" +key = false + +[[members]] +name = "armor" +type = "u32" +key = false + +[[members]] +name = "attack" +type = "u32" +key = false diff --git a/examples/spawn-and-move/manifests/dev/deployment/abis/contracts/dojo_examples-actions-40b6994c.json b/examples/spawn-and-move/manifests/dev/deployment/abis/contracts/dojo_examples-actions-40b6994c.json index 16ee68e05e..1e5a2ea426 100644 --- a/examples/spawn-and-move/manifests/dev/deployment/abis/contracts/dojo_examples-actions-40b6994c.json +++ b/examples/spawn-and-move/manifests/dev/deployment/abis/contracts/dojo_examples-actions-40b6994c.json @@ -296,6 +296,18 @@ ], "outputs": [], "state_mutability": "external" + }, + { + "type": "function", + "name": "enter_dungeon", + "inputs": [ + { + "name": "dungeon_address", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" } ] }, diff --git a/examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-something-71cfad55.json b/examples/spawn-and-move/manifests/dev/deployment/abis/contracts/dojo_examples-dungeon-6620e0e6.json similarity index 92% rename from examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-something-71cfad55.json rename to examples/spawn-and-move/manifests/dev/deployment/abis/contracts/dojo_examples-dungeon-6620e0e6.json index fc1c520022..b48fc407a5 100644 --- a/examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-something-71cfad55.json +++ b/examples/spawn-and-move/manifests/dev/deployment/abis/contracts/dojo_examples-dungeon-6620e0e6.json @@ -128,16 +128,16 @@ }, { "type": "impl", - "name": "ISomethingImpl", - "interface_name": "dojo_examples::something::ISomething" + "name": "IDungeonImpl", + "interface_name": "dojo_examples::dungeon::IDungeon" }, { "type": "interface", - "name": "dojo_examples::something::ISomething", + "name": "dojo_examples::dungeon::IDungeon", "items": [ { "type": "function", - "name": "something", + "name": "enter", "inputs": [], "outputs": [], "state_mutability": "view" @@ -147,11 +147,11 @@ { "type": "impl", "name": "IDojoInitImpl", - "interface_name": "dojo_examples::something::something::IDojoInit" + "interface_name": "dojo_examples::dungeon::dungeon::IDojoInit" }, { "type": "interface", - "name": "dojo_examples::something::something::IDojoInit", + "name": "dojo_examples::dungeon::dungeon::IDojoInit", "items": [ { "type": "function", @@ -211,7 +211,7 @@ }, { "type": "event", - "name": "dojo_examples::something::something::Event", + "name": "dojo_examples::dungeon::dungeon::Event", "kind": "enum", "variants": [ { diff --git a/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-Flatbow-3632af69.json b/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-Flatbow-3632af69.json new file mode 100644 index 0000000000..50d5861a0a --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-Flatbow-3632af69.json @@ -0,0 +1,411 @@ +[ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::IModel" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::database::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::database::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::database::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::IModel", + "items": [ + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "tag", + "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": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "flatbowImpl", + "interface_name": "armory::Iflatbow" + }, + { + "type": "struct", + "name": "armory::Flatbow", + "members": [ + { + "name": "id", + "type": "core::integer::u32" + }, + { + "name": "atk_speek", + "type": "core::integer::u32" + }, + { + "name": "range", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "armory::Iflatbow", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "armory::Flatbow" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "armory::flatbow::Event", + "kind": "enum", + "variants": [] + } +] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-ModelA-689f21bc.json b/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-ModelA-689f21bc.json new file mode 100644 index 0000000000..ee60a6f0a8 --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-ModelA-689f21bc.json @@ -0,0 +1,407 @@ +[ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::IModel" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::database::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::database::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::database::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::IModel", + "items": [ + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "tag", + "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": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "model_aImpl", + "interface_name": "simple_lib::Imodel_a" + }, + { + "type": "struct", + "name": "simple_lib::ModelA", + "members": [ + { + "name": "player", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "data", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "simple_lib::Imodel_a", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "simple_lib::ModelA" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "simple_lib::model_a::Event", + "kind": "enum", + "variants": [] + } +] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-RiverSkale-27fcbc29.json b/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-RiverSkale-27fcbc29.json new file mode 100644 index 0000000000..4d4a41214e --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-RiverSkale-27fcbc29.json @@ -0,0 +1,415 @@ +[ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::IModel" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::database::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::database::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::database::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::IModel", + "items": [ + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "tag", + "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": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "river_skaleImpl", + "interface_name": "bestiary::Iriver_skale" + }, + { + "type": "struct", + "name": "bestiary::RiverSkale", + "members": [ + { + "name": "id", + "type": "core::integer::u32" + }, + { + "name": "health", + "type": "core::integer::u32" + }, + { + "name": "armor", + "type": "core::integer::u32" + }, + { + "name": "attack", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "bestiary::Iriver_skale", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "bestiary::RiverSkale" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "bestiary::river_skale::Event", + "kind": "enum", + "variants": [] + } +] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/deployment/manifest.json b/examples/spawn-and-move/manifests/dev/deployment/manifest.json index 99501691fc..cf27fae433 100644 --- a/examples/spawn-and-move/manifests/dev/deployment/manifest.json +++ b/examples/spawn-and-move/manifests/dev/deployment/manifest.json @@ -1130,8 +1130,8 @@ { "kind": "DojoContract", "address": "0x2e85647f570d2a4abdffdd668823702548d20d1d6aaef74b6a4eb9670a32798", - "class_hash": "0x647694c15fff8476c82ea146d0dbdbbb17d3425d5ba05a7320e4322f916df1d", - "original_class_hash": "0x647694c15fff8476c82ea146d0dbdbbb17d3425d5ba05a7320e4322f916df1d", + "class_hash": "0x5693c8ae37b78934041173e9a1abd868e09b89d27fb2fc53702b69e48bfa94f", + "original_class_hash": "0x5693c8ae37b78934041173e9a1abd868e09b89d27fb2fc53702b69e48bfa94f", "base_class_hash": "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4", "abi": [ { @@ -1431,6 +1431,18 @@ ], "outputs": [], "state_mutability": "external" + }, + { + "type": "function", + "name": "enter_dungeon", + "inputs": [ + { + "name": "dungeon_address", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" } ] }, @@ -1522,6 +1534,243 @@ "tag": "dojo_examples-actions", "manifest_name": "dojo_examples-actions-40b6994c" }, + { + "kind": "DojoContract", + "address": "0x4f38db968d53b073189760e1256d827195de3904542cf62d60e6bd3707f8504", + "class_hash": "0x14b3096b82a761f63dd47277c2b5ac18925dea43586418483939a2f1f57f674", + "original_class_hash": "0x14b3096b82a761f63dd47277c2b5ac18925dea43586418483939a2f1f57f674", + "base_class_hash": "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4", + "abi": [ + { + "type": "impl", + "name": "ContractImpl", + "interface_name": "dojo::contract::IContract" + }, + { + "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::contract::IContract", + "items": [ + { + "type": "function", + "name": "contract_name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "tag", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "selector", + "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": "IDungeonImpl", + "interface_name": "dojo_examples::dungeon::IDungeon" + }, + { + "type": "interface", + "name": "dojo_examples::dungeon::IDungeon", + "items": [ + { + "type": "function", + "name": "enter", + "inputs": [], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "IDojoInitImpl", + "interface_name": "dojo_examples::dungeon::dungeon::IDojoInit" + }, + { + "type": "interface", + "name": "dojo_examples::dungeon::dungeon::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::dungeon::dungeon::Event", + "kind": "enum", + "variants": [ + { + "name": "UpgradeableEvent", + "type": "dojo::components::upgradeable::upgradeable::Event", + "kind": "nested" + } + ] + } + ], + "reads": [], + "writes": [], + "computed": [], + "init_calldata": [], + "tag": "dojo_examples-dungeon", + "manifest_name": "dojo_examples-dungeon-6620e0e6" + }, { "kind": "DojoContract", "address": "0x6a06eb156f956f1691bce4a4573c97b1a5f08d3bfa65fc25c4ed4b55d3e61a1", @@ -2418,28 +2667,23 @@ "kind": "DojoModel", "members": [ { - "name": "identity", - "type": "ContractAddress", - "key": true - }, - { - "name": "channel", - "type": "felt252", + "name": "id", + "type": "u32", "key": true }, { - "name": "message", - "type": "ByteArray", + "name": "atk_speek", + "type": "u32", "key": false }, { - "name": "salt", - "type": "felt252", - "key": true + "name": "range", + "type": "u32", + "key": false } ], - "class_hash": "0x572bf6d3cbcd69fd6404a993110c3b84379882587b21b7ad5b2761088cb19c3", - "original_class_hash": "0x572bf6d3cbcd69fd6404a993110c3b84379882587b21b7ad5b2761088cb19c3", + "class_hash": "0x452abb4fc0af6e0e08e6f652ce77d7330000d4e4bec995005785c7d3f12ea1a", + "original_class_hash": "0x452abb4fc0af6e0e08e6f652ce77d7330000d4e4bec995005785c7d3f12ea1a", "abi": [ { "type": "impl", @@ -2805,34 +3049,900 @@ }, { "type": "impl", - "name": "messageImpl", - "interface_name": "dojo_examples::models::Imessage" + "name": "flatbowImpl", + "interface_name": "armory::Iflatbow" }, { "type": "struct", - "name": "dojo_examples::models::Message", + "name": "armory::Flatbow", + "members": [ + { + "name": "id", + "type": "core::integer::u32" + }, + { + "name": "atk_speek", + "type": "core::integer::u32" + }, + { + "name": "range", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "armory::Iflatbow", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "armory::Flatbow" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "armory::flatbow::Event", + "kind": "enum", + "variants": [] + } + ], + "tag": "dojo_examples-Flatbow", + "manifest_name": "dojo_examples-Flatbow-3632af69" + }, + { + "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": "0x572bf6d3cbcd69fd6404a993110c3b84379882587b21b7ad5b2761088cb19c3", + "original_class_hash": "0x572bf6d3cbcd69fd6404a993110c3b84379882587b21b7ad5b2761088cb19c3", + "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": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "tag", + "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": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "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", + "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": [] + } + ], + "tag": "dojo_examples-Message", + "manifest_name": "dojo_examples-Message-1bb1d226" + }, + { + "kind": "DojoModel", + "members": [ + { + "name": "account", + "type": "ContractAddress", + "key": true + }, + { + "name": "amount", + "type": "u128", + "key": false + } + ], + "class_hash": "0x4463c89586bc5015a7bc97e9e4af123330842b20aa6f6587c795d6d35907a9d", + "original_class_hash": "0x4463c89586bc5015a7bc97e9e4af123330842b20aa6f6587c795d6d35907a9d", + "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": "message", - "type": "core::byte_array::ByteArray" + "name": "attrs", + "type": "core::array::Span::" }, { - "name": "salt", + "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_examples::models::Imessage", + "name": "dojo::model::IModel", + "items": [ + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "tag", + "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": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "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", @@ -2840,7 +3950,7 @@ "inputs": [ { "name": "model", - "type": "dojo_examples::models::Message" + "type": "dojo_examples::models::MockToken" } ], "outputs": [], @@ -2850,30 +3960,30 @@ }, { "type": "event", - "name": "dojo_examples::models::message::Event", + "name": "dojo_examples::models::mock_token::Event", "kind": "enum", "variants": [] } ], - "tag": "dojo_examples-Message", - "manifest_name": "dojo_examples-Message-1bb1d226" + "tag": "dojo_examples-MockToken", + "manifest_name": "dojo_examples-MockToken-38903c7c" }, { "kind": "DojoModel", "members": [ { - "name": "account", + "name": "player", "type": "ContractAddress", "key": true }, { - "name": "amount", - "type": "u128", + "name": "direction", + "type": "Direction", "key": false } ], - "class_hash": "0x4463c89586bc5015a7bc97e9e4af123330842b20aa6f6587c795d6d35907a9d", - "original_class_hash": "0x4463c89586bc5015a7bc97e9e4af123330842b20aa6f6587c795d6d35907a9d", + "class_hash": "0x36b7886db455f41fac4263da9f0d21190bb575c8555bde1c3357486495c0be1", + "original_class_hash": "0x36b7886db455f41fac4263da9f0d21190bb575c8555bde1c3357486495c0be1", "abi": [ { "type": "impl", @@ -3239,26 +4349,52 @@ }, { "type": "impl", - "name": "mock_tokenImpl", - "interface_name": "dojo_examples::models::Imock_token" + "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::models::MockToken", + "name": "dojo_examples::actions::actions::Moved", "members": [ { - "name": "account", + "name": "player", "type": "core::starknet::contract_address::ContractAddress" }, { - "name": "amount", - "type": "core::integer::u128" + "name": "direction", + "type": "dojo_examples::models::Direction" } ] }, { "type": "interface", - "name": "dojo_examples::models::Imock_token", + "name": "dojo_examples::actions::actions::Imoved", "items": [ { "type": "function", @@ -3266,7 +4402,7 @@ "inputs": [ { "name": "model", - "type": "dojo_examples::models::MockToken" + "type": "dojo_examples::actions::actions::Moved" } ], "outputs": [], @@ -3276,13 +4412,13 @@ }, { "type": "event", - "name": "dojo_examples::models::mock_token::Event", + "name": "dojo_examples::actions::actions::moved::Event", "kind": "enum", "variants": [] } ], - "tag": "dojo_examples-MockToken", - "manifest_name": "dojo_examples-MockToken-38903c7c" + "tag": "dojo_examples-Moved", + "manifest_name": "dojo_examples-Moved-318ae40d" }, { "kind": "DojoModel", @@ -3293,13 +4429,18 @@ "key": true }, { - "name": "direction", + "name": "remaining", + "type": "u8", + "key": false + }, + { + "name": "last_direction", "type": "Direction", "key": false } ], - "class_hash": "0x36b7886db455f41fac4263da9f0d21190bb575c8555bde1c3357486495c0be1", - "original_class_hash": "0x36b7886db455f41fac4263da9f0d21190bb575c8555bde1c3357486495c0be1", + "class_hash": "0x23ec6500e0f3e8c64c6fb3ee3ed3259d81c0bde627c8c9c1177da098189dd89", + "original_class_hash": "0x23ec6500e0f3e8c64c6fb3ee3ed3259d81c0bde627c8c9c1177da098189dd89", "abi": [ { "type": "impl", @@ -3665,8 +4806,8 @@ }, { "type": "impl", - "name": "movedImpl", - "interface_name": "dojo_examples::actions::actions::Imoved" + "name": "movesImpl", + "interface_name": "dojo_examples::models::Imoves" }, { "type": "enum", @@ -3696,21 +4837,25 @@ }, { "type": "struct", - "name": "dojo_examples::actions::actions::Moved", + "name": "dojo_examples::models::Moves", "members": [ { "name": "player", "type": "core::starknet::contract_address::ContractAddress" }, { - "name": "direction", + "name": "remaining", + "type": "core::integer::u8" + }, + { + "name": "last_direction", "type": "dojo_examples::models::Direction" } ] }, { "type": "interface", - "name": "dojo_examples::actions::actions::Imoved", + "name": "dojo_examples::models::Imoves", "items": [ { "type": "function", @@ -3718,7 +4863,7 @@ "inputs": [ { "name": "model", - "type": "dojo_examples::actions::actions::Moved" + "type": "dojo_examples::models::Moves" } ], "outputs": [], @@ -3728,13 +4873,13 @@ }, { "type": "event", - "name": "dojo_examples::actions::actions::moved::Event", + "name": "dojo_examples::models::moves::Event", "kind": "enum", "variants": [] } ], - "tag": "dojo_examples-Moved", - "manifest_name": "dojo_examples-Moved-318ae40d" + "tag": "dojo_examples-Moves", + "manifest_name": "dojo_examples-Moves-2e2accba" }, { "kind": "DojoModel", @@ -3745,18 +4890,23 @@ "key": true }, { - "name": "remaining", - "type": "u8", + "name": "name", + "type": "ByteArray", "key": false }, { - "name": "last_direction", - "type": "Direction", + "name": "items", + "type": "Array", + "key": false + }, + { + "name": "favorite_item", + "type": "Option", "key": false } ], - "class_hash": "0x23ec6500e0f3e8c64c6fb3ee3ed3259d81c0bde627c8c9c1177da098189dd89", - "original_class_hash": "0x23ec6500e0f3e8c64c6fb3ee3ed3259d81c0bde627c8c9c1177da098189dd89", + "class_hash": "0x13f8294fde1c2605e9825782ae293b3bae2291e6cbd20d4ef8878ff044d4b82", + "original_class_hash": "0x13f8294fde1c2605e9825782ae293b3bae2291e6cbd20d4ef8878ff044d4b82", "abi": [ { "type": "impl", @@ -4122,56 +5272,48 @@ }, { "type": "impl", - "name": "movesImpl", - "interface_name": "dojo_examples::models::Imoves" + "name": "player_configImpl", + "interface_name": "dojo_examples::models::Iplayer_config" }, { - "type": "enum", - "name": "dojo_examples::models::Direction", - "variants": [ - { - "name": "None", - "type": "()" - }, - { - "name": "Left", - "type": "()" - }, - { - "name": "Right", - "type": "()" - }, + "type": "struct", + "name": "dojo_examples::models::PlayerItem", + "members": [ { - "name": "Up", - "type": "()" + "name": "item_id", + "type": "core::integer::u32" }, { - "name": "Down", - "type": "()" + "name": "quantity", + "type": "core::integer::u32" } ] }, { "type": "struct", - "name": "dojo_examples::models::Moves", + "name": "dojo_examples::models::PlayerConfig", "members": [ { "name": "player", "type": "core::starknet::contract_address::ContractAddress" }, { - "name": "remaining", - "type": "core::integer::u8" + "name": "name", + "type": "core::byte_array::ByteArray" }, { - "name": "last_direction", - "type": "dojo_examples::models::Direction" + "name": "items", + "type": "core::array::Array::" + }, + { + "name": "favorite_item", + "type": "core::option::Option::" } ] }, { "type": "interface", - "name": "dojo_examples::models::Imoves", + "name": "dojo_examples::models::Iplayer_config", "items": [ { "type": "function", @@ -4179,7 +5321,7 @@ "inputs": [ { "name": "model", - "type": "dojo_examples::models::Moves" + "type": "dojo_examples::models::PlayerConfig" } ], "outputs": [], @@ -4189,13 +5331,13 @@ }, { "type": "event", - "name": "dojo_examples::models::moves::Event", + "name": "dojo_examples::models::player_config::Event", "kind": "enum", "variants": [] } ], - "tag": "dojo_examples-Moves", - "manifest_name": "dojo_examples-Moves-2e2accba" + "tag": "dojo_examples-PlayerConfig", + "manifest_name": "dojo_examples-PlayerConfig-3adad785" }, { "kind": "DojoModel", @@ -4206,23 +5348,13 @@ "key": true }, { - "name": "name", - "type": "ByteArray", - "key": false - }, - { - "name": "items", - "type": "Array", - "key": false - }, - { - "name": "favorite_item", - "type": "Option", + "name": "vec", + "type": "Vec2", "key": false } ], - "class_hash": "0x13f8294fde1c2605e9825782ae293b3bae2291e6cbd20d4ef8878ff044d4b82", - "original_class_hash": "0x13f8294fde1c2605e9825782ae293b3bae2291e6cbd20d4ef8878ff044d4b82", + "class_hash": "0x7104c882f56f62ef1f2453319bf6a1f5784b5f33b63b65506c38d62c3e3fd40", + "original_class_hash": "0x7104c882f56f62ef1f2453319bf6a1f5784b5f33b63b65506c38d62c3e3fd40", "abi": [ { "type": "impl", @@ -4588,48 +5720,40 @@ }, { "type": "impl", - "name": "player_configImpl", - "interface_name": "dojo_examples::models::Iplayer_config" + "name": "positionImpl", + "interface_name": "dojo_examples::models::Iposition" }, { "type": "struct", - "name": "dojo_examples::models::PlayerItem", + "name": "dojo_examples::models::Vec2", "members": [ { - "name": "item_id", + "name": "x", "type": "core::integer::u32" }, { - "name": "quantity", + "name": "y", "type": "core::integer::u32" } ] }, { "type": "struct", - "name": "dojo_examples::models::PlayerConfig", + "name": "dojo_examples::models::Position", "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::" + "name": "vec", + "type": "dojo_examples::models::Vec2" } ] }, { "type": "interface", - "name": "dojo_examples::models::Iplayer_config", + "name": "dojo_examples::models::Iposition", "items": [ { "type": "function", @@ -4637,7 +5761,7 @@ "inputs": [ { "name": "model", - "type": "dojo_examples::models::PlayerConfig" + "type": "dojo_examples::models::Position" } ], "outputs": [], @@ -4647,30 +5771,40 @@ }, { "type": "event", - "name": "dojo_examples::models::player_config::Event", + "name": "dojo_examples::models::position::Event", "kind": "enum", "variants": [] } ], - "tag": "dojo_examples-PlayerConfig", - "manifest_name": "dojo_examples-PlayerConfig-3adad785" + "tag": "dojo_examples-Position", + "manifest_name": "dojo_examples-Position-1e145e26" }, { "kind": "DojoModel", "members": [ { - "name": "player", - "type": "ContractAddress", + "name": "id", + "type": "u32", "key": true }, { - "name": "vec", - "type": "Vec2", + "name": "health", + "type": "u32", + "key": false + }, + { + "name": "armor", + "type": "u32", + "key": false + }, + { + "name": "attack", + "type": "u32", "key": false } ], - "class_hash": "0x7104c882f56f62ef1f2453319bf6a1f5784b5f33b63b65506c38d62c3e3fd40", - "original_class_hash": "0x7104c882f56f62ef1f2453319bf6a1f5784b5f33b63b65506c38d62c3e3fd40", + "class_hash": "0x645afa3c2890d1b0d1176e20c703225ad7dfa4a16b67417bcd4fad97eac1ebb", + "original_class_hash": "0x645afa3c2890d1b0d1176e20c703225ad7dfa4a16b67417bcd4fad97eac1ebb", "abi": [ { "type": "impl", @@ -5036,40 +6170,34 @@ }, { "type": "impl", - "name": "positionImpl", - "interface_name": "dojo_examples::models::Iposition" + "name": "river_skaleImpl", + "interface_name": "bestiary::Iriver_skale" }, { "type": "struct", - "name": "dojo_examples::models::Vec2", + "name": "bestiary::RiverSkale", "members": [ { - "name": "x", + "name": "id", "type": "core::integer::u32" }, { - "name": "y", + "name": "health", "type": "core::integer::u32" - } - ] - }, - { - "type": "struct", - "name": "dojo_examples::models::Position", - "members": [ + }, { - "name": "player", - "type": "core::starknet::contract_address::ContractAddress" + "name": "armor", + "type": "core::integer::u32" }, { - "name": "vec", - "type": "dojo_examples::models::Vec2" + "name": "attack", + "type": "core::integer::u32" } ] }, { "type": "interface", - "name": "dojo_examples::models::Iposition", + "name": "bestiary::Iriver_skale", "items": [ { "type": "function", @@ -5077,7 +6205,7 @@ "inputs": [ { "name": "model", - "type": "dojo_examples::models::Position" + "type": "bestiary::RiverSkale" } ], "outputs": [], @@ -5087,13 +6215,13 @@ }, { "type": "event", - "name": "dojo_examples::models::position::Event", + "name": "bestiary::river_skale::Event", "kind": "enum", "variants": [] } ], - "tag": "dojo_examples-Position", - "manifest_name": "dojo_examples-Position-1e145e26" + "tag": "dojo_examples-RiverSkale", + "manifest_name": "dojo_examples-RiverSkale-27fcbc29" }, { "kind": "DojoModel", diff --git a/examples/spawn-and-move/manifests/dev/deployment/manifest.toml b/examples/spawn-and-move/manifests/dev/deployment/manifest.toml index 6c9080ead0..39db99a835 100644 --- a/examples/spawn-and-move/manifests/dev/deployment/manifest.toml +++ b/examples/spawn-and-move/manifests/dev/deployment/manifest.toml @@ -24,8 +24,8 @@ manifest_name = "dojo-base" [[contracts]] kind = "DojoContract" address = "0x2e85647f570d2a4abdffdd668823702548d20d1d6aaef74b6a4eb9670a32798" -class_hash = "0x647694c15fff8476c82ea146d0dbdbbb17d3425d5ba05a7320e4322f916df1d" -original_class_hash = "0x647694c15fff8476c82ea146d0dbdbbb17d3425d5ba05a7320e4322f916df1d" +class_hash = "0x5693c8ae37b78934041173e9a1abd868e09b89d27fb2fc53702b69e48bfa94f" +original_class_hash = "0x5693c8ae37b78934041173e9a1abd868e09b89d27fb2fc53702b69e48bfa94f" base_class_hash = "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4" abi = "manifests/dev/deployment/abis/contracts/dojo_examples-actions-40b6994c.json" reads = [] @@ -38,6 +38,20 @@ init_calldata = [] tag = "dojo_examples-actions" manifest_name = "dojo_examples-actions-40b6994c" +[[contracts]] +kind = "DojoContract" +address = "0x4f38db968d53b073189760e1256d827195de3904542cf62d60e6bd3707f8504" +class_hash = "0x14b3096b82a761f63dd47277c2b5ac18925dea43586418483939a2f1f57f674" +original_class_hash = "0x14b3096b82a761f63dd47277c2b5ac18925dea43586418483939a2f1f57f674" +base_class_hash = "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4" +abi = "manifests/dev/deployment/abis/contracts/dojo_examples-dungeon-6620e0e6.json" +reads = [] +writes = [] +computed = [] +init_calldata = [] +tag = "dojo_examples-dungeon" +manifest_name = "dojo_examples-dungeon-6620e0e6" + [[contracts]] kind = "DojoContract" address = "0x6a06eb156f956f1691bce4a4573c97b1a5f08d3bfa65fc25c4ed4b55d3e61a1" @@ -93,6 +107,29 @@ name = "value" type = "u8" key = false +[[models]] +kind = "DojoModel" +class_hash = "0x452abb4fc0af6e0e08e6f652ce77d7330000d4e4bec995005785c7d3f12ea1a" +original_class_hash = "0x452abb4fc0af6e0e08e6f652ce77d7330000d4e4bec995005785c7d3f12ea1a" +abi = "manifests/dev/deployment/abis/models/dojo_examples-Flatbow-3632af69.json" +tag = "dojo_examples-Flatbow" +manifest_name = "dojo_examples-Flatbow-3632af69" + +[[models.members]] +name = "id" +type = "u32" +key = true + +[[models.members]] +name = "atk_speek" +type = "u32" +key = false + +[[models.members]] +name = "range" +type = "u32" +key = false + [[models]] kind = "DojoModel" class_hash = "0x572bf6d3cbcd69fd6404a993110c3b84379882587b21b7ad5b2761088cb19c3" @@ -226,6 +263,34 @@ name = "vec" type = "Vec2" key = false +[[models]] +kind = "DojoModel" +class_hash = "0x645afa3c2890d1b0d1176e20c703225ad7dfa4a16b67417bcd4fad97eac1ebb" +original_class_hash = "0x645afa3c2890d1b0d1176e20c703225ad7dfa4a16b67417bcd4fad97eac1ebb" +abi = "manifests/dev/deployment/abis/models/dojo_examples-RiverSkale-27fcbc29.json" +tag = "dojo_examples-RiverSkale" +manifest_name = "dojo_examples-RiverSkale-27fcbc29" + +[[models.members]] +name = "id" +type = "u32" +key = true + +[[models.members]] +name = "health" +type = "u32" +key = false + +[[models.members]] +name = "armor" +type = "u32" +key = false + +[[models.members]] +name = "attack" +type = "u32" +key = false + [[models]] kind = "DojoModel" class_hash = "0x48dfe99daae31ced8d121079c148d084311483f047519d2d3fae363f15c7a1f" diff --git a/examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-actions-40b6994c.json b/examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-actions-40b6994c.json index a8654af001..1e5a2ea426 100644 --- a/examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-actions-40b6994c.json +++ b/examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-actions-40b6994c.json @@ -299,15 +299,15 @@ }, { "type": "function", - "name": "call_something", + "name": "enter_dungeon", "inputs": [ { - "name": "something_address", + "name": "dungeon_address", "type": "core::starknet::contract_address::ContractAddress" } ], "outputs": [], - "state_mutability": "view" + "state_mutability": "external" } ] }, diff --git a/examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-dungeon-6620e0e6.json b/examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-dungeon-6620e0e6.json new file mode 100644 index 0000000000..b48fc407a5 --- /dev/null +++ b/examples/spawn-and-move/manifests/release/base/abis/contracts/dojo_examples-dungeon-6620e0e6.json @@ -0,0 +1,224 @@ +[ + { + "type": "impl", + "name": "ContractImpl", + "interface_name": "dojo::contract::IContract" + }, + { + "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::contract::IContract", + "items": [ + { + "type": "function", + "name": "contract_name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "tag", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "selector", + "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": "IDungeonImpl", + "interface_name": "dojo_examples::dungeon::IDungeon" + }, + { + "type": "interface", + "name": "dojo_examples::dungeon::IDungeon", + "items": [ + { + "type": "function", + "name": "enter", + "inputs": [], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "IDojoInitImpl", + "interface_name": "dojo_examples::dungeon::dungeon::IDojoInit" + }, + { + "type": "interface", + "name": "dojo_examples::dungeon::dungeon::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::dungeon::dungeon::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/base/abis/models/dojo_examples-Flatbow-3632af69.json b/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-Flatbow-3632af69.json new file mode 100644 index 0000000000..50d5861a0a --- /dev/null +++ b/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-Flatbow-3632af69.json @@ -0,0 +1,411 @@ +[ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::IModel" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::database::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::database::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::database::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::IModel", + "items": [ + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "tag", + "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": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "flatbowImpl", + "interface_name": "armory::Iflatbow" + }, + { + "type": "struct", + "name": "armory::Flatbow", + "members": [ + { + "name": "id", + "type": "core::integer::u32" + }, + { + "name": "atk_speek", + "type": "core::integer::u32" + }, + { + "name": "range", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "armory::Iflatbow", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "armory::Flatbow" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "armory::flatbow::Event", + "kind": "enum", + "variants": [] + } +] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-RiverSkale-27fcbc29.json b/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-RiverSkale-27fcbc29.json new file mode 100644 index 0000000000..4d4a41214e --- /dev/null +++ b/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-RiverSkale-27fcbc29.json @@ -0,0 +1,415 @@ +[ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::IModel" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::database::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::database::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::database::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::IModel", + "items": [ + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "tag", + "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": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "river_skaleImpl", + "interface_name": "bestiary::Iriver_skale" + }, + { + "type": "struct", + "name": "bestiary::RiverSkale", + "members": [ + { + "name": "id", + "type": "core::integer::u32" + }, + { + "name": "health", + "type": "core::integer::u32" + }, + { + "name": "armor", + "type": "core::integer::u32" + }, + { + "name": "attack", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "bestiary::Iriver_skale", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "bestiary::RiverSkale" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "bestiary::river_skale::Event", + "kind": "enum", + "variants": [] + } +] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-actions-40b6994c.toml b/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-actions-40b6994c.toml index e5a46e3a69..9b73241efc 100644 --- a/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-actions-40b6994c.toml +++ b/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-actions-40b6994c.toml @@ -1,6 +1,6 @@ kind = "DojoContract" -class_hash = "0x1843e2e8c174c087de5ebaf04eee196eb0526b6345ad5ac3a6055d4e0dd1363" -original_class_hash = "0x1843e2e8c174c087de5ebaf04eee196eb0526b6345ad5ac3a6055d4e0dd1363" +class_hash = "0x5693c8ae37b78934041173e9a1abd868e09b89d27fb2fc53702b69e48bfa94f" +original_class_hash = "0x5693c8ae37b78934041173e9a1abd868e09b89d27fb2fc53702b69e48bfa94f" base_class_hash = "0x0" abi = "manifests/release/base/abis/contracts/dojo_examples-actions-40b6994c.json" reads = [] diff --git a/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-dungeon-6620e0e6.toml b/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-dungeon-6620e0e6.toml new file mode 100644 index 0000000000..5c41c10ae2 --- /dev/null +++ b/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-dungeon-6620e0e6.toml @@ -0,0 +1,11 @@ +kind = "DojoContract" +class_hash = "0x14b3096b82a761f63dd47277c2b5ac18925dea43586418483939a2f1f57f674" +original_class_hash = "0x14b3096b82a761f63dd47277c2b5ac18925dea43586418483939a2f1f57f674" +base_class_hash = "0x0" +abi = "manifests/release/base/abis/contracts/dojo_examples-dungeon-6620e0e6.json" +reads = [] +writes = [] +computed = [] +init_calldata = [] +tag = "dojo_examples-dungeon" +manifest_name = "dojo_examples-dungeon-6620e0e6" diff --git a/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-something-71cfad55.toml b/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-something-71cfad55.toml deleted file mode 100644 index cb4974411e..0000000000 --- a/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-something-71cfad55.toml +++ /dev/null @@ -1,11 +0,0 @@ -kind = "DojoContract" -class_hash = "0x2633dd37ecb3e273b309a3339da5dc820f2b77d4da474d7215952a1b60950dc" -original_class_hash = "0x2633dd37ecb3e273b309a3339da5dc820f2b77d4da474d7215952a1b60950dc" -base_class_hash = "0x0" -abi = "manifests/release/base/abis/contracts/dojo_examples-something-71cfad55.json" -reads = [] -writes = [] -computed = [] -init_calldata = [] -tag = "dojo_examples-something" -manifest_name = "dojo_examples-something-71cfad55" diff --git a/examples/spawn-and-move/manifests/release/base/models/dojo_examples-Flatbow-3632af69.toml b/examples/spawn-and-move/manifests/release/base/models/dojo_examples-Flatbow-3632af69.toml new file mode 100644 index 0000000000..882bfd9cf8 --- /dev/null +++ b/examples/spawn-and-move/manifests/release/base/models/dojo_examples-Flatbow-3632af69.toml @@ -0,0 +1,21 @@ +kind = "DojoModel" +class_hash = "0x452abb4fc0af6e0e08e6f652ce77d7330000d4e4bec995005785c7d3f12ea1a" +original_class_hash = "0x452abb4fc0af6e0e08e6f652ce77d7330000d4e4bec995005785c7d3f12ea1a" +abi = "manifests/release/base/abis/models/dojo_examples-Flatbow-3632af69.json" +tag = "dojo_examples-Flatbow" +manifest_name = "dojo_examples-Flatbow-3632af69" + +[[members]] +name = "id" +type = "u32" +key = true + +[[members]] +name = "atk_speek" +type = "u32" +key = false + +[[members]] +name = "range" +type = "u32" +key = false diff --git a/examples/spawn-and-move/manifests/release/base/models/dojo_examples-RiverSkale-27fcbc29.toml b/examples/spawn-and-move/manifests/release/base/models/dojo_examples-RiverSkale-27fcbc29.toml new file mode 100644 index 0000000000..c586684dd4 --- /dev/null +++ b/examples/spawn-and-move/manifests/release/base/models/dojo_examples-RiverSkale-27fcbc29.toml @@ -0,0 +1,26 @@ +kind = "DojoModel" +class_hash = "0x645afa3c2890d1b0d1176e20c703225ad7dfa4a16b67417bcd4fad97eac1ebb" +original_class_hash = "0x645afa3c2890d1b0d1176e20c703225ad7dfa4a16b67417bcd4fad97eac1ebb" +abi = "manifests/release/base/abis/models/dojo_examples-RiverSkale-27fcbc29.json" +tag = "dojo_examples-RiverSkale" +manifest_name = "dojo_examples-RiverSkale-27fcbc29" + +[[members]] +name = "id" +type = "u32" +key = true + +[[members]] +name = "health" +type = "u32" +key = false + +[[members]] +name = "armor" +type = "u32" +key = false + +[[members]] +name = "attack" +type = "u32" +key = false diff --git a/examples/spawn-and-move/src/actions.cairo b/examples/spawn-and-move/src/actions.cairo index 350ad568ee..bc95a5899d 100644 --- a/examples/spawn-and-move/src/actions.cairo +++ b/examples/spawn-and-move/src/actions.cairo @@ -1,6 +1,4 @@ use dojo_examples::models::{Direction, Position, Vec2}; -#[cfg(feature: 'something')] -use starknet::ContractAddress; #[dojo::interface] trait IActions { @@ -10,8 +8,8 @@ trait IActions { fn get_player_position(world: @IWorldDispatcher) -> Position; fn reset_player_config(ref world: IWorldDispatcher); fn set_player_server_profile(ref world: IWorldDispatcher, server_id: u32, name: ByteArray); - #[cfg(feature: 'something')] - fn call_something(something_address: ContractAddress); + #[cfg(feature: 'dungeon')] + fn enter_dungeon(ref world: IWorldDispatcher, dungeon_address: starknet::ContractAddress); } #[dojo::interface] @@ -30,8 +28,15 @@ mod actions { Position, Moves, Direction, Vec2, PlayerConfig, PlayerItem, ServerProfile }; use dojo_examples::utils::next_position; - #[cfg(feature: 'something')] - use dojo_examples::something::{ISomethingDispatcher, ISomethingDispatcherTrait}; + + // Featues can be used on modules, structs, trait and `use`. Not inside + // a function. + #[cfg(feature: 'dungeon')] + use dojo_examples::dungeon::{IDungeonDispatcher, IDungeonDispatcherTrait}; + #[cfg(feature: 'dungeon')] + use armory::Flatbow; + #[cfg(feature: 'dungeon')] + use bestiary::RiverSkale; #[derive(Copy, Drop, Serde)] #[dojo::event] @@ -130,11 +135,14 @@ mod actions { get!(world, player, (Position)) } - #[cfg(feature: 'something')] - fn call_something(something_address: ContractAddress) { - let something = ISomethingDispatcher { contract_address: something_address }; + #[cfg(feature: 'dungeon')] + fn enter_dungeon(ref world: IWorldDispatcher, dungeon_address: ContractAddress) { + let flatbow = Flatbow { id: 1, atk_speek: 2, range: 1 }; + let river_skale = RiverSkale { id: 1, health: 5, armor: 3, attack: 2 }; + + set!(world, (flatbow, river_skale)); - something.something(); + IDungeonDispatcher { contract_address: dungeon_address }.enter(); } } diff --git a/examples/spawn-and-move/src/dungeon.cairo b/examples/spawn-and-move/src/dungeon.cairo new file mode 100644 index 0000000000..ce7e40af9c --- /dev/null +++ b/examples/spawn-and-move/src/dungeon.cairo @@ -0,0 +1,12 @@ +#[dojo::interface] +trait IDungeon { + fn enter(); +} + +#[dojo::contract] +mod dungeon { + #[abi(embed_v0)] + impl IDungeonImpl of super::IDungeon { + fn enter() {} + } +} diff --git a/examples/spawn-and-move/src/lib.cairo b/examples/spawn-and-move/src/lib.cairo index 1eb02d648a..508962290e 100644 --- a/examples/spawn-and-move/src/lib.cairo +++ b/examples/spawn-and-move/src/lib.cairo @@ -3,5 +3,5 @@ mod models; mod utils; mod others; mod mock_token; -#[cfg(feature: 'something')] -mod something; +#[cfg(feature: 'dungeon')] +mod dungeon; diff --git a/examples/spawn-and-move/src/something.cairo b/examples/spawn-and-move/src/something.cairo deleted file mode 100644 index d6746dfce6..0000000000 --- a/examples/spawn-and-move/src/something.cairo +++ /dev/null @@ -1,12 +0,0 @@ -#[dojo::interface] -trait ISomething { - fn something(); -} - -#[dojo::contract] -mod something { - #[abi(embed_v0)] - impl ISomethingImpl of super::ISomething { - fn something() {} - } -} From 1ddc411a58fadcf939fab01d413ae3e19c4144bd Mon Sep 17 00:00:00 2001 From: glihm Date: Wed, 10 Jul 2024 20:49:32 -0600 Subject: [PATCH 03/15] fix: add missing namespace for testing dojo core --- crates/dojo-core/Scarb.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/dojo-core/Scarb.toml b/crates/dojo-core/Scarb.toml index 0aa197423e..5b60872629 100644 --- a/crates/dojo-core/Scarb.toml +++ b/crates/dojo-core/Scarb.toml @@ -7,3 +7,8 @@ version = "0.7.3" [dependencies] dojo_plugin = { git = "https://github.com/dojoengine/dojo", tag = "v0.7.3" } starknet = "=2.6.4" + +# Dojo core is tested with sozo, hence we need a namespace for the test +# command to work. +[tool.dojo.world] +namespace = "dojo" From 18dfea277106a5f3a931bc7c6b4bd607cc9fb26a Mon Sep 17 00:00:00 2001 From: glihm Date: Wed, 10 Jul 2024 20:55:54 -0600 Subject: [PATCH 04/15] fix: use unwrap_or instead of match --- crates/dojo-lang/src/contract.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/dojo-lang/src/contract.rs b/crates/dojo-lang/src/contract.rs index 1f5284d461..4703cb755d 100644 --- a/crates/dojo-lang/src/contract.rs +++ b/crates/dojo-lang/src/contract.rs @@ -54,10 +54,7 @@ impl DojoContract { let mut has_storage = false; let mut has_init = false; - let contract_namespace = match parameters.namespace { - Some(x) => x.to_string(), - None => default_namespace, - }; + let contract_namespace = parameters.namespace.unwrap_or(default_namespace); for (id, value) in [("name", &name.to_string()), ("namespace", &contract_namespace)] { if !is_name_valid(value) { From 38e4474fc391d10a7e31cbfb2a837d9c6859cae7 Mon Sep 17 00:00:00 2001 From: glihm Date: Thu, 11 Jul 2024 09:54:59 -0600 Subject: [PATCH 05/15] fix: use and_then instead of nested tests --- crates/dojo-lang/src/utils.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/dojo-lang/src/utils.rs b/crates/dojo-lang/src/utils.rs index 3b9a7d553c..43bc4aeb73 100644 --- a/crates/dojo-lang/src/utils.rs +++ b/crates/dojo-lang/src/utils.rs @@ -38,15 +38,15 @@ pub fn get_default_namespace(db: &dyn SyntaxGroup) -> Option { Err(_) => return Option::None, }; - if config.contains_key("tool") - && config["tool"].as_table().unwrap().contains_key("dojo") - && config["tool"]["dojo"].as_table().unwrap().contains_key("world") - && config["tool"]["dojo"]["world"].as_table().unwrap().contains_key("namespace") - { - return Some( - config["tool"]["dojo"]["world"]["namespace"].as_str().unwrap().to_string(), - ); - }; + if let Some(tool) = config.get("tool").and_then(|t| t.as_table()) { + if let Some(dojo) = tool.get("dojo").and_then(|d| d.as_table()) { + if let Some(world) = dojo.get("world").and_then(|w| w.as_table()) { + if let Some(namespace) = world.get("namespace").and_then(|n| n.as_str()) { + return Some(namespace.to_string()); + } + } + } + } } Option::None From fba3732b51e06d4ede962fb82ac3d095badf0645 Mon Sep 17 00:00:00 2001 From: glihm Date: Thu, 11 Jul 2024 17:43:42 -0600 Subject: [PATCH 06/15] fix: change namespace config as a struct in the scarb manifest --- Cargo.lock | 1 + crates/dojo-core/Scarb.toml | 2 +- crates/dojo-lang/src/compiler.rs | 11 +- crates/dojo-lang/src/contract.rs | 12 +- .../contracts/ccf-cairo_v240-8d921297.json | 8 - .../contracts/ccf-cairo_v260-465ec7fe.json | 8 - .../manifests/dev/base/abis/dojo-base.json | 98 -- .../manifests/dev/base/abis/dojo-world.json | 1105 ----------------- .../contracts/ccf-cairo_v240-8d921297.toml | 11 - .../contracts/ccf-cairo_v260-465ec7fe.toml | 11 - .../manifests/dev/base/dojo-base.toml | 6 - .../manifests/dev/base/dojo-world.toml | 6 - crates/dojo-lang/src/model.rs | 19 +- crates/dojo-lang/src/plugin.rs | 27 +- .../dojo-lang/src/plugin_test_data/introspect | 216 ++-- crates/dojo-lang/src/plugin_test_data/model | 44 +- crates/dojo-lang/src/plugin_test_data/print | 14 +- crates/dojo-lang/src/plugin_test_data/system | 92 +- crates/dojo-lang/src/semantics/test_data/get | 42 +- crates/dojo-lang/src/semantics/test_data/set | 16 +- crates/dojo-lang/src/utils.rs | 41 +- crates/dojo-world/Cargo.toml | 1 + crates/dojo-world/src/metadata.rs | 198 ++- crates/dojo-world/src/metadata_test.rs | 8 +- examples/game-lib/armory/Scarb.toml | 2 +- examples/game-lib/armory/src/lib.cairo | 2 +- examples/game-lib/bestiary/Scarb.toml | 2 +- examples/game-lib/bestiary/src/lib.cairo | 2 +- .../models/bestiary-RiverSkale-1bce2040.toml | 26 - examples/spawn-and-move/Scarb.toml | 7 +- ...jo_examples_foes-RiverSkale-39535c12.json} | 0 ...jo_examples_weapons-Flatbow-22f5bd16.json} | 0 .../dojo_examples-actions-40b6994c.toml | 4 +- .../dojo_examples-Flatbow-3632af69.toml | 21 - .../dojo_examples-RiverSkale-27fcbc29.toml | 26 - ...ojo_examples_foes-RiverSkale-39535c12.toml | 26 + ...ojo_examples_weapons-Flatbow-22f5bd16.toml | 21 + ...jo_examples_foes-RiverSkale-39535c12.json} | 0 ...jo_examples_weapons-Flatbow-22f5bd16.json} | 0 .../manifests/dev/deployment/manifest.json | 422 +++---- .../manifests/dev/deployment/manifest.toml | 82 +- ...jo_examples_foes-RiverSkale-39535c12.json} | 0 ...ojo_examples_weapons-Flatbow-22f5bd16.json | 411 ++++++ .../dojo_examples-actions-40b6994c.toml | 4 +- .../dojo_examples-Flatbow-3632af69.toml | 21 - .../dojo_examples-RiverSkale-27fcbc29.toml | 26 - ...ojo_examples_foes-RiverSkale-39535c12.toml | 26 + ...ojo_examples_weapons-Flatbow-22f5bd16.toml | 21 + 48 files changed, 1253 insertions(+), 1896 deletions(-) delete mode 100644 crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/contracts/ccf-cairo_v240-8d921297.json delete mode 100644 crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/contracts/ccf-cairo_v260-465ec7fe.json delete mode 100644 crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-base.json delete mode 100644 crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-world.json delete mode 100644 crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/contracts/ccf-cairo_v240-8d921297.toml delete mode 100644 crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/contracts/ccf-cairo_v260-465ec7fe.toml delete mode 100644 crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-base.toml delete mode 100644 crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-world.toml delete mode 100644 examples/game-lib/manifests/dev/base/models/bestiary-RiverSkale-1bce2040.toml rename examples/{game-lib/manifests/dev/base/abis/models/bestiary-RiverSkale-1bce2040.json => spawn-and-move/manifests/dev/base/abis/models/dojo_examples_foes-RiverSkale-39535c12.json} (100%) rename examples/spawn-and-move/manifests/dev/base/abis/models/{dojo_examples-Flatbow-3632af69.json => dojo_examples_weapons-Flatbow-22f5bd16.json} (100%) delete mode 100644 examples/spawn-and-move/manifests/dev/base/models/dojo_examples-Flatbow-3632af69.toml delete mode 100644 examples/spawn-and-move/manifests/dev/base/models/dojo_examples-RiverSkale-27fcbc29.toml create mode 100644 examples/spawn-and-move/manifests/dev/base/models/dojo_examples_foes-RiverSkale-39535c12.toml create mode 100644 examples/spawn-and-move/manifests/dev/base/models/dojo_examples_weapons-Flatbow-22f5bd16.toml rename examples/spawn-and-move/manifests/dev/{base/abis/models/dojo_examples-RiverSkale-27fcbc29.json => deployment/abis/models/dojo_examples_foes-RiverSkale-39535c12.json} (100%) rename examples/spawn-and-move/manifests/{release/base/abis/models/dojo_examples-Flatbow-3632af69.json => dev/deployment/abis/models/dojo_examples_weapons-Flatbow-22f5bd16.json} (100%) rename examples/spawn-and-move/manifests/release/base/abis/models/{dojo_examples-RiverSkale-27fcbc29.json => dojo_examples_foes-RiverSkale-39535c12.json} (100%) create mode 100644 examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples_weapons-Flatbow-22f5bd16.json delete mode 100644 examples/spawn-and-move/manifests/release/base/models/dojo_examples-Flatbow-3632af69.toml delete mode 100644 examples/spawn-and-move/manifests/release/base/models/dojo_examples-RiverSkale-27fcbc29.toml create mode 100644 examples/spawn-and-move/manifests/release/base/models/dojo_examples_foes-RiverSkale-39535c12.toml create mode 100644 examples/spawn-and-move/manifests/release/base/models/dojo_examples_weapons-Flatbow-22f5bd16.toml diff --git a/Cargo.lock b/Cargo.lock index 330fc070f5..d3d05531a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4963,6 +4963,7 @@ dependencies = [ "ipfs-api-backend-hyper", "katana-runner", "num-traits 0.2.19", + "regex", "scarb", "serde", "serde_json", diff --git a/crates/dojo-core/Scarb.toml b/crates/dojo-core/Scarb.toml index 5b60872629..eddba51daa 100644 --- a/crates/dojo-core/Scarb.toml +++ b/crates/dojo-core/Scarb.toml @@ -11,4 +11,4 @@ starknet = "=2.6.4" # Dojo core is tested with sozo, hence we need a namespace for the test # command to work. [tool.dojo.world] -namespace = "dojo" +namespace = { default = "dojo" } diff --git a/crates/dojo-lang/src/compiler.rs b/crates/dojo-lang/src/compiler.rs index eb4454cf0b..11e79380cb 100644 --- a/crates/dojo-lang/src/compiler.rs +++ b/crates/dojo-lang/src/compiler.rs @@ -26,7 +26,7 @@ use dojo_world::manifest::{ ABIS_DIR, BASE_CONTRACT_TAG, BASE_DIR, BASE_QUALIFIED_PATH, CONTRACTS_DIR, MANIFESTS_DIR, MODELS_DIR, WORLD_CONTRACT_TAG, WORLD_QUALIFIED_PATH, }; -use dojo_world::metadata::get_default_namespace_from_ws; +use dojo_world::metadata::get_namespace_config_from_ws; use itertools::Itertools; use scarb::compiler::helpers::{build_compiler_config, collect_main_crate_ids}; use scarb::compiler::{CairoCompilationUnit, CompilationUnitAttributes, Compiler}; @@ -88,8 +88,6 @@ impl Compiler for DojoCompiler { let props: Props = unit.main_component().target_props()?; let target_dir = unit.target_dir(ws); - let default_namespace = get_default_namespace_from_ws(ws)?; - let compiler_config = build_compiler_config(&unit, ws); let mut main_crate_ids = collect_main_crate_ids(&unit, db); @@ -137,7 +135,6 @@ impl Compiler for DojoCompiler { &main_crate_ids, compiled_classes, props.build_external_contracts, - &default_namespace, )?; Ok(()) } @@ -223,8 +220,9 @@ fn update_files( crate_ids: &[CrateId], compiled_artifacts: HashMap, external_contracts: Option>, - default_namespace: &str, ) -> anyhow::Result<()> { + let namespace_config = get_namespace_config_from_ws(ws)?; + let profile_name = ws.current_profile().expect("Scarb profile expected to be defined.").to_string(); let relative_manifest_dir = Utf8PathBuf::new().join(MANIFESTS_DIR).join(profile_name); @@ -247,6 +245,7 @@ fn update_files( let mut crate_ids = crate_ids.to_vec(); + // World and base contracts from Dojo core. for (qualified_path, tag) in [(WORLD_QUALIFIED_PATH, WORLD_CONTRACT_TAG), (BASE_QUALIFIED_PATH, BASE_CONTRACT_TAG)] { @@ -311,7 +310,7 @@ fn update_files( contracts.extend(get_dojo_contract_artifacts( db, module_id, - &naming::get_tag(default_namespace, &aux_data.contract_name), + &naming::get_tag(&namespace_config.default, &aux_data.contract_name), &compiled_artifacts, )?); } diff --git a/crates/dojo-lang/src/contract.rs b/crates/dojo-lang/src/contract.rs index 4703cb755d..4467486b0a 100644 --- a/crates/dojo-lang/src/contract.rs +++ b/crates/dojo-lang/src/contract.rs @@ -16,11 +16,11 @@ use cairo_lang_syntax::node::{ast, ids, Terminal, TypedStablePtr, TypedSyntaxNod use cairo_lang_utils::unordered_hash_map::UnorderedHashMap; use dojo_types::system::Dependency; use dojo_world::contracts::naming; +use dojo_world::metadata::{is_name_valid, NamespaceConfig}; 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_name_valid; const DOJO_INIT_FN: &str = "dojo_init"; const CONTRACT_NAMESPACE: &str = "namespace"; @@ -40,7 +40,7 @@ impl DojoContract { pub fn from_module( db: &dyn SyntaxGroup, module_ast: &ast::ItemModule, - default_namespace: String, + namespace_config: &NamespaceConfig, metadata: &MacroPluginMetadata<'_>, ) -> PluginResult { let name = module_ast.name(db).text(db); @@ -54,7 +54,11 @@ impl DojoContract { let mut has_storage = false; let mut has_init = false; - let contract_namespace = parameters.namespace.unwrap_or(default_namespace); + let unmapped_namespace = parameters.namespace.unwrap_or(namespace_config.default.clone()); + + // Maps namespace from the tag to ensure higher precision on matching namespace mappings. + let contract_namespace = + namespace_config.get_mapping(&naming::get_tag(&unmapped_namespace, &name)); for (id, value) in [("name", &name.to_string()), ("namespace", &contract_namespace)] { if !is_name_valid(value) { @@ -64,7 +68,7 @@ impl DojoContract { stable_ptr: module_ast.stable_ptr().0, message: format!( "The contract {id} '{value}' can only contain characters (a-z/A-Z), \ - numbers (0-9) and underscore (_)" + digits (0-9) and underscore (_)." ), severity: Severity::Error, }], diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/contracts/ccf-cairo_v240-8d921297.json b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/contracts/ccf-cairo_v240-8d921297.json deleted file mode 100644 index fdb8ff1c75..0000000000 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/contracts/ccf-cairo_v240-8d921297.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - { - "type": "event", - "name": "compiler_cairo::cairo_24::cairo_v240::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/contracts/ccf-cairo_v260-465ec7fe.json b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/contracts/ccf-cairo_v260-465ec7fe.json deleted file mode 100644 index 86eebdcf3f..0000000000 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/contracts/ccf-cairo_v260-465ec7fe.json +++ /dev/null @@ -1,8 +0,0 @@ -[ - { - "type": "event", - "name": "compiler_cairo::cairo_26::cairo_v260::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-base.json b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-base.json deleted file mode 100644 index ee9ceaac66..0000000000 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-base.json +++ /dev/null @@ -1,98 +0,0 @@ -[ - { - "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": "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": "constructor", - "name": "constructor", - "inputs": [] - }, - { - "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::base::base::Event", - "kind": "enum", - "variants": [ - { - "name": "UpgradeableEvent", - "type": "dojo::components::upgradeable::upgradeable::Event", - "kind": "flat" - } - ] - } -] \ No newline at end of file diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-world.json b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-world.json deleted file mode 100644 index 0e5e96210e..0000000000 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-world.json +++ /dev/null @@ -1,1105 +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": "register_namespace", - "inputs": [ - { - "name": "namespace", - "type": "core::byte_array::ByteArray" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "deploy_contract", - "inputs": [ - { - "name": "salt", - "type": "core::felt252" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - }, - { - "name": "init_calldata", - "type": "core::array::Span::" - } - ], - "outputs": [ - { - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "state_mutability": "external" - }, - { - "type": "function", - "name": "upgrade_contract", - "inputs": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [ - { - "type": "core::starknet::class_hash::ClassHash" - } - ], - "state_mutability": "external" - }, - { - "type": "function", - "name": "uuid", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u32" - } - ], - "state_mutability": "external" - }, - { - "type": "function", - "name": "emit", - "inputs": [ - { - "name": "keys", - "type": "core::array::Array::" - }, - { - "name": "values", - "type": "core::array::Span::" - } - ], - "outputs": [], - "state_mutability": "view" - }, - { - "type": "function", - "name": "entity", - "inputs": [ - { - "name": "model", - "type": "core::felt252" - }, - { - "name": "keys", - "type": "core::array::Span::" - }, - { - "name": "layout", - "type": "dojo::database::introspect::Layout" - } - ], - "outputs": [ - { - "type": "core::array::Span::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "set_entity", - "inputs": [ - { - "name": "model", - "type": "core::felt252" - }, - { - "name": "keys", - "type": "core::array::Span::" - }, - { - "name": "values", - "type": "core::array::Span::" - }, - { - "name": "layout", - "type": "dojo::database::introspect::Layout" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "delete_entity", - "inputs": [ - { - "name": "model", - "type": "core::felt252" - }, - { - "name": "keys", - "type": "core::array::Span::" - }, - { - "name": "layout", - "type": "dojo::database::introspect::Layout" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "base", - "inputs": [], - "outputs": [ - { - "type": "core::starknet::class_hash::ClassHash" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "is_owner", - "inputs": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "resource", - "type": "core::felt252" - } - ], - "outputs": [ - { - "type": "core::bool" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "grant_owner", - "inputs": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "resource", - "type": "core::felt252" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "revoke_owner", - "inputs": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "resource", - "type": "core::felt252" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "is_writer", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [ - { - "type": "core::bool" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "grant_writer", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "revoke_writer", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "can_write_resource", - "inputs": [ - { - "name": "resource_id", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [ - { - "type": "core::bool" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "can_write_model", - "inputs": [ - { - "name": "model_id", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [ - { - "type": "core::bool" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "can_write_namespace", - "inputs": [ - { - "name": "namespace_id", - "type": "core::felt252" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [ - { - "type": "core::bool" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "UpgradeableWorld", - "interface_name": "dojo::world::IUpgradeableWorld" - }, - { - "type": "interface", - "name": "dojo::world::IUpgradeableWorld", - "items": [ - { - "type": "function", - "name": "upgrade", - "inputs": [ - { - "name": "new_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "impl", - "name": "UpgradeableState", - "interface_name": "dojo::interfaces::IUpgradeableState" - }, - { - "type": "struct", - "name": "dojo::interfaces::StorageUpdate", - "members": [ - { - "name": "key", - "type": "core::felt252" - }, - { - "name": "value", - "type": "core::felt252" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::interfaces::ProgramOutput", - "members": [ - { - "name": "prev_state_root", - "type": "core::felt252" - }, - { - "name": "new_state_root", - "type": "core::felt252" - }, - { - "name": "block_number", - "type": "core::felt252" - }, - { - "name": "block_hash", - "type": "core::felt252" - }, - { - "name": "config_hash", - "type": "core::felt252" - }, - { - "name": "world_da_hash", - "type": "core::felt252" - }, - { - "name": "message_to_starknet_segment", - "type": "core::array::Span::" - }, - { - "name": "message_to_appchain_segment", - "type": "core::array::Span::" - } - ] - }, - { - "type": "interface", - "name": "dojo::interfaces::IUpgradeableState", - "items": [ - { - "type": "function", - "name": "upgrade_state", - "inputs": [ - { - "name": "new_state", - "type": "core::array::Span::" - }, - { - "name": "program_output", - "type": "dojo::interfaces::ProgramOutput" - }, - { - "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" - }, - { - "name": "namespace", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "name", - "type": "core::byte_array::ByteArray", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::ContractUpgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::WorldUpgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::MetadataUpdate", - "kind": "struct", - "members": [ - { - "name": "resource", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "uri", - "type": "core::byte_array::ByteArray", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::NamespaceRegistered", - "kind": "struct", - "members": [ - { - "name": "namespace", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "hash", - "type": "core::felt252", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::ModelRegistered", - "kind": "struct", - "members": [ - { - "name": "name", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "namespace", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "prev_class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "prev_address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::StoreSetRecord", - "kind": "struct", - "members": [ - { - "name": "table", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "keys", - "type": "core::array::Span::", - "kind": "data" - }, - { - "name": "values", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::StoreDelRecord", - "kind": "struct", - "members": [ - { - "name": "table", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "keys", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::WriterUpdated", - "kind": "struct", - "members": [ - { - "name": "resource", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "value", - "type": "core::bool", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world::OwnerUpdated", - "kind": "struct", - "members": [ - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "resource", - "type": "core::felt252", - "kind": "data" - }, - { - "name": "value", - "type": "core::bool", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::config::component::Config::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": "NamespaceRegistered", - "type": "dojo::world::world::NamespaceRegistered", - "kind": "nested" - }, - { - "name": "ModelRegistered", - "type": "dojo::world::world::ModelRegistered", - "kind": "nested" - }, - { - "name": "StoreSetRecord", - "type": "dojo::world::world::StoreSetRecord", - "kind": "nested" - }, - { - "name": "StoreDelRecord", - "type": "dojo::world::world::StoreDelRecord", - "kind": "nested" - }, - { - "name": "WriterUpdated", - "type": "dojo::world::world::WriterUpdated", - "kind": "nested" - }, - { - "name": "OwnerUpdated", - "type": "dojo::world::world::OwnerUpdated", - "kind": "nested" - }, - { - "name": "ConfigEvent", - "type": "dojo::config::component::Config::Event", - "kind": "nested" - }, - { - "name": "StateUpdated", - "type": "dojo::world::world::StateUpdated", - "kind": "nested" - } - ] - } -] \ No newline at end of file diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/contracts/ccf-cairo_v240-8d921297.toml b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/contracts/ccf-cairo_v240-8d921297.toml deleted file mode 100644 index 2fd8e54479..0000000000 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/contracts/ccf-cairo_v240-8d921297.toml +++ /dev/null @@ -1,11 +0,0 @@ -kind = "DojoContract" -class_hash = "0x1b29f38120f222120acf9b3d66f7015d47c0b11d4e9acdfefa243958c60909d" -original_class_hash = "0x1b29f38120f222120acf9b3d66f7015d47c0b11d4e9acdfefa243958c60909d" -base_class_hash = "0x0" -abi = "manifests/dev/base/abis/contracts/ccf-cairo_v240-8d921297.json" -reads = [] -writes = [] -computed = [] -init_calldata = [] -tag = "ccf-cairo_v240" -manifest_name = "ccf-cairo_v240-8d921297" diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/contracts/ccf-cairo_v260-465ec7fe.toml b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/contracts/ccf-cairo_v260-465ec7fe.toml deleted file mode 100644 index cd8f1e26b2..0000000000 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/contracts/ccf-cairo_v260-465ec7fe.toml +++ /dev/null @@ -1,11 +0,0 @@ -kind = "DojoContract" -class_hash = "0x412449a631f6652b3bbe27841fb6776639e493baad1a5894daeb9260d1b0a63" -original_class_hash = "0x412449a631f6652b3bbe27841fb6776639e493baad1a5894daeb9260d1b0a63" -base_class_hash = "0x0" -abi = "manifests/dev/base/abis/contracts/ccf-cairo_v260-465ec7fe.json" -reads = [] -writes = [] -computed = [] -init_calldata = [] -tag = "ccf-cairo_v260" -manifest_name = "ccf-cairo_v260-465ec7fe" diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-base.toml b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-base.toml deleted file mode 100644 index aa92e94fac..0000000000 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-base.toml +++ /dev/null @@ -1,6 +0,0 @@ -kind = "Class" -class_hash = "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4" -original_class_hash = "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4" -abi = "manifests/dev/base/abis/dojo-base.json" -tag = "dojo-base" -manifest_name = "dojo-base" diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-world.toml b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-world.toml deleted file mode 100644 index 83a7a20228..0000000000 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-world.toml +++ /dev/null @@ -1,6 +0,0 @@ -kind = "Class" -class_hash = "0x210dd8e484e5555dc74a4a600b17878fc108911719b04139309acc874160c51" -original_class_hash = "0x210dd8e484e5555dc74a4a600b17878fc108911719b04139309acc874160c51" -abi = "manifests/dev/base/abis/dojo-world.json" -tag = "dojo-world" -manifest_name = "dojo-world" diff --git a/crates/dojo-lang/src/model.rs b/crates/dojo-lang/src/model.rs index c04e6f3530..e501699087 100644 --- a/crates/dojo-lang/src/model.rs +++ b/crates/dojo-lang/src/model.rs @@ -11,9 +11,9 @@ use cairo_lang_utils::unordered_hash_map::UnorderedHashMap; use convert_case::{Case, Casing}; use dojo_world::contracts::naming; use dojo_world::manifest::Member; +use dojo_world::metadata::{is_name_valid, NamespaceConfig}; use crate::plugin::{DojoAuxData, Model, DOJO_MODEL_ATTR}; -use crate::utils::is_name_valid; const DEFAULT_MODEL_VERSION: u8 = 1; @@ -192,14 +192,18 @@ pub fn handle_model_struct( db: &dyn SyntaxGroup, aux_data: &mut DojoAuxData, struct_ast: ItemStruct, - default_namespace: String, + namespace_config: &NamespaceConfig, ) -> (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 = parameters.namespace.unwrap_or(default_namespace); + let unmapped_namespace = parameters.namespace.unwrap_or(namespace_config.default.clone()); + + // Maps namespace from the tag to ensure higher precision on matching namespace mappings. + let model_namespace = + namespace_config.get_mapping(&naming::get_tag(&unmapped_namespace, &model_name)); for (id, value) in [("name", &model_name), ("namespace", &model_namespace)] { if !is_name_valid(value) { @@ -208,8 +212,8 @@ pub fn handle_model_struct( vec![PluginDiagnostic { stable_ptr: struct_ast.name(db).stable_ptr().0, message: format!( - "The model {id} '{value}' can only contain characters (a-z/A-Z), numbers \ - (0-9) and underscore (_)" + "The {id} '{value}' can only contain characters (a-z/A-Z), digits (0-9) \ + and underscore (_)." ) .to_string(), severity: Severity::Error, @@ -297,9 +301,8 @@ pub fn handle_model_struct( let serialized_values: Vec<_> = 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(), + name: model_name.clone(), namespace: model_namespace.clone(), members: members.to_vec(), }); @@ -486,7 +489,7 @@ mod $contract_name$ { } ", &UnorderedHashMap::from([ - ("contract_name".to_string(), RewriteNode::Text(name.to_case(Case::Snake))), + ("contract_name".to_string(), RewriteNode::Text(model_name.to_case(Case::Snake))), ("type_name".to_string(), RewriteNode::Text(model_name)), ("namespace".to_string(), RewriteNode::Text("namespace".to_string())), ("serialized_keys".to_string(), RewriteNode::new_modified(serialized_keys)), diff --git a/crates/dojo-lang/src/plugin.rs b/crates/dojo-lang/src/plugin.rs index 9cf0b82520..0f3e2641b4 100644 --- a/crates/dojo-lang/src/plugin.rs +++ b/crates/dojo-lang/src/plugin.rs @@ -18,6 +18,7 @@ use cairo_lang_syntax::node::{ast, Terminal, TypedSyntaxNode}; use dojo_types::system::Dependency; use dojo_world::contracts::naming; use dojo_world::manifest::Member; +use dojo_world::metadata::NamespaceConfig; use scarb::compiler::plugin::builtin::BuiltinStarkNetPlugin; use scarb::compiler::plugin::{CairoPlugin, CairoPluginInstance}; use scarb::core::{PackageId, PackageName, SourceId}; @@ -35,7 +36,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_default_namespace; +use crate::utils::get_namespace_config; pub const DOJO_CONTRACT_ATTR: &str = "dojo::contract"; pub const DOJO_INTERFACE_ATTR: &str = "dojo::interface"; @@ -111,11 +112,11 @@ impl BuiltinDojoPlugin { &self, db: &dyn SyntaxGroup, module_ast: ast::ItemModule, - default_namespace: String, + namespace_config: &NamespaceConfig, metadata: &MacroPluginMetadata<'_>, ) -> PluginResult { if module_ast.has_attr(db, DOJO_CONTRACT_ATTR) { - return DojoContract::from_module(db, &module_ast, default_namespace, metadata); + return DojoContract::from_module(db, &module_ast, namespace_config, metadata); } PluginResult::default() @@ -150,7 +151,7 @@ impl BuiltinDojoPlugin { &self, db: &dyn SyntaxGroup, fn_ast: ast::FunctionWithBody, - default_namespace: String, + namespace_config: &NamespaceConfig, ) -> PluginResult { let attrs = fn_ast.attributes(db).query_attr(db, "computed"); if attrs.is_empty() { @@ -177,7 +178,7 @@ impl BuiltinDojoPlugin { let mut tag = None; if args.len() == 1 { let model_name = args[0].text(db); - tag = Some(naming::get_tag(&model_name, &default_namespace)); + tag = Some(naming::get_tag(&model_name, &namespace_config.default)); let model_type_node = param_els[1].type_clause(db).ty(db); if let ast::Expr::Path(model_type_path) = model_type_node { @@ -342,16 +343,14 @@ impl MacroPlugin for BuiltinDojoPlugin { item_ast: ast::ModuleItem, metadata: &MacroPluginMetadata<'_>, ) -> PluginResult { - let default_namespace = match get_default_namespace(db) { - Option::Some(x) => x, - Option::None => { + let namespace_config = match get_namespace_config(db) { + Ok(config) => config, + Err(e) => { return PluginResult { code: Option::None, diagnostics: vec![PluginDiagnostic { stable_ptr: item_ast.stable_ptr().0, - message: "Unable to find the default namespace. Be sure to have a \ - 'tool.dojo.world.namespace' field in your Scarb.toml file." - .into(), + message: format!("{e}"), severity: Severity::Error, }], remove_original_item: false, @@ -361,7 +360,7 @@ impl MacroPlugin for BuiltinDojoPlugin { match item_ast { ast::ModuleItem::Module(module_ast) => { - self.handle_mod(db, module_ast, default_namespace, metadata) + self.handle_mod(db, module_ast, &namespace_config, metadata) } ast::ModuleItem::Trait(trait_ast) => self.handle_trait(db, trait_ast, metadata), ast::ModuleItem::Enum(enum_ast) => { @@ -505,7 +504,7 @@ impl MacroPlugin for BuiltinDojoPlugin { db, &mut aux_data, struct_ast.clone(), - default_namespace, + &namespace_config, ); rewrite_nodes.push(model_rewrite_nodes); diagnostics.extend(model_diagnostics); @@ -544,7 +543,7 @@ impl MacroPlugin for BuiltinDojoPlugin { remove_original_item: false, } } - ast::ModuleItem::FreeFunction(fn_ast) => self.handle_fn(db, fn_ast, default_namespace), + ast::ModuleItem::FreeFunction(fn_ast) => self.handle_fn(db, fn_ast, &namespace_config), _ => PluginResult::default(), } } diff --git a/crates/dojo-lang/src/plugin_test_data/introspect b/crates/dojo-lang/src/plugin_test_data/introspect index 2c59dfb0a8..76b3602f77 100644 --- a/crates/dojo-lang/src/plugin_test_data/introspect +++ b/crates/dojo-lang/src/plugin_test_data/introspect @@ -814,542 +814,542 @@ impl EnumWithBadOptionSerde of core::serde::Serde:: { } //! > expected_diagnostics -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:1:1 use core::serde::Serde; ^*********************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:3:1 #[derive(Copy, Drop, Serde, Introspect)] ^**************************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:9:1 #[derive(Serde, Copy, Drop, Introspect)] ^**************************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:15:1 #[derive(Serde, Copy, Drop, Introspect)] ^**************************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:21:1 #[derive(Serde, Copy, Drop, Introspect)] ^**************************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:27:1 #[derive(Serde, Copy, Drop, Introspect)] ^**************************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:33:1 #[derive(Serde, Copy, Drop, Introspect)] ^**************************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:39:1 #[derive(Serde, Copy, Drop, Introspect)] ^**************************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:45:1 #[derive(Serde, Copy, Drop, Introspect)] ^**************************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:51:1 #[derive(Serde, Copy, Drop, Introspect)] ^**************************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:57:1 #[derive(Serde, Copy, Drop, Introspect)] ^**************************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:63:1 #[derive(Serde, Copy, Drop, Introspect)] ^**************************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:69:1 #[derive(Serde, Copy, Drop, Introspect)] ^**************************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:76:1 #[derive(Copy, Drop, Introspect)] ^*******************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:84:1 #[derive(Copy, Drop, Introspect)] ^*******************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:92:1 #[derive(Copy, Drop, Introspect)] ^*******************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:100:1 #[derive(Copy, Drop, Introspect)] ^*******************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:108:1 #[derive(Copy, Drop, Introspect)] ^*******************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:116:1 #[derive(Copy, Drop, Introspect)] ^*******************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:124:1 #[derive(Copy, Drop, Introspect)] ^*******************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:132:1 #[derive(Copy, Drop, Introspect)] ^*******************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:140:1 #[derive(Copy, Drop, Introspect)] ^*******************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:148:1 #[derive(Copy, Drop, Introspect)] ^*******************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:156:1 #[derive(Copy, Drop, Introspect)] ^*******************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:164:1 #[derive(Copy, Drop, Serde, Introspect)] ^**************************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:169:1 #[derive(Copy, Drop, Serde, Introspect)] ^**************************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:174:1 #[derive(Copy, Drop, Serde, Introspect)] ^**************************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:179:1 #[derive(Introspect, IntrospectPacked)] ^*************************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:182:1 #[derive(Introspect, IntrospectPacked)] ^*************************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:185:1 #[derive(Introspect)] ^*******************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:189:1 #[derive(Introspect)] ^*******************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:193:1 #[derive(IntrospectPacked)] ^*************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:198:1 #[derive(IntrospectPacked)] ^*************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:204:1 #[derive(IntrospectPacked)] ^*************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:210:1 #[derive(IntrospectPacked)] ^*************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:216:1 #[derive(IntrospectPacked)] ^*************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:222:1 #[derive(IntrospectPacked)] ^*************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:229:1 #[derive(IntrospectPacked)] ^*************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:236:1 #[derive(IntrospectPacked)] ^*************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:243:1 #[derive(IntrospectPacked)] ^*************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:249:1 #[derive(IntrospectPacked)] ^*************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:2:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:2:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:2:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:8:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:8:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:8:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:14:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:14:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:14:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:20:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:20:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:20:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:26:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:26:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:26:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:32:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:32:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:32:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:38:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:38:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:38:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:44:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:44:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:44:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:50:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:50:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:50:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:56:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:56:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:56:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:62:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:62:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:62:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:68:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:68:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:68:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:75:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:75:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:83:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:83:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:91:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:91:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:99:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:99:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:107:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:107:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:115:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:115:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:123:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:123:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:131:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:131:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:139:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:139:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:147:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:147:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:155:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:155:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:163:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:163:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:163:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:168:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:168:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:168:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:173:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:173:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:173:1 ^ diff --git a/crates/dojo-lang/src/plugin_test_data/model b/crates/dojo-lang/src/plugin_test_data/model index 0eff60161f..39c5ece18c 100644 --- a/crates/dojo-lang/src/plugin_test_data/model +++ b/crates/dojo-lang/src/plugin_test_data/model @@ -314,112 +314,112 @@ struct ModelWithTupleNoPrimitives { } //! > expected_diagnostics -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:1:1 #[dojo::model(version: 0)] ^************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:9:1 #[dojo::model(version: 0, version: 0)] ^************************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:16:1 #[dojo::model(version: hello)] ^****************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:23:1 #[dojo::model(version)] ^*********************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:30:1 #[dojo::model(my_arg: 1)] ^***********************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:37:1 #[dojo::model(my_arg)] ^********************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:44:1 #[dojo::model(version: 2)] ^************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:51:1 #[dojo::model(version: 0)] ^************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:58:1 #[dojo::model(namespace: 'MyNamespace')] ^**************************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:65:1 #[dojo::model(namespace: 'my_namespace')] ^***************************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:72:1 #[dojo::model(namespace: "my_namespace")] ^***************************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:79:1 #[dojo::model] ^************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:86:1 #[dojo::model] ^************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:91:1 #[dojo::model] ^************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:97:1 #[dojo::model] ^************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:103:1 #[dojo::model] ^************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:112:1 #[dojo::model] ^************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:115:1 #[dojo::model] ^************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:123:1 #[dojo::model] ^************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:131:1 #[dojo::model] ^************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:139:1 #[dojo::model] ^************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:147:1 #[dojo::model] ^************^ diff --git a/crates/dojo-lang/src/plugin_test_data/print b/crates/dojo-lang/src/plugin_test_data/print index 0ed58b1d50..7bf048fb4c 100644 --- a/crates/dojo-lang/src/plugin_test_data/print +++ b/crates/dojo-lang/src/plugin_test_data/print @@ -77,12 +77,12 @@ enum Enemy { } //! > expected_diagnostics -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:1:1 use serde::Serde; ^***************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:2:1 use debug::PrintTrait; ^********************^ @@ -92,7 +92,7 @@ error: Unknown derive `Print` - a plugin might be missing. #[derive(Print)] ^***^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:4:1 #[derive(Print)] ^**************^ @@ -102,12 +102,12 @@ error: Unknown derive `Print` - a plugin might be missing. #[derive(Print)] ^***^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:12:1 #[derive(Print)] ^**************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:17:1 use starknet::ContractAddress; ^****************************^ @@ -117,7 +117,7 @@ error: Unknown derive `Print` - a plugin might be missing. #[derive(Print)] ^***^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:19:1 #[derive(Print)] ^**************^ @@ -127,7 +127,7 @@ error: Unknown derive `Print` - a plugin might be missing. #[derive(Print)] ^***^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:28:1 #[derive(Print)] ^**************^ diff --git a/crates/dojo-lang/src/plugin_test_data/system b/crates/dojo-lang/src/plugin_test_data/system index 8c306419d8..80ee85d356 100644 --- a/crates/dojo-lang/src/plugin_test_data/system +++ b/crates/dojo-lang/src/plugin_test_data/system @@ -355,32 +355,32 @@ mod ctxnamed { } //! > expected_diagnostics -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:1:1 #[dojo::contract(namespace: "My@Namespace")] ^******************************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:11:1 #[dojo::contract(namespace: 'my_namespace')] ^******************************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:21:1 #[dojo::contract(namespace: "my_namespace")] ^******************************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:28:1 #[dojo::contract] ^***************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:38:1 #[dojo::contract] ^***************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:52:1 #[starknet::component] ^********************^ @@ -390,7 +390,7 @@ error: Unsupported attribute. #[starknet::component] ^********************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:58:1 #[starknet::component] ^********************^ @@ -400,17 +400,17 @@ error: Unsupported attribute. #[starknet::component] ^********************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:64:1 #[dojo::contract] ^***************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:85:1 #[dojo::interface] ^****************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:88:1 #[dojo::interface] ^****************^ @@ -420,82 +420,82 @@ error: Unsupported attribute. #[my_attr] ^********^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:96:1 #[dojo::interface] ^****************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:109:1 #[dojo::interface] ^****************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:124:1 #[dojo::contract] ^***************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:171:1 #[dojo::contract] ^***************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:222:1 #[dojo::contract] ^***************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:239:1 #[dojo::contract] ^***************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:3:5 use traits::Into; ^***************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:4:5 use dojo::world::Context; ^***********************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:6:5 fn execute(ctx: Context, name: felt252) { ^***************************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:13:5 use traits::Into; ^***************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:14:5 use dojo::world::Context; ^***********************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:16:5 fn execute(ctx: Context, name: felt252) { ^***************************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:23:5 fn execute(value: felt252) -> felt252 { ^*************************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:30:5 use traits::Into; ^***************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:31:5 use dojo::world::Context; ^***********************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:33:5 fn execute(ctx2: Context, name: felt252) { ^****************************************^ @@ -505,7 +505,7 @@ error: Unknown derive `starknet::Event` - a plugin might be missing. #[derive(Drop, starknet::Event)] ^*************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:40:5 #[event] ^******^ @@ -520,22 +520,22 @@ error: Unknown derive `starknet::Event` - a plugin might be missing. #[derive(Drop, starknet::Event)] ^*************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:46:5 #[derive(Drop, starknet::Event)] ^******************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:40:1 #[event] ^**********^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:45:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:54:5 #[storage] ^********^ @@ -545,7 +545,7 @@ error: Unsupported attribute. #[storage] ^********^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:60:5 #[storage] ^********^ @@ -555,7 +555,7 @@ error: Unsupported attribute. #[storage] ^********^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:66:5 component!(path: testcomponent1, storage: testcomponent1_storage, event: testcomponent1_event); ^*********************************************************************************************^ @@ -565,7 +565,7 @@ error: Unknown inline item macro: 'component'. component!(path: testcomponent1, storage: testcomponent1_storage, event: testcomponent1_event); ^*********************************************************************************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:67:5 component!(path: testcomponent2, storage: testcomponent2_storage, event: testcomponent2_event); ^*********************************************************************************************^ @@ -575,7 +575,7 @@ error: Unknown inline item macro: 'component'. component!(path: testcomponent2, storage: testcomponent2_storage, event: testcomponent2_event); ^*********************************************************************************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:69:5 #[storage] ^********^ @@ -600,7 +600,7 @@ error: Unknown derive `starknet::Event` - a plugin might be missing. #[derive(Drop, starknet::Event)] ^*************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:77:5 #[event] ^******^ @@ -615,12 +615,12 @@ error: Unsupported attribute. #[flat] ^*****^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:76:1 ^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:126:5 #[abi(embed_v0)] ^**************^ @@ -635,22 +635,22 @@ error: Generated trait must have generic args matching the impl's generic params impl InternalImplBad of InternalUtils { ^**************************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:163:5 #[generate_trait] ^***************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:163:5 #[generate_trait] ^***************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:173:5 #[derive(Drop)] ^*************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:178:5 #[abi(embed_v0)] ^**************^ @@ -660,22 +660,22 @@ error: Unsupported attribute. #[abi(embed_v0)] ^**************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:213:5 #[generate_trait] ^***************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:173:1 #[derive(Drop)] ^*****************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:213:5 #[generate_trait] ^***************^ -error: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). --> test_src/lib.cairo:224:5 fn dojo_init( ^***********^ diff --git a/crates/dojo-lang/src/semantics/test_data/get b/crates/dojo-lang/src/semantics/test_data/get index 355d7f40c1..ff66c3cba3 100644 --- a/crates/dojo-lang/src/semantics/test_data/get +++ b/crates/dojo-lang/src/semantics/test_data/get @@ -29,37 +29,37 @@ Missing( ) //! > semantic_diagnostics -error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). --> lib.cairo:1:1 use array::ArrayTrait; ^********************^ -error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). --> lib.cairo:2:1 use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; ^*********************************************************^ -error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). --> lib.cairo:4:1 #[derive(Copy, Drop, Serde, Introspect)] ^**************************************^ -error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). --> lib.cairo:10:1 fn test_func() { let key: felt252 = 0xb0b; ^****************************************^ -error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). --> lib.cairo:3:1 ^ -error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). --> lib.cairo:3:1 ^ -error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). --> lib.cairo:3:1 ^ @@ -112,37 +112,37 @@ Missing( ) //! > semantic_diagnostics -error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). --> lib.cairo:1:1 use array::ArrayTrait; ^********************^ -error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). --> lib.cairo:2:1 use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; ^*********************************************************^ -error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). --> lib.cairo:4:1 #[derive(Copy, Drop, Serde, Introspect)] ^**************************************^ -error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). --> lib.cairo:10:1 fn test_func() { let key: felt252 = 0xb0b; ^****************************************^ -error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). --> lib.cairo:3:1 ^ -error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). --> lib.cairo:3:1 ^ -error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). --> lib.cairo:3:1 ^ @@ -321,37 +321,37 @@ Block( ) //! > semantic_diagnostics -error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). --> lib.cairo:1:1 use array::ArrayTrait; ^********************^ -error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). --> lib.cairo:2:1 use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; ^*********************************************************^ -error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). --> lib.cairo:4:1 #[derive(Copy, Drop, Serde, Introspect)] ^**************************************^ -error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). --> lib.cairo:10:1 fn test_func() { let key: felt252 = 0xb0b; ^****************************************^ -error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). --> lib.cairo:3:1 ^ -error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). --> lib.cairo:3:1 ^ -error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). --> lib.cairo:3:1 ^ diff --git a/crates/dojo-lang/src/semantics/test_data/set b/crates/dojo-lang/src/semantics/test_data/set index e9b415c178..34a7fae2b5 100644 --- a/crates/dojo-lang/src/semantics/test_data/set +++ b/crates/dojo-lang/src/semantics/test_data/set @@ -18,7 +18,7 @@ Missing( ) //! > semantic_diagnostics -error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). --> lib.cairo:1:1 fn test_func() { { ^*****************^ @@ -50,7 +50,7 @@ Missing( ) //! > semantic_diagnostics -error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). --> lib.cairo:1:1 fn test_func() { { ^*****************^ @@ -234,7 +234,7 @@ Block( ) //! > semantic_diagnostics -error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). --> lib.cairo:1:1 use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; ^*********************************************************^ @@ -244,27 +244,27 @@ error: Plugin diagnostic: Unknown derive `Model` - a plugin might be missing. #[derive(Copy, Drop, Serde, Model)] ^***^ -error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). --> lib.cairo:3:1 #[derive(Copy, Drop, Serde, Model)] ^*********************************^ -error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). --> lib.cairo:9:1 fn test_func() { let key: felt252 = 0xb0b; ^****************************************^ -error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). --> lib.cairo:2:1 ^ -error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). --> lib.cairo:2:1 ^ -error: Plugin diagnostic: Unable to find the default namespace. Be sure to have a 'tool.dojo.world.namespace' field in your Scarb.toml file. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). --> lib.cairo:2:1 ^ diff --git a/crates/dojo-lang/src/utils.rs b/crates/dojo-lang/src/utils.rs index 43bc4aeb73..4c6b5e25a6 100644 --- a/crates/dojo-lang/src/utils.rs +++ b/crates/dojo-lang/src/utils.rs @@ -1,7 +1,9 @@ use std::fs; +use anyhow::Result; use cairo_lang_filesystem::ids::Directory; use cairo_lang_syntax::node::db::SyntaxGroup; +use dojo_world::metadata::NamespaceConfig; use regex::Regex; use toml::Table; @@ -10,13 +12,15 @@ pub fn is_name_valid(name: &str) -> bool { Regex::new(r"^[a-zA-Z0-9_]+$").unwrap().is_match(name) } -// Parses the configuration file of the first crate to extract the default namespace. +/// Get the namespace configuration from the workspace. // TODO: Ask to Scarb team to expose this information with the new macro system. -pub fn get_default_namespace(db: &dyn SyntaxGroup) -> Option { +pub fn get_namespace_config(db: &dyn SyntaxGroup) -> Result { let crates = db.crates(); if crates.is_empty() { - return Option::None; + return Err(anyhow::anyhow!( + "No crates found in the workspace, hence no namespace configuration." + )); } // Crates[0] is always the root crate that triggered the build origin. @@ -24,30 +28,45 @@ pub fn get_default_namespace(db: &dyn SyntaxGroup) -> Option { // or the crate using the library otherwise. let configuration = match db.crate_config(crates[0]) { Option::Some(cfg) => cfg, - Option::None => return Option::None, + Option::None => return Err(anyhow::anyhow!("No configuration found for the root crate.")), }; - if let Directory::Real(path) = configuration.root { + if let Directory::Real(ref path) = configuration.root { let config_path = path.parent().unwrap().join("Scarb.toml"); - let config_content = match fs::read_to_string(config_path) { + let config_content = match fs::read_to_string(&config_path) { Ok(x) => x, - Err(_) => return Option::None, + Err(e) => return Err(anyhow::anyhow!("Failed to read Scarb.toml file: {e}.")), }; let config = match config_content.parse::
() { Ok(x) => x, - Err(_) => return Option::None, + Err(e) => return Err(anyhow::anyhow!("Failed to parse Scarb.toml file: {e}.")), }; if let Some(tool) = config.get("tool").and_then(|t| t.as_table()) { if let Some(dojo) = tool.get("dojo").and_then(|d| d.as_table()) { if let Some(world) = dojo.get("world").and_then(|w| w.as_table()) { - if let Some(namespace) = world.get("namespace").and_then(|n| n.as_str()) { - return Some(namespace.to_string()); + if let Some(namespace_config) = + world.get("namespace").and_then(|n| n.as_table()) + { + match toml::from_str::(&namespace_config.to_string()) { + Ok(config) => return config.validate(), + Err(e) => { + return Err(anyhow::anyhow!( + "Failed to parse namespace configuration of {}: {}", + config_path.to_string_lossy().to_string(), + e + )); + } + } } } } } } - Option::None + Err(anyhow::anyhow!( + "Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: \ + {:?}.", + configuration.root + )) } diff --git a/crates/dojo-world/Cargo.toml b/crates/dojo-world/Cargo.toml index 0dd118523f..3a639a155f 100644 --- a/crates/dojo-world/Cargo.toml +++ b/crates/dojo-world/Cargo.toml @@ -17,6 +17,7 @@ camino.workspace = true convert_case.workspace = true futures.workspace = true num-traits = { workspace = true, optional = true } +regex.workspace = true serde.workspace = true serde_json.workspace = true serde_with.workspace = true diff --git a/crates/dojo-world/src/metadata.rs b/crates/dojo-world/src/metadata.rs index e948cf2ada..b489258dea 100644 --- a/crates/dojo-world/src/metadata.rs +++ b/crates/dojo-world/src/metadata.rs @@ -5,6 +5,7 @@ use std::path::PathBuf; use anyhow::{anyhow, Context, Result}; use camino::Utf8PathBuf; use ipfs_api_backend_hyper::{IpfsApi, IpfsClient, TryFromUri}; +use regex::Regex; use scarb::core::{ManifestMetadata, Workspace}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use serde_json::json; @@ -54,6 +55,20 @@ fn build_artifact_from_filename( /// /// A [`String`] object containing the namespace. pub fn get_default_namespace_from_ws(ws: &Workspace<'_>) -> Result { + let metadata = dojo_metadata_from_workspace(ws)?; + Ok(metadata.world.namespace.default) +} + +/// Get the namespace configuration from the workspace. +/// +/// # Arguments +/// +/// * `ws`: the workspace. +/// +/// # Returns +/// +/// A [`NamespaceConfig`] object containing the namespace configuration. +pub fn get_namespace_config_from_ws(ws: &Workspace<'_>) -> Result { let metadata = dojo_metadata_from_workspace(ws)?; Ok(metadata.world.namespace) } @@ -248,12 +263,103 @@ impl Uri { } } +/// Checks if the provided namespace follows the format rules. +pub fn is_name_valid(namespace: &str) -> bool { + Regex::new(r"^[a-zA-Z0-9_]+$").unwrap().is_match(namespace) +} + +/// Namespace configuration for the world +#[derive(Default, Serialize, Deserialize, Debug, Clone, PartialEq)] +pub struct NamespaceConfig { + pub default: String, + pub mappings: Option>, +} + +impl NamespaceConfig { + /// Create a new namespace configuration with a default namespace. + pub fn new(default: &str) -> Self { + NamespaceConfig { default: default.to_string(), mappings: None } + } + + /// Add mappings to the namespace configuration. + pub fn with_mappings(mut self, mappings: HashMap) -> Self { + self.mappings = Some(mappings); + self + } + + /// Get the namespace for a given tag or namespace, or return the default + /// namespace if no mapping was found. + /// + /// If the input is a tag, a first perfect match is checked. If no match + /// for the tag, then a check is done against the namespace of the tag. + /// If the input is a namespace, a perfect match if checked. + /// + /// Examples: + /// - `get_mapping("armory-Flatbow")` first checks for `armory-Flatbow` tag, then for `armory` + /// namespace in mapping keys. + /// - `get_mapping("armory")` checks for `armory` namespace in mapping keys. + /// + /// # Arguments + /// + /// * `tag_or_namespace`: the tag or namespace to get the namespace for. + /// + /// # Returns + /// + /// A [`String`] object containing the namespace. + pub fn get_mapping(&self, tag_or_namespace: &str) -> String { + if let Some(namespace_from_tag) = + self.mappings.as_ref().and_then(|m| m.get(tag_or_namespace)) + { + namespace_from_tag.clone() + } else if tag_or_namespace.contains('-') { + // TODO: we can't access the dojo-world/contracts from here as it belongs to a different + // feature. The naming module has to be relocated in more generic place, + // always available. + let (namespace, _) = tag_or_namespace.split_at(tag_or_namespace.rfind('-').unwrap()); + self.mappings + .as_ref() + .and_then(|m| m.get(namespace)) + .unwrap_or(&self.default) + .to_string() + } else { + self.default.clone() + } + } + + /// Validates the namespace configuration and their names. + /// + /// # Returns + /// + /// A [`Result`] object containing the namespace configuration if valid, error otherwise. + pub fn validate(self) -> Result { + if self.default.is_empty() { + return Err(anyhow::anyhow!("Default namespace is empty")); + } + + if !is_name_valid(&self.default) { + return Err(anyhow::anyhow!("Invalid default namespace `{}`", self.default)); + } + + for (tag_or_namespace, namespace) in self.mappings.as_ref().unwrap_or(&HashMap::new()) { + if !is_name_valid(namespace) { + return Err(anyhow::anyhow!( + "Invalid namespace `{}` for tag or namespace `{}`", + namespace, + tag_or_namespace + )); + } + } + + Ok(self) + } +} + /// World metadata coming from the project configuration (Scarb.toml) #[derive(Default, Serialize, Deserialize, Debug, Clone)] pub struct ProjectWorldMetadata { pub name: Option, pub seed: String, - pub namespace: String, + pub namespace: NamespaceConfig, pub description: Option, pub cover_uri: Option, pub icon_uri: Option, @@ -266,7 +372,7 @@ pub struct ProjectWorldMetadata { pub struct WorldMetadata { pub name: Option, pub seed: String, - pub namespace: String, + pub namespace: NamespaceConfig, pub description: Option, pub cover_uri: Option, pub icon_uri: Option, @@ -454,3 +560,91 @@ impl MetadataExt for ManifestMetadata { Ok(project_metadata) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_namespace_config_get_mapping() { + let config = NamespaceConfig { + default: "nm".to_string(), + mappings: Some(HashMap::from([ + ("tag1".to_string(), "namespace1".to_string()), + ("namespace2".to_string(), "namespace2".to_string()), + ("armory-Flatbow".to_string(), "weapons".to_string()), + ])), + }; + + assert_eq!(config.get_mapping("tag1"), "namespace1"); + assert_eq!(config.get_mapping("tag1-TestModel"), "namespace1"); + assert_eq!(config.get_mapping("namespace2"), "namespace2"); + assert_eq!(config.get_mapping("armory-Flatbow"), "weapons"); + assert_eq!(config.get_mapping("armory"), "nm"); + assert_eq!(config.get_mapping("unknown"), "nm"); + } + + #[test] + fn test_namespace_config_validate() { + let valid_config = NamespaceConfig { + default: "valid_default".to_string(), + mappings: Some(HashMap::from([ + ("tag1".to_string(), "valid_namespace1".to_string()), + ("tag2".to_string(), "valid_namespace2".to_string()), + ])), + }; + assert!(valid_config.validate().is_ok()); + + let empty_default_config = NamespaceConfig { default: "".to_string(), mappings: None }; + assert!(empty_default_config.validate().is_err()); + + let invalid_default_config = + NamespaceConfig { default: "invalid-default".to_string(), mappings: None }; + assert!(invalid_default_config.validate().is_err()); + + let invalid_mapping_config = NamespaceConfig { + default: "valid_default".to_string(), + mappings: Some(HashMap::from([ + ("tag1".to_string(), "valid_namespace".to_string()), + ("tag2".to_string(), "invalid-namespace".to_string()), + ])), + }; + assert!(invalid_mapping_config.validate().is_err()); + } + + #[test] + fn test_namespace_config_new() { + let config = NamespaceConfig::new("default_namespace"); + assert_eq!(config.default, "default_namespace"); + assert_eq!(config.mappings, None); + } + + #[test] + fn test_namespace_config_with_mappings() { + let mut mappings = HashMap::new(); + mappings.insert("tag1".to_string(), "namespace1".to_string()); + mappings.insert("tag2".to_string(), "namespace2".to_string()); + + let config = NamespaceConfig::new("default_namespace").with_mappings(mappings.clone()); + assert_eq!(config.default, "default_namespace"); + assert_eq!(config.mappings, Some(mappings)); + } + + #[test] + fn test_is_name_valid_with_valid_names() { + assert!(is_name_valid("validName")); + assert!(is_name_valid("valid_name")); + assert!(is_name_valid("ValidName123")); + assert!(is_name_valid("VALID_NAME")); + assert!(is_name_valid("v")); + } + + #[test] + fn test_is_name_valid_with_invalid_names() { + assert!(!is_name_valid("invalid-name")); + assert!(!is_name_valid("invalid name")); + assert!(!is_name_valid("invalid.name")); + assert!(!is_name_valid("invalid!name")); + assert!(!is_name_valid("")); + } +} diff --git a/crates/dojo-world/src/metadata_test.rs b/crates/dojo-world/src/metadata_test.rs index ff32eda35c..ba58f89d34 100644 --- a/crates/dojo-world/src/metadata_test.rs +++ b/crates/dojo-world/src/metadata_test.rs @@ -10,8 +10,8 @@ use url::Url; use crate::contracts::naming::{get_filename_from_tag, TAG_SEPARATOR}; use crate::manifest::{CONTRACTS_DIR, MODELS_DIR, WORLD_CONTRACT_TAG}; use crate::metadata::{ - dojo_metadata_from_workspace, ArtifactMetadata, ProjectMetadata, Uri, WorldMetadata, ABIS_DIR, - BASE_DIR, MANIFESTS_DIR, + dojo_metadata_from_workspace, ArtifactMetadata, NamespaceConfig, ProjectMetadata, Uri, + WorldMetadata, ABIS_DIR, BASE_DIR, MANIFESTS_DIR, }; #[test] @@ -67,13 +67,13 @@ namespace = "dojo_examples" assert_eq!(world.website, Some(Url::parse("https://dojoengine.org").unwrap())); assert_eq!(world.socials.unwrap().get("x"), Some(&"https://x.com/dojostarknet".to_string())); assert_eq!(world.seed, String::from("dojo_examples")); - assert_eq!(world.namespace, String::from("dojo_examples")); + assert_eq!(world.namespace, NamespaceConfig::new("dojo_examples")); } #[tokio::test] async fn world_metadata_hash_and_upload() { let meta = WorldMetadata { - namespace: "dojo_examples".to_string(), + namespace: NamespaceConfig::new("dojo_examples"), name: Some("Test World".to_string()), seed: String::from("dojo_examples"), description: Some("A world used for testing".to_string()), diff --git a/examples/game-lib/armory/Scarb.toml b/examples/game-lib/armory/Scarb.toml index 68d819791f..fdab38f9eb 100644 --- a/examples/game-lib/armory/Scarb.toml +++ b/examples/game-lib/armory/Scarb.toml @@ -13,4 +13,4 @@ dojo.workspace = true [tool.dojo.world] name = "armory" seed = "armory" -namespace = "armory" +namespace = { default = "armory" } diff --git a/examples/game-lib/armory/src/lib.cairo b/examples/game-lib/armory/src/lib.cairo index ab37e3d807..a283a97df1 100644 --- a/examples/game-lib/armory/src/lib.cairo +++ b/examples/game-lib/armory/src/lib.cairo @@ -1,5 +1,5 @@ #[derive(Drop, Serde)] -#[dojo::model] +#[dojo::model(namespace: "armory")] struct Flatbow { #[key] id: u32, diff --git a/examples/game-lib/bestiary/Scarb.toml b/examples/game-lib/bestiary/Scarb.toml index fdfc5bf310..0ed5683c30 100644 --- a/examples/game-lib/bestiary/Scarb.toml +++ b/examples/game-lib/bestiary/Scarb.toml @@ -13,4 +13,4 @@ dojo.workspace = true [tool.dojo.world] name = "bestiary" seed = "bestiary" -namespace = "bestiary" +namespace = { default = "bestiary" } diff --git a/examples/game-lib/bestiary/src/lib.cairo b/examples/game-lib/bestiary/src/lib.cairo index 09b862ee30..86478ee6a8 100644 --- a/examples/game-lib/bestiary/src/lib.cairo +++ b/examples/game-lib/bestiary/src/lib.cairo @@ -1,5 +1,5 @@ #[derive(Drop, Serde)] -#[dojo::model] +#[dojo::model(namespace: "bestiary")] struct RiverSkale { #[key] id: u32, diff --git a/examples/game-lib/manifests/dev/base/models/bestiary-RiverSkale-1bce2040.toml b/examples/game-lib/manifests/dev/base/models/bestiary-RiverSkale-1bce2040.toml deleted file mode 100644 index 89737084f9..0000000000 --- a/examples/game-lib/manifests/dev/base/models/bestiary-RiverSkale-1bce2040.toml +++ /dev/null @@ -1,26 +0,0 @@ -kind = "DojoModel" -class_hash = "0x9efdf4d850ee4e4f837ff4f4b472739589a3aed34d22d1efa18ee743480ef7" -original_class_hash = "0x9efdf4d850ee4e4f837ff4f4b472739589a3aed34d22d1efa18ee743480ef7" -abi = "manifests/dev/base/abis/models/bestiary-RiverSkale-1bce2040.json" -tag = "bestiary-RiverSkale" -manifest_name = "bestiary-RiverSkale-1bce2040" - -[[members]] -name = "id" -type = "u32" -key = true - -[[members]] -name = "health" -type = "u32" -key = false - -[[members]] -name = "armor" -type = "u32" -key = false - -[[members]] -name = "attack" -type = "u32" -key = false diff --git a/examples/spawn-and-move/Scarb.toml b/examples/spawn-and-move/Scarb.toml index 2b9b087c2e..a41276f6bf 100644 --- a/examples/spawn-and-move/Scarb.toml +++ b/examples/spawn-and-move/Scarb.toml @@ -30,7 +30,12 @@ dungeon = [] description = "example world" name = "example" seed = "dojo_examples" -namespace = "dojo_examples" + +[tool.dojo.world.namespace] +default = "dojo_examples" +# remapping can be done at tag level, or for the whole namespace. +# In this example, `armory-Flatbow` model will be belong to `dojo_examples_weapons` namespace, and all `bestiary` models will belong to the `dojo_examples_foes` namespace when compiled into `spawn-and-move`. +mappings = { "armory-Flatbow" = "dojo_examples_weapons", "bestiary" = "dojo_examples_foes" } [tool.dojo.env] rpc_url = "http://localhost:5050/" diff --git a/examples/game-lib/manifests/dev/base/abis/models/bestiary-RiverSkale-1bce2040.json b/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples_foes-RiverSkale-39535c12.json similarity index 100% rename from examples/game-lib/manifests/dev/base/abis/models/bestiary-RiverSkale-1bce2040.json rename to examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples_foes-RiverSkale-39535c12.json diff --git a/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-Flatbow-3632af69.json b/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples_weapons-Flatbow-22f5bd16.json similarity index 100% rename from examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-Flatbow-3632af69.json rename to examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples_weapons-Flatbow-22f5bd16.json diff --git a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-actions-40b6994c.toml b/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-actions-40b6994c.toml index c22cd90a7e..677007342b 100644 --- a/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-actions-40b6994c.toml +++ b/examples/spawn-and-move/manifests/dev/base/contracts/dojo_examples-actions-40b6994c.toml @@ -1,6 +1,6 @@ kind = "DojoContract" -class_hash = "0x5693c8ae37b78934041173e9a1abd868e09b89d27fb2fc53702b69e48bfa94f" -original_class_hash = "0x5693c8ae37b78934041173e9a1abd868e09b89d27fb2fc53702b69e48bfa94f" +class_hash = "0x2c975b0d681861edd6caad5fbc0b42dc3e8b034b6c0b0a7628fb3a7bedf1e8d" +original_class_hash = "0x2c975b0d681861edd6caad5fbc0b42dc3e8b034b6c0b0a7628fb3a7bedf1e8d" base_class_hash = "0x0" abi = "manifests/dev/base/abis/contracts/dojo_examples-actions-40b6994c.json" reads = [] diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-Flatbow-3632af69.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-Flatbow-3632af69.toml deleted file mode 100644 index 036b378ddd..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-Flatbow-3632af69.toml +++ /dev/null @@ -1,21 +0,0 @@ -kind = "DojoModel" -class_hash = "0x452abb4fc0af6e0e08e6f652ce77d7330000d4e4bec995005785c7d3f12ea1a" -original_class_hash = "0x452abb4fc0af6e0e08e6f652ce77d7330000d4e4bec995005785c7d3f12ea1a" -abi = "manifests/dev/base/abis/models/dojo_examples-Flatbow-3632af69.json" -tag = "dojo_examples-Flatbow" -manifest_name = "dojo_examples-Flatbow-3632af69" - -[[members]] -name = "id" -type = "u32" -key = true - -[[members]] -name = "atk_speek" -type = "u32" -key = false - -[[members]] -name = "range" -type = "u32" -key = false diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-RiverSkale-27fcbc29.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-RiverSkale-27fcbc29.toml deleted file mode 100644 index b128e42cf7..0000000000 --- a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples-RiverSkale-27fcbc29.toml +++ /dev/null @@ -1,26 +0,0 @@ -kind = "DojoModel" -class_hash = "0x645afa3c2890d1b0d1176e20c703225ad7dfa4a16b67417bcd4fad97eac1ebb" -original_class_hash = "0x645afa3c2890d1b0d1176e20c703225ad7dfa4a16b67417bcd4fad97eac1ebb" -abi = "manifests/dev/base/abis/models/dojo_examples-RiverSkale-27fcbc29.json" -tag = "dojo_examples-RiverSkale" -manifest_name = "dojo_examples-RiverSkale-27fcbc29" - -[[members]] -name = "id" -type = "u32" -key = true - -[[members]] -name = "health" -type = "u32" -key = false - -[[members]] -name = "armor" -type = "u32" -key = false - -[[members]] -name = "attack" -type = "u32" -key = false diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_foes-RiverSkale-39535c12.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_foes-RiverSkale-39535c12.toml new file mode 100644 index 0000000000..878704633a --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_foes-RiverSkale-39535c12.toml @@ -0,0 +1,26 @@ +kind = "DojoModel" +class_hash = "0x34e17c9bad7ccfa7286e07ed3a9af0b2922c7ee77a4889a1c59d0a6dd7aeacc" +original_class_hash = "0x34e17c9bad7ccfa7286e07ed3a9af0b2922c7ee77a4889a1c59d0a6dd7aeacc" +abi = "manifests/dev/base/abis/models/dojo_examples_foes-RiverSkale-39535c12.json" +tag = "dojo_examples_foes-RiverSkale" +manifest_name = "dojo_examples_foes-RiverSkale-39535c12" + +[[members]] +name = "id" +type = "u32" +key = true + +[[members]] +name = "health" +type = "u32" +key = false + +[[members]] +name = "armor" +type = "u32" +key = false + +[[members]] +name = "attack" +type = "u32" +key = false diff --git a/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_weapons-Flatbow-22f5bd16.toml b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_weapons-Flatbow-22f5bd16.toml new file mode 100644 index 0000000000..1a9ed18d70 --- /dev/null +++ b/examples/spawn-and-move/manifests/dev/base/models/dojo_examples_weapons-Flatbow-22f5bd16.toml @@ -0,0 +1,21 @@ +kind = "DojoModel" +class_hash = "0x672ce1913b025af73d80030f0e7e8d5fa4debe9b011cf0a39a27514cac4a3b5" +original_class_hash = "0x672ce1913b025af73d80030f0e7e8d5fa4debe9b011cf0a39a27514cac4a3b5" +abi = "manifests/dev/base/abis/models/dojo_examples_weapons-Flatbow-22f5bd16.json" +tag = "dojo_examples_weapons-Flatbow" +manifest_name = "dojo_examples_weapons-Flatbow-22f5bd16" + +[[members]] +name = "id" +type = "u32" +key = true + +[[members]] +name = "atk_speek" +type = "u32" +key = false + +[[members]] +name = "range" +type = "u32" +key = false diff --git a/examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-RiverSkale-27fcbc29.json b/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples_foes-RiverSkale-39535c12.json similarity index 100% rename from examples/spawn-and-move/manifests/dev/base/abis/models/dojo_examples-RiverSkale-27fcbc29.json rename to examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples_foes-RiverSkale-39535c12.json diff --git a/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-Flatbow-3632af69.json b/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples_weapons-Flatbow-22f5bd16.json similarity index 100% rename from examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-Flatbow-3632af69.json rename to examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples_weapons-Flatbow-22f5bd16.json diff --git a/examples/spawn-and-move/manifests/dev/deployment/manifest.json b/examples/spawn-and-move/manifests/dev/deployment/manifest.json index cf27fae433..6271eddae0 100644 --- a/examples/spawn-and-move/manifests/dev/deployment/manifest.json +++ b/examples/spawn-and-move/manifests/dev/deployment/manifest.json @@ -1130,8 +1130,8 @@ { "kind": "DojoContract", "address": "0x2e85647f570d2a4abdffdd668823702548d20d1d6aaef74b6a4eb9670a32798", - "class_hash": "0x5693c8ae37b78934041173e9a1abd868e09b89d27fb2fc53702b69e48bfa94f", - "original_class_hash": "0x5693c8ae37b78934041173e9a1abd868e09b89d27fb2fc53702b69e48bfa94f", + "class_hash": "0x2c975b0d681861edd6caad5fbc0b42dc3e8b034b6c0b0a7628fb3a7bedf1e8d", + "original_class_hash": "0x2c975b0d681861edd6caad5fbc0b42dc3e8b034b6c0b0a7628fb3a7bedf1e8d", "base_class_hash": "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4", "abi": [ { @@ -2667,23 +2667,28 @@ "kind": "DojoModel", "members": [ { - "name": "id", - "type": "u32", + "name": "identity", + "type": "ContractAddress", "key": true }, { - "name": "atk_speek", - "type": "u32", - "key": false + "name": "channel", + "type": "felt252", + "key": true }, { - "name": "range", - "type": "u32", + "name": "message", + "type": "ByteArray", "key": false + }, + { + "name": "salt", + "type": "felt252", + "key": true } ], - "class_hash": "0x452abb4fc0af6e0e08e6f652ce77d7330000d4e4bec995005785c7d3f12ea1a", - "original_class_hash": "0x452abb4fc0af6e0e08e6f652ce77d7330000d4e4bec995005785c7d3f12ea1a", + "class_hash": "0x572bf6d3cbcd69fd6404a993110c3b84379882587b21b7ad5b2761088cb19c3", + "original_class_hash": "0x572bf6d3cbcd69fd6404a993110c3b84379882587b21b7ad5b2761088cb19c3", "abi": [ { "type": "impl", @@ -3049,30 +3054,34 @@ }, { "type": "impl", - "name": "flatbowImpl", - "interface_name": "armory::Iflatbow" + "name": "messageImpl", + "interface_name": "dojo_examples::models::Imessage" }, { "type": "struct", - "name": "armory::Flatbow", + "name": "dojo_examples::models::Message", "members": [ { - "name": "id", - "type": "core::integer::u32" + "name": "identity", + "type": "core::starknet::contract_address::ContractAddress" }, { - "name": "atk_speek", - "type": "core::integer::u32" + "name": "channel", + "type": "core::felt252" }, { - "name": "range", - "type": "core::integer::u32" + "name": "message", + "type": "core::byte_array::ByteArray" + }, + { + "name": "salt", + "type": "core::felt252" } ] }, { "type": "interface", - "name": "armory::Iflatbow", + "name": "dojo_examples::models::Imessage", "items": [ { "type": "function", @@ -3080,7 +3089,7 @@ "inputs": [ { "name": "model", - "type": "armory::Flatbow" + "type": "dojo_examples::models::Message" } ], "outputs": [], @@ -3090,40 +3099,30 @@ }, { "type": "event", - "name": "armory::flatbow::Event", + "name": "dojo_examples::models::message::Event", "kind": "enum", "variants": [] } ], - "tag": "dojo_examples-Flatbow", - "manifest_name": "dojo_examples-Flatbow-3632af69" + "tag": "dojo_examples-Message", + "manifest_name": "dojo_examples-Message-1bb1d226" }, { "kind": "DojoModel", "members": [ { - "name": "identity", + "name": "account", "type": "ContractAddress", "key": true }, { - "name": "channel", - "type": "felt252", - "key": true - }, - { - "name": "message", - "type": "ByteArray", + "name": "amount", + "type": "u128", "key": false - }, - { - "name": "salt", - "type": "felt252", - "key": true } ], - "class_hash": "0x572bf6d3cbcd69fd6404a993110c3b84379882587b21b7ad5b2761088cb19c3", - "original_class_hash": "0x572bf6d3cbcd69fd6404a993110c3b84379882587b21b7ad5b2761088cb19c3", + "class_hash": "0x4463c89586bc5015a7bc97e9e4af123330842b20aa6f6587c795d6d35907a9d", + "original_class_hash": "0x4463c89586bc5015a7bc97e9e4af123330842b20aa6f6587c795d6d35907a9d", "abi": [ { "type": "impl", @@ -3489,34 +3488,26 @@ }, { "type": "impl", - "name": "messageImpl", - "interface_name": "dojo_examples::models::Imessage" + "name": "mock_tokenImpl", + "interface_name": "dojo_examples::models::Imock_token" }, { "type": "struct", - "name": "dojo_examples::models::Message", + "name": "dojo_examples::models::MockToken", "members": [ { - "name": "identity", + "name": "account", "type": "core::starknet::contract_address::ContractAddress" }, { - "name": "channel", - "type": "core::felt252" - }, - { - "name": "message", - "type": "core::byte_array::ByteArray" - }, - { - "name": "salt", - "type": "core::felt252" + "name": "amount", + "type": "core::integer::u128" } ] }, { "type": "interface", - "name": "dojo_examples::models::Imessage", + "name": "dojo_examples::models::Imock_token", "items": [ { "type": "function", @@ -3524,7 +3515,7 @@ "inputs": [ { "name": "model", - "type": "dojo_examples::models::Message" + "type": "dojo_examples::models::MockToken" } ], "outputs": [], @@ -3534,30 +3525,30 @@ }, { "type": "event", - "name": "dojo_examples::models::message::Event", + "name": "dojo_examples::models::mock_token::Event", "kind": "enum", "variants": [] } ], - "tag": "dojo_examples-Message", - "manifest_name": "dojo_examples-Message-1bb1d226" + "tag": "dojo_examples-MockToken", + "manifest_name": "dojo_examples-MockToken-38903c7c" }, { "kind": "DojoModel", "members": [ { - "name": "account", + "name": "player", "type": "ContractAddress", "key": true }, { - "name": "amount", - "type": "u128", + "name": "direction", + "type": "Direction", "key": false } ], - "class_hash": "0x4463c89586bc5015a7bc97e9e4af123330842b20aa6f6587c795d6d35907a9d", - "original_class_hash": "0x4463c89586bc5015a7bc97e9e4af123330842b20aa6f6587c795d6d35907a9d", + "class_hash": "0x36b7886db455f41fac4263da9f0d21190bb575c8555bde1c3357486495c0be1", + "original_class_hash": "0x36b7886db455f41fac4263da9f0d21190bb575c8555bde1c3357486495c0be1", "abi": [ { "type": "impl", @@ -3923,26 +3914,52 @@ }, { "type": "impl", - "name": "mock_tokenImpl", - "interface_name": "dojo_examples::models::Imock_token" + "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::models::MockToken", + "name": "dojo_examples::actions::actions::Moved", "members": [ { - "name": "account", + "name": "player", "type": "core::starknet::contract_address::ContractAddress" }, { - "name": "amount", - "type": "core::integer::u128" + "name": "direction", + "type": "dojo_examples::models::Direction" } ] }, { "type": "interface", - "name": "dojo_examples::models::Imock_token", + "name": "dojo_examples::actions::actions::Imoved", "items": [ { "type": "function", @@ -3950,7 +3967,7 @@ "inputs": [ { "name": "model", - "type": "dojo_examples::models::MockToken" + "type": "dojo_examples::actions::actions::Moved" } ], "outputs": [], @@ -3960,13 +3977,13 @@ }, { "type": "event", - "name": "dojo_examples::models::mock_token::Event", + "name": "dojo_examples::actions::actions::moved::Event", "kind": "enum", "variants": [] } ], - "tag": "dojo_examples-MockToken", - "manifest_name": "dojo_examples-MockToken-38903c7c" + "tag": "dojo_examples-Moved", + "manifest_name": "dojo_examples-Moved-318ae40d" }, { "kind": "DojoModel", @@ -3977,13 +3994,18 @@ "key": true }, { - "name": "direction", + "name": "remaining", + "type": "u8", + "key": false + }, + { + "name": "last_direction", "type": "Direction", "key": false } ], - "class_hash": "0x36b7886db455f41fac4263da9f0d21190bb575c8555bde1c3357486495c0be1", - "original_class_hash": "0x36b7886db455f41fac4263da9f0d21190bb575c8555bde1c3357486495c0be1", + "class_hash": "0x23ec6500e0f3e8c64c6fb3ee3ed3259d81c0bde627c8c9c1177da098189dd89", + "original_class_hash": "0x23ec6500e0f3e8c64c6fb3ee3ed3259d81c0bde627c8c9c1177da098189dd89", "abi": [ { "type": "impl", @@ -4349,8 +4371,8 @@ }, { "type": "impl", - "name": "movedImpl", - "interface_name": "dojo_examples::actions::actions::Imoved" + "name": "movesImpl", + "interface_name": "dojo_examples::models::Imoves" }, { "type": "enum", @@ -4380,21 +4402,25 @@ }, { "type": "struct", - "name": "dojo_examples::actions::actions::Moved", + "name": "dojo_examples::models::Moves", "members": [ { "name": "player", "type": "core::starknet::contract_address::ContractAddress" }, { - "name": "direction", + "name": "remaining", + "type": "core::integer::u8" + }, + { + "name": "last_direction", "type": "dojo_examples::models::Direction" } ] }, { "type": "interface", - "name": "dojo_examples::actions::actions::Imoved", + "name": "dojo_examples::models::Imoves", "items": [ { "type": "function", @@ -4402,7 +4428,7 @@ "inputs": [ { "name": "model", - "type": "dojo_examples::actions::actions::Moved" + "type": "dojo_examples::models::Moves" } ], "outputs": [], @@ -4412,13 +4438,13 @@ }, { "type": "event", - "name": "dojo_examples::actions::actions::moved::Event", + "name": "dojo_examples::models::moves::Event", "kind": "enum", "variants": [] } ], - "tag": "dojo_examples-Moved", - "manifest_name": "dojo_examples-Moved-318ae40d" + "tag": "dojo_examples-Moves", + "manifest_name": "dojo_examples-Moves-2e2accba" }, { "kind": "DojoModel", @@ -4429,18 +4455,23 @@ "key": true }, { - "name": "remaining", - "type": "u8", + "name": "name", + "type": "ByteArray", "key": false }, { - "name": "last_direction", - "type": "Direction", + "name": "items", + "type": "Array", + "key": false + }, + { + "name": "favorite_item", + "type": "Option", "key": false } ], - "class_hash": "0x23ec6500e0f3e8c64c6fb3ee3ed3259d81c0bde627c8c9c1177da098189dd89", - "original_class_hash": "0x23ec6500e0f3e8c64c6fb3ee3ed3259d81c0bde627c8c9c1177da098189dd89", + "class_hash": "0x13f8294fde1c2605e9825782ae293b3bae2291e6cbd20d4ef8878ff044d4b82", + "original_class_hash": "0x13f8294fde1c2605e9825782ae293b3bae2291e6cbd20d4ef8878ff044d4b82", "abi": [ { "type": "impl", @@ -4806,56 +4837,48 @@ }, { "type": "impl", - "name": "movesImpl", - "interface_name": "dojo_examples::models::Imoves" + "name": "player_configImpl", + "interface_name": "dojo_examples::models::Iplayer_config" }, { - "type": "enum", - "name": "dojo_examples::models::Direction", - "variants": [ - { - "name": "None", - "type": "()" - }, - { - "name": "Left", - "type": "()" - }, - { - "name": "Right", - "type": "()" - }, + "type": "struct", + "name": "dojo_examples::models::PlayerItem", + "members": [ { - "name": "Up", - "type": "()" + "name": "item_id", + "type": "core::integer::u32" }, { - "name": "Down", - "type": "()" + "name": "quantity", + "type": "core::integer::u32" } ] }, { "type": "struct", - "name": "dojo_examples::models::Moves", + "name": "dojo_examples::models::PlayerConfig", "members": [ { "name": "player", "type": "core::starknet::contract_address::ContractAddress" }, { - "name": "remaining", - "type": "core::integer::u8" + "name": "name", + "type": "core::byte_array::ByteArray" }, { - "name": "last_direction", - "type": "dojo_examples::models::Direction" + "name": "items", + "type": "core::array::Array::" + }, + { + "name": "favorite_item", + "type": "core::option::Option::" } ] }, { "type": "interface", - "name": "dojo_examples::models::Imoves", + "name": "dojo_examples::models::Iplayer_config", "items": [ { "type": "function", @@ -4863,7 +4886,7 @@ "inputs": [ { "name": "model", - "type": "dojo_examples::models::Moves" + "type": "dojo_examples::models::PlayerConfig" } ], "outputs": [], @@ -4873,13 +4896,13 @@ }, { "type": "event", - "name": "dojo_examples::models::moves::Event", + "name": "dojo_examples::models::player_config::Event", "kind": "enum", "variants": [] } ], - "tag": "dojo_examples-Moves", - "manifest_name": "dojo_examples-Moves-2e2accba" + "tag": "dojo_examples-PlayerConfig", + "manifest_name": "dojo_examples-PlayerConfig-3adad785" }, { "kind": "DojoModel", @@ -4890,23 +4913,13 @@ "key": true }, { - "name": "name", - "type": "ByteArray", - "key": false - }, - { - "name": "items", - "type": "Array", - "key": false - }, - { - "name": "favorite_item", - "type": "Option", + "name": "vec", + "type": "Vec2", "key": false } ], - "class_hash": "0x13f8294fde1c2605e9825782ae293b3bae2291e6cbd20d4ef8878ff044d4b82", - "original_class_hash": "0x13f8294fde1c2605e9825782ae293b3bae2291e6cbd20d4ef8878ff044d4b82", + "class_hash": "0x7104c882f56f62ef1f2453319bf6a1f5784b5f33b63b65506c38d62c3e3fd40", + "original_class_hash": "0x7104c882f56f62ef1f2453319bf6a1f5784b5f33b63b65506c38d62c3e3fd40", "abi": [ { "type": "impl", @@ -5272,48 +5285,40 @@ }, { "type": "impl", - "name": "player_configImpl", - "interface_name": "dojo_examples::models::Iplayer_config" + "name": "positionImpl", + "interface_name": "dojo_examples::models::Iposition" }, { "type": "struct", - "name": "dojo_examples::models::PlayerItem", + "name": "dojo_examples::models::Vec2", "members": [ { - "name": "item_id", + "name": "x", "type": "core::integer::u32" }, { - "name": "quantity", + "name": "y", "type": "core::integer::u32" } ] }, { "type": "struct", - "name": "dojo_examples::models::PlayerConfig", + "name": "dojo_examples::models::Position", "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::" + "name": "vec", + "type": "dojo_examples::models::Vec2" } ] }, { "type": "interface", - "name": "dojo_examples::models::Iplayer_config", + "name": "dojo_examples::models::Iposition", "items": [ { "type": "function", @@ -5321,7 +5326,7 @@ "inputs": [ { "name": "model", - "type": "dojo_examples::models::PlayerConfig" + "type": "dojo_examples::models::Position" } ], "outputs": [], @@ -5331,13 +5336,13 @@ }, { "type": "event", - "name": "dojo_examples::models::player_config::Event", + "name": "dojo_examples::models::position::Event", "kind": "enum", "variants": [] } ], - "tag": "dojo_examples-PlayerConfig", - "manifest_name": "dojo_examples-PlayerConfig-3adad785" + "tag": "dojo_examples-Position", + "manifest_name": "dojo_examples-Position-1e145e26" }, { "kind": "DojoModel", @@ -5348,13 +5353,18 @@ "key": true }, { - "name": "vec", - "type": "Vec2", + "name": "server_id", + "type": "u32", + "key": true + }, + { + "name": "name", + "type": "ByteArray", "key": false } ], - "class_hash": "0x7104c882f56f62ef1f2453319bf6a1f5784b5f33b63b65506c38d62c3e3fd40", - "original_class_hash": "0x7104c882f56f62ef1f2453319bf6a1f5784b5f33b63b65506c38d62c3e3fd40", + "class_hash": "0x48dfe99daae31ced8d121079c148d084311483f047519d2d3fae363f15c7a1f", + "original_class_hash": "0x48dfe99daae31ced8d121079c148d084311483f047519d2d3fae363f15c7a1f", "abi": [ { "type": "impl", @@ -5720,40 +5730,30 @@ }, { "type": "impl", - "name": "positionImpl", - "interface_name": "dojo_examples::models::Iposition" + "name": "server_profileImpl", + "interface_name": "dojo_examples::models::Iserver_profile" }, { "type": "struct", - "name": "dojo_examples::models::Vec2", + "name": "dojo_examples::models::ServerProfile", "members": [ { - "name": "x", - "type": "core::integer::u32" + "name": "player", + "type": "core::starknet::contract_address::ContractAddress" }, { - "name": "y", + "name": "server_id", "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" + "name": "name", + "type": "core::byte_array::ByteArray" } ] }, { "type": "interface", - "name": "dojo_examples::models::Iposition", + "name": "dojo_examples::models::Iserver_profile", "items": [ { "type": "function", @@ -5761,7 +5761,7 @@ "inputs": [ { "name": "model", - "type": "dojo_examples::models::Position" + "type": "dojo_examples::models::ServerProfile" } ], "outputs": [], @@ -5771,13 +5771,13 @@ }, { "type": "event", - "name": "dojo_examples::models::position::Event", + "name": "dojo_examples::models::server_profile::Event", "kind": "enum", "variants": [] } ], - "tag": "dojo_examples-Position", - "manifest_name": "dojo_examples-Position-1e145e26" + "tag": "dojo_examples-ServerProfile", + "manifest_name": "dojo_examples-ServerProfile-4caad1e6" }, { "kind": "DojoModel", @@ -5803,8 +5803,8 @@ "key": false } ], - "class_hash": "0x645afa3c2890d1b0d1176e20c703225ad7dfa4a16b67417bcd4fad97eac1ebb", - "original_class_hash": "0x645afa3c2890d1b0d1176e20c703225ad7dfa4a16b67417bcd4fad97eac1ebb", + "class_hash": "0x34e17c9bad7ccfa7286e07ed3a9af0b2922c7ee77a4889a1c59d0a6dd7aeacc", + "original_class_hash": "0x34e17c9bad7ccfa7286e07ed3a9af0b2922c7ee77a4889a1c59d0a6dd7aeacc", "abi": [ { "type": "impl", @@ -6220,30 +6220,30 @@ "variants": [] } ], - "tag": "dojo_examples-RiverSkale", - "manifest_name": "dojo_examples-RiverSkale-27fcbc29" + "tag": "dojo_examples_foes-RiverSkale", + "manifest_name": "dojo_examples_foes-RiverSkale-39535c12" }, { "kind": "DojoModel", "members": [ { - "name": "player", - "type": "ContractAddress", + "name": "id", + "type": "u32", "key": true }, { - "name": "server_id", + "name": "atk_speek", "type": "u32", - "key": true + "key": false }, { - "name": "name", - "type": "ByteArray", + "name": "range", + "type": "u32", "key": false } ], - "class_hash": "0x48dfe99daae31ced8d121079c148d084311483f047519d2d3fae363f15c7a1f", - "original_class_hash": "0x48dfe99daae31ced8d121079c148d084311483f047519d2d3fae363f15c7a1f", + "class_hash": "0x672ce1913b025af73d80030f0e7e8d5fa4debe9b011cf0a39a27514cac4a3b5", + "original_class_hash": "0x672ce1913b025af73d80030f0e7e8d5fa4debe9b011cf0a39a27514cac4a3b5", "abi": [ { "type": "impl", @@ -6609,30 +6609,30 @@ }, { "type": "impl", - "name": "server_profileImpl", - "interface_name": "dojo_examples::models::Iserver_profile" + "name": "flatbowImpl", + "interface_name": "armory::Iflatbow" }, { "type": "struct", - "name": "dojo_examples::models::ServerProfile", + "name": "armory::Flatbow", "members": [ { - "name": "player", - "type": "core::starknet::contract_address::ContractAddress" + "name": "id", + "type": "core::integer::u32" }, { - "name": "server_id", + "name": "atk_speek", "type": "core::integer::u32" }, { - "name": "name", - "type": "core::byte_array::ByteArray" + "name": "range", + "type": "core::integer::u32" } ] }, { "type": "interface", - "name": "dojo_examples::models::Iserver_profile", + "name": "armory::Iflatbow", "items": [ { "type": "function", @@ -6640,7 +6640,7 @@ "inputs": [ { "name": "model", - "type": "dojo_examples::models::ServerProfile" + "type": "armory::Flatbow" } ], "outputs": [], @@ -6650,13 +6650,13 @@ }, { "type": "event", - "name": "dojo_examples::models::server_profile::Event", + "name": "armory::flatbow::Event", "kind": "enum", "variants": [] } ], - "tag": "dojo_examples-ServerProfile", - "manifest_name": "dojo_examples-ServerProfile-4caad1e6" + "tag": "dojo_examples_weapons-Flatbow", + "manifest_name": "dojo_examples_weapons-Flatbow-22f5bd16" } ] } \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/deployment/manifest.toml b/examples/spawn-and-move/manifests/dev/deployment/manifest.toml index 39db99a835..72dc3f36d0 100644 --- a/examples/spawn-and-move/manifests/dev/deployment/manifest.toml +++ b/examples/spawn-and-move/manifests/dev/deployment/manifest.toml @@ -24,8 +24,8 @@ manifest_name = "dojo-base" [[contracts]] kind = "DojoContract" address = "0x2e85647f570d2a4abdffdd668823702548d20d1d6aaef74b6a4eb9670a32798" -class_hash = "0x5693c8ae37b78934041173e9a1abd868e09b89d27fb2fc53702b69e48bfa94f" -original_class_hash = "0x5693c8ae37b78934041173e9a1abd868e09b89d27fb2fc53702b69e48bfa94f" +class_hash = "0x2c975b0d681861edd6caad5fbc0b42dc3e8b034b6c0b0a7628fb3a7bedf1e8d" +original_class_hash = "0x2c975b0d681861edd6caad5fbc0b42dc3e8b034b6c0b0a7628fb3a7bedf1e8d" base_class_hash = "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4" abi = "manifests/dev/deployment/abis/contracts/dojo_examples-actions-40b6994c.json" reads = [] @@ -107,29 +107,6 @@ name = "value" type = "u8" key = false -[[models]] -kind = "DojoModel" -class_hash = "0x452abb4fc0af6e0e08e6f652ce77d7330000d4e4bec995005785c7d3f12ea1a" -original_class_hash = "0x452abb4fc0af6e0e08e6f652ce77d7330000d4e4bec995005785c7d3f12ea1a" -abi = "manifests/dev/deployment/abis/models/dojo_examples-Flatbow-3632af69.json" -tag = "dojo_examples-Flatbow" -manifest_name = "dojo_examples-Flatbow-3632af69" - -[[models.members]] -name = "id" -type = "u32" -key = true - -[[models.members]] -name = "atk_speek" -type = "u32" -key = false - -[[models.members]] -name = "range" -type = "u32" -key = false - [[models]] kind = "DojoModel" class_hash = "0x572bf6d3cbcd69fd6404a993110c3b84379882587b21b7ad5b2761088cb19c3" @@ -265,11 +242,34 @@ key = false [[models]] kind = "DojoModel" -class_hash = "0x645afa3c2890d1b0d1176e20c703225ad7dfa4a16b67417bcd4fad97eac1ebb" -original_class_hash = "0x645afa3c2890d1b0d1176e20c703225ad7dfa4a16b67417bcd4fad97eac1ebb" -abi = "manifests/dev/deployment/abis/models/dojo_examples-RiverSkale-27fcbc29.json" -tag = "dojo_examples-RiverSkale" -manifest_name = "dojo_examples-RiverSkale-27fcbc29" +class_hash = "0x48dfe99daae31ced8d121079c148d084311483f047519d2d3fae363f15c7a1f" +original_class_hash = "0x48dfe99daae31ced8d121079c148d084311483f047519d2d3fae363f15c7a1f" +abi = "manifests/dev/deployment/abis/models/dojo_examples-ServerProfile-4caad1e6.json" +tag = "dojo_examples-ServerProfile" +manifest_name = "dojo_examples-ServerProfile-4caad1e6" + +[[models.members]] +name = "player" +type = "ContractAddress" +key = true + +[[models.members]] +name = "server_id" +type = "u32" +key = true + +[[models.members]] +name = "name" +type = "ByteArray" +key = false + +[[models]] +kind = "DojoModel" +class_hash = "0x34e17c9bad7ccfa7286e07ed3a9af0b2922c7ee77a4889a1c59d0a6dd7aeacc" +original_class_hash = "0x34e17c9bad7ccfa7286e07ed3a9af0b2922c7ee77a4889a1c59d0a6dd7aeacc" +abi = "manifests/dev/deployment/abis/models/dojo_examples_foes-RiverSkale-39535c12.json" +tag = "dojo_examples_foes-RiverSkale" +manifest_name = "dojo_examples_foes-RiverSkale-39535c12" [[models.members]] name = "id" @@ -293,23 +293,23 @@ key = false [[models]] kind = "DojoModel" -class_hash = "0x48dfe99daae31ced8d121079c148d084311483f047519d2d3fae363f15c7a1f" -original_class_hash = "0x48dfe99daae31ced8d121079c148d084311483f047519d2d3fae363f15c7a1f" -abi = "manifests/dev/deployment/abis/models/dojo_examples-ServerProfile-4caad1e6.json" -tag = "dojo_examples-ServerProfile" -manifest_name = "dojo_examples-ServerProfile-4caad1e6" +class_hash = "0x672ce1913b025af73d80030f0e7e8d5fa4debe9b011cf0a39a27514cac4a3b5" +original_class_hash = "0x672ce1913b025af73d80030f0e7e8d5fa4debe9b011cf0a39a27514cac4a3b5" +abi = "manifests/dev/deployment/abis/models/dojo_examples_weapons-Flatbow-22f5bd16.json" +tag = "dojo_examples_weapons-Flatbow" +manifest_name = "dojo_examples_weapons-Flatbow-22f5bd16" [[models.members]] -name = "player" -type = "ContractAddress" +name = "id" +type = "u32" key = true [[models.members]] -name = "server_id" +name = "atk_speek" type = "u32" -key = true +key = false [[models.members]] -name = "name" -type = "ByteArray" +name = "range" +type = "u32" key = false diff --git a/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-RiverSkale-27fcbc29.json b/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples_foes-RiverSkale-39535c12.json similarity index 100% rename from examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples-RiverSkale-27fcbc29.json rename to examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples_foes-RiverSkale-39535c12.json diff --git a/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples_weapons-Flatbow-22f5bd16.json b/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples_weapons-Flatbow-22f5bd16.json new file mode 100644 index 0000000000..50d5861a0a --- /dev/null +++ b/examples/spawn-and-move/manifests/release/base/abis/models/dojo_examples_weapons-Flatbow-22f5bd16.json @@ -0,0 +1,411 @@ +[ + { + "type": "impl", + "name": "DojoModelImpl", + "interface_name": "dojo::model::IModel" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "enum", + "name": "core::option::Option::", + "variants": [ + { + "name": "Some", + "type": "core::integer::u32" + }, + { + "name": "None", + "type": "()" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Member", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "ty", + "type": "dojo::database::introspect::Ty" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Struct", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::Enum", + "members": [ + { + "name": "name", + "type": "core::felt252" + }, + { + "name": "attrs", + "type": "core::array::Span::" + }, + { + "name": "children", + "type": "core::array::Span::<(core::felt252, dojo::database::introspect::Ty)>" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Ty", + "variants": [ + { + "name": "Primitive", + "type": "core::felt252" + }, + { + "name": "Struct", + "type": "dojo::database::introspect::Struct" + }, + { + "name": "Enum", + "type": "dojo::database::introspect::Enum" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::model::IModel", + "items": [ + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "tag", + "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": "selector", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "name_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "namespace_hash", + "inputs": [], + "outputs": [ + { + "type": "core::felt252" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "unpacked_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "packed_size", + "inputs": [], + "outputs": [ + { + "type": "core::option::Option::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "layout", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Layout" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "schema", + "inputs": [], + "outputs": [ + { + "type": "dojo::database::introspect::Ty" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "flatbowImpl", + "interface_name": "armory::Iflatbow" + }, + { + "type": "struct", + "name": "armory::Flatbow", + "members": [ + { + "name": "id", + "type": "core::integer::u32" + }, + { + "name": "atk_speek", + "type": "core::integer::u32" + }, + { + "name": "range", + "type": "core::integer::u32" + } + ] + }, + { + "type": "interface", + "name": "armory::Iflatbow", + "items": [ + { + "type": "function", + "name": "ensure_abi", + "inputs": [ + { + "name": "model", + "type": "armory::Flatbow" + } + ], + "outputs": [], + "state_mutability": "view" + } + ] + }, + { + "type": "event", + "name": "armory::flatbow::Event", + "kind": "enum", + "variants": [] + } +] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-actions-40b6994c.toml b/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-actions-40b6994c.toml index 9b73241efc..eab0fb52ab 100644 --- a/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-actions-40b6994c.toml +++ b/examples/spawn-and-move/manifests/release/base/contracts/dojo_examples-actions-40b6994c.toml @@ -1,6 +1,6 @@ kind = "DojoContract" -class_hash = "0x5693c8ae37b78934041173e9a1abd868e09b89d27fb2fc53702b69e48bfa94f" -original_class_hash = "0x5693c8ae37b78934041173e9a1abd868e09b89d27fb2fc53702b69e48bfa94f" +class_hash = "0x2c975b0d681861edd6caad5fbc0b42dc3e8b034b6c0b0a7628fb3a7bedf1e8d" +original_class_hash = "0x2c975b0d681861edd6caad5fbc0b42dc3e8b034b6c0b0a7628fb3a7bedf1e8d" base_class_hash = "0x0" abi = "manifests/release/base/abis/contracts/dojo_examples-actions-40b6994c.json" reads = [] diff --git a/examples/spawn-and-move/manifests/release/base/models/dojo_examples-Flatbow-3632af69.toml b/examples/spawn-and-move/manifests/release/base/models/dojo_examples-Flatbow-3632af69.toml deleted file mode 100644 index 882bfd9cf8..0000000000 --- a/examples/spawn-and-move/manifests/release/base/models/dojo_examples-Flatbow-3632af69.toml +++ /dev/null @@ -1,21 +0,0 @@ -kind = "DojoModel" -class_hash = "0x452abb4fc0af6e0e08e6f652ce77d7330000d4e4bec995005785c7d3f12ea1a" -original_class_hash = "0x452abb4fc0af6e0e08e6f652ce77d7330000d4e4bec995005785c7d3f12ea1a" -abi = "manifests/release/base/abis/models/dojo_examples-Flatbow-3632af69.json" -tag = "dojo_examples-Flatbow" -manifest_name = "dojo_examples-Flatbow-3632af69" - -[[members]] -name = "id" -type = "u32" -key = true - -[[members]] -name = "atk_speek" -type = "u32" -key = false - -[[members]] -name = "range" -type = "u32" -key = false diff --git a/examples/spawn-and-move/manifests/release/base/models/dojo_examples-RiverSkale-27fcbc29.toml b/examples/spawn-and-move/manifests/release/base/models/dojo_examples-RiverSkale-27fcbc29.toml deleted file mode 100644 index c586684dd4..0000000000 --- a/examples/spawn-and-move/manifests/release/base/models/dojo_examples-RiverSkale-27fcbc29.toml +++ /dev/null @@ -1,26 +0,0 @@ -kind = "DojoModel" -class_hash = "0x645afa3c2890d1b0d1176e20c703225ad7dfa4a16b67417bcd4fad97eac1ebb" -original_class_hash = "0x645afa3c2890d1b0d1176e20c703225ad7dfa4a16b67417bcd4fad97eac1ebb" -abi = "manifests/release/base/abis/models/dojo_examples-RiverSkale-27fcbc29.json" -tag = "dojo_examples-RiverSkale" -manifest_name = "dojo_examples-RiverSkale-27fcbc29" - -[[members]] -name = "id" -type = "u32" -key = true - -[[members]] -name = "health" -type = "u32" -key = false - -[[members]] -name = "armor" -type = "u32" -key = false - -[[members]] -name = "attack" -type = "u32" -key = false diff --git a/examples/spawn-and-move/manifests/release/base/models/dojo_examples_foes-RiverSkale-39535c12.toml b/examples/spawn-and-move/manifests/release/base/models/dojo_examples_foes-RiverSkale-39535c12.toml new file mode 100644 index 0000000000..d3e5f6de7d --- /dev/null +++ b/examples/spawn-and-move/manifests/release/base/models/dojo_examples_foes-RiverSkale-39535c12.toml @@ -0,0 +1,26 @@ +kind = "DojoModel" +class_hash = "0x34e17c9bad7ccfa7286e07ed3a9af0b2922c7ee77a4889a1c59d0a6dd7aeacc" +original_class_hash = "0x34e17c9bad7ccfa7286e07ed3a9af0b2922c7ee77a4889a1c59d0a6dd7aeacc" +abi = "manifests/release/base/abis/models/dojo_examples_foes-RiverSkale-39535c12.json" +tag = "dojo_examples_foes-RiverSkale" +manifest_name = "dojo_examples_foes-RiverSkale-39535c12" + +[[members]] +name = "id" +type = "u32" +key = true + +[[members]] +name = "health" +type = "u32" +key = false + +[[members]] +name = "armor" +type = "u32" +key = false + +[[members]] +name = "attack" +type = "u32" +key = false diff --git a/examples/spawn-and-move/manifests/release/base/models/dojo_examples_weapons-Flatbow-22f5bd16.toml b/examples/spawn-and-move/manifests/release/base/models/dojo_examples_weapons-Flatbow-22f5bd16.toml new file mode 100644 index 0000000000..3f3455d0a4 --- /dev/null +++ b/examples/spawn-and-move/manifests/release/base/models/dojo_examples_weapons-Flatbow-22f5bd16.toml @@ -0,0 +1,21 @@ +kind = "DojoModel" +class_hash = "0x672ce1913b025af73d80030f0e7e8d5fa4debe9b011cf0a39a27514cac4a3b5" +original_class_hash = "0x672ce1913b025af73d80030f0e7e8d5fa4debe9b011cf0a39a27514cac4a3b5" +abi = "manifests/release/base/abis/models/dojo_examples_weapons-Flatbow-22f5bd16.json" +tag = "dojo_examples_weapons-Flatbow" +manifest_name = "dojo_examples_weapons-Flatbow-22f5bd16" + +[[members]] +name = "id" +type = "u32" +key = true + +[[members]] +name = "atk_speek" +type = "u32" +key = false + +[[members]] +name = "range" +type = "u32" +key = false From 112175f37a4a53456114d961c95f97f3d0536fb1 Mon Sep 17 00:00:00 2001 From: glihm Date: Thu, 11 Jul 2024 19:32:16 -0600 Subject: [PATCH 07/15] fix: fix tests --- .../compiler_cairo/Scarb.toml | 2 +- .../contracts/ccf-cairo_v240-8d921297.json | 8 + .../contracts/ccf-cairo_v260-465ec7fe.json | 8 + .../manifests/dev/base/abis/dojo-base.json | 98 ++ .../manifests/dev/base/abis/dojo-world.json | 1105 +++++++++++++++++ .../contracts/ccf-cairo_v240-8d921297.toml | 11 + .../contracts/ccf-cairo_v260-465ec7fe.toml | 11 + .../manifests/dev/base/dojo-base.toml | 6 + .../manifests/dev/base/dojo-world.toml | 6 + .../dojo-lang/src/plugin_test_data/introspect | 216 ++-- crates/dojo-lang/src/plugin_test_data/model | 44 +- crates/dojo-lang/src/plugin_test_data/print | 14 +- crates/dojo-lang/src/plugin_test_data/system | 92 +- crates/dojo-lang/src/semantics/test_data/get | 42 +- crates/dojo-lang/src/semantics/test_data/set | 16 +- crates/dojo-lang/src/utils.rs | 4 +- crates/dojo-world/src/contracts/world_test.rs | 18 +- crates/dojo-world/src/metadata_test.rs | 4 +- .../torii/graphql/src/tests/metadata_test.rs | 2 +- crates/torii/types-test/Scarb.toml | 2 +- 20 files changed, 1484 insertions(+), 225 deletions(-) create mode 100644 crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/contracts/ccf-cairo_v240-8d921297.json create mode 100644 crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/contracts/ccf-cairo_v260-465ec7fe.json create mode 100644 crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-base.json create mode 100644 crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-world.json create mode 100644 crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/contracts/ccf-cairo_v240-8d921297.toml create mode 100644 crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/contracts/ccf-cairo_v260-465ec7fe.toml create mode 100644 crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-base.toml create mode 100644 crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-world.toml diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/Scarb.toml b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/Scarb.toml index f22ec5c45f..da1668baab 100644 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/Scarb.toml +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/Scarb.toml @@ -19,7 +19,7 @@ build-external-contracts = [ ] description = "Cairo compiler features" name = "compiler_cairo_features" seed = "compiler_cairo_features" -namespace = "ccf" +namespace = { default = "ccf" } [tool.dojo.env] rpc_url = "http://localhost:5050/" diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/contracts/ccf-cairo_v240-8d921297.json b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/contracts/ccf-cairo_v240-8d921297.json new file mode 100644 index 0000000000..fdb8ff1c75 --- /dev/null +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/contracts/ccf-cairo_v240-8d921297.json @@ -0,0 +1,8 @@ +[ + { + "type": "event", + "name": "compiler_cairo::cairo_24::cairo_v240::Event", + "kind": "enum", + "variants": [] + } +] \ No newline at end of file diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/contracts/ccf-cairo_v260-465ec7fe.json b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/contracts/ccf-cairo_v260-465ec7fe.json new file mode 100644 index 0000000000..86eebdcf3f --- /dev/null +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/contracts/ccf-cairo_v260-465ec7fe.json @@ -0,0 +1,8 @@ +[ + { + "type": "event", + "name": "compiler_cairo::cairo_26::cairo_v260::Event", + "kind": "enum", + "variants": [] + } +] \ No newline at end of file diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-base.json b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-base.json new file mode 100644 index 0000000000..ee9ceaac66 --- /dev/null +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-base.json @@ -0,0 +1,98 @@ +[ + { + "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": "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": "constructor", + "name": "constructor", + "inputs": [] + }, + { + "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::base::base::Event", + "kind": "enum", + "variants": [ + { + "name": "UpgradeableEvent", + "type": "dojo::components::upgradeable::upgradeable::Event", + "kind": "flat" + } + ] + } +] \ No newline at end of file diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-world.json b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-world.json new file mode 100644 index 0000000000..0e5e96210e --- /dev/null +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-world.json @@ -0,0 +1,1105 @@ +[ + { + "type": "impl", + "name": "World", + "interface_name": "dojo::world::IWorld" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "struct", + "name": "dojo::resource_metadata::ResourceMetadata", + "members": [ + { + "name": "resource_id", + "type": "core::felt252" + }, + { + "name": "metadata_uri", + "type": "core::byte_array::ByteArray" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::database::introspect::FieldLayout", + "members": [ + { + "name": "selector", + "type": "core::felt252" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "dojo::database::introspect::Layout", + "variants": [ + { + "name": "Fixed", + "type": "core::array::Span::" + }, + { + "name": "Struct", + "type": "core::array::Span::" + }, + { + "name": "Tuple", + "type": "core::array::Span::" + }, + { + "name": "Array", + "type": "core::array::Span::" + }, + { + "name": "ByteArray", + "type": "()" + }, + { + "name": "Enum", + "type": "core::array::Span::" + } + ] + }, + { + "type": "enum", + "name": "core::bool", + "variants": [ + { + "name": "False", + "type": "()" + }, + { + "name": "True", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "dojo::world::IWorld", + "items": [ + { + "type": "function", + "name": "metadata", + "inputs": [ + { + "name": "resource_id", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "dojo::resource_metadata::ResourceMetadata" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "set_metadata", + "inputs": [ + { + "name": "metadata", + "type": "dojo::resource_metadata::ResourceMetadata" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "model", + "inputs": [ + { + "name": "selector", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "(core::starknet::class_hash::ClassHash, core::starknet::contract_address::ContractAddress)" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "register_model", + "inputs": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "register_namespace", + "inputs": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "deploy_contract", + "inputs": [ + { + "name": "salt", + "type": "core::felt252" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + }, + { + "name": "init_calldata", + "type": "core::array::Span::" + } + ], + "outputs": [ + { + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "upgrade_contract", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [ + { + "type": "core::starknet::class_hash::ClassHash" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "uuid", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u32" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "emit", + "inputs": [ + { + "name": "keys", + "type": "core::array::Array::" + }, + { + "name": "values", + "type": "core::array::Span::" + } + ], + "outputs": [], + "state_mutability": "view" + }, + { + "type": "function", + "name": "entity", + "inputs": [ + { + "name": "model", + "type": "core::felt252" + }, + { + "name": "keys", + "type": "core::array::Span::" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ], + "outputs": [ + { + "type": "core::array::Span::" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "set_entity", + "inputs": [ + { + "name": "model", + "type": "core::felt252" + }, + { + "name": "keys", + "type": "core::array::Span::" + }, + { + "name": "values", + "type": "core::array::Span::" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "delete_entity", + "inputs": [ + { + "name": "model", + "type": "core::felt252" + }, + { + "name": "keys", + "type": "core::array::Span::" + }, + { + "name": "layout", + "type": "dojo::database::introspect::Layout" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "base", + "inputs": [], + "outputs": [ + { + "type": "core::starknet::class_hash::ClassHash" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "is_owner", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "resource", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "grant_owner", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "resource", + "type": "core::felt252" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "revoke_owner", + "inputs": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "resource", + "type": "core::felt252" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "is_writer", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "grant_writer", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "revoke_writer", + "inputs": [ + { + "name": "resource", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "can_write_resource", + "inputs": [ + { + "name": "resource_id", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "can_write_model", + "inputs": [ + { + "name": "model_id", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "can_write_namespace", + "inputs": [ + { + "name": "namespace_id", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + } + ] + }, + { + "type": "impl", + "name": "UpgradeableWorld", + "interface_name": "dojo::world::IUpgradeableWorld" + }, + { + "type": "interface", + "name": "dojo::world::IUpgradeableWorld", + "items": [ + { + "type": "function", + "name": "upgrade", + "inputs": [ + { + "name": "new_class_hash", + "type": "core::starknet::class_hash::ClassHash" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "impl", + "name": "UpgradeableState", + "interface_name": "dojo::interfaces::IUpgradeableState" + }, + { + "type": "struct", + "name": "dojo::interfaces::StorageUpdate", + "members": [ + { + "name": "key", + "type": "core::felt252" + }, + { + "name": "value", + "type": "core::felt252" + } + ] + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "struct", + "name": "dojo::interfaces::ProgramOutput", + "members": [ + { + "name": "prev_state_root", + "type": "core::felt252" + }, + { + "name": "new_state_root", + "type": "core::felt252" + }, + { + "name": "block_number", + "type": "core::felt252" + }, + { + "name": "block_hash", + "type": "core::felt252" + }, + { + "name": "config_hash", + "type": "core::felt252" + }, + { + "name": "world_da_hash", + "type": "core::felt252" + }, + { + "name": "message_to_starknet_segment", + "type": "core::array::Span::" + }, + { + "name": "message_to_appchain_segment", + "type": "core::array::Span::" + } + ] + }, + { + "type": "interface", + "name": "dojo::interfaces::IUpgradeableState", + "items": [ + { + "type": "function", + "name": "upgrade_state", + "inputs": [ + { + "name": "new_state", + "type": "core::array::Span::" + }, + { + "name": "program_output", + "type": "dojo::interfaces::ProgramOutput" + }, + { + "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" + }, + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "data" + }, + { + "name": "name", + "type": "core::byte_array::ByteArray", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::ContractUpgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::WorldUpgraded", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::MetadataUpdate", + "kind": "struct", + "members": [ + { + "name": "resource", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "uri", + "type": "core::byte_array::ByteArray", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::NamespaceRegistered", + "kind": "struct", + "members": [ + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "data" + }, + { + "name": "hash", + "type": "core::felt252", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::ModelRegistered", + "kind": "struct", + "members": [ + { + "name": "name", + "type": "core::byte_array::ByteArray", + "kind": "data" + }, + { + "name": "namespace", + "type": "core::byte_array::ByteArray", + "kind": "data" + }, + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "prev_class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "prev_address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::StoreSetRecord", + "kind": "struct", + "members": [ + { + "name": "table", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "keys", + "type": "core::array::Span::", + "kind": "data" + }, + { + "name": "values", + "type": "core::array::Span::", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::StoreDelRecord", + "kind": "struct", + "members": [ + { + "name": "table", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "keys", + "type": "core::array::Span::", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::WriterUpdated", + "kind": "struct", + "members": [ + { + "name": "resource", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "value", + "type": "core::bool", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::world::world::OwnerUpdated", + "kind": "struct", + "members": [ + { + "name": "address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + }, + { + "name": "resource", + "type": "core::felt252", + "kind": "data" + }, + { + "name": "value", + "type": "core::bool", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "dojo::config::component::Config::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": "NamespaceRegistered", + "type": "dojo::world::world::NamespaceRegistered", + "kind": "nested" + }, + { + "name": "ModelRegistered", + "type": "dojo::world::world::ModelRegistered", + "kind": "nested" + }, + { + "name": "StoreSetRecord", + "type": "dojo::world::world::StoreSetRecord", + "kind": "nested" + }, + { + "name": "StoreDelRecord", + "type": "dojo::world::world::StoreDelRecord", + "kind": "nested" + }, + { + "name": "WriterUpdated", + "type": "dojo::world::world::WriterUpdated", + "kind": "nested" + }, + { + "name": "OwnerUpdated", + "type": "dojo::world::world::OwnerUpdated", + "kind": "nested" + }, + { + "name": "ConfigEvent", + "type": "dojo::config::component::Config::Event", + "kind": "nested" + }, + { + "name": "StateUpdated", + "type": "dojo::world::world::StateUpdated", + "kind": "nested" + } + ] + } +] \ No newline at end of file diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/contracts/ccf-cairo_v240-8d921297.toml b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/contracts/ccf-cairo_v240-8d921297.toml new file mode 100644 index 0000000000..2fd8e54479 --- /dev/null +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/contracts/ccf-cairo_v240-8d921297.toml @@ -0,0 +1,11 @@ +kind = "DojoContract" +class_hash = "0x1b29f38120f222120acf9b3d66f7015d47c0b11d4e9acdfefa243958c60909d" +original_class_hash = "0x1b29f38120f222120acf9b3d66f7015d47c0b11d4e9acdfefa243958c60909d" +base_class_hash = "0x0" +abi = "manifests/dev/base/abis/contracts/ccf-cairo_v240-8d921297.json" +reads = [] +writes = [] +computed = [] +init_calldata = [] +tag = "ccf-cairo_v240" +manifest_name = "ccf-cairo_v240-8d921297" diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/contracts/ccf-cairo_v260-465ec7fe.toml b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/contracts/ccf-cairo_v260-465ec7fe.toml new file mode 100644 index 0000000000..cd8f1e26b2 --- /dev/null +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/contracts/ccf-cairo_v260-465ec7fe.toml @@ -0,0 +1,11 @@ +kind = "DojoContract" +class_hash = "0x412449a631f6652b3bbe27841fb6776639e493baad1a5894daeb9260d1b0a63" +original_class_hash = "0x412449a631f6652b3bbe27841fb6776639e493baad1a5894daeb9260d1b0a63" +base_class_hash = "0x0" +abi = "manifests/dev/base/abis/contracts/ccf-cairo_v260-465ec7fe.json" +reads = [] +writes = [] +computed = [] +init_calldata = [] +tag = "ccf-cairo_v260" +manifest_name = "ccf-cairo_v260-465ec7fe" diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-base.toml b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-base.toml new file mode 100644 index 0000000000..aa92e94fac --- /dev/null +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-base.toml @@ -0,0 +1,6 @@ +kind = "Class" +class_hash = "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4" +original_class_hash = "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4" +abi = "manifests/dev/base/abis/dojo-base.json" +tag = "dojo-base" +manifest_name = "dojo-base" diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-world.toml b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-world.toml new file mode 100644 index 0000000000..83a7a20228 --- /dev/null +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-world.toml @@ -0,0 +1,6 @@ +kind = "Class" +class_hash = "0x210dd8e484e5555dc74a4a600b17878fc108911719b04139309acc874160c51" +original_class_hash = "0x210dd8e484e5555dc74a4a600b17878fc108911719b04139309acc874160c51" +abi = "manifests/dev/base/abis/dojo-world.json" +tag = "dojo-world" +manifest_name = "dojo-world" diff --git a/crates/dojo-lang/src/plugin_test_data/introspect b/crates/dojo-lang/src/plugin_test_data/introspect index 76b3602f77..fe65767638 100644 --- a/crates/dojo-lang/src/plugin_test_data/introspect +++ b/crates/dojo-lang/src/plugin_test_data/introspect @@ -814,542 +814,542 @@ impl EnumWithBadOptionSerde of core::serde::Serde:: { } //! > expected_diagnostics -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:1:1 use core::serde::Serde; ^*********************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:3:1 #[derive(Copy, Drop, Serde, Introspect)] ^**************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:9:1 #[derive(Serde, Copy, Drop, Introspect)] ^**************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:15:1 #[derive(Serde, Copy, Drop, Introspect)] ^**************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:21:1 #[derive(Serde, Copy, Drop, Introspect)] ^**************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:27:1 #[derive(Serde, Copy, Drop, Introspect)] ^**************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:33:1 #[derive(Serde, Copy, Drop, Introspect)] ^**************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:39:1 #[derive(Serde, Copy, Drop, Introspect)] ^**************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:45:1 #[derive(Serde, Copy, Drop, Introspect)] ^**************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:51:1 #[derive(Serde, Copy, Drop, Introspect)] ^**************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:57:1 #[derive(Serde, Copy, Drop, Introspect)] ^**************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:63:1 #[derive(Serde, Copy, Drop, Introspect)] ^**************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:69:1 #[derive(Serde, Copy, Drop, Introspect)] ^**************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:76:1 #[derive(Copy, Drop, Introspect)] ^*******************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:84:1 #[derive(Copy, Drop, Introspect)] ^*******************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:92:1 #[derive(Copy, Drop, Introspect)] ^*******************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:100:1 #[derive(Copy, Drop, Introspect)] ^*******************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:108:1 #[derive(Copy, Drop, Introspect)] ^*******************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:116:1 #[derive(Copy, Drop, Introspect)] ^*******************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:124:1 #[derive(Copy, Drop, Introspect)] ^*******************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:132:1 #[derive(Copy, Drop, Introspect)] ^*******************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:140:1 #[derive(Copy, Drop, Introspect)] ^*******************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:148:1 #[derive(Copy, Drop, Introspect)] ^*******************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:156:1 #[derive(Copy, Drop, Introspect)] ^*******************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:164:1 #[derive(Copy, Drop, Serde, Introspect)] ^**************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:169:1 #[derive(Copy, Drop, Serde, Introspect)] ^**************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:174:1 #[derive(Copy, Drop, Serde, Introspect)] ^**************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:179:1 #[derive(Introspect, IntrospectPacked)] ^*************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:182:1 #[derive(Introspect, IntrospectPacked)] ^*************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:185:1 #[derive(Introspect)] ^*******************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:189:1 #[derive(Introspect)] ^*******************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:193:1 #[derive(IntrospectPacked)] ^*************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:198:1 #[derive(IntrospectPacked)] ^*************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:204:1 #[derive(IntrospectPacked)] ^*************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:210:1 #[derive(IntrospectPacked)] ^*************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:216:1 #[derive(IntrospectPacked)] ^*************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:222:1 #[derive(IntrospectPacked)] ^*************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:229:1 #[derive(IntrospectPacked)] ^*************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:236:1 #[derive(IntrospectPacked)] ^*************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:243:1 #[derive(IntrospectPacked)] ^*************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:249:1 #[derive(IntrospectPacked)] ^*************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:2:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:2:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:2:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:8:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:8:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:8:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:14:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:14:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:14:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:20:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:20:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:20:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:26:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:26:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:26:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:32:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:32:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:32:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:38:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:38:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:38:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:44:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:44:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:44:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:50:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:50:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:50:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:56:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:56:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:56:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:62:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:62:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:62:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:68:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:68:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:68:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:75:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:75:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:83:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:83:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:91:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:91:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:99:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:99:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:107:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:107:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:115:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:115:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:123:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:123:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:131:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:131:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:139:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:139:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:147:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:147:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:155:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:155:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:163:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:163:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:163:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:168:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:168:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:168:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:173:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:173:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:173:1 ^ diff --git a/crates/dojo-lang/src/plugin_test_data/model b/crates/dojo-lang/src/plugin_test_data/model index 39c5ece18c..27ccf7e648 100644 --- a/crates/dojo-lang/src/plugin_test_data/model +++ b/crates/dojo-lang/src/plugin_test_data/model @@ -314,112 +314,112 @@ struct ModelWithTupleNoPrimitives { } //! > expected_diagnostics -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:1:1 #[dojo::model(version: 0)] ^************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:9:1 #[dojo::model(version: 0, version: 0)] ^************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:16:1 #[dojo::model(version: hello)] ^****************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:23:1 #[dojo::model(version)] ^*********************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:30:1 #[dojo::model(my_arg: 1)] ^***********************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:37:1 #[dojo::model(my_arg)] ^********************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:44:1 #[dojo::model(version: 2)] ^************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:51:1 #[dojo::model(version: 0)] ^************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:58:1 #[dojo::model(namespace: 'MyNamespace')] ^**************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:65:1 #[dojo::model(namespace: 'my_namespace')] ^***************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:72:1 #[dojo::model(namespace: "my_namespace")] ^***************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:79:1 #[dojo::model] ^************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:86:1 #[dojo::model] ^************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:91:1 #[dojo::model] ^************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:97:1 #[dojo::model] ^************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:103:1 #[dojo::model] ^************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:112:1 #[dojo::model] ^************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:115:1 #[dojo::model] ^************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:123:1 #[dojo::model] ^************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:131:1 #[dojo::model] ^************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:139:1 #[dojo::model] ^************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:147:1 #[dojo::model] ^************^ diff --git a/crates/dojo-lang/src/plugin_test_data/print b/crates/dojo-lang/src/plugin_test_data/print index 7bf048fb4c..f20a89ffad 100644 --- a/crates/dojo-lang/src/plugin_test_data/print +++ b/crates/dojo-lang/src/plugin_test_data/print @@ -77,12 +77,12 @@ enum Enemy { } //! > expected_diagnostics -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:1:1 use serde::Serde; ^***************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:2:1 use debug::PrintTrait; ^********************^ @@ -92,7 +92,7 @@ error: Unknown derive `Print` - a plugin might be missing. #[derive(Print)] ^***^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:4:1 #[derive(Print)] ^**************^ @@ -102,12 +102,12 @@ error: Unknown derive `Print` - a plugin might be missing. #[derive(Print)] ^***^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:12:1 #[derive(Print)] ^**************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:17:1 use starknet::ContractAddress; ^****************************^ @@ -117,7 +117,7 @@ error: Unknown derive `Print` - a plugin might be missing. #[derive(Print)] ^***^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:19:1 #[derive(Print)] ^**************^ @@ -127,7 +127,7 @@ error: Unknown derive `Print` - a plugin might be missing. #[derive(Print)] ^***^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:28:1 #[derive(Print)] ^**************^ diff --git a/crates/dojo-lang/src/plugin_test_data/system b/crates/dojo-lang/src/plugin_test_data/system index 80ee85d356..39788cd740 100644 --- a/crates/dojo-lang/src/plugin_test_data/system +++ b/crates/dojo-lang/src/plugin_test_data/system @@ -355,32 +355,32 @@ mod ctxnamed { } //! > expected_diagnostics -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:1:1 #[dojo::contract(namespace: "My@Namespace")] ^******************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:11:1 #[dojo::contract(namespace: 'my_namespace')] ^******************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:21:1 #[dojo::contract(namespace: "my_namespace")] ^******************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:28:1 #[dojo::contract] ^***************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:38:1 #[dojo::contract] ^***************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:52:1 #[starknet::component] ^********************^ @@ -390,7 +390,7 @@ error: Unsupported attribute. #[starknet::component] ^********************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:58:1 #[starknet::component] ^********************^ @@ -400,17 +400,17 @@ error: Unsupported attribute. #[starknet::component] ^********************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:64:1 #[dojo::contract] ^***************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:85:1 #[dojo::interface] ^****************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:88:1 #[dojo::interface] ^****************^ @@ -420,82 +420,82 @@ error: Unsupported attribute. #[my_attr] ^********^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:96:1 #[dojo::interface] ^****************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:109:1 #[dojo::interface] ^****************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:124:1 #[dojo::contract] ^***************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:171:1 #[dojo::contract] ^***************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:222:1 #[dojo::contract] ^***************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:239:1 #[dojo::contract] ^***************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:3:5 use traits::Into; ^***************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:4:5 use dojo::world::Context; ^***********************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:6:5 fn execute(ctx: Context, name: felt252) { ^***************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:13:5 use traits::Into; ^***************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:14:5 use dojo::world::Context; ^***********************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:16:5 fn execute(ctx: Context, name: felt252) { ^***************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:23:5 fn execute(value: felt252) -> felt252 { ^*************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:30:5 use traits::Into; ^***************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:31:5 use dojo::world::Context; ^***********************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:33:5 fn execute(ctx2: Context, name: felt252) { ^****************************************^ @@ -505,7 +505,7 @@ error: Unknown derive `starknet::Event` - a plugin might be missing. #[derive(Drop, starknet::Event)] ^*************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:40:5 #[event] ^******^ @@ -520,22 +520,22 @@ error: Unknown derive `starknet::Event` - a plugin might be missing. #[derive(Drop, starknet::Event)] ^*************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:46:5 #[derive(Drop, starknet::Event)] ^******************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:40:1 #[event] ^**********^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:45:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:54:5 #[storage] ^********^ @@ -545,7 +545,7 @@ error: Unsupported attribute. #[storage] ^********^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:60:5 #[storage] ^********^ @@ -555,7 +555,7 @@ error: Unsupported attribute. #[storage] ^********^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:66:5 component!(path: testcomponent1, storage: testcomponent1_storage, event: testcomponent1_event); ^*********************************************************************************************^ @@ -565,7 +565,7 @@ error: Unknown inline item macro: 'component'. component!(path: testcomponent1, storage: testcomponent1_storage, event: testcomponent1_event); ^*********************************************************************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:67:5 component!(path: testcomponent2, storage: testcomponent2_storage, event: testcomponent2_event); ^*********************************************************************************************^ @@ -575,7 +575,7 @@ error: Unknown inline item macro: 'component'. component!(path: testcomponent2, storage: testcomponent2_storage, event: testcomponent2_event); ^*********************************************************************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:69:5 #[storage] ^********^ @@ -600,7 +600,7 @@ error: Unknown derive `starknet::Event` - a plugin might be missing. #[derive(Drop, starknet::Event)] ^*************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:77:5 #[event] ^******^ @@ -615,12 +615,12 @@ error: Unsupported attribute. #[flat] ^*****^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:76:1 ^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:126:5 #[abi(embed_v0)] ^**************^ @@ -635,22 +635,22 @@ error: Generated trait must have generic args matching the impl's generic params impl InternalImplBad of InternalUtils { ^**************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:163:5 #[generate_trait] ^***************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:163:5 #[generate_trait] ^***************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:173:5 #[derive(Drop)] ^*************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:178:5 #[abi(embed_v0)] ^**************^ @@ -660,22 +660,22 @@ error: Unsupported attribute. #[abi(embed_v0)] ^**************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:213:5 #[generate_trait] ^***************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:173:1 #[derive(Drop)] ^*****************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:213:5 #[generate_trait] ^***************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("test_src"). +error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> test_src/lib.cairo:224:5 fn dojo_init( ^***********^ diff --git a/crates/dojo-lang/src/semantics/test_data/get b/crates/dojo-lang/src/semantics/test_data/get index ff66c3cba3..db57604909 100644 --- a/crates/dojo-lang/src/semantics/test_data/get +++ b/crates/dojo-lang/src/semantics/test_data/get @@ -29,37 +29,37 @@ Missing( ) //! > semantic_diagnostics -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> lib.cairo:1:1 use array::ArrayTrait; ^********************^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> lib.cairo:2:1 use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; ^*********************************************************^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> lib.cairo:4:1 #[derive(Copy, Drop, Serde, Introspect)] ^**************************************^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> lib.cairo:10:1 fn test_func() { let key: felt252 = 0xb0b; ^****************************************^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> lib.cairo:3:1 ^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> lib.cairo:3:1 ^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> lib.cairo:3:1 ^ @@ -112,37 +112,37 @@ Missing( ) //! > semantic_diagnostics -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> lib.cairo:1:1 use array::ArrayTrait; ^********************^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> lib.cairo:2:1 use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; ^*********************************************************^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> lib.cairo:4:1 #[derive(Copy, Drop, Serde, Introspect)] ^**************************************^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> lib.cairo:10:1 fn test_func() { let key: felt252 = 0xb0b; ^****************************************^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> lib.cairo:3:1 ^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> lib.cairo:3:1 ^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> lib.cairo:3:1 ^ @@ -321,37 +321,37 @@ Block( ) //! > semantic_diagnostics -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> lib.cairo:1:1 use array::ArrayTrait; ^********************^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> lib.cairo:2:1 use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; ^*********************************************************^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> lib.cairo:4:1 #[derive(Copy, Drop, Serde, Introspect)] ^**************************************^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> lib.cairo:10:1 fn test_func() { let key: felt252 = 0xb0b; ^****************************************^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> lib.cairo:3:1 ^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> lib.cairo:3:1 ^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> lib.cairo:3:1 ^ diff --git a/crates/dojo-lang/src/semantics/test_data/set b/crates/dojo-lang/src/semantics/test_data/set index 34a7fae2b5..ce115d64e6 100644 --- a/crates/dojo-lang/src/semantics/test_data/set +++ b/crates/dojo-lang/src/semantics/test_data/set @@ -18,7 +18,7 @@ Missing( ) //! > semantic_diagnostics -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> lib.cairo:1:1 fn test_func() { { ^*****************^ @@ -50,7 +50,7 @@ Missing( ) //! > semantic_diagnostics -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> lib.cairo:1:1 fn test_func() { { ^*****************^ @@ -234,7 +234,7 @@ Block( ) //! > semantic_diagnostics -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> lib.cairo:1:1 use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; ^*********************************************************^ @@ -244,27 +244,27 @@ error: Plugin diagnostic: Unknown derive `Model` - a plugin might be missing. #[derive(Copy, Drop, Serde, Model)] ^***^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> lib.cairo:3:1 #[derive(Copy, Drop, Serde, Model)] ^*********************************^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> lib.cairo:9:1 fn test_func() { let key: felt252 = 0xb0b; ^****************************************^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> lib.cairo:2:1 ^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> lib.cairo:2:1 ^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpJ5NYH6/registry/std/43cf361d9/core/src"). +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. --> lib.cairo:2:1 ^ diff --git a/crates/dojo-lang/src/utils.rs b/crates/dojo-lang/src/utils.rs index 4c6b5e25a6..e8eaa50991 100644 --- a/crates/dojo-lang/src/utils.rs +++ b/crates/dojo-lang/src/utils.rs @@ -65,8 +65,6 @@ pub fn get_namespace_config(db: &dyn SyntaxGroup) -> Result { } Err(anyhow::anyhow!( - "Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid: \ - {:?}.", - configuration.root + "Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid.", )) } diff --git a/crates/dojo-world/src/contracts/world_test.rs b/crates/dojo-world/src/contracts/world_test.rs index b81584b97a..22aade32f3 100644 --- a/crates/dojo-world/src/contracts/world_test.rs +++ b/crates/dojo-world/src/contracts/world_test.rs @@ -108,11 +108,19 @@ pub async fn deploy_world( let world = WorldContract::new(world_address, &account); - world - .register_namespace(&cainome::cairo_serde::ByteArray::from_string("dojo_examples").unwrap()) - .send_with_cfg(&TxnConfig::init_wait()) - .await - .unwrap(); + let calls = vec![ + world.register_namespace_getcall( + &cainome::cairo_serde::ByteArray::from_string("dojo_examples").unwrap(), + ), + world.register_namespace_getcall( + &cainome::cairo_serde::ByteArray::from_string("dojo_examples_foes").unwrap(), + ), + world.register_namespace_getcall( + &cainome::cairo_serde::ByteArray::from_string("dojo_examples_weapons").unwrap(), + ), + ]; + + let _ = account.execute_v1(calls).send_with_cfg(&TxnConfig::init_wait()).await.unwrap(); // Wondering why the `init_wait` is not enough and causes a nonce error. // May be to a delay to create the block as we are in instant mining. diff --git a/crates/dojo-world/src/metadata_test.rs b/crates/dojo-world/src/metadata_test.rs index ba58f89d34..d52fe9beb6 100644 --- a/crates/dojo-world/src/metadata_test.rs +++ b/crates/dojo-world/src/metadata_test.rs @@ -34,7 +34,7 @@ icon_uri = "file://example_icon.png" website = "https://dojoengine.org" socials.x = "https://x.com/dojostarknet" seed = "dojo_examples" -namespace = "dojo_examples" +namespace = { default = "dojo_examples" } "#, ) .unwrap(); @@ -106,7 +106,7 @@ world_address = "0x0248cacaeac64c45be0c19ee8727e0bb86623ca7fa3f0d431a6c55e200697 name = "example" description = "example world" seed = "dojo_examples" -namespace = "dojo_examples" +namespace = { default = "dojo_examples" } cover_uri = "file://example_cover.png" icon_uri = "file://example_icon.png" website = "https://dojoengine.org" diff --git a/crates/torii/graphql/src/tests/metadata_test.rs b/crates/torii/graphql/src/tests/metadata_test.rs index 85ca2340fe..9b649e65f0 100644 --- a/crates/torii/graphql/src/tests/metadata_test.rs +++ b/crates/torii/graphql/src/tests/metadata_test.rs @@ -57,7 +57,7 @@ mod tests { name = "example" description = "example world" seed = "example" - namespace = "example" + namespace = { default = "example" } cover_uri = "file://example_cover.png" website = "https://dojoengine.org" socials.x = "https://x.com/dojostarknet" diff --git a/crates/torii/types-test/Scarb.toml b/crates/torii/types-test/Scarb.toml index 6ff4049f66..1428cbe432 100644 --- a/crates/torii/types-test/Scarb.toml +++ b/crates/torii/types-test/Scarb.toml @@ -13,7 +13,7 @@ dojo = { path = "../../dojo-core" } build-external-contracts = [ ] [tool.dojo.world] -namespace = "types_test" +namespace = { default = "types_test" } seed = "types_test" name = "types test" description = "Graphql types testing" From e43f0eebeb5373eccdbada82b331f7ed884310db Mon Sep 17 00:00:00 2001 From: glihm Date: Thu, 11 Jul 2024 20:42:03 -0600 Subject: [PATCH 08/15] fix: ensure starknet and dojo plugin are correctly injected in plugin test --- Cargo.lock | 1 + crates/benches/contracts/Scarb.toml | 3 + crates/dojo-lang/Cargo.toml | 1 + crates/dojo-lang/src/plugin_test.rs | 51 +- .../dojo-lang/src/plugin_test_data/introspect | 2528 ++- crates/dojo-lang/src/plugin_test_data/model | 16881 +++++++++++++++- crates/dojo-lang/src/plugin_test_data/print | 76 +- crates/dojo-lang/src/plugin_test_data/system | 9159 ++++++++- crates/dojo-lang/src/semantics/test_data/get | 42 +- crates/dojo-lang/src/semantics/test_data/set | 16 +- crates/dojo-lang/src/utils.rs | 4 +- 11 files changed, 27682 insertions(+), 1080 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d3d05531a5..28e342e3de 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4812,6 +4812,7 @@ name = "dojo-lang" version = "1.0.0-alpha.0" dependencies = [ "anyhow", + "assert_fs", "cainome 0.2.3 (git+https://github.com/cartridge-gg/cainome?tag=v0.3.0)", "cairo-lang-compiler 2.6.4", "cairo-lang-debug 2.6.4", diff --git a/crates/benches/contracts/Scarb.toml b/crates/benches/contracts/Scarb.toml index 8668f6a45d..e88b6bc892 100644 --- a/crates/benches/contracts/Scarb.toml +++ b/crates/benches/contracts/Scarb.toml @@ -19,3 +19,6 @@ initializer_class_hash = "0xbeef" # Default account for katana with seed = 0 account_address = "0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03" private_key = "0x1800000000300000180000000000030000000000003006001800006600" + +[tool.dojo.world.namespace] +default = "benches" diff --git a/crates/dojo-lang/Cargo.toml b/crates/dojo-lang/Cargo.toml index e9bf9fa806..08a3510c21 100644 --- a/crates/dojo-lang/Cargo.toml +++ b/crates/dojo-lang/Cargo.toml @@ -55,6 +55,7 @@ tracing.workspace = true url.workspace = true [dev-dependencies] +assert_fs.workspace = true cairo-lang-semantic.workspace = true cairo-lang-test-utils.workspace = true dojo-test-utils = { path = "../dojo-test-utils" } diff --git a/crates/dojo-lang/src/plugin_test.rs b/crates/dojo-lang/src/plugin_test.rs index ca266f465a..055d90dab7 100644 --- a/crates/dojo-lang/src/plugin_test.rs +++ b/crates/dojo-lang/src/plugin_test.rs @@ -7,10 +7,11 @@ use cairo_lang_filesystem::cfg::CfgSet; use cairo_lang_filesystem::db::{ init_files_group, AsFilesGroupMut, CrateConfiguration, FilesDatabase, FilesGroup, FilesGroupEx, }; -use cairo_lang_filesystem::ids::{CrateLongId, Directory, FileLongId}; +use cairo_lang_filesystem::ids::{CrateLongId, Directory}; use cairo_lang_parser::db::ParserDatabase; use cairo_lang_plugins::get_base_plugins; use cairo_lang_plugins::test_utils::expand_module_text; +use cairo_lang_starknet::plugin::StarkNetPlugin; use cairo_lang_syntax::node::db::{SyntaxDatabase, SyntaxGroup}; use cairo_lang_test_utils::parse_test_file::TestRunnerResult; use cairo_lang_test_utils::verify_diagnostics_expectation; @@ -35,7 +36,11 @@ pub fn test_expand_plugin( inputs: &OrderedHashMap, args: &OrderedHashMap, ) -> TestRunnerResult { - test_expand_plugin_inner(inputs, args, &[Arc::new(BuiltinDojoPlugin)]) + test_expand_plugin_inner( + inputs, + args, + &[Arc::new(BuiltinDojoPlugin), Arc::new(StarkNetPlugin::default())], + ) } #[salsa::database(DefsDatabase, ParserDatabase, SyntaxDatabase, FilesDatabase)] @@ -92,16 +97,46 @@ pub fn test_expand_plugin_inner( let cairo_code = &inputs["cairo_code"]; + // Create a temporary directory for the test + let tmp_dir = assert_fs::TempDir::new().unwrap(); + println!("tmp_dir: {tmp_dir:?}"); + let tmp_path = tmp_dir.path(); + + // Create Scarb.toml file + let scarb_toml_path = tmp_path.join("Scarb.toml"); + std::fs::write( + scarb_toml_path, + r#" +[package] +cairo-version = "=2.6.4" +name = "test_package" +version = "0.7.3" + +[cairo] +sierra-replace-ids = true + +[[target.dojo]] + +[tool.dojo.world] +namespace = { default = "test_package" } +seed = "test_package" +"#, + ) + .expect("Failed to write Scarb.toml"); + + // Create src directory + let src_dir = tmp_path.join("src"); + std::fs::create_dir(&src_dir).expect("Failed to create src directory"); + + // Create lib.cairo file + let lib_cairo_path = src_dir.join("lib.cairo"); + std::fs::write(lib_cairo_path, cairo_code).expect("Failed to write lib.cairo"); + let crate_id = db.intern_crate(CrateLongId::Real("test".into())); - let root = Directory::Real("test_src".into()); + let root = Directory::Real(src_dir.to_path_buf()); db.set_crate_config(crate_id, Some(CrateConfiguration::default_for_root(root))); - // Main module file. - let file_id = db.intern_file(FileLongId::OnDisk("test_src/lib.cairo".into())); - db.as_files_group_mut() - .override_file_content(file_id, Some(Arc::new(format!("{cairo_code}\n")))); - let mut diagnostic_items = vec![]; let expanded_module = expand_module_text(db, ModuleId::CrateRoot(crate_id), &mut diagnostic_items); diff --git a/crates/dojo-lang/src/plugin_test_data/introspect b/crates/dojo-lang/src/plugin_test_data/introspect index fe65767638..705b66abf9 100644 --- a/crates/dojo-lang/src/plugin_test_data/introspect +++ b/crates/dojo-lang/src/plugin_test_data/introspect @@ -511,8 +511,7 @@ enum EnumPackableWithInnerPacked { enum EnumNotPackable1 { a: u8, b: u256, -} -impl Vec2Copy of core::traits::Copy::; +}impl Vec2Copy of core::traits::Copy::; impl Vec2Drop of core::traits::Drop::; impl Vec2Serde of core::serde::Serde:: { fn serialize(self: @Vec2, ref output: core::array::Array) { @@ -526,6 +525,52 @@ impl Vec2Serde of core::serde::Serde:: { }) } } + +impl Vec2Introspect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::Some(2) + } + + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Struct( + array![ + dojo::database::introspect::FieldLayout { + selector: 512066735765477566404754172672287371265995314501343422459174036873487219331, + layout: dojo::database::introspect::Introspect::::layout() + }, +dojo::database::introspect::FieldLayout { + selector: 1591024729085637502504777720563487898377940395575083379770417352976841400819, + 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: 'Vec2', + attrs: array![].span(), + children: array![ + dojo::database::introspect::Member { + name: 'x', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'y', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::::ty() + } + + ].span() + } + ) + } +} impl PlainEnumSerde of core::serde::Serde:: { fn serialize(self: @PlainEnum, ref output: core::array::Array) { match self { @@ -546,6 +591,43 @@ impl PlainEnumSerde of core::serde::Serde:: { } impl PlainEnumCopy of core::traits::Copy::; impl PlainEnumDrop of core::traits::Drop::; + +impl PlainEnumIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::Some(1) + } + + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Enum( + array![ + dojo::database::introspect::FieldLayout { + selector: 0, + layout: dojo::database::introspect::Layout::Fixed(array![].span()) + }, +dojo::database::introspect::FieldLayout { + selector: 1, + layout: dojo::database::introspect::Layout::Fixed(array![].span()) + } + ].span() + ) + } + + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Enum( + dojo::database::introspect::Enum { + name: 'PlainEnum', + attrs: array![].span(), + children: array![ + ('Left', dojo::database::introspect::Ty::Tuple(array![].span())), +('Right', dojo::database::introspect::Ty::Tuple(array![].span())) + + ].span() + } + ) + } +} impl EnumWithPrimitiveSerde of core::serde::Serde:: { fn serialize(self: @EnumWithPrimitive, ref output: core::array::Array) { match self { @@ -566,6 +648,43 @@ impl EnumWithPrimitiveSerde of core::serde::Serde:: { } impl EnumWithPrimitiveCopy of core::traits::Copy::; impl EnumWithPrimitiveDrop of core::traits::Drop::; + +impl EnumWithPrimitiveIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::Some(2) + } + + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Enum( + array![ + dojo::database::introspect::FieldLayout { + selector: 0, + layout: dojo::database::introspect::Introspect::::layout() + }, +dojo::database::introspect::FieldLayout { + selector: 1, + layout: dojo::database::introspect::Introspect::::layout() + } + ].span() + ) + } + + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Enum( + dojo::database::introspect::Enum { + name: 'EnumWithPrimitive', + attrs: array![].span(), + children: array![ + ('Left', dojo::database::introspect::Introspect::::ty()), +('Right', dojo::database::introspect::Introspect::::ty()) + + ].span() + } + ) + } +} impl EnumWithStructSerde of core::serde::Serde:: { fn serialize(self: @EnumWithStruct, ref output: core::array::Array) { match self { @@ -586,6 +705,52 @@ impl EnumWithStructSerde of core::serde::Serde:: { } impl EnumWithStructCopy of core::traits::Copy::; impl EnumWithStructDrop of core::traits::Drop::; + +impl EnumWithStructIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + let sizes : Array> = array![ + dojo::database::introspect::Introspect::::size(), +Option::Some(1) + ]; + + if dojo::database::utils::any_none(@sizes) { + return Option::None; + } + Option::Some(dojo::database::utils::sum(sizes)) + + } + + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Enum( + array![ + dojo::database::introspect::FieldLayout { + selector: 0, + layout: dojo::database::introspect::Introspect::::layout() + }, +dojo::database::introspect::FieldLayout { + selector: 1, + layout: dojo::database::introspect::Introspect::::layout() + } + ].span() + ) + } + + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Enum( + dojo::database::introspect::Enum { + name: 'EnumWithStruct', + attrs: array![].span(), + children: array![ + ('Left', dojo::database::introspect::Introspect::::ty()), +('Right', dojo::database::introspect::Introspect::::ty()) + + ].span() + } + ) + } +} impl EnumWithSimpleArraySerde of core::serde::Serde:: { fn serialize(self: @EnumWithSimpleArray, ref output: core::array::Array) { match self { @@ -606,6 +771,51 @@ impl EnumWithSimpleArraySerde of core::serde::Serde:: { } impl EnumWithSimpleArrayCopy of core::traits::Copy::; impl EnumWithSimpleArrayDrop of core::traits::Drop::; + +impl EnumWithSimpleArrayIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::None + } + + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Enum( + array![ + dojo::database::introspect::FieldLayout { + selector: 0, + layout: dojo::database::introspect::Introspect::>::layout() + }, +dojo::database::introspect::FieldLayout { + selector: 1, + layout: dojo::database::introspect::Introspect::>::layout() + } + ].span() + ) + } + + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Enum( + dojo::database::introspect::Enum { + name: 'EnumWithSimpleArray', + attrs: array![].span(), + children: array![ + ('Left', dojo::database::introspect::Ty::Array( + array![ + dojo::database::introspect::Introspect::::ty() + ].span() + )), +('Right', dojo::database::introspect::Ty::Array( + array![ + dojo::database::introspect::Introspect::::ty() + ].span() + )) + + ].span() + } + ) + } +} impl EnumWithByteArraySerde of core::serde::Serde:: { fn serialize(self: @EnumWithByteArray, ref output: core::array::Array) { match self { @@ -626,6 +836,43 @@ impl EnumWithByteArraySerde of core::serde::Serde:: { } impl EnumWithByteArrayCopy of core::traits::Copy::; impl EnumWithByteArrayDrop of core::traits::Drop::; + +impl EnumWithByteArrayIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::None + } + + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Enum( + array![ + dojo::database::introspect::FieldLayout { + selector: 0, + layout: dojo::database::introspect::Introspect::::layout() + }, +dojo::database::introspect::FieldLayout { + selector: 1, + layout: dojo::database::introspect::Introspect::::layout() + } + ].span() + ) + } + + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Enum( + dojo::database::introspect::Enum { + name: 'EnumWithByteArray', + attrs: array![].span(), + children: array![ + ('Left', dojo::database::introspect::Ty::ByteArray), +('Right', dojo::database::introspect::Ty::ByteArray) + + ].span() + } + ) + } +} impl EnumWithSimpleTupleSerde of core::serde::Serde:: { fn serialize(self: @EnumWithSimpleTuple, ref output: core::array::Array) { match self { @@ -646,6 +893,63 @@ impl EnumWithSimpleTupleSerde of core::serde::Serde:: { } impl EnumWithSimpleTupleCopy of core::traits::Copy::; impl EnumWithSimpleTupleDrop of core::traits::Drop::; + +impl EnumWithSimpleTupleIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::Some(4) + } + + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Enum( + array![ + dojo::database::introspect::FieldLayout { + selector: 0, + layout: dojo::database::introspect::Layout::Tuple( + array![ + dojo::database::introspect::Introspect::::layout(), +dojo::database::introspect::Introspect::::layout() + ].span() + ) + }, +dojo::database::introspect::FieldLayout { + selector: 1, + layout: dojo::database::introspect::Layout::Tuple( + array![ + dojo::database::introspect::Introspect::::layout(), +dojo::database::introspect::Introspect::::layout() + ].span() + ) + } + ].span() + ) + } + + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Enum( + dojo::database::introspect::Enum { + name: 'EnumWithSimpleTuple', + attrs: array![].span(), + children: array![ + ('Left', dojo::database::introspect::Ty::Tuple( + array![ + dojo::database::introspect::Introspect::::ty(), +dojo::database::introspect::Introspect::::ty() + ].span() + )), +('Right', dojo::database::introspect::Ty::Tuple( + array![ + dojo::database::introspect::Introspect::::ty(), +dojo::database::introspect::Introspect::::ty() + ].span() + )) + + ].span() + } + ) + } +} impl EnumWithComplexTupleSerde of core::serde::Serde:: { fn serialize(self: @EnumWithComplexTuple, ref output: core::array::Array) { match self { @@ -666,6 +970,72 @@ impl EnumWithComplexTupleSerde of core::serde::Serde:: { } impl EnumWithComplexTupleCopy of core::traits::Copy::; impl EnumWithComplexTupleDrop of core::traits::Drop::; + +impl EnumWithComplexTupleIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + let sizes : Array> = array![ + dojo::database::introspect::Introspect::::size(), +Option::Some(2) + ]; + + if dojo::database::utils::any_none(@sizes) { + return Option::None; + } + Option::Some(dojo::database::utils::sum(sizes)) + + } + + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Enum( + array![ + dojo::database::introspect::FieldLayout { + selector: 0, + layout: dojo::database::introspect::Layout::Tuple( + array![ + dojo::database::introspect::Introspect::::layout(), +dojo::database::introspect::Introspect::::layout() + ].span() + ) + }, +dojo::database::introspect::FieldLayout { + selector: 1, + layout: dojo::database::introspect::Layout::Tuple( + array![ + dojo::database::introspect::Introspect::::layout(), +dojo::database::introspect::Introspect::::layout() + ].span() + ) + } + ].span() + ) + } + + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Enum( + dojo::database::introspect::Enum { + name: 'EnumWithComplexTuple', + attrs: array![].span(), + children: array![ + ('Left', dojo::database::introspect::Ty::Tuple( + array![ + dojo::database::introspect::Introspect::::ty(), +dojo::database::introspect::Introspect::::ty() + ].span() + )), +('Right', dojo::database::introspect::Ty::Tuple( + array![ + dojo::database::introspect::Introspect::::ty(), +dojo::database::introspect::Introspect::::ty() + ].span() + )) + + ].span() + } + ) + } +} impl EnumWithPrimitiveSerde of core::serde::Serde:: { fn serialize(self: @EnumWithPrimitive, ref output: core::array::Array) { match self { @@ -686,6 +1056,43 @@ impl EnumWithPrimitiveSerde of core::serde::Serde:: { } impl EnumWithPrimitiveCopy of core::traits::Copy::; impl EnumWithPrimitiveDrop of core::traits::Drop::; + +impl EnumWithPrimitiveIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::Some(2) + } + + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Enum( + array![ + dojo::database::introspect::FieldLayout { + selector: 0, + layout: dojo::database::introspect::Introspect::::layout() + }, +dojo::database::introspect::FieldLayout { + selector: 1, + layout: dojo::database::introspect::Introspect::::layout() + } + ].span() + ) + } + + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Enum( + dojo::database::introspect::Enum { + name: 'EnumWithPrimitive', + attrs: array![].span(), + children: array![ + ('Left', dojo::database::introspect::Introspect::::ty()), +('Right', dojo::database::introspect::Introspect::::ty()) + + ].span() + } + ) + } +} impl EnumCustomSerde of core::serde::Serde:: { fn serialize(self: @EnumCustom, ref output: core::array::Array) { match self { @@ -706,6 +1113,52 @@ impl EnumCustomSerde of core::serde::Serde:: { } impl EnumCustomCopy of core::traits::Copy::; impl EnumCustomDrop of core::traits::Drop::; + +impl EnumCustomIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + let sizes : Array> = array![ + dojo::database::introspect::Introspect::::size(), +Option::Some(1) + ]; + + if dojo::database::utils::any_none(@sizes) { + return Option::None; + } + Option::Some(dojo::database::utils::sum(sizes)) + + } + + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Enum( + array![ + dojo::database::introspect::FieldLayout { + selector: 0, + layout: dojo::database::introspect::Introspect::::layout() + }, +dojo::database::introspect::FieldLayout { + selector: 1, + layout: dojo::database::introspect::Introspect::::layout() + } + ].span() + ) + } + + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Enum( + dojo::database::introspect::Enum { + name: 'EnumCustom', + attrs: array![].span(), + children: array![ + ('Left', dojo::database::introspect::Introspect::::ty()), +('Right', dojo::database::introspect::Introspect::::ty()) + + ].span() + } + ) + } +} impl EnumTupleMixSerde of core::serde::Serde:: { fn serialize(self: @EnumTupleMix, ref output: core::array::Array) { match self { @@ -726,6 +1179,77 @@ impl EnumTupleMixSerde of core::serde::Serde:: { } impl EnumTupleMixCopy of core::traits::Copy::; impl EnumTupleMixDrop of core::traits::Drop::; + +impl EnumTupleMixIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + let sizes : Array> = array![ + dojo::database::introspect::Introspect::::size(), +dojo::database::introspect::Introspect::::size(), +Option::Some(2) + ]; + + if dojo::database::utils::any_none(@sizes) { + return Option::None; + } + Option::Some(dojo::database::utils::sum(sizes)) + + } + + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Enum( + array![ + dojo::database::introspect::FieldLayout { + selector: 0, + layout: dojo::database::introspect::Layout::Tuple( + array![ + dojo::database::introspect::Introspect::::layout(), +dojo::database::introspect::Introspect::::layout(), +dojo::database::introspect::Introspect::::layout() + ].span() + ) + }, +dojo::database::introspect::FieldLayout { + selector: 1, + layout: dojo::database::introspect::Layout::Tuple( + array![ + dojo::database::introspect::Introspect::::layout(), +dojo::database::introspect::Introspect::::layout(), +dojo::database::introspect::Introspect::::layout() + ].span() + ) + } + ].span() + ) + } + + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Enum( + dojo::database::introspect::Enum { + name: 'EnumTupleMix', + attrs: array![].span(), + children: array![ + ('Left', dojo::database::introspect::Ty::Tuple( + array![ + dojo::database::introspect::Introspect::::ty(), +dojo::database::introspect::Introspect::::ty(), +dojo::database::introspect::Introspect::::ty() + ].span() + )), +('Right', dojo::database::introspect::Ty::Tuple( + array![ + dojo::database::introspect::Introspect::::ty(), +dojo::database::introspect::Introspect::::ty(), +dojo::database::introspect::Introspect::::ty() + ].span() + )) + + ].span() + } + ) + } +} impl EnumWithDifferentVariantDataSerde of core::serde::Serde:: { fn serialize(self: @EnumWithDifferentVariantData, ref output: core::array::Array) { match self { @@ -748,608 +1272,1670 @@ impl EnumWithDifferentVariantDataSerde of core::serde::Serde::; impl EnumWithDifferentVariantDataDrop of core::traits::Drop::; -impl StructWithPrimitivesCopy of core::traits::Copy::; -impl StructWithPrimitivesDrop of core::traits::Drop::; -impl StructWithStructCopy of core::traits::Copy::; -impl StructWithStructDrop of core::traits::Drop::; -impl StructWithSimpleArrayCopy of core::traits::Copy::; -impl StructWithSimpleArrayDrop of core::traits::Drop::; -impl StructWithByteArrayCopy of core::traits::Copy::; -impl StructWithByteArrayDrop of core::traits::Drop::; -impl StructWithComplexArrayCopy of core::traits::Copy::; -impl StructWithComplexArrayDrop of core::traits::Drop::; -impl StructWithSimpleTupleCopy of core::traits::Copy::; -impl StructWithSimpleTupleDrop of core::traits::Drop::; -impl StructWithComplexTupleCopy of core::traits::Copy::; -impl StructWithComplexTupleDrop of core::traits::Drop::; -impl StructWithNestedArraysCopy of core::traits::Copy::; -impl StructWithNestedArraysDrop of core::traits::Drop::; -impl StructWithNestedTuplesCopy of core::traits::Copy::; -impl StructWithNestedTuplesDrop of core::traits::Drop::; -impl StructWithNestedTuplesAndByteArrayCopy of core::traits::Copy::; -impl StructWithNestedTuplesAndByteArrayDrop of core::traits::Drop::; -impl StructWithNestedEverythingCopy of core::traits::Copy::; -impl StructWithNestedEverythingDrop of core::traits::Drop::; -impl GenericStructCopy> of core::traits::Copy::>; -impl GenericStructDrop> of core::traits::Drop::>; -impl GenericStructSerde, +core::traits::Destruct> of core::serde::Serde::> { - fn serialize(self: @GenericStruct, ref output: core::array::Array) { - core::serde::Serde::serialize(self.t, ref output) + +impl EnumWithDifferentVariantDataIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::None } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option> { - core::option::Option::Some(GenericStruct { - t: core::serde::Serde::deserialize(ref serialized)?, - }) + + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Enum( + array![ + dojo::database::introspect::FieldLayout { + selector: 0, + layout: dojo::database::introspect::Layout::Fixed(array![].span()) + }, +dojo::database::introspect::FieldLayout { + selector: 1, + layout: dojo::database::introspect::Introspect::::layout() + }, +dojo::database::introspect::FieldLayout { + selector: 2, + layout: dojo::database::introspect::Layout::Tuple( + array![ + dojo::database::introspect::Introspect::::layout(), +dojo::database::introspect::Introspect::::layout() + ].span() + ) + } + ].span() + ) + } + + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Enum( + dojo::database::introspect::Enum { + name: 'EnumWithDifferentVariantData', + attrs: array![].span(), + children: array![ + ('One', dojo::database::introspect::Ty::Tuple(array![].span())), +('Two', dojo::database::introspect::Introspect::::ty()), +('Three', dojo::database::introspect::Ty::Tuple( + array![ + dojo::database::introspect::Introspect::::ty(), +dojo::database::introspect::Introspect::::ty() + ].span() + )) + + ].span() + } + ) } } -impl StructWithBadOptionCopy of core::traits::Copy::; -impl StructWithBadOptionDrop of core::traits::Drop::; -impl StructWithBadOptionSerde of core::serde::Serde:: { - fn serialize(self: @StructWithBadOption, ref output: core::array::Array) { - core::serde::Serde::serialize(self.x, ref output) +impl StructWithPrimitivesCopy of core::traits::Copy::; +impl StructWithPrimitivesDrop of core::traits::Drop::; + +impl StructWithPrimitivesIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::Some(2) } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(StructWithBadOption { - x: core::serde::Serde::deserialize(ref serialized)?, - }) + + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Struct( + array![ + dojo::database::introspect::FieldLayout { + selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, + layout: dojo::database::introspect::Introspect::::layout() + }, +dojo::database::introspect::FieldLayout { + selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, + layout: dojo::database::introspect::Introspect::::layout() + } + ].span() + ) } -} -impl EnumWithBadOptionCopy of core::traits::Copy::; -impl EnumWithBadOptionDrop of core::traits::Drop::; -impl EnumWithBadOptionSerde of core::serde::Serde:: { - fn serialize(self: @EnumWithBadOption, ref output: core::array::Array) { - match self { - EnumWithBadOption::first(x) => { core::serde::Serde::serialize(@0, ref output); core::serde::Serde::serialize(x, ref output); }, + + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Struct( + dojo::database::introspect::Struct { + name: 'StructWithPrimitives', + attrs: array![].span(), + children: array![ + dojo::database::introspect::Member { + name: 'player', + attrs: array!['key'].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'before', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'after', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::::ty() } - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - let idx: felt252 = core::serde::Serde::deserialize(ref serialized)?; - core::option::Option::Some( - match idx { - 0 => EnumWithBadOption::first(core::serde::Serde::deserialize(ref serialized)?), - _ => { return core::option::Option::None; } + + ].span() } ) } } +impl StructWithStructCopy of core::traits::Copy::; +impl StructWithStructDrop of core::traits::Drop::; -//! > expected_diagnostics -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:1:1 -use core::serde::Serde; -^*********************^ +impl StructWithStructIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + let sizes : Array> = array![ + dojo::database::introspect::Introspect::::size(), +Option::Some(1) + ]; + + if dojo::database::utils::any_none(@sizes) { + return Option::None; + } + Option::Some(dojo::database::utils::sum(sizes)) + + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:3:1 -#[derive(Copy, Drop, Serde, Introspect)] -^**************************************^ + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Struct( + array![ + dojo::database::introspect::FieldLayout { + selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, + layout: dojo::database::introspect::Introspect::::layout() + }, +dojo::database::introspect::FieldLayout { + selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, + layout: dojo::database::introspect::Introspect::::layout() + } + ].span() + ) + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:9:1 -#[derive(Serde, Copy, Drop, Introspect)] -^**************************************^ + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Struct( + dojo::database::introspect::Struct { + name: 'StructWithStruct', + attrs: array![].span(), + children: array![ + dojo::database::introspect::Member { + name: 'player', + attrs: array!['key'].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'before', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'after', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::::ty() + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:15:1 -#[derive(Serde, Copy, Drop, Introspect)] -^**************************************^ + ].span() + } + ) + } +} +impl StructWithSimpleArrayCopy of core::traits::Copy::; +impl StructWithSimpleArrayDrop of core::traits::Drop::; -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:21:1 -#[derive(Serde, Copy, Drop, Introspect)] -^**************************************^ +impl StructWithSimpleArrayIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::None + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:27:1 -#[derive(Serde, Copy, Drop, Introspect)] -^**************************************^ + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Struct( + array![ + dojo::database::introspect::FieldLayout { + selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, + layout: dojo::database::introspect::Introspect::::layout() + }, +dojo::database::introspect::FieldLayout { + selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, + layout: dojo::database::introspect::Introspect::>::layout() + } + ].span() + ) + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:33:1 -#[derive(Serde, Copy, Drop, Introspect)] -^**************************************^ + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Struct( + dojo::database::introspect::Struct { + name: 'StructWithSimpleArray', + attrs: array![].span(), + children: array![ + dojo::database::introspect::Member { + name: 'player', + attrs: array!['key'].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'before', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'after', + attrs: array![].span(), + ty: dojo::database::introspect::Ty::Array( + array![ + dojo::database::introspect::Introspect::::ty() + ].span() + ) + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:39:1 -#[derive(Serde, Copy, Drop, Introspect)] -^**************************************^ + ].span() + } + ) + } +} +impl StructWithByteArrayCopy of core::traits::Copy::; +impl StructWithByteArrayDrop of core::traits::Drop::; -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:45:1 -#[derive(Serde, Copy, Drop, Introspect)] -^**************************************^ +impl StructWithByteArrayIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::None + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:51:1 -#[derive(Serde, Copy, Drop, Introspect)] -^**************************************^ + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Struct( + array![ + dojo::database::introspect::FieldLayout { + selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, + layout: dojo::database::introspect::Introspect::::layout() + }, +dojo::database::introspect::FieldLayout { + selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, + layout: dojo::database::introspect::Introspect::::layout() + } + ].span() + ) + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:57:1 -#[derive(Serde, Copy, Drop, Introspect)] -^**************************************^ + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Struct( + dojo::database::introspect::Struct { + name: 'StructWithByteArray', + attrs: array![].span(), + children: array![ + dojo::database::introspect::Member { + name: 'player', + attrs: array!['key'].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'before', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'after', + attrs: array![].span(), + ty: dojo::database::introspect::Ty::ByteArray + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:63:1 -#[derive(Serde, Copy, Drop, Introspect)] -^**************************************^ + ].span() + } + ) + } +} +impl StructWithComplexArrayCopy of core::traits::Copy::; +impl StructWithComplexArrayDrop of core::traits::Drop::; -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:69:1 -#[derive(Serde, Copy, Drop, Introspect)] -^**************************************^ +impl StructWithComplexArrayIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::None + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:76:1 -#[derive(Copy, Drop, Introspect)] -^*******************************^ + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Struct( + array![ + dojo::database::introspect::FieldLayout { + selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, + layout: dojo::database::introspect::Introspect::::layout() + }, +dojo::database::introspect::FieldLayout { + selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, + layout: dojo::database::introspect::Introspect::>::layout() + } + ].span() + ) + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:84:1 -#[derive(Copy, Drop, Introspect)] -^*******************************^ + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Struct( + dojo::database::introspect::Struct { + name: 'StructWithComplexArray', + attrs: array![].span(), + children: array![ + dojo::database::introspect::Member { + name: 'player', + attrs: array!['key'].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'before', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'after', + attrs: array![].span(), + ty: dojo::database::introspect::Ty::Array( + array![ + dojo::database::introspect::Introspect::::ty() + ].span() + ) + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:92:1 -#[derive(Copy, Drop, Introspect)] -^*******************************^ + ].span() + } + ) + } +} +impl StructWithSimpleTupleCopy of core::traits::Copy::; +impl StructWithSimpleTupleDrop of core::traits::Drop::; -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:100:1 -#[derive(Copy, Drop, Introspect)] -^*******************************^ +impl StructWithSimpleTupleIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::Some(4) + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:108:1 -#[derive(Copy, Drop, Introspect)] -^*******************************^ + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Struct( + array![ + dojo::database::introspect::FieldLayout { + selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, + layout: dojo::database::introspect::Introspect::::layout() + }, +dojo::database::introspect::FieldLayout { + selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, + layout: dojo::database::introspect::Layout::Tuple( + array![ + dojo::database::introspect::Introspect::::layout(), +dojo::database::introspect::Introspect::::layout() + ].span() + ) + } + ].span() + ) + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:116:1 -#[derive(Copy, Drop, Introspect)] -^*******************************^ + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Struct( + dojo::database::introspect::Struct { + name: 'StructWithSimpleTuple', + attrs: array![].span(), + children: array![ + dojo::database::introspect::Member { + name: 'player', + attrs: array!['key'].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'before', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'after', + attrs: array![].span(), + ty: dojo::database::introspect::Ty::Tuple( + array![ + dojo::database::introspect::Introspect::::ty(), +dojo::database::introspect::Introspect::::ty() + ].span() + ) + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:124:1 -#[derive(Copy, Drop, Introspect)] -^*******************************^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:132:1 -#[derive(Copy, Drop, Introspect)] -^*******************************^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:140:1 -#[derive(Copy, Drop, Introspect)] -^*******************************^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:148:1 -#[derive(Copy, Drop, Introspect)] -^*******************************^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:156:1 -#[derive(Copy, Drop, Introspect)] -^*******************************^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:164:1 -#[derive(Copy, Drop, Serde, Introspect)] -^**************************************^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:169:1 -#[derive(Copy, Drop, Serde, Introspect)] -^**************************************^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:174:1 -#[derive(Copy, Drop, Serde, Introspect)] -^**************************************^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:179:1 -#[derive(Introspect, IntrospectPacked)] -^*************************************^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:182:1 -#[derive(Introspect, IntrospectPacked)] -^*************************************^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:185:1 -#[derive(Introspect)] -^*******************^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:189:1 -#[derive(Introspect)] -^*******************^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:193:1 -#[derive(IntrospectPacked)] -^*************************^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:198:1 -#[derive(IntrospectPacked)] -^*************************^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:204:1 -#[derive(IntrospectPacked)] -^*************************^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:210:1 -#[derive(IntrospectPacked)] -^*************************^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:216:1 -#[derive(IntrospectPacked)] -^*************************^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:222:1 -#[derive(IntrospectPacked)] -^*************************^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:229:1 -#[derive(IntrospectPacked)] -^*************************^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:236:1 -#[derive(IntrospectPacked)] -^*************************^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:243:1 -#[derive(IntrospectPacked)] -^*************************^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:249:1 -#[derive(IntrospectPacked)] -^*************************^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:2:1 - -^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:2:1 - -^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:2:1 - -^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:8:1 - -^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:8:1 - -^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:8:1 - -^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:14:1 - -^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:14:1 - -^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:14:1 - -^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:20:1 - -^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:20:1 - -^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:20:1 - -^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:26:1 - -^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:26:1 - -^ + ].span() + } + ) + } +} +impl StructWithComplexTupleCopy of core::traits::Copy::; +impl StructWithComplexTupleDrop of core::traits::Drop::; -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:26:1 +impl StructWithComplexTupleIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + let sizes : Array> = array![ + dojo::database::introspect::Introspect::::size(), +dojo::database::introspect::Introspect::::size(), +Option::Some(2) + ]; + + if dojo::database::utils::any_none(@sizes) { + return Option::None; + } + Option::Some(dojo::database::utils::sum(sizes)) + + } -^ + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Struct( + array![ + dojo::database::introspect::FieldLayout { + selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, + layout: dojo::database::introspect::Introspect::::layout() + }, +dojo::database::introspect::FieldLayout { + selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, + layout: dojo::database::introspect::Layout::Tuple( + array![ + dojo::database::introspect::Introspect::::layout(), +dojo::database::introspect::Introspect::::layout(), +dojo::database::introspect::Introspect::::layout() + ].span() + ) + } + ].span() + ) + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:32:1 + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Struct( + dojo::database::introspect::Struct { + name: 'StructWithComplexTuple', + attrs: array![].span(), + children: array![ + dojo::database::introspect::Member { + name: 'player', + attrs: array!['key'].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'before', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'after', + attrs: array![].span(), + ty: dojo::database::introspect::Ty::Tuple( + array![ + dojo::database::introspect::Introspect::::ty(), +dojo::database::introspect::Introspect::::ty(), +dojo::database::introspect::Introspect::::ty() + ].span() + ) + } -^ + ].span() + } + ) + } +} +impl StructWithNestedArraysCopy of core::traits::Copy::; +impl StructWithNestedArraysDrop of core::traits::Drop::; -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:32:1 +impl StructWithNestedArraysIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::None + } -^ + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Struct( + array![ + dojo::database::introspect::FieldLayout { + selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, + layout: dojo::database::introspect::Introspect::::layout() + }, +dojo::database::introspect::FieldLayout { + selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, + layout: dojo::database::introspect::Layout::Array( + array![ + dojo::database::introspect::Layout::Array( + array![ + dojo::database::introspect::Introspect::>::layout() + ].span() + ) + ].span() + ) + } + ].span() + ) + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:32:1 + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Struct( + dojo::database::introspect::Struct { + name: 'StructWithNestedArrays', + attrs: array![].span(), + children: array![ + dojo::database::introspect::Member { + name: 'player', + attrs: array!['key'].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'before', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'after', + attrs: array![].span(), + ty: dojo::database::introspect::Ty::Array( + array![ + dojo::database::introspect::Ty::Array( + array![ + dojo::database::introspect::Ty::Array( + array![ + dojo::database::introspect::Introspect::::ty() + ].span() + ) + ].span() + ) + ].span() + ) + } -^ + ].span() + } + ) + } +} +impl StructWithNestedTuplesCopy of core::traits::Copy::; +impl StructWithNestedTuplesDrop of core::traits::Drop::; -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:38:1 +impl StructWithNestedTuplesIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + let sizes : Array> = array![ + dojo::database::introspect::Introspect::::size(), +dojo::database::introspect::Introspect::::size(), +Option::Some(3) + ]; + + if dojo::database::utils::any_none(@sizes) { + return Option::None; + } + Option::Some(dojo::database::utils::sum(sizes)) + + } -^ + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Struct( + array![ + dojo::database::introspect::FieldLayout { + selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, + layout: dojo::database::introspect::Introspect::::layout() + }, +dojo::database::introspect::FieldLayout { + selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, + layout: dojo::database::introspect::Layout::Tuple( + array![ + dojo::database::introspect::Layout::Tuple( + array![ + dojo::database::introspect::Introspect::::layout(), +dojo::database::introspect::Introspect::::layout() + ].span() + ), +dojo::database::introspect::Layout::Tuple( + array![ + dojo::database::introspect::Introspect::::layout(), +dojo::database::introspect::Introspect::::layout() + ].span() + ) + ].span() + ) + } + ].span() + ) + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:38:1 + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Struct( + dojo::database::introspect::Struct { + name: 'StructWithNestedTuples', + attrs: array![].span(), + children: array![ + dojo::database::introspect::Member { + name: 'player', + attrs: array!['key'].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'before', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'after', + attrs: array![].span(), + ty: dojo::database::introspect::Ty::Tuple( + array![ + dojo::database::introspect::Ty::Tuple( + array![ + dojo::database::introspect::Introspect::::ty(), +dojo::database::introspect::Introspect::::ty() + ].span() + ), +dojo::database::introspect::Ty::Tuple( + array![ + dojo::database::introspect::Introspect::::ty(), +dojo::database::introspect::Introspect::::ty() + ].span() + ) + ].span() + ) + } -^ + ].span() + } + ) + } +} +impl StructWithNestedTuplesAndByteArrayCopy of core::traits::Copy::; +impl StructWithNestedTuplesAndByteArrayDrop of core::traits::Drop::; -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:38:1 +impl StructWithNestedTuplesAndByteArrayIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::None + } -^ + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Struct( + array![ + dojo::database::introspect::FieldLayout { + selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, + layout: dojo::database::introspect::Introspect::::layout() + }, +dojo::database::introspect::FieldLayout { + selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, + layout: dojo::database::introspect::Layout::Tuple( + array![ + dojo::database::introspect::Layout::Tuple( + array![ + dojo::database::introspect::Introspect::::layout(), +dojo::database::introspect::Introspect::::layout() + ].span() + ), +dojo::database::introspect::Layout::Tuple( + array![ + dojo::database::introspect::Introspect::::layout(), +dojo::database::introspect::Introspect::::layout() + ].span() + ) + ].span() + ) + } + ].span() + ) + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:44:1 + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Struct( + dojo::database::introspect::Struct { + name: 'StructWithNestedTuplesAndByteArray', + attrs: array![].span(), + children: array![ + dojo::database::introspect::Member { + name: 'player', + attrs: array!['key'].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'before', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'after', + attrs: array![].span(), + ty: dojo::database::introspect::Ty::Tuple( + array![ + dojo::database::introspect::Ty::Tuple( + array![ + dojo::database::introspect::Introspect::::ty(), +dojo::database::introspect::Introspect::::ty() + ].span() + ), +dojo::database::introspect::Ty::Tuple( + array![ + dojo::database::introspect::Introspect::::ty(), +dojo::database::introspect::Ty::ByteArray + ].span() + ) + ].span() + ) + } -^ + ].span() + } + ) + } +} +impl StructWithNestedEverythingCopy of core::traits::Copy::; +impl StructWithNestedEverythingDrop of core::traits::Drop::; -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:44:1 +impl StructWithNestedEverythingIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::None + } -^ + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Struct( + array![ + dojo::database::introspect::FieldLayout { + selector: 387461982739864353524563589639770327077359184971688375275386807599796929637, + layout: dojo::database::introspect::Introspect::::layout() + }, +dojo::database::introspect::FieldLayout { + selector: 564613130574576288414461160574656432422962213642984413874723251824844509768, + layout: dojo::database::introspect::Layout::Tuple( + array![ + dojo::database::introspect::Layout::Tuple( + array![ + dojo::database::introspect::Introspect::::layout(), +dojo::database::introspect::Introspect::::layout() + ].span() + ), +dojo::database::introspect::Layout::Tuple( + array![ + dojo::database::introspect::Introspect::::layout(), +dojo::database::introspect::Introspect::::layout() + ].span() + ), +dojo::database::introspect::Layout::Tuple( + array![ + dojo::database::introspect::Layout::Array( + array![ + dojo::database::introspect::Layout::Tuple( + array![ + dojo::database::introspect::Introspect::::layout(), +dojo::database::introspect::Introspect::::layout() + ].span() + ) + ].span() + ), +dojo::database::introspect::Introspect::::layout() + ].span() + ), +dojo::database::introspect::Layout::Tuple( + array![ + dojo::database::introspect::Introspect::::layout() + ].span() + ) + ].span() + ) + } + ].span() + ) + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:44:1 + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Struct( + dojo::database::introspect::Struct { + name: 'StructWithNestedEverything', + attrs: array![].span(), + children: array![ + dojo::database::introspect::Member { + name: 'player', + attrs: array!['key'].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'before', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'after', + attrs: array![].span(), + ty: dojo::database::introspect::Ty::Tuple( + array![ + dojo::database::introspect::Ty::Tuple( + array![ + dojo::database::introspect::Introspect::::ty(), +dojo::database::introspect::Introspect::::ty() + ].span() + ), +dojo::database::introspect::Ty::Tuple( + array![ + dojo::database::introspect::Introspect::::ty(), +dojo::database::introspect::Introspect::::ty() + ].span() + ), +dojo::database::introspect::Ty::Tuple( + array![ + dojo::database::introspect::Ty::Array( + array![ + dojo::database::introspect::Ty::Tuple( + array![ + dojo::database::introspect::Introspect::::ty(), +dojo::database::introspect::Introspect::::ty() + ].span() + ) + ].span() + ), +dojo::database::introspect::Introspect::::ty() + ].span() + ), +dojo::database::introspect::Ty::Tuple( + array![ + dojo::database::introspect::Introspect::::ty() + ].span() + ) + ].span() + ) + } -^ + ].span() + } + ) + } +} +impl GenericStructCopy> of core::traits::Copy::>; +impl GenericStructDrop> of core::traits::Drop::>; +impl GenericStructSerde, +core::traits::Destruct> of core::serde::Serde::> { + fn serialize(self: @GenericStruct, ref output: core::array::Array) { + core::serde::Serde::serialize(self.t, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option> { + core::option::Option::Some(GenericStruct { + t: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:50:1 +impl GenericStructIntrospect> 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: 1246920879054256875300693562709339669009726288543267794550465531256469553289, + layout: dojo::database::introspect::Introspect::::layout() + } + ].span() + ) + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:50:1 + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Struct( + dojo::database::introspect::Struct { + name: 'GenericStruct', + attrs: array![].span(), + children: array![ + dojo::database::introspect::Member { + name: 't', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::::ty() + } -^ + ].span() + } + ) + } +} +impl StructWithBadOptionCopy of core::traits::Copy::; +impl StructWithBadOptionDrop of core::traits::Drop::; +impl StructWithBadOptionSerde of core::serde::Serde:: { + fn serialize(self: @StructWithBadOption, ref output: core::array::Array) { + core::serde::Serde::serialize(self.x, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(StructWithBadOption { + x: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:50:1 +impl StructWithBadOptionIntrospect<> 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: 512066735765477566404754172672287371265995314501343422459174036873487219331, + layout: dojo::database::introspect::Introspect:: +>::layout() + } + ].span() + ) + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:56:1 + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Struct( + dojo::database::introspect::Struct { + name: 'StructWithBadOption', + attrs: array![].span(), + children: array![ + dojo::database::introspect::Member { + name: 'x', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::>::ty() + } -^ + ].span() + } + ) + } +} +impl EnumWithBadOptionCopy of core::traits::Copy::; +impl EnumWithBadOptionDrop of core::traits::Drop::; +impl EnumWithBadOptionSerde of core::serde::Serde:: { + fn serialize(self: @EnumWithBadOption, ref output: core::array::Array) { + match self { + EnumWithBadOption::first(x) => { core::serde::Serde::serialize(@0, ref output); core::serde::Serde::serialize(x, ref output); }, + } + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + let idx: felt252 = core::serde::Serde::deserialize(ref serialized)?; + core::option::Option::Some( + match idx { + 0 => EnumWithBadOption::first(core::serde::Serde::deserialize(ref serialized)?), + _ => { return core::option::Option::None; } + } + ) + } +} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:56:1 +impl EnumWithBadOptionIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + let sizes : Array> = array![ + dojo::database::introspect::Introspect::>::size(), +Option::Some(1) + ]; -^ + if dojo::database::utils::any_none(@sizes) { + return Option::None; + } + Option::Some(dojo::database::utils::sum(sizes)) + + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:56:1 + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Enum( + array![ + dojo::database::introspect::FieldLayout { + selector: 0, + layout: dojo::database::introspect::Introspect::>::layout() + } + ].span() + ) + } -^ + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Enum( + dojo::database::introspect::Enum { + name: 'EnumWithBadOption', + attrs: array![].span(), + children: array![ + ('first', dojo::database::introspect::Introspect::>::ty()) -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:62:1 + ].span() + } + ) + } +} -^ +impl EnumIncompatibleAttrsIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::None + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:62:1 + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Enum( + array![ + + ].span() + ) + } -^ + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Enum( + dojo::database::introspect::Enum { + name: 'EnumIncompatibleAttrs', + attrs: array![].span(), + children: array![ + -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:62:1 + ].span() + } + ) + } +} + +impl EnumIncompatibleAttrsIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::None + } -^ + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Fixed( + array![ + 8 + ].span() + ) + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:68:1 + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Enum( + dojo::database::introspect::Enum { + name: 'EnumIncompatibleAttrs', + attrs: array![].span(), + children: array![ + -^ + ].span() + } + ) + } +} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:68:1 +impl StructIncompatibleAttrsIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::None + } -^ + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Struct( + array![ + + ].span() + ) + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:68:1 + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Struct( + dojo::database::introspect::Struct { + name: 'StructIncompatibleAttrs', + attrs: array![].span(), + children: array![ + -^ + ].span() + } + ) + } +} + +impl StructIncompatibleAttrsIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::None + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:75:1 + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Fixed( + array![ + + ].span() + ) + } -^ + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Struct( + dojo::database::introspect::Struct { + name: 'StructIncompatibleAttrs', + attrs: array![].span(), + children: array![ + -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:75:1 + ].span() + } + ) + } +} -^ +impl StructIncompatibleAttrs2Introspect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::None + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:83:1 + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Struct( + array![ + + ].span() + ) + } -^ + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Struct( + dojo::database::introspect::Struct { + name: 'StructIncompatibleAttrs2', + attrs: array![].span(), + children: array![ + -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:83:1 + ].span() + } + ) + } +} + +impl StructIncompatibleAttrs2Introspect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::None + } -^ + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Fixed( + array![ + + ].span() + ) + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:91:1 + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Struct( + dojo::database::introspect::Struct { + name: 'StructIncompatibleAttrs2', + attrs: array![].span(), + children: array![ + -^ + ].span() + } + ) + } +} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:91:1 +impl EnumIncompatibleAttrs2Introspect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::None + } -^ + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Enum( + array![ + + ].span() + ) + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:99:1 + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Enum( + dojo::database::introspect::Enum { + name: 'EnumIncompatibleAttrs2', + attrs: array![].span(), + children: array![ + -^ + ].span() + } + ) + } +} + +impl EnumIncompatibleAttrs2Introspect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::None + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:99:1 + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Fixed( + array![ + 8 + ].span() + ) + } -^ + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Enum( + dojo::database::introspect::Enum { + name: 'EnumIncompatibleAttrs2', + attrs: array![].span(), + children: array![ + -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:107:1 + ].span() + } + ) + } +} -^ +impl StructPacked1Introspect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::Some(1) + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:107:1 + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Fixed( + array![ + 8 + ].span() + ) + } -^ + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Struct( + dojo::database::introspect::Struct { + name: 'StructPacked1', + attrs: array![].span(), + children: array![ + dojo::database::introspect::Member { + name: 'x', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::::ty() + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:115:1 + ].span() + } + ) + } +} -^ +impl StructPacked2Introspect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::Some(3) + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:115:1 + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Fixed( + array![ + 8,128,128 + ].span() + ) + } -^ + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Struct( + dojo::database::introspect::Struct { + name: 'StructPacked2', + attrs: array![].span(), + children: array![ + dojo::database::introspect::Member { + name: 'x', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'y', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::::ty() + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:123:1 + ].span() + } + ) + } +} -^ +impl StructPacked3Introspect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::Some(4) + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:123:1 + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Fixed( + array![ + 128,128,8,32 + ].span() + ) + } -^ + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Struct( + dojo::database::introspect::Struct { + name: 'StructPacked3', + attrs: array![].span(), + children: array![ + dojo::database::introspect::Member { + name: 'x', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'y', + attrs: array![].span(), + ty: dojo::database::introspect::Ty::Tuple( + array![ + dojo::database::introspect::Introspect::::ty(), +dojo::database::introspect::Introspect::::ty() + ].span() + ) + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:131:1 + ].span() + } + ) + } +} -^ +impl StructNotPackable1Introspect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::None + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:131:1 + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Fixed( + array![ + 8,ERROR + ].span() + ) + } -^ + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Struct( + dojo::database::introspect::Struct { + name: 'StructNotPackable1', + attrs: array![].span(), + children: array![ + dojo::database::introspect::Member { + name: 'x', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'y', + attrs: array![].span(), + ty: dojo::database::introspect::Ty::Array( + array![ + dojo::database::introspect::Introspect::::ty() + ].span() + ) + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:139:1 + ].span() + } + ) + } +} -^ +impl StructPackableWithInnerPackedIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + let sizes : Array> = array![ + dojo::database::introspect::Introspect::::size(), +Option::Some(1) + ]; -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:139:1 + + Option::Some(dojo::database::utils::sum(sizes)) + + } -^ + fn layout() -> dojo::database::introspect::Layout { + let mut layouts = array![ + dojo::database::introspect::Layout::Fixed(array![8].span()), +dojo::database::introspect::Introspect::::layout() + ]; + let mut merged_layout = ArrayTrait::::new(); + + loop { + match ArrayTrait::pop_front(ref layouts) { + Option::Some(mut layout) => { + match layout { + dojo::database::introspect::Layout::Fixed(mut l) => { + loop { + match SpanTrait::pop_front(ref l) { + Option::Some(x) => merged_layout.append(*x), + Option::None(_) => { break; } + }; + }; + }, + _ => panic!("A packed model layout must contain Fixed layouts only."), + }; + }, + Option::None(_) => { break; } + }; + }; + + dojo::database::introspect::Layout::Fixed(merged_layout.span()) + + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:147:1 + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Struct( + dojo::database::introspect::Struct { + name: 'StructPackableWithInnerPacked', + attrs: array![].span(), + children: array![ + dojo::database::introspect::Member { + name: 'x', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'y', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::::ty() + } -^ + ].span() + } + ) + } +} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:147:1 +impl EnumPacked1Introspect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::Some(1) + } -^ + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Fixed( + array![ + 8 + ].span() + ) + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:155:1 + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Enum( + dojo::database::introspect::Enum { + name: 'EnumPacked1', + attrs: array![].span(), + children: array![ + ('a', dojo::database::introspect::Ty::Tuple(array![].span())), +('b', dojo::database::introspect::Ty::Tuple(array![].span())), +('c', dojo::database::introspect::Ty::Tuple(array![].span())) + + ].span() + } + ) + } +} -^ +impl EnumPacked2Introspect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::Some(2) + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:155:1 + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Fixed( + array![ + 8,8 + ].span() + ) + } -^ + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Enum( + dojo::database::introspect::Enum { + name: 'EnumPacked2', + attrs: array![].span(), + children: array![ + ('a', dojo::database::introspect::Introspect::::ty()), +('b', dojo::database::introspect::Introspect::::ty()), +('c', dojo::database::introspect::Introspect::::ty()) + + ].span() + } + ) + } +} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:163:1 +impl EnumPacked3Introspect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::Some(3) + } -^ + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Fixed( + array![ + 8,128,128 + ].span() + ) + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:163:1 + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Enum( + dojo::database::introspect::Enum { + name: 'EnumPacked3', + attrs: array![].span(), + children: array![ + ('a', dojo::database::introspect::Ty::Tuple( + array![ + dojo::database::introspect::Introspect::::ty(), +dojo::database::introspect::Introspect::::ty() + ].span() + )), +('b', dojo::database::introspect::Introspect::::ty()) + + ].span() + } + ) + } +} -^ +impl EnumPackableWithInnerPackedIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + let sizes : Array> = array![ + dojo::database::introspect::Introspect::::size(), +Option::Some(1) + ]; -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:163:1 + + Option::Some(dojo::database::utils::sum(sizes)) + + } -^ + fn layout() -> dojo::database::introspect::Layout { + let mut layouts = array![ + dojo::database::introspect::Layout::Fixed(array![8].span()), +dojo::database::introspect::Introspect::::layout() + ]; + let mut merged_layout = ArrayTrait::::new(); + + loop { + match ArrayTrait::pop_front(ref layouts) { + Option::Some(mut layout) => { + match layout { + dojo::database::introspect::Layout::Fixed(mut l) => { + loop { + match SpanTrait::pop_front(ref l) { + Option::Some(x) => merged_layout.append(*x), + Option::None(_) => { break; } + }; + }; + }, + _ => panic!("A packed model layout must contain Fixed layouts only."), + }; + }, + Option::None(_) => { break; } + }; + }; + + dojo::database::introspect::Layout::Fixed(merged_layout.span()) + + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:168:1 + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Enum( + dojo::database::introspect::Enum { + name: 'EnumPackableWithInnerPacked', + attrs: array![].span(), + children: array![ + ('a', dojo::database::introspect::Introspect::::ty()), +('b', dojo::database::introspect::Introspect::::ty()) + + ].span() + } + ) + } +} -^ +impl EnumNotPackable1Introspect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::None + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:168:1 + fn layout() -> dojo::database::introspect::Layout { + ERROR + } -^ + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Enum( + dojo::database::introspect::Enum { + name: 'EnumNotPackable1', + attrs: array![].span(), + children: array![ + ('a', dojo::database::introspect::Introspect::::ty()), +('b', dojo::database::introspect::Introspect::::ty()) + + ].span() + } + ) + } +} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:168:1 +//! > expected_diagnostics +error: Option cannot be used with tuples. Prefer using a struct. + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp7Umie1/src/lib.cairo:171:6 + x: Option<(u8, u16)> + ^*****************^ -^ +error: Option cannot be used with tuples. Prefer using a struct. + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp7Umie1/src/lib.cairo:176:10 + first: Option<(u8, u16)>, + ^*****************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:173:1 +error: Introspect and IntrospectPacked attributes cannot be used at a same time. + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp7Umie1/src/lib.cairo:180:6 +enum EnumIncompatibleAttrs {} + ^*******************^ -^ +error: Introspect and IntrospectPacked attributes cannot be used at a same time. + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp7Umie1/src/lib.cairo:183:8 +struct StructIncompatibleAttrs {} + ^*********************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:173:1 +error: Introspect and IntrospectPacked attributes cannot be used at a same time. + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp7Umie1/src/lib.cairo:187:8 +struct StructIncompatibleAttrs2 {} + ^**********************^ -^ +error: Introspect and IntrospectPacked attributes cannot be used at a same time. + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp7Umie1/src/lib.cairo:191:6 +enum EnumIncompatibleAttrs2 {} + ^********************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:173:1 +error: Array field cannot be packed. + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp7Umie1/src/lib.cairo:213:6 + y: Array + ^**********^ -^ +error: To be packed, all variants must have fixed layout of same size. + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp7Umie1/src/lib.cairo:250:6 +enum EnumNotPackable1 { + ^**************^ diff --git a/crates/dojo-lang/src/plugin_test_data/model b/crates/dojo-lang/src/plugin_test_data/model index 27ccf7e648..f2630da9cb 100644 --- a/crates/dojo-lang/src/plugin_test_data/model +++ b/crates/dojo-lang/src/plugin_test_data/model @@ -312,114 +312,16817 @@ struct ModelWithTupleNoPrimitives { x: u16, y: (u8, Vec3, u32) } +impl BadModelMultipleAttrIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + dojo::database::introspect::Introspect::::size() + } -//! > expected_diagnostics -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:1:1 -#[dojo::model(version: 0)] -^************************^ + 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: 'BadModelMultipleAttr', + 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 BadModelMultipleVersionsIntrospect<> 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: 'BadModelMultipleVersions', + 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 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, + 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 `BadModelMultipleVersions`: 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 { + "BadModelMultipleVersions" + } + + #[inline(always)] + fn namespace() -> ByteArray { + "test_package" + } + + #[inline(always)] + fn tag() -> ByteArray { + "test_package-BadModelMultipleVersions" + } + + #[inline(always)] + fn version() -> u8 { + 0 + } + + #[inline(always)] + fn selector() -> felt252 { + "BadModelMultipleVersions" + } + + #[inline(always)] + fn instance_selector(self: @BadModelMultipleVersions) -> felt252 { + Self::selector() + } + + #[inline(always)] + fn name_hash() -> felt252 { + 3538888628466873673221842373412072042558277047191927145880480325050722136660 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 3061092720893075933752785490401950953836105364709575990296000909161416686979 + } + + #[inline(always)] + fn keys(self: @BadModelMultipleVersions) -> 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: @BadModelMultipleVersions) -> 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: @BadModelMultipleVersions) -> 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_multiple_versions { + fn ensure_abi(self: @T, model: BadModelMultipleVersions); +} + +#[starknet::contract] +mod bad_model_multiple_versions { + use super::BadModelMultipleVersions; + use super::Ibad_model_multiple_versions; + + #[abi(embed_v0)] + impl DojoModelImpl of dojo::model::IModel{ + fn name(self: @ContractState) -> ByteArray { + dojo::model::Model::::name() + } + + fn namespace(self: @ContractState) -> ByteArray { + dojo::model::Model::::namespace() + } + + fn tag(self: @ContractState) -> ByteArray { + dojo::model::Model::::tag() + } + + fn version(self: @ContractState) -> u8 { + dojo::model::Model::::version() + } + + fn selector(self: @ContractState) -> felt252 { + dojo::model::Model::::selector() + } + + fn name_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::name_hash() + } + + fn namespace_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_hash() + } + + 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_multiple_versionsImpl of Ibad_model_multiple_versions{ + fn ensure_abi(self: @ContractState, model: BadModelMultipleVersions) { + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct ContractStorageBase { +} +#[derive(Drop, Copy)] +pub struct ContractStorageBaseMut { +} +impl StorageBaseImpl of starknet::storage::StorageBaseTrait { + type BaseType = ContractStorageBase; + type BaseMutType = ContractStorageBaseMut; + fn storage_base(self: @ContractState) -> ContractStorageBase { + ContractStorageBase { + } + } + fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { + ContractStorageBaseMut { + } + } +} +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = ContractStorageBase; + fn snapshot_deref(self: @ContractState) -> ContractStorageBase { + self.storage_base() + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = ContractStorageBaseMut; + fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { + self.storage_base_mut() + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +use starknet::storage::{ + StorageMapReadAccessTrait, StorageMapWriteAccessTrait, + StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess +}; +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::version(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::unpacked_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::packed_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::layout(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::schema(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__bad_model_multiple_versionsImpl__ensure_abi(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_model = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + bad_model_multiple_versionsImpl::ensure_abi(@contract_state, __arg_model); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__DojoModelImpl__name as name; + pub use super::__wrapper__DojoModelImpl__namespace as namespace; + pub use super::__wrapper__DojoModelImpl__tag as tag; + pub use super::__wrapper__DojoModelImpl__version as version; + pub use super::__wrapper__DojoModelImpl__selector as selector; + pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; + pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; + pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; + pub use super::__wrapper__DojoModelImpl__layout as layout; + pub use super::__wrapper__DojoModelImpl__schema as schema; + pub use super::__wrapper__bad_model_multiple_versionsImpl__ensure_abi as ensure_abi; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl ContractStorageBaseDrop of core::traits::Drop::; +impl ContractStorageBaseCopy of core::traits::Copy::; +impl ContractStorageBaseMutDrop of core::traits::Drop::; +impl ContractStorageBaseMutCopy of core::traits::Copy::; +} + +impl BadModelBadVersionTypeIntrospect<> 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: 'BadModelBadVersionType', + 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 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, + 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 `BadModelBadVersionType`: 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 { + "BadModelBadVersionType" + } + + #[inline(always)] + fn namespace() -> ByteArray { + "test_package" + } + + #[inline(always)] + fn tag() -> ByteArray { + "test_package-BadModelBadVersionType" + } + + #[inline(always)] + fn version() -> u8 { + 1 + } + + #[inline(always)] + fn selector() -> felt252 { + 3424346430891629531332762252537876298286978002978132542474104837759156545171 + } + + #[inline(always)] + fn instance_selector(self: @BadModelBadVersionType) -> felt252 { + Self::selector() + } + + #[inline(always)] + fn name_hash() -> felt252 { + 760683829940564015458541272487101565210915690045377810379189532484191344547 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 3061092720893075933752785490401950953836105364709575990296000909161416686979 + } + + #[inline(always)] + fn keys(self: @BadModelBadVersionType) -> 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: @BadModelBadVersionType) -> 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: @BadModelBadVersionType) -> 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_bad_version_type { + fn ensure_abi(self: @T, model: BadModelBadVersionType); +} + +#[starknet::contract] +mod bad_model_bad_version_type { + use super::BadModelBadVersionType; + use super::Ibad_model_bad_version_type; + + #[abi(embed_v0)] + impl DojoModelImpl of dojo::model::IModel{ + fn name(self: @ContractState) -> ByteArray { + dojo::model::Model::::name() + } + + fn namespace(self: @ContractState) -> ByteArray { + dojo::model::Model::::namespace() + } + + fn tag(self: @ContractState) -> ByteArray { + dojo::model::Model::::tag() + } + + fn version(self: @ContractState) -> u8 { + dojo::model::Model::::version() + } + + fn selector(self: @ContractState) -> felt252 { + dojo::model::Model::::selector() + } + + fn name_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::name_hash() + } + + fn namespace_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_hash() + } + + 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_bad_version_typeImpl of Ibad_model_bad_version_type{ + fn ensure_abi(self: @ContractState, model: BadModelBadVersionType) { + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct ContractStorageBase { +} +#[derive(Drop, Copy)] +pub struct ContractStorageBaseMut { +} +impl StorageBaseImpl of starknet::storage::StorageBaseTrait { + type BaseType = ContractStorageBase; + type BaseMutType = ContractStorageBaseMut; + fn storage_base(self: @ContractState) -> ContractStorageBase { + ContractStorageBase { + } + } + fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { + ContractStorageBaseMut { + } + } +} +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = ContractStorageBase; + fn snapshot_deref(self: @ContractState) -> ContractStorageBase { + self.storage_base() + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = ContractStorageBaseMut; + fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { + self.storage_base_mut() + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +use starknet::storage::{ + StorageMapReadAccessTrait, StorageMapWriteAccessTrait, + StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess +}; +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::version(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::unpacked_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::packed_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::layout(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::schema(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__bad_model_bad_version_typeImpl__ensure_abi(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_model = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + bad_model_bad_version_typeImpl::ensure_abi(@contract_state, __arg_model); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__DojoModelImpl__name as name; + pub use super::__wrapper__DojoModelImpl__namespace as namespace; + pub use super::__wrapper__DojoModelImpl__tag as tag; + pub use super::__wrapper__DojoModelImpl__version as version; + pub use super::__wrapper__DojoModelImpl__selector as selector; + pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; + pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; + pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; + pub use super::__wrapper__DojoModelImpl__layout as layout; + pub use super::__wrapper__DojoModelImpl__schema as schema; + pub use super::__wrapper__bad_model_bad_version_typeImpl__ensure_abi as ensure_abi; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl ContractStorageBaseDrop of core::traits::Drop::; +impl ContractStorageBaseCopy of core::traits::Copy::; +impl ContractStorageBaseMutDrop of core::traits::Drop::; +impl ContractStorageBaseMutCopy of core::traits::Copy::; +} + +impl BadModelNoVersionValueIntrospect<> 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: 'BadModelNoVersionValue', + 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 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, + 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 `BadModelNoVersionValue`: 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 { + "BadModelNoVersionValue" + } + + #[inline(always)] + fn namespace() -> ByteArray { + "test_package" + } + + #[inline(always)] + fn tag() -> ByteArray { + "test_package-BadModelNoVersionValue" + } + + #[inline(always)] + fn version() -> u8 { + 1 + } + + #[inline(always)] + fn selector() -> felt252 { + 3137507464979648719446085887369604472442296862296217793557428940425307809922 + } + + #[inline(always)] + fn instance_selector(self: @BadModelNoVersionValue) -> felt252 { + Self::selector() + } + + #[inline(always)] + fn name_hash() -> felt252 { + 2459365230136118590954025890011480023818926626380754992635699340900694864996 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 3061092720893075933752785490401950953836105364709575990296000909161416686979 + } + + #[inline(always)] + fn keys(self: @BadModelNoVersionValue) -> 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: @BadModelNoVersionValue) -> 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: @BadModelNoVersionValue) -> 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_no_version_value { + fn ensure_abi(self: @T, model: BadModelNoVersionValue); +} + +#[starknet::contract] +mod bad_model_no_version_value { + use super::BadModelNoVersionValue; + use super::Ibad_model_no_version_value; + + #[abi(embed_v0)] + impl DojoModelImpl of dojo::model::IModel{ + fn name(self: @ContractState) -> ByteArray { + dojo::model::Model::::name() + } + + fn namespace(self: @ContractState) -> ByteArray { + dojo::model::Model::::namespace() + } + + fn tag(self: @ContractState) -> ByteArray { + dojo::model::Model::::tag() + } + + fn version(self: @ContractState) -> u8 { + dojo::model::Model::::version() + } + + fn selector(self: @ContractState) -> felt252 { + dojo::model::Model::::selector() + } + + fn name_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::name_hash() + } + + fn namespace_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_hash() + } + + 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_no_version_valueImpl of Ibad_model_no_version_value{ + fn ensure_abi(self: @ContractState, model: BadModelNoVersionValue) { + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct ContractStorageBase { +} +#[derive(Drop, Copy)] +pub struct ContractStorageBaseMut { +} +impl StorageBaseImpl of starknet::storage::StorageBaseTrait { + type BaseType = ContractStorageBase; + type BaseMutType = ContractStorageBaseMut; + fn storage_base(self: @ContractState) -> ContractStorageBase { + ContractStorageBase { + } + } + fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { + ContractStorageBaseMut { + } + } +} +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = ContractStorageBase; + fn snapshot_deref(self: @ContractState) -> ContractStorageBase { + self.storage_base() + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = ContractStorageBaseMut; + fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { + self.storage_base_mut() + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +use starknet::storage::{ + StorageMapReadAccessTrait, StorageMapWriteAccessTrait, + StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess +}; +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::version(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::unpacked_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::packed_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::layout(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::schema(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__bad_model_no_version_valueImpl__ensure_abi(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_model = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + bad_model_no_version_valueImpl::ensure_abi(@contract_state, __arg_model); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__DojoModelImpl__name as name; + pub use super::__wrapper__DojoModelImpl__namespace as namespace; + pub use super::__wrapper__DojoModelImpl__tag as tag; + pub use super::__wrapper__DojoModelImpl__version as version; + pub use super::__wrapper__DojoModelImpl__selector as selector; + pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; + pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; + pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; + pub use super::__wrapper__DojoModelImpl__layout as layout; + pub use super::__wrapper__DojoModelImpl__schema as schema; + pub use super::__wrapper__bad_model_no_version_valueImpl__ensure_abi as ensure_abi; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl ContractStorageBaseDrop of core::traits::Drop::; +impl ContractStorageBaseCopy of core::traits::Copy::; +impl ContractStorageBaseMutDrop of core::traits::Drop::; +impl ContractStorageBaseMutCopy of core::traits::Copy::; +} + +impl BadModelUnexpectedArgWithValueIntrospect<> 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: 'BadModelUnexpectedArgWithValue', + 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 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, + 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 `BadModelUnexpectedArgWithValue`: 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 { + "BadModelUnexpectedArgWithValue" + } + + #[inline(always)] + fn namespace() -> ByteArray { + "test_package" + } + + #[inline(always)] + fn tag() -> ByteArray { + "test_package-BadModelUnexpectedArgWithValue" + } + + #[inline(always)] + fn version() -> u8 { + 1 + } + + #[inline(always)] + fn selector() -> felt252 { + 3162902274274075293574414479899149167035238805798288683939511839395372839584 + } + + #[inline(always)] + fn instance_selector(self: @BadModelUnexpectedArgWithValue) -> felt252 { + Self::selector() + } + + #[inline(always)] + fn name_hash() -> felt252 { + 3586339245084542986020591057627093254376225984628310828088084183494435682971 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 3061092720893075933752785490401950953836105364709575990296000909161416686979 + } + + #[inline(always)] + fn keys(self: @BadModelUnexpectedArgWithValue) -> 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: @BadModelUnexpectedArgWithValue) -> 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: @BadModelUnexpectedArgWithValue) -> 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_unexpected_arg_with_value { + fn ensure_abi(self: @T, model: BadModelUnexpectedArgWithValue); +} + +#[starknet::contract] +mod bad_model_unexpected_arg_with_value { + use super::BadModelUnexpectedArgWithValue; + use super::Ibad_model_unexpected_arg_with_value; + + #[abi(embed_v0)] + impl DojoModelImpl of dojo::model::IModel{ + fn name(self: @ContractState) -> ByteArray { + dojo::model::Model::::name() + } + + fn namespace(self: @ContractState) -> ByteArray { + dojo::model::Model::::namespace() + } + + fn tag(self: @ContractState) -> ByteArray { + dojo::model::Model::::tag() + } + + fn version(self: @ContractState) -> u8 { + dojo::model::Model::::version() + } + + fn selector(self: @ContractState) -> felt252 { + dojo::model::Model::::selector() + } + + fn name_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::name_hash() + } + + fn namespace_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_hash() + } + + 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_arg_with_valueImpl of Ibad_model_unexpected_arg_with_value{ + fn ensure_abi(self: @ContractState, model: BadModelUnexpectedArgWithValue) { + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct ContractStorageBase { +} +#[derive(Drop, Copy)] +pub struct ContractStorageBaseMut { +} +impl StorageBaseImpl of starknet::storage::StorageBaseTrait { + type BaseType = ContractStorageBase; + type BaseMutType = ContractStorageBaseMut; + fn storage_base(self: @ContractState) -> ContractStorageBase { + ContractStorageBase { + } + } + fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { + ContractStorageBaseMut { + } + } +} +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = ContractStorageBase; + fn snapshot_deref(self: @ContractState) -> ContractStorageBase { + self.storage_base() + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = ContractStorageBaseMut; + fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { + self.storage_base_mut() + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +use starknet::storage::{ + StorageMapReadAccessTrait, StorageMapWriteAccessTrait, + StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess +}; +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::version(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::unpacked_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::packed_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::layout(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::schema(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__bad_model_unexpected_arg_with_valueImpl__ensure_abi(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_model = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + bad_model_unexpected_arg_with_valueImpl::ensure_abi(@contract_state, __arg_model); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__DojoModelImpl__name as name; + pub use super::__wrapper__DojoModelImpl__namespace as namespace; + pub use super::__wrapper__DojoModelImpl__tag as tag; + pub use super::__wrapper__DojoModelImpl__version as version; + pub use super::__wrapper__DojoModelImpl__selector as selector; + pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; + pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; + pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; + pub use super::__wrapper__DojoModelImpl__layout as layout; + pub use super::__wrapper__DojoModelImpl__schema as schema; + pub use super::__wrapper__bad_model_unexpected_arg_with_valueImpl__ensure_abi as ensure_abi; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl ContractStorageBaseDrop of core::traits::Drop::; +impl ContractStorageBaseCopy of core::traits::Copy::; +impl ContractStorageBaseMutDrop of core::traits::Drop::; +impl ContractStorageBaseMutCopy of core::traits::Copy::; +} + +impl BadModelUnexpectedArgIntrospect<> 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: 'BadModelUnexpectedArg', + 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 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, + 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 `BadModelUnexpectedArg`: 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 { + "BadModelUnexpectedArg" + } + + #[inline(always)] + fn namespace() -> ByteArray { + "test_package" + } + + #[inline(always)] + fn tag() -> ByteArray { + "test_package-BadModelUnexpectedArg" + } + + #[inline(always)] + fn version() -> u8 { + 1 + } + + #[inline(always)] + fn selector() -> felt252 { + 2062327100205703339988289387876316143748074129748784084948535166252334131324 + } + + #[inline(always)] + fn instance_selector(self: @BadModelUnexpectedArg) -> felt252 { + Self::selector() + } + + #[inline(always)] + fn name_hash() -> felt252 { + 246403407829267991441535935236143476032296881039254363860883767387993960270 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 3061092720893075933752785490401950953836105364709575990296000909161416686979 + } + + #[inline(always)] + fn keys(self: @BadModelUnexpectedArg) -> 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: @BadModelUnexpectedArg) -> 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: @BadModelUnexpectedArg) -> 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_unexpected_arg { + fn ensure_abi(self: @T, model: BadModelUnexpectedArg); +} + +#[starknet::contract] +mod bad_model_unexpected_arg { + use super::BadModelUnexpectedArg; + use super::Ibad_model_unexpected_arg; + + #[abi(embed_v0)] + impl DojoModelImpl of dojo::model::IModel{ + fn name(self: @ContractState) -> ByteArray { + dojo::model::Model::::name() + } + + fn namespace(self: @ContractState) -> ByteArray { + dojo::model::Model::::namespace() + } + + fn tag(self: @ContractState) -> ByteArray { + dojo::model::Model::::tag() + } + + fn version(self: @ContractState) -> u8 { + dojo::model::Model::::version() + } + + fn selector(self: @ContractState) -> felt252 { + dojo::model::Model::::selector() + } + + fn name_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::name_hash() + } + + fn namespace_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_hash() + } + + 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) { + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct ContractStorageBase { +} +#[derive(Drop, Copy)] +pub struct ContractStorageBaseMut { +} +impl StorageBaseImpl of starknet::storage::StorageBaseTrait { + type BaseType = ContractStorageBase; + type BaseMutType = ContractStorageBaseMut; + fn storage_base(self: @ContractState) -> ContractStorageBase { + ContractStorageBase { + } + } + fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { + ContractStorageBaseMut { + } + } +} +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = ContractStorageBase; + fn snapshot_deref(self: @ContractState) -> ContractStorageBase { + self.storage_base() + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = ContractStorageBaseMut; + fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { + self.storage_base_mut() + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +use starknet::storage::{ + StorageMapReadAccessTrait, StorageMapWriteAccessTrait, + StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess +}; +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::version(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::unpacked_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::packed_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::layout(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::schema(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__bad_model_unexpected_argImpl__ensure_abi(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_model = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + bad_model_unexpected_argImpl::ensure_abi(@contract_state, __arg_model); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__DojoModelImpl__name as name; + pub use super::__wrapper__DojoModelImpl__namespace as namespace; + pub use super::__wrapper__DojoModelImpl__tag as tag; + pub use super::__wrapper__DojoModelImpl__version as version; + pub use super::__wrapper__DojoModelImpl__selector as selector; + pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; + pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; + pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; + pub use super::__wrapper__DojoModelImpl__layout as layout; + pub use super::__wrapper__DojoModelImpl__schema as schema; + pub use super::__wrapper__bad_model_unexpected_argImpl__ensure_abi as ensure_abi; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl ContractStorageBaseDrop of core::traits::Drop::; +impl ContractStorageBaseCopy of core::traits::Copy::; +impl ContractStorageBaseMutDrop of core::traits::Drop::; +impl ContractStorageBaseMutCopy of core::traits::Copy::; +} + +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 namespace() -> ByteArray { + "test_package" + } + + #[inline(always)] + fn tag() -> ByteArray { + "test_package-BadModelNotSupportedVersion" + } + + #[inline(always)] + fn version() -> u8 { + 1 + } + + #[inline(always)] + fn selector() -> felt252 { + 2399868061331388591523307843619168972583102717296603562171130686072940081207 + } + + #[inline(always)] + fn instance_selector(self: @BadModelNotSupportedVersion) -> felt252 { + Self::selector() + } + + #[inline(always)] + fn name_hash() -> felt252 { + 1812257929012908024237871796629728977392496349235879470060252299886369485820 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 3061092720893075933752785490401950953836105364709575990296000909161416686979 + } + + #[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; + + #[abi(embed_v0)] + impl DojoModelImpl of dojo::model::IModel{ + fn name(self: @ContractState) -> ByteArray { + dojo::model::Model::::name() + } + + fn namespace(self: @ContractState) -> ByteArray { + dojo::model::Model::::namespace() + } + + fn tag(self: @ContractState) -> ByteArray { + dojo::model::Model::::tag() + } + + fn version(self: @ContractState) -> u8 { + dojo::model::Model::::version() + } + + fn selector(self: @ContractState) -> felt252 { + dojo::model::Model::::selector() + } + + fn name_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::name_hash() + } + + fn namespace_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_hash() + } + + 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) { + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct ContractStorageBase { +} +#[derive(Drop, Copy)] +pub struct ContractStorageBaseMut { +} +impl StorageBaseImpl of starknet::storage::StorageBaseTrait { + type BaseType = ContractStorageBase; + type BaseMutType = ContractStorageBaseMut; + fn storage_base(self: @ContractState) -> ContractStorageBase { + ContractStorageBase { + } + } + fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { + ContractStorageBaseMut { + } + } +} +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = ContractStorageBase; + fn snapshot_deref(self: @ContractState) -> ContractStorageBase { + self.storage_base() + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = ContractStorageBaseMut; + fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { + self.storage_base_mut() + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +use starknet::storage::{ + StorageMapReadAccessTrait, StorageMapWriteAccessTrait, + StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess +}; +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::version(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::unpacked_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::packed_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::layout(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::schema(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__bad_model_not_supported_versionImpl__ensure_abi(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_model = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + bad_model_not_supported_versionImpl::ensure_abi(@contract_state, __arg_model); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__DojoModelImpl__name as name; + pub use super::__wrapper__DojoModelImpl__namespace as namespace; + pub use super::__wrapper__DojoModelImpl__tag as tag; + pub use super::__wrapper__DojoModelImpl__version as version; + pub use super::__wrapper__DojoModelImpl__selector as selector; + pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; + pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; + pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; + pub use super::__wrapper__DojoModelImpl__layout as layout; + pub use super::__wrapper__DojoModelImpl__schema as schema; + pub use super::__wrapper__bad_model_not_supported_versionImpl__ensure_abi as ensure_abi; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl ContractStorageBaseDrop of core::traits::Drop::; +impl ContractStorageBaseCopy of core::traits::Copy::; +impl ContractStorageBaseMutDrop of core::traits::Drop::; +impl ContractStorageBaseMutCopy of core::traits::Copy::; +} + +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 namespace() -> ByteArray { + "test_package" + } + + #[inline(always)] + fn tag() -> ByteArray { + "test_package-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 name_hash() -> felt252 { + 2212879130471315306779111820244908968466545702031328551192231795237740448313 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 3061092720893075933752785490401950953836105364709575990296000909161416686979 + } + + #[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; + + #[abi(embed_v0)] + impl DojoModelImpl of dojo::model::IModel{ + fn name(self: @ContractState) -> ByteArray { + dojo::model::Model::::name() + } + + fn namespace(self: @ContractState) -> ByteArray { + dojo::model::Model::::namespace() + } + + fn tag(self: @ContractState) -> ByteArray { + dojo::model::Model::::tag() + } + + fn version(self: @ContractState) -> u8 { + dojo::model::Model::::version() + } + + fn selector(self: @ContractState) -> felt252 { + dojo::model::Model::::selector() + } + + fn name_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::name_hash() + } + + fn namespace_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_hash() + } + + 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 modelv_0Impl of Imodelv_0{ + fn ensure_abi(self: @ContractState, model: Modelv0) { + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct ContractStorageBase { +} +#[derive(Drop, Copy)] +pub struct ContractStorageBaseMut { +} +impl StorageBaseImpl of starknet::storage::StorageBaseTrait { + type BaseType = ContractStorageBase; + type BaseMutType = ContractStorageBaseMut; + fn storage_base(self: @ContractState) -> ContractStorageBase { + ContractStorageBase { + } + } + fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { + ContractStorageBaseMut { + } + } +} +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = ContractStorageBase; + fn snapshot_deref(self: @ContractState) -> ContractStorageBase { + self.storage_base() + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = ContractStorageBaseMut; + fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { + self.storage_base_mut() + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +use starknet::storage::{ + StorageMapReadAccessTrait, StorageMapWriteAccessTrait, + StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess +}; +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::version(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::unpacked_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::packed_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::layout(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::schema(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__modelv_0Impl__ensure_abi(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_model = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + modelv_0Impl::ensure_abi(@contract_state, __arg_model); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__DojoModelImpl__name as name; + pub use super::__wrapper__DojoModelImpl__namespace as namespace; + pub use super::__wrapper__DojoModelImpl__tag as tag; + pub use super::__wrapper__DojoModelImpl__version as version; + pub use super::__wrapper__DojoModelImpl__selector as selector; + pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; + pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; + pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; + pub use super::__wrapper__DojoModelImpl__layout as layout; + pub use super::__wrapper__DojoModelImpl__schema as schema; + pub use super::__wrapper__modelv_0Impl__ensure_abi as ensure_abi; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl ContractStorageBaseDrop of core::traits::Drop::; +impl ContractStorageBaseCopy of core::traits::Copy::; +impl ContractStorageBaseMutDrop of core::traits::Drop::; +impl ContractStorageBaseMutCopy of core::traits::Copy::; +} + +impl ModelWithBadNamespaceFormatIntrospect<> 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: '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 ModelWithBadNamespaceFormatModel of dojo::model::Model { + fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::database::introspect::Layout) -> ModelWithBadNamespaceFormat { + 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 `ModelWithBadNamespaceFormat`: 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 { + "ModelWithBadNamespaceFormat" + } + + #[inline(always)] + fn namespace() -> ByteArray { + "test_package" + } + + #[inline(always)] + fn tag() -> ByteArray { + "test_package-ModelWithBadNamespaceFormat" + } + + #[inline(always)] + fn version() -> u8 { + 1 + } + + #[inline(always)] + fn selector() -> felt252 { + 3059539413433693207383279334860020534329215374860715071558931541261069058621 + } + + #[inline(always)] + fn instance_selector(self: @ModelWithBadNamespaceFormat) -> felt252 { + Self::selector() + } + + #[inline(always)] + fn name_hash() -> felt252 { + 513559242384681567568052881519197161166285694153303371154270254637843894159 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 3061092720893075933752785490401950953836105364709575990296000909161416686979 + } + + #[inline(always)] + fn keys(self: @ModelWithBadNamespaceFormat) -> 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: @ModelWithBadNamespaceFormat) -> 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: @ModelWithBadNamespaceFormat) -> 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 Imodel_with_bad_namespace_format { + fn ensure_abi(self: @T, model: ModelWithBadNamespaceFormat); +} + +#[starknet::contract] +mod model_with_bad_namespace_format { + use super::ModelWithBadNamespaceFormat; + use super::Imodel_with_bad_namespace_format; + + #[abi(embed_v0)] + impl DojoModelImpl of dojo::model::IModel{ + fn name(self: @ContractState) -> ByteArray { + dojo::model::Model::::name() + } + + fn namespace(self: @ContractState) -> ByteArray { + dojo::model::Model::::namespace() + } + + fn tag(self: @ContractState) -> ByteArray { + dojo::model::Model::::tag() + } + + fn version(self: @ContractState) -> u8 { + dojo::model::Model::::version() + } + + fn selector(self: @ContractState) -> felt252 { + dojo::model::Model::::selector() + } + + fn name_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::name_hash() + } + + fn namespace_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_hash() + } + + 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 model_with_bad_namespace_formatImpl of Imodel_with_bad_namespace_format{ + fn ensure_abi(self: @ContractState, model: ModelWithBadNamespaceFormat) { + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct ContractStorageBase { +} +#[derive(Drop, Copy)] +pub struct ContractStorageBaseMut { +} +impl StorageBaseImpl of starknet::storage::StorageBaseTrait { + type BaseType = ContractStorageBase; + type BaseMutType = ContractStorageBaseMut; + fn storage_base(self: @ContractState) -> ContractStorageBase { + ContractStorageBase { + } + } + fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { + ContractStorageBaseMut { + } + } +} +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = ContractStorageBase; + fn snapshot_deref(self: @ContractState) -> ContractStorageBase { + self.storage_base() + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = ContractStorageBaseMut; + fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { + self.storage_base_mut() + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +use starknet::storage::{ + StorageMapReadAccessTrait, StorageMapWriteAccessTrait, + StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess +}; +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::version(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::unpacked_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::packed_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::layout(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::schema(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__model_with_bad_namespace_formatImpl__ensure_abi(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_model = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + model_with_bad_namespace_formatImpl::ensure_abi(@contract_state, __arg_model); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__DojoModelImpl__name as name; + pub use super::__wrapper__DojoModelImpl__namespace as namespace; + pub use super::__wrapper__DojoModelImpl__tag as tag; + pub use super::__wrapper__DojoModelImpl__version as version; + pub use super::__wrapper__DojoModelImpl__selector as selector; + pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; + pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; + pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; + pub use super::__wrapper__DojoModelImpl__layout as layout; + pub use super::__wrapper__DojoModelImpl__schema as schema; + pub use super::__wrapper__model_with_bad_namespace_formatImpl__ensure_abi as ensure_abi; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl ContractStorageBaseDrop of core::traits::Drop::; +impl ContractStorageBaseCopy of core::traits::Copy::; +impl ContractStorageBaseMutDrop of core::traits::Drop::; +impl ContractStorageBaseMutCopy of core::traits::Copy::; +} + +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 { + 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 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. + 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 `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) + } + + #[inline(always)] + fn name() -> ByteArray { + "ModelWithShortStringNamespace" + } + + #[inline(always)] + fn namespace() -> ByteArray { + "test_package" + } + + #[inline(always)] + fn tag() -> ByteArray { + "test_package-ModelWithShortStringNamespace" + } + + #[inline(always)] + fn version() -> u8 { + 1 + } + + #[inline(always)] + fn selector() -> felt252 { + 516169310422367104631924468147010406642920381144711483043394373786075028578 + } + + #[inline(always)] + fn instance_selector(self: @ModelWithShortStringNamespace) -> felt252 { + Self::selector() + } + + #[inline(always)] + fn name_hash() -> felt252 { + 4646597166239297873853881466258165424425132957303541470648153031188639878 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 3061092720893075933752785490401950953836105364709575990296000909161416686979 + } + + #[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: @ModelWithShortStringNamespace) -> 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: @ModelWithShortStringNamespace) -> 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 Imodel_with_short_string_namespace { + fn ensure_abi(self: @T, model: ModelWithShortStringNamespace); +} + +#[starknet::contract] +mod model_with_short_string_namespace { + use super::ModelWithShortStringNamespace; + use super::Imodel_with_short_string_namespace; + + #[abi(embed_v0)] + impl DojoModelImpl of dojo::model::IModel{ + fn name(self: @ContractState) -> ByteArray { + dojo::model::Model::::name() + } + + fn namespace(self: @ContractState) -> ByteArray { + dojo::model::Model::::namespace() + } + + fn tag(self: @ContractState) -> ByteArray { + dojo::model::Model::::tag() + } + + fn version(self: @ContractState) -> u8 { + dojo::model::Model::::version() + } + + fn selector(self: @ContractState) -> felt252 { + dojo::model::Model::::selector() + } + + fn name_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::name_hash() + } + + fn namespace_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_hash() + } + + 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 model_with_short_string_namespaceImpl of Imodel_with_short_string_namespace{ + fn ensure_abi(self: @ContractState, model: ModelWithShortStringNamespace) { + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct ContractStorageBase { +} +#[derive(Drop, Copy)] +pub struct ContractStorageBaseMut { +} +impl StorageBaseImpl of starknet::storage::StorageBaseTrait { + type BaseType = ContractStorageBase; + type BaseMutType = ContractStorageBaseMut; + fn storage_base(self: @ContractState) -> ContractStorageBase { + ContractStorageBase { + } + } + fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { + ContractStorageBaseMut { + } + } +} +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = ContractStorageBase; + fn snapshot_deref(self: @ContractState) -> ContractStorageBase { + self.storage_base() + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = ContractStorageBaseMut; + fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { + self.storage_base_mut() + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +use starknet::storage::{ + StorageMapReadAccessTrait, StorageMapWriteAccessTrait, + StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess +}; +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::version(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::unpacked_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::packed_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::layout(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::schema(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__model_with_short_string_namespaceImpl__ensure_abi(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_model = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + model_with_short_string_namespaceImpl::ensure_abi(@contract_state, __arg_model); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__DojoModelImpl__name as name; + pub use super::__wrapper__DojoModelImpl__namespace as namespace; + pub use super::__wrapper__DojoModelImpl__tag as tag; + pub use super::__wrapper__DojoModelImpl__version as version; + pub use super::__wrapper__DojoModelImpl__selector as selector; + pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; + pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; + pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; + pub use super::__wrapper__DojoModelImpl__layout as layout; + pub use super::__wrapper__DojoModelImpl__schema as schema; + pub use super::__wrapper__model_with_short_string_namespaceImpl__ensure_abi as ensure_abi; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl ContractStorageBaseDrop of core::traits::Drop::; +impl ContractStorageBaseCopy of core::traits::Copy::; +impl ContractStorageBaseMutDrop of core::traits::Drop::; +impl ContractStorageBaseMutCopy of core::traits::Copy::; +} + +impl ModelWithStringNamespaceIntrospect<> 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: 'ModelWithStringNamespace', + 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 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. + 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 `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) + } + + #[inline(always)] + fn name() -> ByteArray { + "ModelWithStringNamespace" + } + + #[inline(always)] + fn namespace() -> ByteArray { + "test_package" + } + + #[inline(always)] + fn tag() -> ByteArray { + "test_package-ModelWithStringNamespace" + } + + #[inline(always)] + fn version() -> u8 { + 1 + } + + #[inline(always)] + fn selector() -> felt252 { + 2244952983831849087562617629161882602941157493177409459461888999685738447838 + } + + #[inline(always)] + fn instance_selector(self: @ModelWithStringNamespace) -> felt252 { + Self::selector() + } + + #[inline(always)] + fn name_hash() -> felt252 { + 36187013840655350498900857372670392628596870210415176261336407419317644423 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 3061092720893075933752785490401950953836105364709575990296000909161416686979 + } + + #[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: @ModelWithStringNamespace) -> 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: @ModelWithStringNamespace) -> 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 Imodel_with_string_namespace { + fn ensure_abi(self: @T, model: ModelWithStringNamespace); +} + +#[starknet::contract] +mod model_with_string_namespace { + use super::ModelWithStringNamespace; + use super::Imodel_with_string_namespace; + + #[abi(embed_v0)] + impl DojoModelImpl of dojo::model::IModel{ + fn name(self: @ContractState) -> ByteArray { + dojo::model::Model::::name() + } + + fn namespace(self: @ContractState) -> ByteArray { + dojo::model::Model::::namespace() + } + + fn tag(self: @ContractState) -> ByteArray { + dojo::model::Model::::tag() + } + + fn version(self: @ContractState) -> u8 { + dojo::model::Model::::version() + } + + fn selector(self: @ContractState) -> felt252 { + dojo::model::Model::::selector() + } + + fn name_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::name_hash() + } + + fn namespace_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_hash() + } + + 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 model_with_string_namespaceImpl of Imodel_with_string_namespace{ + fn ensure_abi(self: @ContractState, model: ModelWithStringNamespace) { + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct ContractStorageBase { +} +#[derive(Drop, Copy)] +pub struct ContractStorageBaseMut { +} +impl StorageBaseImpl of starknet::storage::StorageBaseTrait { + type BaseType = ContractStorageBase; + type BaseMutType = ContractStorageBaseMut; + fn storage_base(self: @ContractState) -> ContractStorageBase { + ContractStorageBase { + } + } + fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { + ContractStorageBaseMut { + } + } +} +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = ContractStorageBase; + fn snapshot_deref(self: @ContractState) -> ContractStorageBase { + self.storage_base() + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = ContractStorageBaseMut; + fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { + self.storage_base_mut() + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +use starknet::storage::{ + StorageMapReadAccessTrait, StorageMapWriteAccessTrait, + StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess +}; +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::version(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::unpacked_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::packed_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::layout(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::schema(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__model_with_string_namespaceImpl__ensure_abi(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_model = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + model_with_string_namespaceImpl::ensure_abi(@contract_state, __arg_model); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__DojoModelImpl__name as name; + pub use super::__wrapper__DojoModelImpl__namespace as namespace; + pub use super::__wrapper__DojoModelImpl__tag as tag; + pub use super::__wrapper__DojoModelImpl__version as version; + pub use super::__wrapper__DojoModelImpl__selector as selector; + pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; + pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; + pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; + pub use super::__wrapper__DojoModelImpl__layout as layout; + pub use super::__wrapper__DojoModelImpl__schema as schema; + pub use super::__wrapper__model_with_string_namespaceImpl__ensure_abi as ensure_abi; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl ContractStorageBaseDrop of core::traits::Drop::; +impl ContractStorageBaseCopy of core::traits::Copy::; +impl ContractStorageBaseMutDrop of core::traits::Drop::; +impl ContractStorageBaseMutCopy of core::traits::Copy::; +} + +impl PositionIntrospect<> 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: 'Position', + 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 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, + 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 `Position`: 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 { + "Position" + } + + #[inline(always)] + fn namespace() -> ByteArray { + "test_package" + } + + #[inline(always)] + fn tag() -> ByteArray { + "test_package-Position" + } + + #[inline(always)] + fn version() -> u8 { + 1 + } + + #[inline(always)] + fn selector() -> felt252 { + 2583140722357655302813194934296353271867745884944715988664292532004552033294 + } + + #[inline(always)] + fn instance_selector(self: @Position) -> felt252 { + Self::selector() + } + + #[inline(always)] + fn name_hash() -> felt252 { + 2899920299641094436341712346886623904698864491830316325765258522168980161362 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 3061092720893075933752785490401950953836105364709575990296000909161416686979 + } + + #[inline(always)] + fn keys(self: @Position) -> 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: @Position) -> 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: @Position) -> 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 Iposition { + fn ensure_abi(self: @T, model: Position); +} + +#[starknet::contract] +mod position { + use super::Position; + use super::Iposition; + + #[abi(embed_v0)] + impl DojoModelImpl of dojo::model::IModel{ + fn name(self: @ContractState) -> ByteArray { + dojo::model::Model::::name() + } + + fn namespace(self: @ContractState) -> ByteArray { + dojo::model::Model::::namespace() + } + + fn tag(self: @ContractState) -> ByteArray { + dojo::model::Model::::tag() + } + + fn version(self: @ContractState) -> u8 { + dojo::model::Model::::version() + } + + fn selector(self: @ContractState) -> felt252 { + dojo::model::Model::::selector() + } + + fn name_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::name_hash() + } + + fn namespace_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_hash() + } + + 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 positionImpl of Iposition{ + fn ensure_abi(self: @ContractState, model: Position) { + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct ContractStorageBase { +} +#[derive(Drop, Copy)] +pub struct ContractStorageBaseMut { +} +impl StorageBaseImpl of starknet::storage::StorageBaseTrait { + type BaseType = ContractStorageBase; + type BaseMutType = ContractStorageBaseMut; + fn storage_base(self: @ContractState) -> ContractStorageBase { + ContractStorageBase { + } + } + fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { + ContractStorageBaseMut { + } + } +} +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = ContractStorageBase; + fn snapshot_deref(self: @ContractState) -> ContractStorageBase { + self.storage_base() + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = ContractStorageBaseMut; + fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { + self.storage_base_mut() + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +use starknet::storage::{ + StorageMapReadAccessTrait, StorageMapWriteAccessTrait, + StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess +}; +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::version(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::unpacked_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::packed_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::layout(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::schema(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__positionImpl__ensure_abi(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_model = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + positionImpl::ensure_abi(@contract_state, __arg_model); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__DojoModelImpl__name as name; + pub use super::__wrapper__DojoModelImpl__namespace as namespace; + pub use super::__wrapper__DojoModelImpl__tag as tag; + pub use super::__wrapper__DojoModelImpl__version as version; + pub use super::__wrapper__DojoModelImpl__selector as selector; + pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; + pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; + pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; + pub use super::__wrapper__DojoModelImpl__layout as layout; + pub use super::__wrapper__DojoModelImpl__schema as schema; + pub use super::__wrapper__positionImpl__ensure_abi as ensure_abi; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl ContractStorageBaseDrop of core::traits::Drop::; +impl ContractStorageBaseCopy of core::traits::Copy::; +impl ContractStorageBaseMutDrop of core::traits::Drop::; +impl ContractStorageBaseMutCopy of core::traits::Copy::; +} + +impl RolesIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::None + } + + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Struct( + array![ + dojo::database::introspect::FieldLayout { + selector: 387776731289756409274549987067854286905927440612427426920343953432870065647, + 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: 'Roles', + attrs: array![].span(), + children: array![ + dojo::database::introspect::Member { + name: 'role_ids', + attrs: array![].span(), + ty: dojo::database::introspect::Ty::Array( + array![ + dojo::database::introspect::Introspect::::ty() + ].span() + ) + } + + ].span() + } + ) + } +} + +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, + 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 `Roles`: 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 { + "Roles" + } + + #[inline(always)] + fn namespace() -> ByteArray { + "test_package" + } + + #[inline(always)] + fn tag() -> ByteArray { + "test_package-Roles" + } + + #[inline(always)] + fn version() -> u8 { + 1 + } + + #[inline(always)] + fn selector() -> felt252 { + 2381319068167303801085530774544728044506110381004500761927797648058170896946 + } + + #[inline(always)] + fn instance_selector(self: @Roles) -> felt252 { + Self::selector() + } + + #[inline(always)] + fn name_hash() -> felt252 { + 2030971736961612564423689930729061756599290850089001157163423482274886199516 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 3061092720893075933752785490401950953836105364709575990296000909161416686979 + } + + #[inline(always)] + fn keys(self: @Roles) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + + core::array::ArrayTrait::span(@serialized) + } + + #[inline(always)] + fn values(self: @Roles) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.role_ids, 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: @Roles) -> 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 Iroles { + fn ensure_abi(self: @T, model: Roles); +} + +#[starknet::contract] +mod roles { + use super::Roles; + use super::Iroles; + + #[abi(embed_v0)] + impl DojoModelImpl of dojo::model::IModel{ + fn name(self: @ContractState) -> ByteArray { + dojo::model::Model::::name() + } + + fn namespace(self: @ContractState) -> ByteArray { + dojo::model::Model::::namespace() + } + + fn tag(self: @ContractState) -> ByteArray { + dojo::model::Model::::tag() + } + + fn version(self: @ContractState) -> u8 { + dojo::model::Model::::version() + } + + fn selector(self: @ContractState) -> felt252 { + dojo::model::Model::::selector() + } + + fn name_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::name_hash() + } + + fn namespace_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_hash() + } + + 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 rolesImpl of Iroles{ + fn ensure_abi(self: @ContractState, model: Roles) { + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct ContractStorageBase { +} +#[derive(Drop, Copy)] +pub struct ContractStorageBaseMut { +} +impl StorageBaseImpl of starknet::storage::StorageBaseTrait { + type BaseType = ContractStorageBase; + type BaseMutType = ContractStorageBaseMut; + fn storage_base(self: @ContractState) -> ContractStorageBase { + ContractStorageBase { + } + } + fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { + ContractStorageBaseMut { + } + } +} +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = ContractStorageBase; + fn snapshot_deref(self: @ContractState) -> ContractStorageBase { + self.storage_base() + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = ContractStorageBaseMut; + fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { + self.storage_base_mut() + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +use starknet::storage::{ + StorageMapReadAccessTrait, StorageMapWriteAccessTrait, + StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess +}; +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::version(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::unpacked_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::packed_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::layout(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::schema(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__rolesImpl__ensure_abi(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_model = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + rolesImpl::ensure_abi(@contract_state, __arg_model); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__DojoModelImpl__name as name; + pub use super::__wrapper__DojoModelImpl__namespace as namespace; + pub use super::__wrapper__DojoModelImpl__tag as tag; + pub use super::__wrapper__DojoModelImpl__version as version; + pub use super::__wrapper__DojoModelImpl__selector as selector; + pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; + pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; + pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; + pub use super::__wrapper__DojoModelImpl__layout as layout; + pub use super::__wrapper__DojoModelImpl__schema as schema; + pub use super::__wrapper__rolesImpl__ensure_abi as ensure_abi; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl ContractStorageBaseDrop of core::traits::Drop::; +impl ContractStorageBaseCopy of core::traits::Copy::; +impl ContractStorageBaseMutDrop of core::traits::Drop::; +impl ContractStorageBaseMutCopy of core::traits::Copy::; +} + +impl OnlyKeyModelIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::None + } + + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Struct( + array![ + + ].span() + ) + } + + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Struct( + dojo::database::introspect::Struct { + name: 'OnlyKeyModel', + attrs: array![].span(), + children: array![ + dojo::database::introspect::Member { + name: 'id', + attrs: array!['key'].span(), + ty: dojo::database::introspect::Introspect::::ty() + } + + ].span() + } + ) + } +} + +impl OnlyKeyModelModel of dojo::model::Model { + fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::database::introspect::Layout) -> OnlyKeyModel { + 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 `OnlyKeyModel`: 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 { + "OnlyKeyModel" + } + + #[inline(always)] + fn namespace() -> ByteArray { + "test_package" + } + + #[inline(always)] + fn tag() -> ByteArray { + "test_package-OnlyKeyModel" + } + + #[inline(always)] + fn version() -> u8 { + 1 + } + + #[inline(always)] + fn selector() -> felt252 { + 399971050958024375507922651483187108363916132710819632852036528607645634778 + } + + #[inline(always)] + fn instance_selector(self: @OnlyKeyModel) -> felt252 { + Self::selector() + } + + #[inline(always)] + fn name_hash() -> felt252 { + 1001826121797570811408809643478760373535949956555931325019299477987282578617 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 3061092720893075933752785490401950953836105364709575990296000909161416686979 + } + + #[inline(always)] + fn keys(self: @OnlyKeyModel) -> 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: @OnlyKeyModel) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + + core::array::ArrayTrait::span(@serialized) + } + + #[inline(always)] + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Introspect::::layout() + } + + #[inline(always)] + fn instance_layout(self: @OnlyKeyModel) -> 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 Ionly_key_model { + fn ensure_abi(self: @T, model: OnlyKeyModel); +} + +#[starknet::contract] +mod only_key_model { + use super::OnlyKeyModel; + use super::Ionly_key_model; + + #[abi(embed_v0)] + impl DojoModelImpl of dojo::model::IModel{ + fn name(self: @ContractState) -> ByteArray { + dojo::model::Model::::name() + } + + fn namespace(self: @ContractState) -> ByteArray { + dojo::model::Model::::namespace() + } + + fn tag(self: @ContractState) -> ByteArray { + dojo::model::Model::::tag() + } + + fn version(self: @ContractState) -> u8 { + dojo::model::Model::::version() + } + + fn selector(self: @ContractState) -> felt252 { + dojo::model::Model::::selector() + } + + fn name_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::name_hash() + } + + fn namespace_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_hash() + } + + 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 only_key_modelImpl of Ionly_key_model{ + fn ensure_abi(self: @ContractState, model: OnlyKeyModel) { + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct ContractStorageBase { +} +#[derive(Drop, Copy)] +pub struct ContractStorageBaseMut { +} +impl StorageBaseImpl of starknet::storage::StorageBaseTrait { + type BaseType = ContractStorageBase; + type BaseMutType = ContractStorageBaseMut; + fn storage_base(self: @ContractState) -> ContractStorageBase { + ContractStorageBase { + } + } + fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { + ContractStorageBaseMut { + } + } +} +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = ContractStorageBase; + fn snapshot_deref(self: @ContractState) -> ContractStorageBase { + self.storage_base() + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = ContractStorageBaseMut; + fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { + self.storage_base_mut() + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +use starknet::storage::{ + StorageMapReadAccessTrait, StorageMapWriteAccessTrait, + StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess +}; +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::version(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::unpacked_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::packed_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::layout(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::schema(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__only_key_modelImpl__ensure_abi(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_model = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + only_key_modelImpl::ensure_abi(@contract_state, __arg_model); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__DojoModelImpl__name as name; + pub use super::__wrapper__DojoModelImpl__namespace as namespace; + pub use super::__wrapper__DojoModelImpl__tag as tag; + pub use super::__wrapper__DojoModelImpl__version as version; + pub use super::__wrapper__DojoModelImpl__selector as selector; + pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; + pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; + pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; + pub use super::__wrapper__DojoModelImpl__layout as layout; + pub use super::__wrapper__DojoModelImpl__schema as schema; + pub use super::__wrapper__only_key_modelImpl__ensure_abi as ensure_abi; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl ContractStorageBaseDrop of core::traits::Drop::; +impl ContractStorageBaseCopy of core::traits::Copy::; +impl ContractStorageBaseMutDrop of core::traits::Drop::; +impl ContractStorageBaseMutCopy of core::traits::Copy::; +} + +impl U256KeyModelIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::None + } + + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Struct( + array![ + + ].span() + ) + } + + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Struct( + dojo::database::introspect::Struct { + name: 'U256KeyModel', + attrs: array![].span(), + children: array![ + dojo::database::introspect::Member { + name: 'id', + attrs: array!['key'].span(), + ty: dojo::database::introspect::Introspect::::ty() + } + + ].span() + } + ) + } +} + +impl U256KeyModelModel of dojo::model::Model { + fn entity(world: dojo::world::IWorldDispatcher, keys: Span, layout: dojo::database::introspect::Layout) -> U256KeyModel { + 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 `U256KeyModel`: 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 { + "U256KeyModel" + } + + #[inline(always)] + fn namespace() -> ByteArray { + "test_package" + } + + #[inline(always)] + fn tag() -> ByteArray { + "test_package-U256KeyModel" + } + + #[inline(always)] + fn version() -> u8 { + 1 + } + + #[inline(always)] + fn selector() -> felt252 { + 3403346971723769227042162502675592040860576799654783499419654467804113799823 + } + + #[inline(always)] + fn instance_selector(self: @U256KeyModel) -> felt252 { + Self::selector() + } + + #[inline(always)] + fn name_hash() -> felt252 { + 1848733002266458148515852001373055968326209639346734967305014900020806934517 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 3061092720893075933752785490401950953836105364709575990296000909161416686979 + } + + #[inline(always)] + fn keys(self: @U256KeyModel) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.id, ref serialized); + core::array::ArrayTrait::span(@serialized) + } + + #[inline(always)] + fn values(self: @U256KeyModel) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + + core::array::ArrayTrait::span(@serialized) + } + + #[inline(always)] + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Introspect::::layout() + } + + #[inline(always)] + fn instance_layout(self: @U256KeyModel) -> 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 Iu_256_key_model { + fn ensure_abi(self: @T, model: U256KeyModel); +} + +#[starknet::contract] +mod u_256_key_model { + use super::U256KeyModel; + use super::Iu_256_key_model; + + #[abi(embed_v0)] + impl DojoModelImpl of dojo::model::IModel{ + fn name(self: @ContractState) -> ByteArray { + dojo::model::Model::::name() + } + + fn namespace(self: @ContractState) -> ByteArray { + dojo::model::Model::::namespace() + } + + fn tag(self: @ContractState) -> ByteArray { + dojo::model::Model::::tag() + } + + fn version(self: @ContractState) -> u8 { + dojo::model::Model::::version() + } + + fn selector(self: @ContractState) -> felt252 { + dojo::model::Model::::selector() + } + + fn name_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::name_hash() + } + + fn namespace_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_hash() + } + + 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 u_256_key_modelImpl of Iu_256_key_model{ + fn ensure_abi(self: @ContractState, model: U256KeyModel) { + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct ContractStorageBase { +} +#[derive(Drop, Copy)] +pub struct ContractStorageBaseMut { +} +impl StorageBaseImpl of starknet::storage::StorageBaseTrait { + type BaseType = ContractStorageBase; + type BaseMutType = ContractStorageBaseMut; + fn storage_base(self: @ContractState) -> ContractStorageBase { + ContractStorageBase { + } + } + fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { + ContractStorageBaseMut { + } + } +} +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = ContractStorageBase; + fn snapshot_deref(self: @ContractState) -> ContractStorageBase { + self.storage_base() + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = ContractStorageBaseMut; + fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { + self.storage_base_mut() + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +use starknet::storage::{ + StorageMapReadAccessTrait, StorageMapWriteAccessTrait, + StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess +}; +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::version(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::unpacked_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::packed_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::layout(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::schema(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__u_256_key_modelImpl__ensure_abi(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_model = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + u_256_key_modelImpl::ensure_abi(@contract_state, __arg_model); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__DojoModelImpl__name as name; + pub use super::__wrapper__DojoModelImpl__namespace as namespace; + pub use super::__wrapper__DojoModelImpl__tag as tag; + pub use super::__wrapper__DojoModelImpl__version as version; + pub use super::__wrapper__DojoModelImpl__selector as selector; + pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; + pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; + pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; + pub use super::__wrapper__DojoModelImpl__layout as layout; + pub use super::__wrapper__DojoModelImpl__schema as schema; + pub use super::__wrapper__u_256_key_modelImpl__ensure_abi as ensure_abi; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl ContractStorageBaseDrop of core::traits::Drop::; +impl ContractStorageBaseCopy of core::traits::Copy::; +impl ContractStorageBaseMutDrop of core::traits::Drop::; +impl ContractStorageBaseMutCopy of core::traits::Copy::; +} + +impl PlayerIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::Some(1) + } + + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Struct( + array![ + dojo::database::introspect::FieldLayout { + selector: 1528802474226268325865027367859591458315299653151958663884057507666229546336, + 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: 'Player', + attrs: array![].span(), + children: array![ + dojo::database::introspect::Member { + name: 'game', + attrs: array!['key'].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'player', + attrs: array!['key'].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'name', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::::ty() + } + + ].span() + } + ) + } +} + +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, + 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 `Player`: 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 { + "Player" + } + + #[inline(always)] + fn namespace() -> ByteArray { + "test_package" + } + + #[inline(always)] + fn tag() -> ByteArray { + "test_package-Player" + } + + #[inline(always)] + fn version() -> u8 { + 1 + } + + #[inline(always)] + fn selector() -> felt252 { + 3068209845672224878774101526910835120619854456556690065951127565061014675679 + } + + #[inline(always)] + fn instance_selector(self: @Player) -> felt252 { + Self::selector() + } + + #[inline(always)] + fn name_hash() -> felt252 { + 1073075359926275415180704315933677548333097210683379121732618306925003101845 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 3061092720893075933752785490401950953836105364709575990296000909161416686979 + } + + #[inline(always)] + fn keys(self: @Player) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::array::ArrayTrait::append(ref serialized, *self.game);core::serde::Serde::serialize(self.player, ref serialized); + core::array::ArrayTrait::span(@serialized) + } + + #[inline(always)] + fn values(self: @Player) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::array::ArrayTrait::append(ref serialized, *self.name); + core::array::ArrayTrait::span(@serialized) + } + + #[inline(always)] + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Introspect::::layout() + } + + #[inline(always)] + fn instance_layout(self: @Player) -> 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 Iplayer { + fn ensure_abi(self: @T, model: Player); +} + +#[starknet::contract] +mod player { + use super::Player; + use super::Iplayer; + + #[abi(embed_v0)] + impl DojoModelImpl of dojo::model::IModel{ + fn name(self: @ContractState) -> ByteArray { + dojo::model::Model::::name() + } + + fn namespace(self: @ContractState) -> ByteArray { + dojo::model::Model::::namespace() + } + + fn tag(self: @ContractState) -> ByteArray { + dojo::model::Model::::tag() + } + + fn version(self: @ContractState) -> u8 { + dojo::model::Model::::version() + } + + fn selector(self: @ContractState) -> felt252 { + dojo::model::Model::::selector() + } + + fn name_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::name_hash() + } + + fn namespace_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_hash() + } + + 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 playerImpl of Iplayer{ + fn ensure_abi(self: @ContractState, model: Player) { + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct ContractStorageBase { +} +#[derive(Drop, Copy)] +pub struct ContractStorageBaseMut { +} +impl StorageBaseImpl of starknet::storage::StorageBaseTrait { + type BaseType = ContractStorageBase; + type BaseMutType = ContractStorageBaseMut; + fn storage_base(self: @ContractState) -> ContractStorageBase { + ContractStorageBase { + } + } + fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { + ContractStorageBaseMut { + } + } +} +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = ContractStorageBase; + fn snapshot_deref(self: @ContractState) -> ContractStorageBase { + self.storage_base() + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = ContractStorageBaseMut; + fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { + self.storage_base_mut() + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +use starknet::storage::{ + StorageMapReadAccessTrait, StorageMapWriteAccessTrait, + StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess +}; +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::version(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::unpacked_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::packed_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::layout(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::schema(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__playerImpl__ensure_abi(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_model = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + playerImpl::ensure_abi(@contract_state, __arg_model); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__DojoModelImpl__name as name; + pub use super::__wrapper__DojoModelImpl__namespace as namespace; + pub use super::__wrapper__DojoModelImpl__tag as tag; + pub use super::__wrapper__DojoModelImpl__version as version; + pub use super::__wrapper__DojoModelImpl__selector as selector; + pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; + pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; + pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; + pub use super::__wrapper__DojoModelImpl__layout as layout; + pub use super::__wrapper__DojoModelImpl__schema as schema; + pub use super::__wrapper__playerImpl__ensure_abi as ensure_abi; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl ContractStorageBaseDrop of core::traits::Drop::; +impl ContractStorageBaseCopy of core::traits::Copy::; +impl ContractStorageBaseMutDrop of core::traits::Drop::; +impl ContractStorageBaseMutCopy of core::traits::Copy::; +} + +impl ModelWithSimpleArrayIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::None + } + + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Struct( + array![ + dojo::database::introspect::FieldLayout { + selector: 512066735765477566404754172672287371265995314501343422459174036873487219331, + layout: dojo::database::introspect::Introspect::::layout() + }, +dojo::database::introspect::FieldLayout { + selector: 1591024729085637502504777720563487898377940395575083379770417352976841400819, + 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: 'ModelWithSimpleArray', + attrs: array![].span(), + children: array![ + dojo::database::introspect::Member { + name: 'player', + attrs: array!['key'].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'x', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'y', + attrs: array![].span(), + ty: dojo::database::introspect::Ty::Array( + array![ + dojo::database::introspect::Introspect::::ty() + ].span() + ) + } + + ].span() + } + ) + } +} + +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, + 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 `ModelWithSimpleArray`: 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 { + "ModelWithSimpleArray" + } + + #[inline(always)] + fn namespace() -> ByteArray { + "test_package" + } + + #[inline(always)] + fn tag() -> ByteArray { + "test_package-ModelWithSimpleArray" + } + + #[inline(always)] + fn version() -> u8 { + 1 + } + + #[inline(always)] + fn selector() -> felt252 { + 516248842335934132822768408262411488579427278776919857986291389606250466377 + } + + #[inline(always)] + fn instance_selector(self: @ModelWithSimpleArray) -> felt252 { + Self::selector() + } + + #[inline(always)] + fn name_hash() -> felt252 { + 173141902001925402715103859951360389436088950156916962046507357841237663931 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 3061092720893075933752785490401950953836105364709575990296000909161416686979 + } + + #[inline(always)] + fn keys(self: @ModelWithSimpleArray) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.player, ref serialized); + core::array::ArrayTrait::span(@serialized) + } + + #[inline(always)] + fn values(self: @ModelWithSimpleArray) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.x, ref serialized);core::serde::Serde::serialize(self.y, 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: @ModelWithSimpleArray) -> 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 Imodel_with_simple_array { + fn ensure_abi(self: @T, model: ModelWithSimpleArray); +} + +#[starknet::contract] +mod model_with_simple_array { + use super::ModelWithSimpleArray; + use super::Imodel_with_simple_array; + + #[abi(embed_v0)] + impl DojoModelImpl of dojo::model::IModel{ + fn name(self: @ContractState) -> ByteArray { + dojo::model::Model::::name() + } + + fn namespace(self: @ContractState) -> ByteArray { + dojo::model::Model::::namespace() + } + + fn tag(self: @ContractState) -> ByteArray { + dojo::model::Model::::tag() + } + + fn version(self: @ContractState) -> u8 { + dojo::model::Model::::version() + } + + fn selector(self: @ContractState) -> felt252 { + dojo::model::Model::::selector() + } + + fn name_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::name_hash() + } + + fn namespace_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_hash() + } + + 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 model_with_simple_arrayImpl of Imodel_with_simple_array{ + fn ensure_abi(self: @ContractState, model: ModelWithSimpleArray) { + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct ContractStorageBase { +} +#[derive(Drop, Copy)] +pub struct ContractStorageBaseMut { +} +impl StorageBaseImpl of starknet::storage::StorageBaseTrait { + type BaseType = ContractStorageBase; + type BaseMutType = ContractStorageBaseMut; + fn storage_base(self: @ContractState) -> ContractStorageBase { + ContractStorageBase { + } + } + fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { + ContractStorageBaseMut { + } + } +} +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = ContractStorageBase; + fn snapshot_deref(self: @ContractState) -> ContractStorageBase { + self.storage_base() + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = ContractStorageBaseMut; + fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { + self.storage_base_mut() + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +use starknet::storage::{ + StorageMapReadAccessTrait, StorageMapWriteAccessTrait, + StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess +}; +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::version(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::unpacked_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::packed_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::layout(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::schema(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__model_with_simple_arrayImpl__ensure_abi(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_model = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + model_with_simple_arrayImpl::ensure_abi(@contract_state, __arg_model); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__DojoModelImpl__name as name; + pub use super::__wrapper__DojoModelImpl__namespace as namespace; + pub use super::__wrapper__DojoModelImpl__tag as tag; + pub use super::__wrapper__DojoModelImpl__version as version; + pub use super::__wrapper__DojoModelImpl__selector as selector; + pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; + pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; + pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; + pub use super::__wrapper__DojoModelImpl__layout as layout; + pub use super::__wrapper__DojoModelImpl__schema as schema; + pub use super::__wrapper__model_with_simple_arrayImpl__ensure_abi as ensure_abi; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl ContractStorageBaseDrop of core::traits::Drop::; +impl ContractStorageBaseCopy of core::traits::Copy::; +impl ContractStorageBaseMutDrop of core::traits::Drop::; +impl ContractStorageBaseMutCopy of core::traits::Copy::; +} + +impl ModelWithByteArrayIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::None + } + + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Struct( + array![ + dojo::database::introspect::FieldLayout { + selector: 512066735765477566404754172672287371265995314501343422459174036873487219331, + layout: dojo::database::introspect::Introspect::::layout() + }, +dojo::database::introspect::FieldLayout { + selector: 1591024729085637502504777720563487898377940395575083379770417352976841400819, + 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: 'ModelWithByteArray', + attrs: array![].span(), + children: array![ + dojo::database::introspect::Member { + name: 'player', + attrs: array!['key'].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'x', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'y', + attrs: array![].span(), + ty: dojo::database::introspect::Ty::ByteArray + } + + ].span() + } + ) + } +} + +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, + 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 `ModelWithByteArray`: 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 { + "ModelWithByteArray" + } + + #[inline(always)] + fn namespace() -> ByteArray { + "test_package" + } + + #[inline(always)] + fn tag() -> ByteArray { + "test_package-ModelWithByteArray" + } + + #[inline(always)] + fn version() -> u8 { + 1 + } + + #[inline(always)] + fn selector() -> felt252 { + 858867864009207556499907034628308336720989886132468668210801974294049151990 + } + + #[inline(always)] + fn instance_selector(self: @ModelWithByteArray) -> felt252 { + Self::selector() + } + + #[inline(always)] + fn name_hash() -> felt252 { + 2176409715042145900636260236501596599545103472111273072320531220776338338674 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 3061092720893075933752785490401950953836105364709575990296000909161416686979 + } + + #[inline(always)] + fn keys(self: @ModelWithByteArray) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.player, ref serialized); + core::array::ArrayTrait::span(@serialized) + } + + #[inline(always)] + fn values(self: @ModelWithByteArray) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.x, ref serialized);core::serde::Serde::serialize(self.y, 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: @ModelWithByteArray) -> 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 Imodel_with_byte_array { + fn ensure_abi(self: @T, model: ModelWithByteArray); +} + +#[starknet::contract] +mod model_with_byte_array { + use super::ModelWithByteArray; + use super::Imodel_with_byte_array; + + #[abi(embed_v0)] + impl DojoModelImpl of dojo::model::IModel{ + fn name(self: @ContractState) -> ByteArray { + dojo::model::Model::::name() + } + + fn namespace(self: @ContractState) -> ByteArray { + dojo::model::Model::::namespace() + } + + fn tag(self: @ContractState) -> ByteArray { + dojo::model::Model::::tag() + } + + fn version(self: @ContractState) -> u8 { + dojo::model::Model::::version() + } + + fn selector(self: @ContractState) -> felt252 { + dojo::model::Model::::selector() + } + + fn name_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::name_hash() + } + + fn namespace_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_hash() + } + + 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 model_with_byte_arrayImpl of Imodel_with_byte_array{ + fn ensure_abi(self: @ContractState, model: ModelWithByteArray) { + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct ContractStorageBase { +} +#[derive(Drop, Copy)] +pub struct ContractStorageBaseMut { +} +impl StorageBaseImpl of starknet::storage::StorageBaseTrait { + type BaseType = ContractStorageBase; + type BaseMutType = ContractStorageBaseMut; + fn storage_base(self: @ContractState) -> ContractStorageBase { + ContractStorageBase { + } + } + fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { + ContractStorageBaseMut { + } + } +} +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = ContractStorageBase; + fn snapshot_deref(self: @ContractState) -> ContractStorageBase { + self.storage_base() + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = ContractStorageBaseMut; + fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { + self.storage_base_mut() + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +use starknet::storage::{ + StorageMapReadAccessTrait, StorageMapWriteAccessTrait, + StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess +}; +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::version(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::unpacked_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::packed_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::layout(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::schema(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__model_with_byte_arrayImpl__ensure_abi(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_model = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + model_with_byte_arrayImpl::ensure_abi(@contract_state, __arg_model); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__DojoModelImpl__name as name; + pub use super::__wrapper__DojoModelImpl__namespace as namespace; + pub use super::__wrapper__DojoModelImpl__tag as tag; + pub use super::__wrapper__DojoModelImpl__version as version; + pub use super::__wrapper__DojoModelImpl__selector as selector; + pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; + pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; + pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; + pub use super::__wrapper__DojoModelImpl__layout as layout; + pub use super::__wrapper__DojoModelImpl__schema as schema; + pub use super::__wrapper__model_with_byte_arrayImpl__ensure_abi as ensure_abi; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl ContractStorageBaseDrop of core::traits::Drop::; +impl ContractStorageBaseCopy of core::traits::Copy::; +impl ContractStorageBaseMutDrop of core::traits::Drop::; +impl ContractStorageBaseMutCopy of core::traits::Copy::; +} + +impl ModelWithComplexArrayIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::None + } + + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Struct( + array![ + dojo::database::introspect::FieldLayout { + selector: 512066735765477566404754172672287371265995314501343422459174036873487219331, + layout: dojo::database::introspect::Introspect::::layout() + }, +dojo::database::introspect::FieldLayout { + selector: 1591024729085637502504777720563487898377940395575083379770417352976841400819, + 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: 'ModelWithComplexArray', + attrs: array![].span(), + children: array![ + dojo::database::introspect::Member { + name: 'player', + attrs: array!['key'].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'x', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'y', + attrs: array![].span(), + ty: dojo::database::introspect::Ty::Array( + array![ + dojo::database::introspect::Introspect::::ty() + ].span() + ) + } + + ].span() + } + ) + } +} + +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, + 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 `ModelWithComplexArray`: 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 { + "ModelWithComplexArray" + } + + #[inline(always)] + fn namespace() -> ByteArray { + "test_package" + } + + #[inline(always)] + fn tag() -> ByteArray { + "test_package-ModelWithComplexArray" + } + + #[inline(always)] + fn version() -> u8 { + 1 + } + + #[inline(always)] + fn selector() -> felt252 { + 298653312264896693167501639402458085580783343254117966446641652721994965516 + } + + #[inline(always)] + fn instance_selector(self: @ModelWithComplexArray) -> felt252 { + Self::selector() + } + + #[inline(always)] + fn name_hash() -> felt252 { + 2866472224509756243720005045848892642397514372569303051745174230372637769655 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 3061092720893075933752785490401950953836105364709575990296000909161416686979 + } + + #[inline(always)] + fn keys(self: @ModelWithComplexArray) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.player, ref serialized); + core::array::ArrayTrait::span(@serialized) + } + + #[inline(always)] + fn values(self: @ModelWithComplexArray) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.x, ref serialized);core::serde::Serde::serialize(self.y, 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: @ModelWithComplexArray) -> 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 Imodel_with_complex_array { + fn ensure_abi(self: @T, model: ModelWithComplexArray); +} + +#[starknet::contract] +mod model_with_complex_array { + use super::ModelWithComplexArray; + use super::Imodel_with_complex_array; + + #[abi(embed_v0)] + impl DojoModelImpl of dojo::model::IModel{ + fn name(self: @ContractState) -> ByteArray { + dojo::model::Model::::name() + } + + fn namespace(self: @ContractState) -> ByteArray { + dojo::model::Model::::namespace() + } + + fn tag(self: @ContractState) -> ByteArray { + dojo::model::Model::::tag() + } + + fn version(self: @ContractState) -> u8 { + dojo::model::Model::::version() + } + + fn selector(self: @ContractState) -> felt252 { + dojo::model::Model::::selector() + } + + fn name_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::name_hash() + } + + fn namespace_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_hash() + } + + 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 model_with_complex_arrayImpl of Imodel_with_complex_array{ + fn ensure_abi(self: @ContractState, model: ModelWithComplexArray) { + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct ContractStorageBase { +} +#[derive(Drop, Copy)] +pub struct ContractStorageBaseMut { +} +impl StorageBaseImpl of starknet::storage::StorageBaseTrait { + type BaseType = ContractStorageBase; + type BaseMutType = ContractStorageBaseMut; + fn storage_base(self: @ContractState) -> ContractStorageBase { + ContractStorageBase { + } + } + fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { + ContractStorageBaseMut { + } + } +} +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = ContractStorageBase; + fn snapshot_deref(self: @ContractState) -> ContractStorageBase { + self.storage_base() + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = ContractStorageBaseMut; + fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { + self.storage_base_mut() + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +use starknet::storage::{ + StorageMapReadAccessTrait, StorageMapWriteAccessTrait, + StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess +}; +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::version(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::unpacked_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::packed_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::layout(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::schema(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__model_with_complex_arrayImpl__ensure_abi(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_model = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + model_with_complex_arrayImpl::ensure_abi(@contract_state, __arg_model); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__DojoModelImpl__name as name; + pub use super::__wrapper__DojoModelImpl__namespace as namespace; + pub use super::__wrapper__DojoModelImpl__tag as tag; + pub use super::__wrapper__DojoModelImpl__version as version; + pub use super::__wrapper__DojoModelImpl__selector as selector; + pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; + pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; + pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; + pub use super::__wrapper__DojoModelImpl__layout as layout; + pub use super::__wrapper__DojoModelImpl__schema as schema; + pub use super::__wrapper__model_with_complex_arrayImpl__ensure_abi as ensure_abi; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl ContractStorageBaseDrop of core::traits::Drop::; +impl ContractStorageBaseCopy of core::traits::Copy::; +impl ContractStorageBaseMutDrop of core::traits::Drop::; +impl ContractStorageBaseMutCopy of core::traits::Copy::; +} + +impl ModelWithTupleIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + Option::Some(4) + } + + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Struct( + array![ + dojo::database::introspect::FieldLayout { + selector: 512066735765477566404754172672287371265995314501343422459174036873487219331, + layout: dojo::database::introspect::Introspect::::layout() + }, +dojo::database::introspect::FieldLayout { + selector: 1591024729085637502504777720563487898377940395575083379770417352976841400819, + layout: dojo::database::introspect::Layout::Tuple( + array![ + dojo::database::introspect::Introspect::::layout(), +dojo::database::introspect::Introspect::::layout(), +dojo::database::introspect::Introspect::::layout() + ].span() + ) + } + ].span() + ) + } + + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Struct( + dojo::database::introspect::Struct { + name: 'ModelWithTuple', + attrs: array![].span(), + children: array![ + dojo::database::introspect::Member { + name: 'player', + attrs: array!['key'].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'x', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'y', + attrs: array![].span(), + ty: dojo::database::introspect::Ty::Tuple( + array![ + dojo::database::introspect::Introspect::::ty(), +dojo::database::introspect::Introspect::::ty(), +dojo::database::introspect::Introspect::::ty() + ].span() + ) + } + + ].span() + } + ) + } +} + +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, + 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 `ModelWithTuple`: 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 { + "ModelWithTuple" + } + + #[inline(always)] + fn namespace() -> ByteArray { + "test_package" + } + + #[inline(always)] + fn tag() -> ByteArray { + "test_package-ModelWithTuple" + } + + #[inline(always)] + fn version() -> u8 { + 1 + } + + #[inline(always)] + fn selector() -> felt252 { + 3520389162382437315776520663535583701836688108885454850509972628400715241 + } + + #[inline(always)] + fn instance_selector(self: @ModelWithTuple) -> felt252 { + Self::selector() + } + + #[inline(always)] + fn name_hash() -> felt252 { + 3222351670132870101782632958288197874250493316621507272653773018669253981260 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 3061092720893075933752785490401950953836105364709575990296000909161416686979 + } + + #[inline(always)] + fn keys(self: @ModelWithTuple) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.player, ref serialized); + core::array::ArrayTrait::span(@serialized) + } + + #[inline(always)] + fn values(self: @ModelWithTuple) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.x, ref serialized);core::serde::Serde::serialize(self.y, 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: @ModelWithTuple) -> 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 Imodel_with_tuple { + fn ensure_abi(self: @T, model: ModelWithTuple); +} + +#[starknet::contract] +mod model_with_tuple { + use super::ModelWithTuple; + use super::Imodel_with_tuple; + + #[abi(embed_v0)] + impl DojoModelImpl of dojo::model::IModel{ + fn name(self: @ContractState) -> ByteArray { + dojo::model::Model::::name() + } + + fn namespace(self: @ContractState) -> ByteArray { + dojo::model::Model::::namespace() + } + + fn tag(self: @ContractState) -> ByteArray { + dojo::model::Model::::tag() + } + + fn version(self: @ContractState) -> u8 { + dojo::model::Model::::version() + } + + fn selector(self: @ContractState) -> felt252 { + dojo::model::Model::::selector() + } + + fn name_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::name_hash() + } + + fn namespace_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_hash() + } + + 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 model_with_tupleImpl of Imodel_with_tuple{ + fn ensure_abi(self: @ContractState, model: ModelWithTuple) { + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct ContractStorageBase { +} +#[derive(Drop, Copy)] +pub struct ContractStorageBaseMut { +} +impl StorageBaseImpl of starknet::storage::StorageBaseTrait { + type BaseType = ContractStorageBase; + type BaseMutType = ContractStorageBaseMut; + fn storage_base(self: @ContractState) -> ContractStorageBase { + ContractStorageBase { + } + } + fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { + ContractStorageBaseMut { + } + } +} +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = ContractStorageBase; + fn snapshot_deref(self: @ContractState) -> ContractStorageBase { + self.storage_base() + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = ContractStorageBaseMut; + fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { + self.storage_base_mut() + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +use starknet::storage::{ + StorageMapReadAccessTrait, StorageMapWriteAccessTrait, + StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess +}; +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::version(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::unpacked_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::packed_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::layout(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::schema(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__model_with_tupleImpl__ensure_abi(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_model = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + model_with_tupleImpl::ensure_abi(@contract_state, __arg_model); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__DojoModelImpl__name as name; + pub use super::__wrapper__DojoModelImpl__namespace as namespace; + pub use super::__wrapper__DojoModelImpl__tag as tag; + pub use super::__wrapper__DojoModelImpl__version as version; + pub use super::__wrapper__DojoModelImpl__selector as selector; + pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; + pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; + pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; + pub use super::__wrapper__DojoModelImpl__layout as layout; + pub use super::__wrapper__DojoModelImpl__schema as schema; + pub use super::__wrapper__model_with_tupleImpl__ensure_abi as ensure_abi; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl ContractStorageBaseDrop of core::traits::Drop::; +impl ContractStorageBaseCopy of core::traits::Copy::; +impl ContractStorageBaseMutDrop of core::traits::Drop::; +impl ContractStorageBaseMutCopy of core::traits::Copy::; +} + +impl ModelWithTupleNoPrimitivesIntrospect<> of dojo::database::introspect::Introspect> { + #[inline(always)] + fn size() -> Option { + let sizes : Array> = array![ + dojo::database::introspect::Introspect::::size(), +Option::Some(3) + ]; + + if dojo::database::utils::any_none(@sizes) { + return Option::None; + } + Option::Some(dojo::database::utils::sum(sizes)) + + } + + fn layout() -> dojo::database::introspect::Layout { + dojo::database::introspect::Layout::Struct( + array![ + dojo::database::introspect::FieldLayout { + selector: 512066735765477566404754172672287371265995314501343422459174036873487219331, + layout: dojo::database::introspect::Introspect::::layout() + }, +dojo::database::introspect::FieldLayout { + selector: 1591024729085637502504777720563487898377940395575083379770417352976841400819, + layout: dojo::database::introspect::Layout::Tuple( + array![ + dojo::database::introspect::Introspect::::layout(), +dojo::database::introspect::Introspect::::layout(), +dojo::database::introspect::Introspect::::layout() + ].span() + ) + } + ].span() + ) + } + + #[inline(always)] + fn ty() -> dojo::database::introspect::Ty { + dojo::database::introspect::Ty::Struct( + dojo::database::introspect::Struct { + name: 'ModelWithTupleNoPrimitives', + attrs: array![].span(), + children: array![ + dojo::database::introspect::Member { + name: 'player', + attrs: array!['key'].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'x', + attrs: array![].span(), + ty: dojo::database::introspect::Introspect::::ty() + }, +dojo::database::introspect::Member { + name: 'y', + attrs: array![].span(), + ty: dojo::database::introspect::Ty::Tuple( + array![ + dojo::database::introspect::Introspect::::ty(), +dojo::database::introspect::Introspect::::ty(), +dojo::database::introspect::Introspect::::ty() + ].span() + ) + } + + ].span() + } + ) + } +} + +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, + 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 `ModelWithTupleNoPrimitives`: 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 { + "ModelWithTupleNoPrimitives" + } + + #[inline(always)] + fn namespace() -> ByteArray { + "test_package" + } + + #[inline(always)] + fn tag() -> ByteArray { + "test_package-ModelWithTupleNoPrimitives" + } + + #[inline(always)] + fn version() -> u8 { + 1 + } + + #[inline(always)] + fn selector() -> felt252 { + 2133652848391750418502705747419625263797079439106286994977255727801602328040 + } + + #[inline(always)] + fn instance_selector(self: @ModelWithTupleNoPrimitives) -> felt252 { + Self::selector() + } + + #[inline(always)] + fn name_hash() -> felt252 { + 157059227407493660591195028728750607977045261142495925435047270200565107096 + } + + #[inline(always)] + fn namespace_hash() -> felt252 { + 3061092720893075933752785490401950953836105364709575990296000909161416686979 + } + + #[inline(always)] + fn keys(self: @ModelWithTupleNoPrimitives) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.player, ref serialized); + core::array::ArrayTrait::span(@serialized) + } + + #[inline(always)] + fn values(self: @ModelWithTupleNoPrimitives) -> Span { + let mut serialized = core::array::ArrayTrait::new(); + core::serde::Serde::serialize(self.x, ref serialized);core::serde::Serde::serialize(self.y, 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: @ModelWithTupleNoPrimitives) -> 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 Imodel_with_tuple_no_primitives { + fn ensure_abi(self: @T, model: ModelWithTupleNoPrimitives); +} + +#[starknet::contract] +mod model_with_tuple_no_primitives { + use super::ModelWithTupleNoPrimitives; + use super::Imodel_with_tuple_no_primitives; + + #[abi(embed_v0)] + impl DojoModelImpl of dojo::model::IModel{ + fn name(self: @ContractState) -> ByteArray { + dojo::model::Model::::name() + } + + fn namespace(self: @ContractState) -> ByteArray { + dojo::model::Model::::namespace() + } + + fn tag(self: @ContractState) -> ByteArray { + dojo::model::Model::::tag() + } + + fn version(self: @ContractState) -> u8 { + dojo::model::Model::::version() + } + + fn selector(self: @ContractState) -> felt252 { + dojo::model::Model::::selector() + } + + fn name_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::name_hash() + } + + fn namespace_hash(self: @ContractState) -> felt252 { + dojo::model::Model::::namespace_hash() + } + + 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 model_with_tuple_no_primitivesImpl of Imodel_with_tuple_no_primitives{ + fn ensure_abi(self: @ContractState, model: ModelWithTupleNoPrimitives) { + } + } +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} + + +pub struct Storage { +} + +#[derive(Drop, Copy)] +pub struct ContractStorageBase { +} +#[derive(Drop, Copy)] +pub struct ContractStorageBaseMut { +} +impl StorageBaseImpl of starknet::storage::StorageBaseTrait { + type BaseType = ContractStorageBase; + type BaseMutType = ContractStorageBaseMut; + fn storage_base(self: @ContractState) -> ContractStorageBase { + ContractStorageBase { + } + } + fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { + ContractStorageBaseMut { + } + } +} +pub struct ContractState { +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = ContractStorageBase; + fn snapshot_deref(self: @ContractState) -> ContractStorageBase { + self.storage_base() + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = ContractStorageBaseMut; + fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { + self.storage_base_mut() + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + } +} + +use starknet::storage::{ + StorageMapReadAccessTrait, StorageMapWriteAccessTrait, + StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess +}; +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__version(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::version(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__unpacked_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::unpacked_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__packed_size(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::packed_size(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::>::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__layout(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::layout(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__DojoModelImpl__schema(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = DojoModelImpl::schema(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__model_with_tuple_no_primitivesImpl__ensure_abi(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_model = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + model_with_tuple_no_primitivesImpl::ensure_abi(@contract_state, __arg_model); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__DojoModelImpl__name as name; + pub use super::__wrapper__DojoModelImpl__namespace as namespace; + pub use super::__wrapper__DojoModelImpl__tag as tag; + pub use super::__wrapper__DojoModelImpl__version as version; + pub use super::__wrapper__DojoModelImpl__selector as selector; + pub use super::__wrapper__DojoModelImpl__name_hash as name_hash; + pub use super::__wrapper__DojoModelImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__DojoModelImpl__unpacked_size as unpacked_size; + pub use super::__wrapper__DojoModelImpl__packed_size as packed_size; + pub use super::__wrapper__DojoModelImpl__layout as layout; + pub use super::__wrapper__DojoModelImpl__schema as schema; + pub use super::__wrapper__model_with_tuple_no_primitivesImpl__ensure_abi as ensure_abi; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl ContractStorageBaseDrop of core::traits::Drop::; +impl ContractStorageBaseCopy of core::traits::Copy::; +impl ContractStorageBaseMutDrop of core::traits::Drop::; +impl ContractStorageBaseMutCopy of core::traits::Copy::; +} +trait Ibad_model_multiple_versionsDispatcherTrait { + fn ensure_abi(self: T, model: BadModelMultipleVersions); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Ibad_model_multiple_versionsDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl Ibad_model_multiple_versionsDispatcherImpl of Ibad_model_multiple_versionsDispatcherTrait { + fn ensure_abi(self: Ibad_model_multiple_versionsDispatcher, model: BadModelMultipleVersions) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Ibad_model_multiple_versionsLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl Ibad_model_multiple_versionsLibraryDispatcherImpl of Ibad_model_multiple_versionsDispatcherTrait { + fn ensure_abi(self: Ibad_model_multiple_versionsLibraryDispatcher, model: BadModelMultipleVersions) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +trait Ibad_model_multiple_versionsSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn ensure_abi(self: T, model: BadModelMultipleVersions) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Ibad_model_multiple_versionsSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl Ibad_model_multiple_versionsSafeLibraryDispatcherImpl of Ibad_model_multiple_versionsSafeDispatcherTrait { + fn ensure_abi(self: Ibad_model_multiple_versionsSafeLibraryDispatcher, model: BadModelMultipleVersions) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Ibad_model_multiple_versionsSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl Ibad_model_multiple_versionsSafeDispatcherImpl of Ibad_model_multiple_versionsSafeDispatcherTrait { + fn ensure_abi(self: Ibad_model_multiple_versionsSafeDispatcher, model: BadModelMultipleVersions) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +trait Ibad_model_bad_version_typeDispatcherTrait { + fn ensure_abi(self: T, model: BadModelBadVersionType); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Ibad_model_bad_version_typeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl Ibad_model_bad_version_typeDispatcherImpl of Ibad_model_bad_version_typeDispatcherTrait { + fn ensure_abi(self: Ibad_model_bad_version_typeDispatcher, model: BadModelBadVersionType) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Ibad_model_bad_version_typeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl Ibad_model_bad_version_typeLibraryDispatcherImpl of Ibad_model_bad_version_typeDispatcherTrait { + fn ensure_abi(self: Ibad_model_bad_version_typeLibraryDispatcher, model: BadModelBadVersionType) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +trait Ibad_model_bad_version_typeSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn ensure_abi(self: T, model: BadModelBadVersionType) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Ibad_model_bad_version_typeSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl Ibad_model_bad_version_typeSafeLibraryDispatcherImpl of Ibad_model_bad_version_typeSafeDispatcherTrait { + fn ensure_abi(self: Ibad_model_bad_version_typeSafeLibraryDispatcher, model: BadModelBadVersionType) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Ibad_model_bad_version_typeSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl Ibad_model_bad_version_typeSafeDispatcherImpl of Ibad_model_bad_version_typeSafeDispatcherTrait { + fn ensure_abi(self: Ibad_model_bad_version_typeSafeDispatcher, model: BadModelBadVersionType) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +trait Ibad_model_no_version_valueDispatcherTrait { + fn ensure_abi(self: T, model: BadModelNoVersionValue); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Ibad_model_no_version_valueDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl Ibad_model_no_version_valueDispatcherImpl of Ibad_model_no_version_valueDispatcherTrait { + fn ensure_abi(self: Ibad_model_no_version_valueDispatcher, model: BadModelNoVersionValue) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Ibad_model_no_version_valueLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl Ibad_model_no_version_valueLibraryDispatcherImpl of Ibad_model_no_version_valueDispatcherTrait { + fn ensure_abi(self: Ibad_model_no_version_valueLibraryDispatcher, model: BadModelNoVersionValue) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +trait Ibad_model_no_version_valueSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn ensure_abi(self: T, model: BadModelNoVersionValue) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Ibad_model_no_version_valueSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl Ibad_model_no_version_valueSafeLibraryDispatcherImpl of Ibad_model_no_version_valueSafeDispatcherTrait { + fn ensure_abi(self: Ibad_model_no_version_valueSafeLibraryDispatcher, model: BadModelNoVersionValue) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Ibad_model_no_version_valueSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl Ibad_model_no_version_valueSafeDispatcherImpl of Ibad_model_no_version_valueSafeDispatcherTrait { + fn ensure_abi(self: Ibad_model_no_version_valueSafeDispatcher, model: BadModelNoVersionValue) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +trait Ibad_model_unexpected_arg_with_valueDispatcherTrait { + fn ensure_abi(self: T, model: BadModelUnexpectedArgWithValue); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Ibad_model_unexpected_arg_with_valueDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl Ibad_model_unexpected_arg_with_valueDispatcherImpl of Ibad_model_unexpected_arg_with_valueDispatcherTrait { + fn ensure_abi(self: Ibad_model_unexpected_arg_with_valueDispatcher, model: BadModelUnexpectedArgWithValue) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Ibad_model_unexpected_arg_with_valueLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl Ibad_model_unexpected_arg_with_valueLibraryDispatcherImpl of Ibad_model_unexpected_arg_with_valueDispatcherTrait { + fn ensure_abi(self: Ibad_model_unexpected_arg_with_valueLibraryDispatcher, model: BadModelUnexpectedArgWithValue) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +trait Ibad_model_unexpected_arg_with_valueSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn ensure_abi(self: T, model: BadModelUnexpectedArgWithValue) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcherImpl of Ibad_model_unexpected_arg_with_valueSafeDispatcherTrait { + fn ensure_abi(self: Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcher, model: BadModelUnexpectedArgWithValue) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Ibad_model_unexpected_arg_with_valueSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl Ibad_model_unexpected_arg_with_valueSafeDispatcherImpl of Ibad_model_unexpected_arg_with_valueSafeDispatcherTrait { + fn ensure_abi(self: Ibad_model_unexpected_arg_with_valueSafeDispatcher, model: BadModelUnexpectedArgWithValue) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +trait Ibad_model_unexpected_argDispatcherTrait { + fn ensure_abi(self: T, model: BadModelUnexpectedArg); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Ibad_model_unexpected_argDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl Ibad_model_unexpected_argDispatcherImpl of Ibad_model_unexpected_argDispatcherTrait { + fn ensure_abi(self: Ibad_model_unexpected_argDispatcher, model: BadModelUnexpectedArg) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Ibad_model_unexpected_argLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl Ibad_model_unexpected_argLibraryDispatcherImpl of Ibad_model_unexpected_argDispatcherTrait { + fn ensure_abi(self: Ibad_model_unexpected_argLibraryDispatcher, model: BadModelUnexpectedArg) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +trait Ibad_model_unexpected_argSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn ensure_abi(self: T, model: BadModelUnexpectedArg) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Ibad_model_unexpected_argSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl Ibad_model_unexpected_argSafeLibraryDispatcherImpl of Ibad_model_unexpected_argSafeDispatcherTrait { + fn ensure_abi(self: Ibad_model_unexpected_argSafeLibraryDispatcher, model: BadModelUnexpectedArg) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Ibad_model_unexpected_argSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl Ibad_model_unexpected_argSafeDispatcherImpl of Ibad_model_unexpected_argSafeDispatcherTrait { + fn ensure_abi(self: Ibad_model_unexpected_argSafeDispatcher, model: BadModelUnexpectedArg) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +trait Ibad_model_not_supported_versionDispatcherTrait { + fn ensure_abi(self: T, model: BadModelNotSupportedVersion); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Ibad_model_not_supported_versionDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl Ibad_model_not_supported_versionDispatcherImpl of Ibad_model_not_supported_versionDispatcherTrait { + fn ensure_abi(self: Ibad_model_not_supported_versionDispatcher, model: BadModelNotSupportedVersion) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Ibad_model_not_supported_versionLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl Ibad_model_not_supported_versionLibraryDispatcherImpl of Ibad_model_not_supported_versionDispatcherTrait { + fn ensure_abi(self: Ibad_model_not_supported_versionLibraryDispatcher, model: BadModelNotSupportedVersion) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +trait Ibad_model_not_supported_versionSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn ensure_abi(self: T, model: BadModelNotSupportedVersion) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Ibad_model_not_supported_versionSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl Ibad_model_not_supported_versionSafeLibraryDispatcherImpl of Ibad_model_not_supported_versionSafeDispatcherTrait { + fn ensure_abi(self: Ibad_model_not_supported_versionSafeLibraryDispatcher, model: BadModelNotSupportedVersion) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Ibad_model_not_supported_versionSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl Ibad_model_not_supported_versionSafeDispatcherImpl of Ibad_model_not_supported_versionSafeDispatcherTrait { + fn ensure_abi(self: Ibad_model_not_supported_versionSafeDispatcher, model: BadModelNotSupportedVersion) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +trait Imodelv_0DispatcherTrait { + fn ensure_abi(self: T, model: Modelv0); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodelv_0Dispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl Imodelv_0DispatcherImpl of Imodelv_0DispatcherTrait { + fn ensure_abi(self: Imodelv_0Dispatcher, model: Modelv0) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodelv_0LibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl Imodelv_0LibraryDispatcherImpl of Imodelv_0DispatcherTrait { + fn ensure_abi(self: Imodelv_0LibraryDispatcher, model: Modelv0) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +trait Imodelv_0SafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn ensure_abi(self: T, model: Modelv0) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodelv_0SafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl Imodelv_0SafeLibraryDispatcherImpl of Imodelv_0SafeDispatcherTrait { + fn ensure_abi(self: Imodelv_0SafeLibraryDispatcher, model: Modelv0) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodelv_0SafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl Imodelv_0SafeDispatcherImpl of Imodelv_0SafeDispatcherTrait { + fn ensure_abi(self: Imodelv_0SafeDispatcher, model: Modelv0) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +trait Imodel_with_bad_namespace_formatDispatcherTrait { + fn ensure_abi(self: T, model: ModelWithBadNamespaceFormat); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodel_with_bad_namespace_formatDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl Imodel_with_bad_namespace_formatDispatcherImpl of Imodel_with_bad_namespace_formatDispatcherTrait { + fn ensure_abi(self: Imodel_with_bad_namespace_formatDispatcher, model: ModelWithBadNamespaceFormat) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodel_with_bad_namespace_formatLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl Imodel_with_bad_namespace_formatLibraryDispatcherImpl of Imodel_with_bad_namespace_formatDispatcherTrait { + fn ensure_abi(self: Imodel_with_bad_namespace_formatLibraryDispatcher, model: ModelWithBadNamespaceFormat) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +trait Imodel_with_bad_namespace_formatSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn ensure_abi(self: T, model: ModelWithBadNamespaceFormat) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodel_with_bad_namespace_formatSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl Imodel_with_bad_namespace_formatSafeLibraryDispatcherImpl of Imodel_with_bad_namespace_formatSafeDispatcherTrait { + fn ensure_abi(self: Imodel_with_bad_namespace_formatSafeLibraryDispatcher, model: ModelWithBadNamespaceFormat) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodel_with_bad_namespace_formatSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl Imodel_with_bad_namespace_formatSafeDispatcherImpl of Imodel_with_bad_namespace_formatSafeDispatcherTrait { + fn ensure_abi(self: Imodel_with_bad_namespace_formatSafeDispatcher, model: ModelWithBadNamespaceFormat) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +trait Imodel_with_short_string_namespaceDispatcherTrait { + fn ensure_abi(self: T, model: ModelWithShortStringNamespace); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodel_with_short_string_namespaceDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl Imodel_with_short_string_namespaceDispatcherImpl of Imodel_with_short_string_namespaceDispatcherTrait { + fn ensure_abi(self: Imodel_with_short_string_namespaceDispatcher, model: ModelWithShortStringNamespace) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodel_with_short_string_namespaceLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl Imodel_with_short_string_namespaceLibraryDispatcherImpl of Imodel_with_short_string_namespaceDispatcherTrait { + fn ensure_abi(self: Imodel_with_short_string_namespaceLibraryDispatcher, model: ModelWithShortStringNamespace) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +trait Imodel_with_short_string_namespaceSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn ensure_abi(self: T, model: ModelWithShortStringNamespace) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodel_with_short_string_namespaceSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl Imodel_with_short_string_namespaceSafeLibraryDispatcherImpl of Imodel_with_short_string_namespaceSafeDispatcherTrait { + fn ensure_abi(self: Imodel_with_short_string_namespaceSafeLibraryDispatcher, model: ModelWithShortStringNamespace) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodel_with_short_string_namespaceSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl Imodel_with_short_string_namespaceSafeDispatcherImpl of Imodel_with_short_string_namespaceSafeDispatcherTrait { + fn ensure_abi(self: Imodel_with_short_string_namespaceSafeDispatcher, model: ModelWithShortStringNamespace) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +trait Imodel_with_string_namespaceDispatcherTrait { + fn ensure_abi(self: T, model: ModelWithStringNamespace); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodel_with_string_namespaceDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl Imodel_with_string_namespaceDispatcherImpl of Imodel_with_string_namespaceDispatcherTrait { + fn ensure_abi(self: Imodel_with_string_namespaceDispatcher, model: ModelWithStringNamespace) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodel_with_string_namespaceLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl Imodel_with_string_namespaceLibraryDispatcherImpl of Imodel_with_string_namespaceDispatcherTrait { + fn ensure_abi(self: Imodel_with_string_namespaceLibraryDispatcher, model: ModelWithStringNamespace) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +trait Imodel_with_string_namespaceSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn ensure_abi(self: T, model: ModelWithStringNamespace) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodel_with_string_namespaceSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl Imodel_with_string_namespaceSafeLibraryDispatcherImpl of Imodel_with_string_namespaceSafeDispatcherTrait { + fn ensure_abi(self: Imodel_with_string_namespaceSafeLibraryDispatcher, model: ModelWithStringNamespace) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodel_with_string_namespaceSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl Imodel_with_string_namespaceSafeDispatcherImpl of Imodel_with_string_namespaceSafeDispatcherTrait { + fn ensure_abi(self: Imodel_with_string_namespaceSafeDispatcher, model: ModelWithStringNamespace) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +trait IpositionDispatcherTrait { + fn ensure_abi(self: T, model: Position); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IpositionDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IpositionDispatcherImpl of IpositionDispatcherTrait { + fn ensure_abi(self: IpositionDispatcher, model: Position) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IpositionLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IpositionLibraryDispatcherImpl of IpositionDispatcherTrait { + fn ensure_abi(self: IpositionLibraryDispatcher, model: Position) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +trait IpositionSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn ensure_abi(self: T, model: Position) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IpositionSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IpositionSafeLibraryDispatcherImpl of IpositionSafeDispatcherTrait { + fn ensure_abi(self: IpositionSafeLibraryDispatcher, model: Position) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IpositionSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IpositionSafeDispatcherImpl of IpositionSafeDispatcherTrait { + fn ensure_abi(self: IpositionSafeDispatcher, model: Position) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +trait IrolesDispatcherTrait { + fn ensure_abi(self: T, model: Roles); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IrolesDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IrolesDispatcherImpl of IrolesDispatcherTrait { + fn ensure_abi(self: IrolesDispatcher, model: Roles) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IrolesLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IrolesLibraryDispatcherImpl of IrolesDispatcherTrait { + fn ensure_abi(self: IrolesLibraryDispatcher, model: Roles) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +trait IrolesSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn ensure_abi(self: T, model: Roles) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IrolesSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IrolesSafeLibraryDispatcherImpl of IrolesSafeDispatcherTrait { + fn ensure_abi(self: IrolesSafeLibraryDispatcher, model: Roles) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IrolesSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IrolesSafeDispatcherImpl of IrolesSafeDispatcherTrait { + fn ensure_abi(self: IrolesSafeDispatcher, model: Roles) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +trait Ionly_key_modelDispatcherTrait { + fn ensure_abi(self: T, model: OnlyKeyModel); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Ionly_key_modelDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl Ionly_key_modelDispatcherImpl of Ionly_key_modelDispatcherTrait { + fn ensure_abi(self: Ionly_key_modelDispatcher, model: OnlyKeyModel) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Ionly_key_modelLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl Ionly_key_modelLibraryDispatcherImpl of Ionly_key_modelDispatcherTrait { + fn ensure_abi(self: Ionly_key_modelLibraryDispatcher, model: OnlyKeyModel) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +trait Ionly_key_modelSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn ensure_abi(self: T, model: OnlyKeyModel) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Ionly_key_modelSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl Ionly_key_modelSafeLibraryDispatcherImpl of Ionly_key_modelSafeDispatcherTrait { + fn ensure_abi(self: Ionly_key_modelSafeLibraryDispatcher, model: OnlyKeyModel) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Ionly_key_modelSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl Ionly_key_modelSafeDispatcherImpl of Ionly_key_modelSafeDispatcherTrait { + fn ensure_abi(self: Ionly_key_modelSafeDispatcher, model: OnlyKeyModel) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +trait Iu_256_key_modelDispatcherTrait { + fn ensure_abi(self: T, model: U256KeyModel); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Iu_256_key_modelDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl Iu_256_key_modelDispatcherImpl of Iu_256_key_modelDispatcherTrait { + fn ensure_abi(self: Iu_256_key_modelDispatcher, model: U256KeyModel) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Iu_256_key_modelLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl Iu_256_key_modelLibraryDispatcherImpl of Iu_256_key_modelDispatcherTrait { + fn ensure_abi(self: Iu_256_key_modelLibraryDispatcher, model: U256KeyModel) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +trait Iu_256_key_modelSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn ensure_abi(self: T, model: U256KeyModel) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Iu_256_key_modelSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl Iu_256_key_modelSafeLibraryDispatcherImpl of Iu_256_key_modelSafeDispatcherTrait { + fn ensure_abi(self: Iu_256_key_modelSafeLibraryDispatcher, model: U256KeyModel) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Iu_256_key_modelSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl Iu_256_key_modelSafeDispatcherImpl of Iu_256_key_modelSafeDispatcherTrait { + fn ensure_abi(self: Iu_256_key_modelSafeDispatcher, model: U256KeyModel) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +trait IplayerDispatcherTrait { + fn ensure_abi(self: T, model: Player); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IplayerDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IplayerDispatcherImpl of IplayerDispatcherTrait { + fn ensure_abi(self: IplayerDispatcher, model: Player) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IplayerLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IplayerLibraryDispatcherImpl of IplayerDispatcherTrait { + fn ensure_abi(self: IplayerLibraryDispatcher, model: Player) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +trait IplayerSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn ensure_abi(self: T, model: Player) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IplayerSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IplayerSafeLibraryDispatcherImpl of IplayerSafeDispatcherTrait { + fn ensure_abi(self: IplayerSafeLibraryDispatcher, model: Player) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IplayerSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IplayerSafeDispatcherImpl of IplayerSafeDispatcherTrait { + fn ensure_abi(self: IplayerSafeDispatcher, model: Player) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +trait Imodel_with_simple_arrayDispatcherTrait { + fn ensure_abi(self: T, model: ModelWithSimpleArray); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodel_with_simple_arrayDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl Imodel_with_simple_arrayDispatcherImpl of Imodel_with_simple_arrayDispatcherTrait { + fn ensure_abi(self: Imodel_with_simple_arrayDispatcher, model: ModelWithSimpleArray) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodel_with_simple_arrayLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl Imodel_with_simple_arrayLibraryDispatcherImpl of Imodel_with_simple_arrayDispatcherTrait { + fn ensure_abi(self: Imodel_with_simple_arrayLibraryDispatcher, model: ModelWithSimpleArray) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +trait Imodel_with_simple_arraySafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn ensure_abi(self: T, model: ModelWithSimpleArray) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodel_with_simple_arraySafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl Imodel_with_simple_arraySafeLibraryDispatcherImpl of Imodel_with_simple_arraySafeDispatcherTrait { + fn ensure_abi(self: Imodel_with_simple_arraySafeLibraryDispatcher, model: ModelWithSimpleArray) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodel_with_simple_arraySafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl Imodel_with_simple_arraySafeDispatcherImpl of Imodel_with_simple_arraySafeDispatcherTrait { + fn ensure_abi(self: Imodel_with_simple_arraySafeDispatcher, model: ModelWithSimpleArray) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +trait Imodel_with_byte_arrayDispatcherTrait { + fn ensure_abi(self: T, model: ModelWithByteArray); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodel_with_byte_arrayDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl Imodel_with_byte_arrayDispatcherImpl of Imodel_with_byte_arrayDispatcherTrait { + fn ensure_abi(self: Imodel_with_byte_arrayDispatcher, model: ModelWithByteArray) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodel_with_byte_arrayLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl Imodel_with_byte_arrayLibraryDispatcherImpl of Imodel_with_byte_arrayDispatcherTrait { + fn ensure_abi(self: Imodel_with_byte_arrayLibraryDispatcher, model: ModelWithByteArray) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +trait Imodel_with_byte_arraySafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn ensure_abi(self: T, model: ModelWithByteArray) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodel_with_byte_arraySafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl Imodel_with_byte_arraySafeLibraryDispatcherImpl of Imodel_with_byte_arraySafeDispatcherTrait { + fn ensure_abi(self: Imodel_with_byte_arraySafeLibraryDispatcher, model: ModelWithByteArray) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodel_with_byte_arraySafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl Imodel_with_byte_arraySafeDispatcherImpl of Imodel_with_byte_arraySafeDispatcherTrait { + fn ensure_abi(self: Imodel_with_byte_arraySafeDispatcher, model: ModelWithByteArray) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +trait Imodel_with_complex_arrayDispatcherTrait { + fn ensure_abi(self: T, model: ModelWithComplexArray); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodel_with_complex_arrayDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl Imodel_with_complex_arrayDispatcherImpl of Imodel_with_complex_arrayDispatcherTrait { + fn ensure_abi(self: Imodel_with_complex_arrayDispatcher, model: ModelWithComplexArray) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodel_with_complex_arrayLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl Imodel_with_complex_arrayLibraryDispatcherImpl of Imodel_with_complex_arrayDispatcherTrait { + fn ensure_abi(self: Imodel_with_complex_arrayLibraryDispatcher, model: ModelWithComplexArray) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +trait Imodel_with_complex_arraySafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn ensure_abi(self: T, model: ModelWithComplexArray) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodel_with_complex_arraySafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:9:1 -#[dojo::model(version: 0, version: 0)] -^************************************^ +impl Imodel_with_complex_arraySafeLibraryDispatcherImpl of Imodel_with_complex_arraySafeDispatcherTrait { + fn ensure_abi(self: Imodel_with_complex_arraySafeLibraryDispatcher, model: ModelWithComplexArray) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:16:1 -#[dojo::model(version: hello)] -^****************************^ + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:23:1 -#[dojo::model(version)] -^*********************^ +} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:30:1 -#[dojo::model(my_arg: 1)] -^***********************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:37:1 -#[dojo::model(my_arg)] -^********************^ +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodel_with_complex_arraySafeDispatcher { + pub contract_address: starknet::ContractAddress, +} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:44:1 -#[dojo::model(version: 2)] -^************************^ +impl Imodel_with_complex_arraySafeDispatcherImpl of Imodel_with_complex_arraySafeDispatcherTrait { + fn ensure_abi(self: Imodel_with_complex_arraySafeDispatcher, model: ModelWithComplexArray) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:51:1 -#[dojo::model(version: 0)] -^************************^ + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:58:1 -#[dojo::model(namespace: 'MyNamespace')] -^**************************************^ +} +trait Imodel_with_tupleDispatcherTrait { + fn ensure_abi(self: T, model: ModelWithTuple); +} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:65:1 -#[dojo::model(namespace: 'my_namespace')] -^***************************************^ +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodel_with_tupleDispatcher { + pub contract_address: starknet::ContractAddress, +} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:72:1 -#[dojo::model(namespace: "my_namespace")] -^***************************************^ +impl Imodel_with_tupleDispatcherImpl of Imodel_with_tupleDispatcherTrait { + fn ensure_abi(self: Imodel_with_tupleDispatcher, model: ModelWithTuple) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:79:1 -#[dojo::model] -^************^ + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:86:1 -#[dojo::model] -^************^ +} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:91:1 -#[dojo::model] -^************^ +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodel_with_tupleLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:97:1 -#[dojo::model] -^************^ +impl Imodel_with_tupleLibraryDispatcherImpl of Imodel_with_tupleDispatcherTrait { + fn ensure_abi(self: Imodel_with_tupleLibraryDispatcher, model: ModelWithTuple) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:103:1 -#[dojo::model] -^************^ + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:112:1 -#[dojo::model] -^************^ +} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:115:1 -#[dojo::model] -^************^ +trait Imodel_with_tupleSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn ensure_abi(self: T, model: ModelWithTuple) -> starknet::SyscallResult<()>; +} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:123:1 -#[dojo::model] -^************^ +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodel_with_tupleSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:131:1 -#[dojo::model] -^************^ +impl Imodel_with_tupleSafeLibraryDispatcherImpl of Imodel_with_tupleSafeDispatcherTrait { + fn ensure_abi(self: Imodel_with_tupleSafeLibraryDispatcher, model: ModelWithTuple) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:139:1 -#[dojo::model] -^************^ + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:147:1 -#[dojo::model] -^************^ +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodel_with_tupleSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl Imodel_with_tupleSafeDispatcherImpl of Imodel_with_tupleSafeDispatcherTrait { + fn ensure_abi(self: Imodel_with_tupleSafeDispatcher, model: ModelWithTuple) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +trait Imodel_with_tuple_no_primitivesDispatcherTrait { + fn ensure_abi(self: T, model: ModelWithTupleNoPrimitives); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodel_with_tuple_no_primitivesDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl Imodel_with_tuple_no_primitivesDispatcherImpl of Imodel_with_tuple_no_primitivesDispatcherTrait { + fn ensure_abi(self: Imodel_with_tuple_no_primitivesDispatcher, model: ModelWithTupleNoPrimitives) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodel_with_tuple_no_primitivesLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl Imodel_with_tuple_no_primitivesLibraryDispatcherImpl of Imodel_with_tuple_no_primitivesDispatcherTrait { + fn ensure_abi(self: Imodel_with_tuple_no_primitivesLibraryDispatcher, model: ModelWithTupleNoPrimitives) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +trait Imodel_with_tuple_no_primitivesSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn ensure_abi(self: T, model: ModelWithTupleNoPrimitives) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodel_with_tuple_no_primitivesSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl Imodel_with_tuple_no_primitivesSafeLibraryDispatcherImpl of Imodel_with_tuple_no_primitivesSafeDispatcherTrait { + fn ensure_abi(self: Imodel_with_tuple_no_primitivesSafeLibraryDispatcher, model: ModelWithTupleNoPrimitives) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct Imodel_with_tuple_no_primitivesSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl Imodel_with_tuple_no_primitivesSafeDispatcherImpl of Imodel_with_tuple_no_primitivesSafeDispatcherTrait { + fn ensure_abi(self: Imodel_with_tuple_no_primitivesSafeDispatcher, model: ModelWithTupleNoPrimitives) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@model, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("ensure_abi"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +impl Ibad_model_multiple_versionsDispatcherCopy of core::traits::Copy::; +impl Ibad_model_multiple_versionsDispatcherDrop of core::traits::Drop::; +impl Ibad_model_multiple_versionsDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Ibad_model_multiple_versionsDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Ibad_model_multiple_versionsDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIbad_model_multiple_versionsDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Ibad_model_multiple_versionsDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_multiple_versionsDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Ibad_model_multiple_versionsDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_multiple_versionsDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIbad_model_multiple_versionsDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Ibad_model_multiple_versionsLibraryDispatcherCopy of core::traits::Copy::; +impl Ibad_model_multiple_versionsLibraryDispatcherDrop of core::traits::Drop::; +impl Ibad_model_multiple_versionsLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Ibad_model_multiple_versionsLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Ibad_model_multiple_versionsLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIbad_model_multiple_versionsLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Ibad_model_multiple_versionsLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_multiple_versionsLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Ibad_model_multiple_versionsLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_multiple_versionsLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIbad_model_multiple_versionsLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Ibad_model_multiple_versionsSafeLibraryDispatcherCopy of core::traits::Copy::; +impl Ibad_model_multiple_versionsSafeLibraryDispatcherDrop of core::traits::Drop::; +impl Ibad_model_multiple_versionsSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Ibad_model_multiple_versionsSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Ibad_model_multiple_versionsSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIbad_model_multiple_versionsSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Ibad_model_multiple_versionsSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_multiple_versionsSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Ibad_model_multiple_versionsSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_multiple_versionsSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIbad_model_multiple_versionsSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Ibad_model_multiple_versionsSafeDispatcherCopy of core::traits::Copy::; +impl Ibad_model_multiple_versionsSafeDispatcherDrop of core::traits::Drop::; +impl Ibad_model_multiple_versionsSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Ibad_model_multiple_versionsSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Ibad_model_multiple_versionsSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIbad_model_multiple_versionsSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Ibad_model_multiple_versionsSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_multiple_versionsSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Ibad_model_multiple_versionsSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_multiple_versionsSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIbad_model_multiple_versionsSafeDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Ibad_model_bad_version_typeDispatcherCopy of core::traits::Copy::; +impl Ibad_model_bad_version_typeDispatcherDrop of core::traits::Drop::; +impl Ibad_model_bad_version_typeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Ibad_model_bad_version_typeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Ibad_model_bad_version_typeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIbad_model_bad_version_typeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Ibad_model_bad_version_typeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_bad_version_typeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Ibad_model_bad_version_typeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_bad_version_typeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIbad_model_bad_version_typeDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Ibad_model_bad_version_typeLibraryDispatcherCopy of core::traits::Copy::; +impl Ibad_model_bad_version_typeLibraryDispatcherDrop of core::traits::Drop::; +impl Ibad_model_bad_version_typeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Ibad_model_bad_version_typeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Ibad_model_bad_version_typeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIbad_model_bad_version_typeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Ibad_model_bad_version_typeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_bad_version_typeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Ibad_model_bad_version_typeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_bad_version_typeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIbad_model_bad_version_typeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Ibad_model_bad_version_typeSafeLibraryDispatcherCopy of core::traits::Copy::; +impl Ibad_model_bad_version_typeSafeLibraryDispatcherDrop of core::traits::Drop::; +impl Ibad_model_bad_version_typeSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Ibad_model_bad_version_typeSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Ibad_model_bad_version_typeSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIbad_model_bad_version_typeSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Ibad_model_bad_version_typeSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_bad_version_typeSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Ibad_model_bad_version_typeSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_bad_version_typeSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIbad_model_bad_version_typeSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Ibad_model_bad_version_typeSafeDispatcherCopy of core::traits::Copy::; +impl Ibad_model_bad_version_typeSafeDispatcherDrop of core::traits::Drop::; +impl Ibad_model_bad_version_typeSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Ibad_model_bad_version_typeSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Ibad_model_bad_version_typeSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIbad_model_bad_version_typeSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Ibad_model_bad_version_typeSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_bad_version_typeSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Ibad_model_bad_version_typeSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_bad_version_typeSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIbad_model_bad_version_typeSafeDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Ibad_model_no_version_valueDispatcherCopy of core::traits::Copy::; +impl Ibad_model_no_version_valueDispatcherDrop of core::traits::Drop::; +impl Ibad_model_no_version_valueDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Ibad_model_no_version_valueDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Ibad_model_no_version_valueDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIbad_model_no_version_valueDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Ibad_model_no_version_valueDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_no_version_valueDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Ibad_model_no_version_valueDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_no_version_valueDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIbad_model_no_version_valueDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Ibad_model_no_version_valueLibraryDispatcherCopy of core::traits::Copy::; +impl Ibad_model_no_version_valueLibraryDispatcherDrop of core::traits::Drop::; +impl Ibad_model_no_version_valueLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Ibad_model_no_version_valueLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Ibad_model_no_version_valueLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIbad_model_no_version_valueLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Ibad_model_no_version_valueLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_no_version_valueLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Ibad_model_no_version_valueLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_no_version_valueLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIbad_model_no_version_valueLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Ibad_model_no_version_valueSafeLibraryDispatcherCopy of core::traits::Copy::; +impl Ibad_model_no_version_valueSafeLibraryDispatcherDrop of core::traits::Drop::; +impl Ibad_model_no_version_valueSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Ibad_model_no_version_valueSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Ibad_model_no_version_valueSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIbad_model_no_version_valueSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Ibad_model_no_version_valueSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_no_version_valueSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Ibad_model_no_version_valueSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_no_version_valueSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIbad_model_no_version_valueSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Ibad_model_no_version_valueSafeDispatcherCopy of core::traits::Copy::; +impl Ibad_model_no_version_valueSafeDispatcherDrop of core::traits::Drop::; +impl Ibad_model_no_version_valueSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Ibad_model_no_version_valueSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Ibad_model_no_version_valueSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIbad_model_no_version_valueSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Ibad_model_no_version_valueSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_no_version_valueSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Ibad_model_no_version_valueSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_no_version_valueSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIbad_model_no_version_valueSafeDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Ibad_model_unexpected_arg_with_valueDispatcherCopy of core::traits::Copy::; +impl Ibad_model_unexpected_arg_with_valueDispatcherDrop of core::traits::Drop::; +impl Ibad_model_unexpected_arg_with_valueDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Ibad_model_unexpected_arg_with_valueDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Ibad_model_unexpected_arg_with_valueDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIbad_model_unexpected_arg_with_valueDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Ibad_model_unexpected_arg_with_valueDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_unexpected_arg_with_valueDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Ibad_model_unexpected_arg_with_valueDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_unexpected_arg_with_valueDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIbad_model_unexpected_arg_with_valueDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Ibad_model_unexpected_arg_with_valueLibraryDispatcherCopy of core::traits::Copy::; +impl Ibad_model_unexpected_arg_with_valueLibraryDispatcherDrop of core::traits::Drop::; +impl Ibad_model_unexpected_arg_with_valueLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Ibad_model_unexpected_arg_with_valueLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Ibad_model_unexpected_arg_with_valueLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIbad_model_unexpected_arg_with_valueLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Ibad_model_unexpected_arg_with_valueLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_unexpected_arg_with_valueLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Ibad_model_unexpected_arg_with_valueLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_unexpected_arg_with_valueLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIbad_model_unexpected_arg_with_valueLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcherCopy of core::traits::Copy::; +impl Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcherDrop of core::traits::Drop::; +impl Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIbad_model_unexpected_arg_with_valueSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_unexpected_arg_with_valueSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIbad_model_unexpected_arg_with_valueSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Ibad_model_unexpected_arg_with_valueSafeDispatcherCopy of core::traits::Copy::; +impl Ibad_model_unexpected_arg_with_valueSafeDispatcherDrop of core::traits::Drop::; +impl Ibad_model_unexpected_arg_with_valueSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Ibad_model_unexpected_arg_with_valueSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Ibad_model_unexpected_arg_with_valueSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIbad_model_unexpected_arg_with_valueSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Ibad_model_unexpected_arg_with_valueSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_unexpected_arg_with_valueSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Ibad_model_unexpected_arg_with_valueSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_unexpected_arg_with_valueSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIbad_model_unexpected_arg_with_valueSafeDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Ibad_model_unexpected_argDispatcherCopy of core::traits::Copy::; +impl Ibad_model_unexpected_argDispatcherDrop of core::traits::Drop::; +impl Ibad_model_unexpected_argDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Ibad_model_unexpected_argDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Ibad_model_unexpected_argDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIbad_model_unexpected_argDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Ibad_model_unexpected_argDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_unexpected_argDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Ibad_model_unexpected_argDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_unexpected_argDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIbad_model_unexpected_argDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Ibad_model_unexpected_argLibraryDispatcherCopy of core::traits::Copy::; +impl Ibad_model_unexpected_argLibraryDispatcherDrop of core::traits::Drop::; +impl Ibad_model_unexpected_argLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Ibad_model_unexpected_argLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Ibad_model_unexpected_argLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIbad_model_unexpected_argLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Ibad_model_unexpected_argLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_unexpected_argLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Ibad_model_unexpected_argLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_unexpected_argLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIbad_model_unexpected_argLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Ibad_model_unexpected_argSafeLibraryDispatcherCopy of core::traits::Copy::; +impl Ibad_model_unexpected_argSafeLibraryDispatcherDrop of core::traits::Drop::; +impl Ibad_model_unexpected_argSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Ibad_model_unexpected_argSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Ibad_model_unexpected_argSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIbad_model_unexpected_argSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Ibad_model_unexpected_argSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_unexpected_argSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Ibad_model_unexpected_argSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_unexpected_argSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIbad_model_unexpected_argSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Ibad_model_unexpected_argSafeDispatcherCopy of core::traits::Copy::; +impl Ibad_model_unexpected_argSafeDispatcherDrop of core::traits::Drop::; +impl Ibad_model_unexpected_argSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Ibad_model_unexpected_argSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Ibad_model_unexpected_argSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIbad_model_unexpected_argSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Ibad_model_unexpected_argSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_unexpected_argSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Ibad_model_unexpected_argSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_unexpected_argSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIbad_model_unexpected_argSafeDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Ibad_model_not_supported_versionDispatcherCopy of core::traits::Copy::; +impl Ibad_model_not_supported_versionDispatcherDrop of core::traits::Drop::; +impl Ibad_model_not_supported_versionDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Ibad_model_not_supported_versionDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Ibad_model_not_supported_versionDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIbad_model_not_supported_versionDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Ibad_model_not_supported_versionDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_not_supported_versionDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Ibad_model_not_supported_versionDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_not_supported_versionDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIbad_model_not_supported_versionDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Ibad_model_not_supported_versionLibraryDispatcherCopy of core::traits::Copy::; +impl Ibad_model_not_supported_versionLibraryDispatcherDrop of core::traits::Drop::; +impl Ibad_model_not_supported_versionLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Ibad_model_not_supported_versionLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Ibad_model_not_supported_versionLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIbad_model_not_supported_versionLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Ibad_model_not_supported_versionLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_not_supported_versionLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Ibad_model_not_supported_versionLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_not_supported_versionLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIbad_model_not_supported_versionLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Ibad_model_not_supported_versionSafeLibraryDispatcherCopy of core::traits::Copy::; +impl Ibad_model_not_supported_versionSafeLibraryDispatcherDrop of core::traits::Drop::; +impl Ibad_model_not_supported_versionSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Ibad_model_not_supported_versionSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Ibad_model_not_supported_versionSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIbad_model_not_supported_versionSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Ibad_model_not_supported_versionSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_not_supported_versionSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Ibad_model_not_supported_versionSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_not_supported_versionSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIbad_model_not_supported_versionSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Ibad_model_not_supported_versionSafeDispatcherCopy of core::traits::Copy::; +impl Ibad_model_not_supported_versionSafeDispatcherDrop of core::traits::Drop::; +impl Ibad_model_not_supported_versionSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Ibad_model_not_supported_versionSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Ibad_model_not_supported_versionSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIbad_model_not_supported_versionSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Ibad_model_not_supported_versionSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ibad_model_not_supported_versionSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Ibad_model_not_supported_versionSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ibad_model_not_supported_versionSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIbad_model_not_supported_versionSafeDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodelv_0DispatcherCopy of core::traits::Copy::; +impl Imodelv_0DispatcherDrop of core::traits::Drop::; +impl Imodelv_0DispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodelv_0Dispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodelv_0Dispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodelv_0Dispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodelv_0Dispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodelv_0Dispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodelv_0Dispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodelv_0Dispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodelv_0Dispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodelv_0LibraryDispatcherCopy of core::traits::Copy::; +impl Imodelv_0LibraryDispatcherDrop of core::traits::Drop::; +impl Imodelv_0LibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodelv_0LibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodelv_0LibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodelv_0LibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodelv_0LibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodelv_0LibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodelv_0LibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodelv_0LibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodelv_0LibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodelv_0SafeLibraryDispatcherCopy of core::traits::Copy::; +impl Imodelv_0SafeLibraryDispatcherDrop of core::traits::Drop::; +impl Imodelv_0SafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodelv_0SafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodelv_0SafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodelv_0SafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodelv_0SafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodelv_0SafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodelv_0SafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodelv_0SafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodelv_0SafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodelv_0SafeDispatcherCopy of core::traits::Copy::; +impl Imodelv_0SafeDispatcherDrop of core::traits::Drop::; +impl Imodelv_0SafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodelv_0SafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodelv_0SafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodelv_0SafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodelv_0SafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodelv_0SafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodelv_0SafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodelv_0SafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodelv_0SafeDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodel_with_bad_namespace_formatDispatcherCopy of core::traits::Copy::; +impl Imodel_with_bad_namespace_formatDispatcherDrop of core::traits::Drop::; +impl Imodel_with_bad_namespace_formatDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodel_with_bad_namespace_formatDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodel_with_bad_namespace_formatDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodel_with_bad_namespace_formatDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodel_with_bad_namespace_formatDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_bad_namespace_formatDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodel_with_bad_namespace_formatDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_bad_namespace_formatDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodel_with_bad_namespace_formatDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodel_with_bad_namespace_formatLibraryDispatcherCopy of core::traits::Copy::; +impl Imodel_with_bad_namespace_formatLibraryDispatcherDrop of core::traits::Drop::; +impl Imodel_with_bad_namespace_formatLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodel_with_bad_namespace_formatLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodel_with_bad_namespace_formatLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodel_with_bad_namespace_formatLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodel_with_bad_namespace_formatLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_bad_namespace_formatLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodel_with_bad_namespace_formatLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_bad_namespace_formatLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodel_with_bad_namespace_formatLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodel_with_bad_namespace_formatSafeLibraryDispatcherCopy of core::traits::Copy::; +impl Imodel_with_bad_namespace_formatSafeLibraryDispatcherDrop of core::traits::Drop::; +impl Imodel_with_bad_namespace_formatSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodel_with_bad_namespace_formatSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodel_with_bad_namespace_formatSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodel_with_bad_namespace_formatSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodel_with_bad_namespace_formatSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_bad_namespace_formatSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodel_with_bad_namespace_formatSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_bad_namespace_formatSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodel_with_bad_namespace_formatSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodel_with_bad_namespace_formatSafeDispatcherCopy of core::traits::Copy::; +impl Imodel_with_bad_namespace_formatSafeDispatcherDrop of core::traits::Drop::; +impl Imodel_with_bad_namespace_formatSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodel_with_bad_namespace_formatSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodel_with_bad_namespace_formatSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodel_with_bad_namespace_formatSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodel_with_bad_namespace_formatSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_bad_namespace_formatSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodel_with_bad_namespace_formatSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_bad_namespace_formatSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodel_with_bad_namespace_formatSafeDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodel_with_short_string_namespaceDispatcherCopy of core::traits::Copy::; +impl Imodel_with_short_string_namespaceDispatcherDrop of core::traits::Drop::; +impl Imodel_with_short_string_namespaceDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodel_with_short_string_namespaceDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodel_with_short_string_namespaceDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodel_with_short_string_namespaceDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodel_with_short_string_namespaceDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_short_string_namespaceDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodel_with_short_string_namespaceDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_short_string_namespaceDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodel_with_short_string_namespaceDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodel_with_short_string_namespaceLibraryDispatcherCopy of core::traits::Copy::; +impl Imodel_with_short_string_namespaceLibraryDispatcherDrop of core::traits::Drop::; +impl Imodel_with_short_string_namespaceLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodel_with_short_string_namespaceLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodel_with_short_string_namespaceLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodel_with_short_string_namespaceLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodel_with_short_string_namespaceLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_short_string_namespaceLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodel_with_short_string_namespaceLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_short_string_namespaceLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodel_with_short_string_namespaceLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodel_with_short_string_namespaceSafeLibraryDispatcherCopy of core::traits::Copy::; +impl Imodel_with_short_string_namespaceSafeLibraryDispatcherDrop of core::traits::Drop::; +impl Imodel_with_short_string_namespaceSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodel_with_short_string_namespaceSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodel_with_short_string_namespaceSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodel_with_short_string_namespaceSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodel_with_short_string_namespaceSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_short_string_namespaceSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodel_with_short_string_namespaceSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_short_string_namespaceSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodel_with_short_string_namespaceSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodel_with_short_string_namespaceSafeDispatcherCopy of core::traits::Copy::; +impl Imodel_with_short_string_namespaceSafeDispatcherDrop of core::traits::Drop::; +impl Imodel_with_short_string_namespaceSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodel_with_short_string_namespaceSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodel_with_short_string_namespaceSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodel_with_short_string_namespaceSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodel_with_short_string_namespaceSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_short_string_namespaceSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodel_with_short_string_namespaceSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_short_string_namespaceSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodel_with_short_string_namespaceSafeDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodel_with_string_namespaceDispatcherCopy of core::traits::Copy::; +impl Imodel_with_string_namespaceDispatcherDrop of core::traits::Drop::; +impl Imodel_with_string_namespaceDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodel_with_string_namespaceDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodel_with_string_namespaceDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodel_with_string_namespaceDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodel_with_string_namespaceDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_string_namespaceDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodel_with_string_namespaceDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_string_namespaceDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodel_with_string_namespaceDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodel_with_string_namespaceLibraryDispatcherCopy of core::traits::Copy::; +impl Imodel_with_string_namespaceLibraryDispatcherDrop of core::traits::Drop::; +impl Imodel_with_string_namespaceLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodel_with_string_namespaceLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodel_with_string_namespaceLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodel_with_string_namespaceLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodel_with_string_namespaceLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_string_namespaceLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodel_with_string_namespaceLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_string_namespaceLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodel_with_string_namespaceLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodel_with_string_namespaceSafeLibraryDispatcherCopy of core::traits::Copy::; +impl Imodel_with_string_namespaceSafeLibraryDispatcherDrop of core::traits::Drop::; +impl Imodel_with_string_namespaceSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodel_with_string_namespaceSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodel_with_string_namespaceSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodel_with_string_namespaceSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodel_with_string_namespaceSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_string_namespaceSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodel_with_string_namespaceSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_string_namespaceSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodel_with_string_namespaceSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodel_with_string_namespaceSafeDispatcherCopy of core::traits::Copy::; +impl Imodel_with_string_namespaceSafeDispatcherDrop of core::traits::Drop::; +impl Imodel_with_string_namespaceSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodel_with_string_namespaceSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodel_with_string_namespaceSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodel_with_string_namespaceSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodel_with_string_namespaceSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_string_namespaceSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodel_with_string_namespaceSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_string_namespaceSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodel_with_string_namespaceSafeDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IpositionDispatcherCopy of core::traits::Copy::; +impl IpositionDispatcherDrop of core::traits::Drop::; +impl IpositionDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IpositionDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IpositionDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIpositionDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IpositionDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IpositionDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IpositionDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IpositionDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIpositionDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IpositionLibraryDispatcherCopy of core::traits::Copy::; +impl IpositionLibraryDispatcherDrop of core::traits::Drop::; +impl IpositionLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IpositionLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IpositionLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIpositionLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IpositionLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IpositionLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IpositionLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IpositionLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIpositionLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IpositionSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IpositionSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IpositionSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IpositionSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IpositionSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIpositionSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IpositionSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IpositionSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IpositionSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IpositionSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIpositionSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IpositionSafeDispatcherCopy of core::traits::Copy::; +impl IpositionSafeDispatcherDrop of core::traits::Drop::; +impl IpositionSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IpositionSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IpositionSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIpositionSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IpositionSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IpositionSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IpositionSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IpositionSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIpositionSafeDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IrolesDispatcherCopy of core::traits::Copy::; +impl IrolesDispatcherDrop of core::traits::Drop::; +impl IrolesDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IrolesDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IrolesDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIrolesDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IrolesDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IrolesDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IrolesDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IrolesDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIrolesDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IrolesLibraryDispatcherCopy of core::traits::Copy::; +impl IrolesLibraryDispatcherDrop of core::traits::Drop::; +impl IrolesLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IrolesLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IrolesLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIrolesLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IrolesLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IrolesLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IrolesLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IrolesLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIrolesLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IrolesSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IrolesSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IrolesSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IrolesSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IrolesSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIrolesSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IrolesSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IrolesSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IrolesSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IrolesSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIrolesSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IrolesSafeDispatcherCopy of core::traits::Copy::; +impl IrolesSafeDispatcherDrop of core::traits::Drop::; +impl IrolesSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IrolesSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IrolesSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIrolesSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IrolesSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IrolesSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IrolesSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IrolesSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIrolesSafeDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Ionly_key_modelDispatcherCopy of core::traits::Copy::; +impl Ionly_key_modelDispatcherDrop of core::traits::Drop::; +impl Ionly_key_modelDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Ionly_key_modelDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Ionly_key_modelDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIonly_key_modelDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Ionly_key_modelDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ionly_key_modelDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Ionly_key_modelDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ionly_key_modelDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIonly_key_modelDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Ionly_key_modelLibraryDispatcherCopy of core::traits::Copy::; +impl Ionly_key_modelLibraryDispatcherDrop of core::traits::Drop::; +impl Ionly_key_modelLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Ionly_key_modelLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Ionly_key_modelLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIonly_key_modelLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Ionly_key_modelLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ionly_key_modelLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Ionly_key_modelLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ionly_key_modelLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIonly_key_modelLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Ionly_key_modelSafeLibraryDispatcherCopy of core::traits::Copy::; +impl Ionly_key_modelSafeLibraryDispatcherDrop of core::traits::Drop::; +impl Ionly_key_modelSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Ionly_key_modelSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Ionly_key_modelSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIonly_key_modelSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Ionly_key_modelSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ionly_key_modelSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Ionly_key_modelSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ionly_key_modelSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIonly_key_modelSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Ionly_key_modelSafeDispatcherCopy of core::traits::Copy::; +impl Ionly_key_modelSafeDispatcherDrop of core::traits::Drop::; +impl Ionly_key_modelSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Ionly_key_modelSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Ionly_key_modelSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIonly_key_modelSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Ionly_key_modelSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Ionly_key_modelSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Ionly_key_modelSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Ionly_key_modelSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIonly_key_modelSafeDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Iu_256_key_modelDispatcherCopy of core::traits::Copy::; +impl Iu_256_key_modelDispatcherDrop of core::traits::Drop::; +impl Iu_256_key_modelDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Iu_256_key_modelDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Iu_256_key_modelDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIu_256_key_modelDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Iu_256_key_modelDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Iu_256_key_modelDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Iu_256_key_modelDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Iu_256_key_modelDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIu_256_key_modelDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Iu_256_key_modelLibraryDispatcherCopy of core::traits::Copy::; +impl Iu_256_key_modelLibraryDispatcherDrop of core::traits::Drop::; +impl Iu_256_key_modelLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Iu_256_key_modelLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Iu_256_key_modelLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIu_256_key_modelLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Iu_256_key_modelLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Iu_256_key_modelLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Iu_256_key_modelLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Iu_256_key_modelLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIu_256_key_modelLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Iu_256_key_modelSafeLibraryDispatcherCopy of core::traits::Copy::; +impl Iu_256_key_modelSafeLibraryDispatcherDrop of core::traits::Drop::; +impl Iu_256_key_modelSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Iu_256_key_modelSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Iu_256_key_modelSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIu_256_key_modelSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Iu_256_key_modelSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Iu_256_key_modelSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Iu_256_key_modelSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Iu_256_key_modelSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIu_256_key_modelSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Iu_256_key_modelSafeDispatcherCopy of core::traits::Copy::; +impl Iu_256_key_modelSafeDispatcherDrop of core::traits::Drop::; +impl Iu_256_key_modelSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Iu_256_key_modelSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Iu_256_key_modelSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIu_256_key_modelSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Iu_256_key_modelSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Iu_256_key_modelSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Iu_256_key_modelSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Iu_256_key_modelSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIu_256_key_modelSafeDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IplayerDispatcherCopy of core::traits::Copy::; +impl IplayerDispatcherDrop of core::traits::Drop::; +impl IplayerDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IplayerDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IplayerDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIplayerDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IplayerDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IplayerDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IplayerDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IplayerDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIplayerDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IplayerLibraryDispatcherCopy of core::traits::Copy::; +impl IplayerLibraryDispatcherDrop of core::traits::Drop::; +impl IplayerLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IplayerLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IplayerLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIplayerLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IplayerLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IplayerLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IplayerLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IplayerLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIplayerLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IplayerSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IplayerSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IplayerSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IplayerSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IplayerSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIplayerSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IplayerSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IplayerSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IplayerSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IplayerSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIplayerSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IplayerSafeDispatcherCopy of core::traits::Copy::; +impl IplayerSafeDispatcherDrop of core::traits::Drop::; +impl IplayerSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IplayerSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IplayerSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIplayerSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IplayerSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IplayerSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IplayerSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IplayerSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIplayerSafeDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodel_with_simple_arrayDispatcherCopy of core::traits::Copy::; +impl Imodel_with_simple_arrayDispatcherDrop of core::traits::Drop::; +impl Imodel_with_simple_arrayDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodel_with_simple_arrayDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodel_with_simple_arrayDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodel_with_simple_arrayDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodel_with_simple_arrayDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_simple_arrayDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodel_with_simple_arrayDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_simple_arrayDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodel_with_simple_arrayDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodel_with_simple_arrayLibraryDispatcherCopy of core::traits::Copy::; +impl Imodel_with_simple_arrayLibraryDispatcherDrop of core::traits::Drop::; +impl Imodel_with_simple_arrayLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodel_with_simple_arrayLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodel_with_simple_arrayLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodel_with_simple_arrayLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodel_with_simple_arrayLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_simple_arrayLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodel_with_simple_arrayLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_simple_arrayLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodel_with_simple_arrayLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodel_with_simple_arraySafeLibraryDispatcherCopy of core::traits::Copy::; +impl Imodel_with_simple_arraySafeLibraryDispatcherDrop of core::traits::Drop::; +impl Imodel_with_simple_arraySafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodel_with_simple_arraySafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodel_with_simple_arraySafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodel_with_simple_arraySafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodel_with_simple_arraySafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_simple_arraySafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodel_with_simple_arraySafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_simple_arraySafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodel_with_simple_arraySafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodel_with_simple_arraySafeDispatcherCopy of core::traits::Copy::; +impl Imodel_with_simple_arraySafeDispatcherDrop of core::traits::Drop::; +impl Imodel_with_simple_arraySafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodel_with_simple_arraySafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodel_with_simple_arraySafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodel_with_simple_arraySafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodel_with_simple_arraySafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_simple_arraySafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodel_with_simple_arraySafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_simple_arraySafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodel_with_simple_arraySafeDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodel_with_byte_arrayDispatcherCopy of core::traits::Copy::; +impl Imodel_with_byte_arrayDispatcherDrop of core::traits::Drop::; +impl Imodel_with_byte_arrayDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodel_with_byte_arrayDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodel_with_byte_arrayDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodel_with_byte_arrayDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodel_with_byte_arrayDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_byte_arrayDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodel_with_byte_arrayDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_byte_arrayDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodel_with_byte_arrayDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodel_with_byte_arrayLibraryDispatcherCopy of core::traits::Copy::; +impl Imodel_with_byte_arrayLibraryDispatcherDrop of core::traits::Drop::; +impl Imodel_with_byte_arrayLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodel_with_byte_arrayLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodel_with_byte_arrayLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodel_with_byte_arrayLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodel_with_byte_arrayLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_byte_arrayLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodel_with_byte_arrayLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_byte_arrayLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodel_with_byte_arrayLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodel_with_byte_arraySafeLibraryDispatcherCopy of core::traits::Copy::; +impl Imodel_with_byte_arraySafeLibraryDispatcherDrop of core::traits::Drop::; +impl Imodel_with_byte_arraySafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodel_with_byte_arraySafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodel_with_byte_arraySafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodel_with_byte_arraySafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodel_with_byte_arraySafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_byte_arraySafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodel_with_byte_arraySafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_byte_arraySafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodel_with_byte_arraySafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodel_with_byte_arraySafeDispatcherCopy of core::traits::Copy::; +impl Imodel_with_byte_arraySafeDispatcherDrop of core::traits::Drop::; +impl Imodel_with_byte_arraySafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodel_with_byte_arraySafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodel_with_byte_arraySafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodel_with_byte_arraySafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodel_with_byte_arraySafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_byte_arraySafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodel_with_byte_arraySafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_byte_arraySafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodel_with_byte_arraySafeDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodel_with_complex_arrayDispatcherCopy of core::traits::Copy::; +impl Imodel_with_complex_arrayDispatcherDrop of core::traits::Drop::; +impl Imodel_with_complex_arrayDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodel_with_complex_arrayDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodel_with_complex_arrayDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodel_with_complex_arrayDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodel_with_complex_arrayDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_complex_arrayDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodel_with_complex_arrayDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_complex_arrayDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodel_with_complex_arrayDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodel_with_complex_arrayLibraryDispatcherCopy of core::traits::Copy::; +impl Imodel_with_complex_arrayLibraryDispatcherDrop of core::traits::Drop::; +impl Imodel_with_complex_arrayLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodel_with_complex_arrayLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodel_with_complex_arrayLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodel_with_complex_arrayLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodel_with_complex_arrayLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_complex_arrayLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodel_with_complex_arrayLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_complex_arrayLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodel_with_complex_arrayLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodel_with_complex_arraySafeLibraryDispatcherCopy of core::traits::Copy::; +impl Imodel_with_complex_arraySafeLibraryDispatcherDrop of core::traits::Drop::; +impl Imodel_with_complex_arraySafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodel_with_complex_arraySafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodel_with_complex_arraySafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodel_with_complex_arraySafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodel_with_complex_arraySafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_complex_arraySafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodel_with_complex_arraySafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_complex_arraySafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodel_with_complex_arraySafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodel_with_complex_arraySafeDispatcherCopy of core::traits::Copy::; +impl Imodel_with_complex_arraySafeDispatcherDrop of core::traits::Drop::; +impl Imodel_with_complex_arraySafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodel_with_complex_arraySafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodel_with_complex_arraySafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodel_with_complex_arraySafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodel_with_complex_arraySafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_complex_arraySafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodel_with_complex_arraySafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_complex_arraySafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodel_with_complex_arraySafeDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodel_with_tupleDispatcherCopy of core::traits::Copy::; +impl Imodel_with_tupleDispatcherDrop of core::traits::Drop::; +impl Imodel_with_tupleDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodel_with_tupleDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodel_with_tupleDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodel_with_tupleDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodel_with_tupleDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_tupleDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodel_with_tupleDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_tupleDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodel_with_tupleDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodel_with_tupleLibraryDispatcherCopy of core::traits::Copy::; +impl Imodel_with_tupleLibraryDispatcherDrop of core::traits::Drop::; +impl Imodel_with_tupleLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodel_with_tupleLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodel_with_tupleLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodel_with_tupleLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodel_with_tupleLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_tupleLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodel_with_tupleLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_tupleLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodel_with_tupleLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodel_with_tupleSafeLibraryDispatcherCopy of core::traits::Copy::; +impl Imodel_with_tupleSafeLibraryDispatcherDrop of core::traits::Drop::; +impl Imodel_with_tupleSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodel_with_tupleSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodel_with_tupleSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodel_with_tupleSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodel_with_tupleSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_tupleSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodel_with_tupleSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_tupleSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodel_with_tupleSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodel_with_tupleSafeDispatcherCopy of core::traits::Copy::; +impl Imodel_with_tupleSafeDispatcherDrop of core::traits::Drop::; +impl Imodel_with_tupleSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodel_with_tupleSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodel_with_tupleSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodel_with_tupleSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodel_with_tupleSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_tupleSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodel_with_tupleSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_tupleSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodel_with_tupleSafeDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodel_with_tuple_no_primitivesDispatcherCopy of core::traits::Copy::; +impl Imodel_with_tuple_no_primitivesDispatcherDrop of core::traits::Drop::; +impl Imodel_with_tuple_no_primitivesDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodel_with_tuple_no_primitivesDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodel_with_tuple_no_primitivesDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodel_with_tuple_no_primitivesDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodel_with_tuple_no_primitivesDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_tuple_no_primitivesDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodel_with_tuple_no_primitivesDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_tuple_no_primitivesDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodel_with_tuple_no_primitivesDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodel_with_tuple_no_primitivesLibraryDispatcherCopy of core::traits::Copy::; +impl Imodel_with_tuple_no_primitivesLibraryDispatcherDrop of core::traits::Drop::; +impl Imodel_with_tuple_no_primitivesLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodel_with_tuple_no_primitivesLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodel_with_tuple_no_primitivesLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodel_with_tuple_no_primitivesLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodel_with_tuple_no_primitivesLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_tuple_no_primitivesLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodel_with_tuple_no_primitivesLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_tuple_no_primitivesLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodel_with_tuple_no_primitivesLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodel_with_tuple_no_primitivesSafeLibraryDispatcherCopy of core::traits::Copy::; +impl Imodel_with_tuple_no_primitivesSafeLibraryDispatcherDrop of core::traits::Drop::; +impl Imodel_with_tuple_no_primitivesSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodel_with_tuple_no_primitivesSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodel_with_tuple_no_primitivesSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodel_with_tuple_no_primitivesSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodel_with_tuple_no_primitivesSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_tuple_no_primitivesSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodel_with_tuple_no_primitivesSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_tuple_no_primitivesSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodel_with_tuple_no_primitivesSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl Imodel_with_tuple_no_primitivesSafeDispatcherCopy of core::traits::Copy::; +impl Imodel_with_tuple_no_primitivesSafeDispatcherDrop of core::traits::Drop::; +impl Imodel_with_tuple_no_primitivesSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @Imodel_with_tuple_no_primitivesSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(Imodel_with_tuple_no_primitivesSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreImodel_with_tuple_no_primitivesSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + Imodel_with_tuple_no_primitivesSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: Imodel_with_tuple_no_primitivesSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + Imodel_with_tuple_no_primitivesSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: Imodel_with_tuple_no_primitivesSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageImodel_with_tuple_no_primitivesSafeDispatcher of starknet::storage_access::DeriveStorage:: {} + +//! > expected_diagnostics +error: A Dojo model must have zero or one dojo::model attribute. + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpkivhTu/src/lib.cairo:1:1 +#[dojo::model(version: 0)] +^************************^ + +error: Too many 'version' attributes for dojo::model + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpkivhTu/src/lib.cairo:9:1 +#[dojo::model(version: 0, version: 0)] +^************************************^ + +error: The argument 'version' of dojo::model must be an integer + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpkivhTu/src/lib.cairo:16:24 +#[dojo::model(version: hello)] + ^***^ + +error: Unexpected argument 'version' for dojo::model + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpkivhTu/src/lib.cairo:23:15 +#[dojo::model(version)] + ^*****^ + +error: Unexpected argument 'my_arg' for dojo::model + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpkivhTu/src/lib.cairo:30:15 +#[dojo::model(my_arg: 1)] + ^*******^ + +error: Unexpected argument 'my_arg' for dojo::model + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpkivhTu/src/lib.cairo:37:15 +#[dojo::model(my_arg)] + ^****^ + +error: dojo::model version 2 not supported + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpkivhTu/src/lib.cairo:44:24 +#[dojo::model(version: 2)] + ^ + +error: Model must define at least one #[key] attribute + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpkivhTu/src/lib.cairo:87:8 +struct Roles { + ^***^ + +error: Model must define at least one member that is not a key + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpkivhTu/src/lib.cairo:92:8 +struct OnlyKeyModel { + ^**********^ + +error: Model must define at least one member that is not a key + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpkivhTu/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. + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpkivhTu/src/lib.cairo:98:8 +struct U256KeyModel { + ^**********^ diff --git a/crates/dojo-lang/src/plugin_test_data/print b/crates/dojo-lang/src/plugin_test_data/print index f20a89ffad..402b2b9345 100644 --- a/crates/dojo-lang/src/plugin_test_data/print +++ b/crates/dojo-lang/src/plugin_test_data/print @@ -75,59 +75,59 @@ enum Enemy { Bot: felt252, OtherPlayer: ContractAddress, } +#[cfg(test)] +impl PositionStructPrintImpl of core::debug::PrintTrait { + fn print(self: Position) { + core::debug::PrintTrait::print('id'); core::debug::PrintTrait::print(self.id); +core::debug::PrintTrait::print('x'); core::debug::PrintTrait::print(self.x); +core::debug::PrintTrait::print('y'); core::debug::PrintTrait::print(self.y); + } +} -//! > expected_diagnostics -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:1:1 -use serde::Serde; -^***************^ +#[cfg(test)] +impl RolesStructPrintImpl of core::debug::PrintTrait { + fn print(self: Roles) { + core::debug::PrintTrait::print('role_ids'); core::debug::PrintTrait::print(self.role_ids); + } +} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:2:1 -use debug::PrintTrait; -^********************^ +#[cfg(test)] +impl PlayerStructPrintImpl of core::debug::PrintTrait { + fn print(self: Player) { + core::debug::PrintTrait::print('game'); core::debug::PrintTrait::print(self.game); +core::debug::PrintTrait::print('player'); core::debug::PrintTrait::print(self.player); +core::debug::PrintTrait::print('name'); core::debug::PrintTrait::print(self.name); + } +} + +#[cfg(test)] +impl EnemyEnumPrintImpl of core::debug::PrintTrait { + fn print(self: Enemy) { + match self { + Enemy::Unknown => { core::debug::PrintTrait::print('Unknown'); }, +Enemy::Bot(v) => { core::debug::PrintTrait::print('Bot'); core::debug::PrintTrait::print(v); }, +Enemy::OtherPlayer(v) => { core::debug::PrintTrait::print('OtherPlayer'); core::debug::PrintTrait::print(v); } + } + } +} +//! > expected_diagnostics error: Unknown derive `Print` - a plugin might be missing. - --> test_src/lib.cairo:4:10 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpACPmcs/src/lib.cairo:4:10 #[derive(Print)] ^***^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:4:1 -#[derive(Print)] -^**************^ - error: Unknown derive `Print` - a plugin might be missing. - --> test_src/lib.cairo:12:10 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpACPmcs/src/lib.cairo:12:10 #[derive(Print)] ^***^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:12:1 -#[derive(Print)] -^**************^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:17:1 -use starknet::ContractAddress; -^****************************^ - error: Unknown derive `Print` - a plugin might be missing. - --> test_src/lib.cairo:19:10 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpACPmcs/src/lib.cairo:19:10 #[derive(Print)] ^***^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:19:1 -#[derive(Print)] -^**************^ - error: Unknown derive `Print` - a plugin might be missing. - --> test_src/lib.cairo:28:10 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpACPmcs/src/lib.cairo:28:10 #[derive(Print)] ^***^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:28:1 -#[derive(Print)] -^**************^ diff --git a/crates/dojo-lang/src/plugin_test_data/system b/crates/dojo-lang/src/plugin_test_data/system index 39788cd740..464bba89d9 100644 --- a/crates/dojo-lang/src/plugin_test_data/system +++ b/crates/dojo-lang/src/plugin_test_data/system @@ -355,577 +355,8848 @@ mod ctxnamed { } //! > expected_diagnostics -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:1:1 -#[dojo::contract(namespace: "My@Namespace")] -^******************************************^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:11:1 -#[dojo::contract(namespace: 'my_namespace')] -^******************************************^ +error: Anything other than functions is not supported in a dojo::interface + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:90:5 + const ONE: u8; + ^************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:21:1 -#[dojo::contract(namespace: "my_namespace")] -^******************************************^ +error: World parameter must be the first parameter. + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:111:5 + fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252; + ^***********************************************************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:28:1 -#[dojo::contract] -^***************^ +error: World parameter must be the first parameter. + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:112:5 + fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; + ^*********************************************************************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:38:1 -#[dojo::contract] -^***************^ +error: You cannot use `self` and `world` parameters together. + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:113:5 + fn do_with_self_and_world_inv(world: @IWorldDispatcher, self: @ContractState) -> felt252; + ^***************************************************************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:52:1 -#[starknet::component] -^********************^ +error: You cannot use `self` and `world` parameters together. + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:114:5 + fn do_with_ref_self_and_world_inv( + ^********************************^ -error: Unsupported attribute. - --> test_src/lib.cairo:52:1 -#[starknet::component] -^********************^ +error: World parameter must be the first parameter. + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:121:5 + fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252; + ^****************************************************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:58:1 -#[starknet::component] -^********************^ +error: World parameter must be the first parameter. + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:128:9 + fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252 { + ^************************************************************************************^ -error: Unsupported attribute. - --> test_src/lib.cairo:58:1 -#[starknet::component] -^********************^ +error: World parameter must be the first parameter. + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:132:9 + fn do_with_ref_self_and_world( + ^****************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:64:1 -#[dojo::contract] -^***************^ +error: You cannot use `self` and `world` parameters together. + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:138:9 + fn do_with_self_and_world_inv(world: @IWorldDispatcher, self: @ContractState) -> felt252 { + ^****************************************************************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:85:1 -#[dojo::interface] -^****************^ +error: You cannot use `self` and `world` parameters together. + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:142:9 + fn do_with_ref_self_and_world_inv( + ^********************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:88:1 -#[dojo::interface] -^****************^ +error: World parameter must be the first parameter. + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:158:9 + fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252 { + ^*****************************************************************************^ -error: Unsupported attribute. - --> test_src/lib.cairo:92:5 - #[my_attr] - ^********^ +error: You cannot use `world` and `#[generate_trait]` together. Use `self` instead. + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:165:9 + fn bad_func_using_generate(world: @IWorldDispatcher) -> felt252 { + ^***************************************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:96:1 -#[dojo::interface] -^****************^ +error: World parameter must be a snapshot if `ref` is not used. + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:224:5 + fn dojo_init( + ^***********^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:109:1 -#[dojo::interface] -^****************^ +error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:105:5 + fn do_with_self(self: @ContractState) -> felt252; + ^**********************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:124:1 -#[dojo::contract] -^***************^ +error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:106:5 + fn do_with_ref_self(ref self: ContractState) -> felt252; + ^*****************************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:171:1 -#[dojo::contract] -^***************^ +error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:111:5 + fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252; + ^**********************************************************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:222:1 -#[dojo::contract] -^***************^ +error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:112:5 + fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; + ^********************************************************************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:239:1 -#[dojo::contract] -^***************^ +error: `starknet::interface` functions don't support `ref` parameters other than the first one. + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:112:5 + fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; + ^********************************************************************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:3:5 - use traits::Into; - ^***************^ +error: `starknet::interface` functions don't support `ref` parameters other than the first one. + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:114:5 + fn do_with_ref_self_and_world_inv( + ^********************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:4:5 - use dojo::world::Context; - ^***********************^ +error: `starknet::interface` functions don't support `ref` parameters other than the first one. + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:117:5 + fn do_with_several_world_dispatchers( + ^***********************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:6:5 - fn execute(ctx: Context, name: felt252) { - ^***************************************^ +error: `starknet::interface` functions don't support `ref` parameters other than the first one. + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:121:5 + fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252; + ^***************************************************************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:13:5 - use traits::Into; +error: Generated trait must have generic args matching the impl's generic params. + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:163:5 + #[generate_trait] ^***************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:14:5 - use dojo::world::Context; - ^***********************^ - -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:16:5 - fn execute(ctx: Context, name: felt252) { - ^***************************************^ +//! > expanded_cairo_code -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:23:5 - fn execute(value: felt252) -> felt252 { - ^*************************************^ +#[starknet::component] +mod testcomponent1 { +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:30:5 - use traits::Into; - ^***************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:31:5 - use dojo::world::Context; - ^***********************^ +pub struct Storage { +} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:33:5 - fn execute(ctx2: Context, name: felt252) { - ^****************************************^ +#[derive(Drop, Copy)] +pub struct ComponentStorageBase { +} +#[derive(Drop, Copy)] +pub struct ComponentStorageBaseMut { +} +impl StorageBaseImpl of starknet::storage::StorageBaseTrait> { + type BaseType = ComponentStorageBase; + type BaseMutType = ComponentStorageBaseMut; + fn storage_base(self: @ComponentState) -> ComponentStorageBase { + ComponentStorageBase { + } + } + fn storage_base_mut(ref self: ComponentState) -> ComponentStorageBaseMut { + ComponentStorageBaseMut { + } + } +} +pub struct ComponentState { +} -error: Unknown derive `starknet::Event` - a plugin might be missing. - --> test_src/lib.cairo:41:20 - #[derive(Drop, starknet::Event)] - ^*************^ +impl ComponentStateDrop of Drop> {} + +impl ComponentStateDeref of core::ops::SnapshotDeref> { + type Target = ComponentStorageBase; + fn snapshot_deref(self: @ComponentState) -> ComponentStorageBase { + self.storage_base() + } +} +impl ComponentStateDerefMut of core::ops::DerefMut> { + type Target = ComponentStorageBaseMut; + fn deref_mut(ref self: ComponentState) -> ComponentStorageBaseMut { + self.storage_base_mut() + } +} +pub fn unsafe_new_component_state() -> ComponentState { + ComponentState:: { + } +} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:40:5 - #[event] - ^******^ -error: Unsupported attribute. - --> test_src/lib.cairo:40:5 - #[event] - ^******^ +use starknet::storage::{ + StorageMapReadAccessTrait, StorageMapWriteAccessTrait, + StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess +}; +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; +pub trait HasComponent { + fn get_component(self: @TContractState) -> @ComponentState; + fn get_component_mut(ref self: TContractState) -> ComponentState; + fn get_contract(self: @ComponentState) -> @TContractState; + fn get_contract_mut(ref self: ComponentState) -> TContractState; + fn emit>(ref self: ComponentState, event: S); +} +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl ComponentStorageBaseDrop of core::traits::Drop::; +impl ComponentStorageBaseCopy of core::traits::Copy::; +impl ComponentStorageBaseMutDrop of core::traits::Drop::; +impl ComponentStorageBaseMutCopy of core::traits::Copy::; +} -error: Unknown derive `starknet::Event` - a plugin might be missing. - --> test_src/lib.cairo:46:20 - #[derive(Drop, starknet::Event)] - ^*************^ +#[starknet::component] +mod testcomponent2 { +#[event] +#[derive(Drop, starknet::Event)] +pub enum Event {} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:46:5 - #[derive(Drop, starknet::Event)] - ^******************************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:40:1 - #[event] -^**********^ +pub struct Storage { +} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:45:1 +#[derive(Drop, Copy)] +pub struct ComponentStorageBase { +} +#[derive(Drop, Copy)] +pub struct ComponentStorageBaseMut { +} +impl StorageBaseImpl of starknet::storage::StorageBaseTrait> { + type BaseType = ComponentStorageBase; + type BaseMutType = ComponentStorageBaseMut; + fn storage_base(self: @ComponentState) -> ComponentStorageBase { + ComponentStorageBase { + } + } + fn storage_base_mut(ref self: ComponentState) -> ComponentStorageBaseMut { + ComponentStorageBaseMut { + } + } +} +pub struct ComponentState { +} -^ +impl ComponentStateDrop of Drop> {} + +impl ComponentStateDeref of core::ops::SnapshotDeref> { + type Target = ComponentStorageBase; + fn snapshot_deref(self: @ComponentState) -> ComponentStorageBase { + self.storage_base() + } +} +impl ComponentStateDerefMut of core::ops::DerefMut> { + type Target = ComponentStorageBaseMut; + fn deref_mut(ref self: ComponentState) -> ComponentStorageBaseMut { + self.storage_base_mut() + } +} +pub fn unsafe_new_component_state() -> ComponentState { + ComponentState:: { + } +} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:54:5 - #[storage] - ^********^ -error: Unsupported attribute. - --> test_src/lib.cairo:54:5 - #[storage] - ^********^ +use starknet::storage::{ + StorageMapReadAccessTrait, StorageMapWriteAccessTrait, + StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess +}; +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; +pub trait HasComponent { + fn get_component(self: @TContractState) -> @ComponentState; + fn get_component_mut(ref self: TContractState) -> ComponentState; + fn get_contract(self: @ComponentState) -> @TContractState; + fn get_contract_mut(ref self: ComponentState) -> TContractState; + fn emit>(ref self: ComponentState, event: S); +} +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + Option::None + } +} +impl ComponentStorageBaseDrop of core::traits::Drop::; +impl ComponentStorageBaseCopy of core::traits::Copy::; +impl ComponentStorageBaseMutDrop of core::traits::Drop::; +impl ComponentStorageBaseMutCopy of core::traits::Copy::; +} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:60:5 - #[storage] - ^********^ + #[starknet::contract] + mod bad_namespace_format { + use dojo::world; + use dojo::world::IWorldDispatcher; + use dojo::world::IWorldDispatcherTrait; + use dojo::world::IWorldProvider; + use dojo::contract::IContract; + + #[abi(embed_v0)] + impl ContractImpl of IContract { + fn contract_name(self: @ContractState) -> ByteArray { + "bad_namespace_format" + } + + fn namespace(self: @ContractState) -> ByteArray { + "test_package" + } + + fn tag(self: @ContractState) -> ByteArray { + "test_package-bad_namespace_format" + } + + fn name_hash(self: @ContractState) -> felt252 { + 2014299465256018364248618312205774234949844604916563661777686628154176783488 + } + + fn namespace_hash(self: @ContractState) -> felt252 { + 3061092720893075933752785490401950953836105364709575990296000909161416686979 + } + + fn selector(self: @ContractState) -> felt252 { + 2931670046498875274448874829231097042977275875153600823491451406128208153107 + } + } + + #[abi(embed_v0)] + impl WorldProviderImpl of IWorldProvider { + fn world(self: @ContractState) -> IWorldDispatcher { + self.world_dispatcher.read() + } + } + + #[abi(embed_v0)] + impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; + + use traits::Into; + use dojo::world::Context; -error: Unsupported attribute. - --> test_src/lib.cairo:60:5 - #[storage] - ^********^ + fn execute(ctx: Context, name: felt252) { + return (); + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:66:5 - component!(path: testcomponent1, storage: testcomponent1_storage, event: testcomponent1_event); - ^*********************************************************************************************^ + #[starknet::interface] + trait IDojoInit { + fn dojo_init(self: @ContractState); + } + + #[abi(embed_v0)] + impl IDojoInitImpl of IDojoInit { + fn dojo_init(self: @ContractState) { + assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); + } + } + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, + } +trait IDojoInitDispatcherTrait { + fn dojo_init(self: T); +} -error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo:66:5 - component!(path: testcomponent1, storage: testcomponent1_storage, event: testcomponent1_event); - ^*********************************************************************************************^ +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitDispatcher { + pub contract_address: starknet::ContractAddress, +} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:67:5 - component!(path: testcomponent2, storage: testcomponent2_storage, event: testcomponent2_event); - ^*********************************************************************************************^ +impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitDispatcher) { + let mut __calldata__ = core::traits::Default::default(); -error: Unknown inline item macro: 'component'. - --> test_src/lib.cairo:67:5 - component!(path: testcomponent2, storage: testcomponent2_storage, event: testcomponent2_event); - ^*********************************************************************************************^ + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:69:5 - #[storage] - ^********^ +} -error: Unsupported attribute. - --> test_src/lib.cairo:69:5 - #[storage] - ^********^ +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} -error: Unsupported attribute. - --> test_src/lib.cairo:71:9 - #[substorage(v0)] - ^***************^ +impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitLibraryDispatcher) { + let mut __calldata__ = core::traits::Default::default(); -error: Unsupported attribute. - --> test_src/lib.cairo:73:9 - #[substorage(v0)] - ^***************^ + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } -error: Unknown derive `starknet::Event` - a plugin might be missing. - --> test_src/lib.cairo:78:20 - #[derive(Drop, starknet::Event)] - ^*************^ +} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:77:5 - #[event] - ^******^ +trait IDojoInitSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn dojo_init(self: T) -> starknet::SyscallResult<()>; +} -error: Unsupported attribute. - --> test_src/lib.cairo:77:5 - #[event] - ^******^ +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} -error: Unsupported attribute. - --> test_src/lib.cairo:80:9 - #[flat] - ^*****^ +impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:76:1 + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } -^ +} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:126:5 - #[abi(embed_v0)] - ^**************^ -error: Unsupported attribute. - --> test_src/lib.cairo:126:5 - #[abi(embed_v0)] - ^**************^ +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} -error: Generated trait must have generic args matching the impl's generic params. - --> test_src/lib.cairo:164:29 - impl InternalImplBad of InternalUtils { - ^**************************^ +impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:163:5 - #[generate_trait] - ^***************^ + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:163:5 - #[generate_trait] - ^***************^ +} +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + Event::UpgradeableEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + if __selector__ == selector!("UpgradeableEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::UpgradeableEvent(val)); + } + Option::None + } +} +impl EventUpgradeableEventIntoEvent of Into { + fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { + Event::UpgradeableEvent(self) + } +} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:173:5 - #[derive(Drop)] - ^*************^ -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:178:5 - #[abi(embed_v0)] - ^**************^ +pub struct Storage { + pub world_dispatcher: IWorldDispatcher, + pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, +} -error: Unsupported attribute. - --> test_src/lib.cairo:178:5 - #[abi(embed_v0)] - ^**************^ +#[derive(Drop, Copy)] +pub struct ContractStorageBase { + pub world_dispatcher: starknet::storage::StorageBase, + pub upgradeable: starknet::storage::StorageBase, +} +#[derive(Drop, Copy)] +pub struct ContractStorageBaseMut { + pub world_dispatcher: starknet::storage::StorageBase>, + pub upgradeable: starknet::storage::StorageBase>, +} +impl StorageBaseImpl of starknet::storage::StorageBaseTrait { + type BaseType = ContractStorageBase; + type BaseMutType = ContractStorageBaseMut; + fn storage_base(self: @ContractState) -> ContractStorageBase { + ContractStorageBase { + world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, + upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, + } + } + fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { + ContractStorageBaseMut { + world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, + upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, + } + } +} +pub struct ContractState { + pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, +} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:213:5 - #[generate_trait] - ^***************^ +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = ContractStorageBase; + fn snapshot_deref(self: @ContractState) -> ContractStorageBase { + self.storage_base() + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = ContractStorageBaseMut; + fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { + self.storage_base_mut() + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), + } +} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:173:1 - #[derive(Drop)] -^*****************^ +use starknet::storage::{ + StorageMapReadAccessTrait, StorageMapWriteAccessTrait, + StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess +}; +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::contract_name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:213:5 - #[generate_trait] - ^***************^ +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} -error: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. - --> test_src/lib.cairo:224:5 - fn dojo_init( - ^***********^ +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} -//! > expanded_cairo_code -#[dojo::contract(namespace: "My@Namespace")] -mod bad_namespace_format { - use traits::Into; - use dojo::world::Context; +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} - fn execute(ctx: Context, name: felt252) { - return (); - } +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) } -#[dojo::contract(namespace: 'my_namespace')] -mod spawn { - use traits::Into; - use dojo::world::Context; +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} - fn execute(ctx: Context, name: felt252) { - return (); - } +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = WorldProviderImpl::world(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) } -#[dojo::contract(namespace: "my_namespace")] -mod proxy { - fn execute(value: felt252) -> felt252 { - value +impl ContractStateUpgradableImpl of + dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() } } +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + IDojoInitImpl::dojo_init(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} -#[dojo::contract] -mod ctxnamed { - use traits::Into; - use dojo::world::Context; - fn execute(ctx2: Context, name: felt252) { - return (); - } +pub mod __external { + pub use super::__wrapper__ContractImpl__contract_name as contract_name; + pub use super::__wrapper__ContractImpl__namespace as namespace; + pub use super::__wrapper__ContractImpl__tag as tag; + pub use super::__wrapper__ContractImpl__name_hash as name_hash; + pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__ContractImpl__selector as selector; + pub use super::__wrapper__WorldProviderImpl__world as world; + pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; } - -#[dojo::contract] -mod withevent { - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - TestEvent: TestEvent, +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } } - #[derive(Drop, starknet::Event)] - struct TestEvent { - address: ContractAddress, +impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { + fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { + @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { + dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() + } + fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { + let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); + let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); } -impl EventDrop of core::traits::Drop::; -impl TestEventDrop of core::traits::Drop::; } - -#[starknet::component] -mod testcomponent1 { - #[storage] - struct Storage {} +impl IDojoInitDispatcherCopy of core::traits::Copy::; +impl IDojoInitDispatcherDrop of core::traits::Drop::; +impl IDojoInitDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } } +#[feature("derive-storage")] +impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} +impl ContractStorageBaseDrop of core::traits::Drop::; +impl ContractStorageBaseCopy of core::traits::Copy::; +impl ContractStorageBaseMutDrop of core::traits::Drop::; +impl ContractStorageBaseMutCopy of core::traits::Copy::; + + } + + #[starknet::contract] + mod spawn { + use dojo::world; + use dojo::world::IWorldDispatcher; + use dojo::world::IWorldDispatcherTrait; + use dojo::world::IWorldProvider; + use dojo::contract::IContract; + + #[abi(embed_v0)] + impl ContractImpl of IContract { + fn contract_name(self: @ContractState) -> ByteArray { + "spawn" + } + + fn namespace(self: @ContractState) -> ByteArray { + "test_package" + } + + fn tag(self: @ContractState) -> ByteArray { + "test_package-spawn" + } + + fn name_hash(self: @ContractState) -> felt252 { + 2776321589048333240377325502911505147617911439383944762363370901236132332849 + } + + fn namespace_hash(self: @ContractState) -> felt252 { + 3061092720893075933752785490401950953836105364709575990296000909161416686979 + } + + fn selector(self: @ContractState) -> felt252 { + 2472087249524108479557800499207886557849609293388925195637428170796835731505 + } + } + + #[abi(embed_v0)] + impl WorldProviderImpl of IWorldProvider { + fn world(self: @ContractState) -> IWorldDispatcher { + self.world_dispatcher.read() + } + } + + #[abi(embed_v0)] + impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; + + use traits::Into; + use dojo::world::Context; -#[starknet::component] -mod testcomponent2 { - #[storage] - struct Storage {} + fn execute(ctx: Context, name: felt252) { + return (); + } + + #[starknet::interface] + trait IDojoInit { + fn dojo_init(self: @ContractState); + } + + #[abi(embed_v0)] + impl IDojoInitImpl of IDojoInit { + fn dojo_init(self: @ContractState) { + assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); + } + } + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, + } +trait IDojoInitDispatcherTrait { + fn dojo_init(self: T); } -#[dojo::contract] -mod withcomponent { +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitDispatcher { + pub contract_address: starknet::ContractAddress, +} - #[storage] - struct Storage { - #[substorage(v0)] - testcomponent1_storage: testcomponent1::Storage, - #[substorage(v0)] - testcomponent2_storage: testcomponent2::Storage, +impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () } - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - #[flat] - testcomponent1_event: testcomponent1::Event, - testcomponent2_event: testcomponent2::Event, +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitLibraryDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () } -impl EventDrop of core::traits::Drop::; + } -#[dojo::interface] -trait IEmptyTrait; -#[dojo::interface] -trait IFaultyTrait { - const ONE: u8; +trait IDojoInitSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn dojo_init(self: T) -> starknet::SyscallResult<()>; +} - #[my_attr] - fn do_with_attrs(p1: u8) -> u16; +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, } -#[dojo::interface] -trait INominalTrait { - fn do_no_param() -> felt252; - fn do_no_param_but_world(world: @IWorldDispatcher) -> felt252; - fn do_no_param_but_world_ref(ref world: IWorldDispatcher) -> felt252; - fn do_params_no_world(p1: felt252, p2: u8) -> felt252; - fn do_params_and_world(world: @IWorldDispatcher, p2: u8) -> felt252; - fn do_params_and_world_ref(ref world: IWorldDispatcher, p2: u8) -> felt252; +impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } - fn do_with_self(self: @ContractState) -> felt252; - fn do_with_ref_self(ref self: ContractState) -> felt252; } -#[dojo::interface] -trait IFaultyTrait { - fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252; - fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; - fn do_with_self_and_world_inv(world: @IWorldDispatcher, self: @ContractState) -> felt252; - fn do_with_ref_self_and_world_inv( - ref world: IWorldDispatcher, ref self: ContractState - ) -> felt252; - fn do_with_several_world_dispatchers( - world: @IWorldDispatcher, vec: Vec2, ref another_world: IWorldDispatcher - ) -> felt252; - fn do_with_world_not_named_world(another_world: @IWorldDispatcher) -> felt252; - fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252; + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitSafeDispatcher { + pub contract_address: starknet::ContractAddress, } -#[dojo::contract] -mod MyFaultyContract { - #[abi(embed_v0)] - impl TestFaultyImpl of IFaultyTrait { - fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252 { - 'land' - } +impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); - fn do_with_ref_self_and_world( - ref self: ContractState, ref world: IWorldDispatcher - ) -> felt252 { - 'land' - } + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } - fn do_with_self_and_world_inv(world: @IWorldDispatcher, self: @ContractState) -> felt252 { - 'land' +} +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + Event::UpgradeableEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, } - - fn do_with_ref_self_and_world_inv( - ref world: IWorldDispatcher, ref self: ContractState - ) -> felt252 { - 'land' + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + if __selector__ == selector!("UpgradeableEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::UpgradeableEvent(val)); } + Option::None + } +} +impl EventUpgradeableEventIntoEvent of Into { + fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { + Event::UpgradeableEvent(self) + } +} - fn do_with_several_world_dispatchers( - world: @IWorldDispatcher, vec: Vec2, ref another_world: IWorldDispatcher - ) -> felt252 { - 'land' - } - fn do_with_world_not_named_world(another_world: @IWorldDispatcher) -> felt252 { - 'land' - } +pub struct Storage { + pub world_dispatcher: IWorldDispatcher, + pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, +} - fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252 { - 'land' +#[derive(Drop, Copy)] +pub struct ContractStorageBase { + pub world_dispatcher: starknet::storage::StorageBase, + pub upgradeable: starknet::storage::StorageBase, +} +#[derive(Drop, Copy)] +pub struct ContractStorageBaseMut { + pub world_dispatcher: starknet::storage::StorageBase>, + pub upgradeable: starknet::storage::StorageBase>, +} +impl StorageBaseImpl of starknet::storage::StorageBaseTrait { + type BaseType = ContractStorageBase; + type BaseMutType = ContractStorageBaseMut; + fn storage_base(self: @ContractState) -> ContractStorageBase { + ContractStorageBase { + world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, + upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, } } - - #[generate_trait] - impl InternalImplBad of InternalUtils { - fn bad_func_using_generate(world: @IWorldDispatcher) -> felt252 { - 'land' + fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { + ContractStorageBaseMut { + world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, + upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, } } - trait InternalUtils{ - fn bad_func_using_generate(world: @IWorldDispatcher) -> felt252; - } +} +pub struct ContractState { + pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, } -#[dojo::contract] -mod MyNominalContract { - #[derive(Drop)] - struct Action { - damage: u8 +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = ContractStorageBase; + fn snapshot_deref(self: @ContractState) -> ContractStorageBase { + self.storage_base() + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = ContractStorageBaseMut; + fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { + self.storage_base_mut() + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), } +} - #[abi(embed_v0)] - impl TestNominalImpl of INominalTrait { - fn do_no_param() -> felt252 { - 'land' - } +use starknet::storage::{ + StorageMapReadAccessTrait, StorageMapWriteAccessTrait, + StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess +}; +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::contract_name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} - fn do_no_param_but_world(world: @IWorldDispatcher) -> felt252 { - 'land' - } +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} - fn do_no_param_but_world_ref(ref world: IWorldDispatcher) -> felt252 { - 'land' - } +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} - fn do_params_no_world(p1: felt252, p2: u8) -> felt252 { - 'land' - } +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} - fn do_params_and_world(world: @IWorldDispatcher, p2: u8) -> felt252 { - 'land' - } +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} - fn do_params_and_world_ref(ref world: IWorldDispatcher, p2: u8) -> felt252 { - 'land' - } +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} - fn do_with_self(self: @ContractState) -> felt252 { - 'land' - } +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = WorldProviderImpl::world(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} - fn do_with_ref_self(ref self: ContractState) -> felt252 { - 'land' - } +impl ContractStateUpgradableImpl of + dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() } +} +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + IDojoInitImpl::dojo_init(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} - #[generate_trait] - impl ImplInternalNoContractState of InternalNoContractState { - fn func1(world: IWorldDispatcher) -> felt252 { - let _w = world; - 42 + +pub mod __external { + pub use super::__wrapper__ContractImpl__contract_name as contract_name; + pub use super::__wrapper__ContractImpl__namespace as namespace; + pub use super::__wrapper__ContractImpl__tag as tag; + pub use super::__wrapper__ContractImpl__name_hash as name_hash; + pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__ContractImpl__selector as selector; + pub use super::__wrapper__WorldProviderImpl__world as world; + pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) } } -impl ActionDrop of core::traits::Drop::; - trait InternalNoContractState { - fn func1(world: IWorldDispatcher) -> felt252; + +impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { + fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { + @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { + dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() + } + fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { + let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); + let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); } } - -#[dojo::contract] -mod init_test { - fn dojo_init( - world: IWorldDispatcher, - actions_address: ContractAddress, - actions_class: ClassHash, - value: u8 - ) { - emit!( - world, - ContractInitialized { - contract_address: actions_address, contract_class: actions_class, value +impl IDojoInitDispatcherCopy of core::traits::Copy::; +impl IDojoInitDispatcherDrop of core::traits::Drop::; +impl IDojoInitDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, } - ); + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() } } - -#[dojo::contract] -mod no_init_test {} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} +impl ContractStorageBaseDrop of core::traits::Drop::; +impl ContractStorageBaseCopy of core::traits::Copy::; +impl ContractStorageBaseMutDrop of core::traits::Drop::; +impl ContractStorageBaseMutCopy of core::traits::Copy::; + + } + + #[starknet::contract] + mod proxy { + use dojo::world; + use dojo::world::IWorldDispatcher; + use dojo::world::IWorldDispatcherTrait; + use dojo::world::IWorldProvider; + use dojo::contract::IContract; + + #[abi(embed_v0)] + impl ContractImpl of IContract { + fn contract_name(self: @ContractState) -> ByteArray { + "proxy" + } + + fn namespace(self: @ContractState) -> ByteArray { + "test_package" + } + + fn tag(self: @ContractState) -> ByteArray { + "test_package-proxy" + } + + fn name_hash(self: @ContractState) -> felt252 { + 379211399603323842291430789821178524592027629543381998047225121027704003915 + } + + fn namespace_hash(self: @ContractState) -> felt252 { + 3061092720893075933752785490401950953836105364709575990296000909161416686979 + } + + fn selector(self: @ContractState) -> felt252 { + 3522586352349720867166847576673128733430338006217587257445073829693434546448 + } + } + + #[abi(embed_v0)] + impl WorldProviderImpl of IWorldProvider { + fn world(self: @ContractState) -> IWorldDispatcher { + self.world_dispatcher.read() + } + } + + #[abi(embed_v0)] + impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; + + fn execute(value: felt252) -> felt252 { + value + } + + #[starknet::interface] + trait IDojoInit { + fn dojo_init(self: @ContractState); + } + + #[abi(embed_v0)] + impl IDojoInitImpl of IDojoInit { + fn dojo_init(self: @ContractState) { + assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); + } + } + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, + } +trait IDojoInitDispatcherTrait { + fn dojo_init(self: T); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitLibraryDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +trait IDojoInitSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn dojo_init(self: T) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + Event::UpgradeableEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + if __selector__ == selector!("UpgradeableEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::UpgradeableEvent(val)); + } + Option::None + } +} +impl EventUpgradeableEventIntoEvent of Into { + fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { + Event::UpgradeableEvent(self) + } +} + + +pub struct Storage { + pub world_dispatcher: IWorldDispatcher, + pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, +} + +#[derive(Drop, Copy)] +pub struct ContractStorageBase { + pub world_dispatcher: starknet::storage::StorageBase, + pub upgradeable: starknet::storage::StorageBase, +} +#[derive(Drop, Copy)] +pub struct ContractStorageBaseMut { + pub world_dispatcher: starknet::storage::StorageBase>, + pub upgradeable: starknet::storage::StorageBase>, +} +impl StorageBaseImpl of starknet::storage::StorageBaseTrait { + type BaseType = ContractStorageBase; + type BaseMutType = ContractStorageBaseMut; + fn storage_base(self: @ContractState) -> ContractStorageBase { + ContractStorageBase { + world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, + upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, + } + } + fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { + ContractStorageBaseMut { + world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, + upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, + } + } +} +pub struct ContractState { + pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = ContractStorageBase; + fn snapshot_deref(self: @ContractState) -> ContractStorageBase { + self.storage_base() + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = ContractStorageBaseMut; + fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { + self.storage_base_mut() + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), + } +} + +use starknet::storage::{ + StorageMapReadAccessTrait, StorageMapWriteAccessTrait, + StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess +}; +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::contract_name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = WorldProviderImpl::world(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +impl ContractStateUpgradableImpl of + dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + IDojoInitImpl::dojo_init(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__ContractImpl__contract_name as contract_name; + pub use super::__wrapper__ContractImpl__namespace as namespace; + pub use super::__wrapper__ContractImpl__tag as tag; + pub use super::__wrapper__ContractImpl__name_hash as name_hash; + pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__ContractImpl__selector as selector; + pub use super::__wrapper__WorldProviderImpl__world as world; + pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } + +impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { + fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { + @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { + dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() + } + fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { + let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); + let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); + } +} +impl IDojoInitDispatcherCopy of core::traits::Copy::; +impl IDojoInitDispatcherDrop of core::traits::Drop::; +impl IDojoInitDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} +impl ContractStorageBaseDrop of core::traits::Drop::; +impl ContractStorageBaseCopy of core::traits::Copy::; +impl ContractStorageBaseMutDrop of core::traits::Drop::; +impl ContractStorageBaseMutCopy of core::traits::Copy::; + + } + + #[starknet::contract] + mod ctxnamed { + use dojo::world; + use dojo::world::IWorldDispatcher; + use dojo::world::IWorldDispatcherTrait; + use dojo::world::IWorldProvider; + use dojo::contract::IContract; + + #[abi(embed_v0)] + impl ContractImpl of IContract { + fn contract_name(self: @ContractState) -> ByteArray { + "ctxnamed" + } + + fn namespace(self: @ContractState) -> ByteArray { + "test_package" + } + + fn tag(self: @ContractState) -> ByteArray { + "test_package-ctxnamed" + } + + fn name_hash(self: @ContractState) -> felt252 { + 1120614286815912604239420768209466007446460277061516527925636408561239543041 + } + + fn namespace_hash(self: @ContractState) -> felt252 { + 3061092720893075933752785490401950953836105364709575990296000909161416686979 + } + + fn selector(self: @ContractState) -> felt252 { + 882574079468045629402181499911470715863025356910172410020020548741739455774 + } + } + + #[abi(embed_v0)] + impl WorldProviderImpl of IWorldProvider { + fn world(self: @ContractState) -> IWorldDispatcher { + self.world_dispatcher.read() + } + } + + #[abi(embed_v0)] + impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; + + use traits::Into; + use dojo::world::Context; + + fn execute(ctx2: Context, name: felt252) { + return (); + } + + #[starknet::interface] + trait IDojoInit { + fn dojo_init(self: @ContractState); + } + + #[abi(embed_v0)] + impl IDojoInitImpl of IDojoInit { + fn dojo_init(self: @ContractState) { + assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); + } + } + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, + } +trait IDojoInitDispatcherTrait { + fn dojo_init(self: T); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitLibraryDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +trait IDojoInitSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn dojo_init(self: T) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + Event::UpgradeableEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + if __selector__ == selector!("UpgradeableEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::UpgradeableEvent(val)); + } + Option::None + } +} +impl EventUpgradeableEventIntoEvent of Into { + fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { + Event::UpgradeableEvent(self) + } +} + + +pub struct Storage { + pub world_dispatcher: IWorldDispatcher, + pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, +} + +#[derive(Drop, Copy)] +pub struct ContractStorageBase { + pub world_dispatcher: starknet::storage::StorageBase, + pub upgradeable: starknet::storage::StorageBase, +} +#[derive(Drop, Copy)] +pub struct ContractStorageBaseMut { + pub world_dispatcher: starknet::storage::StorageBase>, + pub upgradeable: starknet::storage::StorageBase>, +} +impl StorageBaseImpl of starknet::storage::StorageBaseTrait { + type BaseType = ContractStorageBase; + type BaseMutType = ContractStorageBaseMut; + fn storage_base(self: @ContractState) -> ContractStorageBase { + ContractStorageBase { + world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, + upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, + } + } + fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { + ContractStorageBaseMut { + world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, + upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, + } + } +} +pub struct ContractState { + pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = ContractStorageBase; + fn snapshot_deref(self: @ContractState) -> ContractStorageBase { + self.storage_base() + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = ContractStorageBaseMut; + fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { + self.storage_base_mut() + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), + } +} + +use starknet::storage::{ + StorageMapReadAccessTrait, StorageMapWriteAccessTrait, + StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess +}; +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::contract_name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = WorldProviderImpl::world(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +impl ContractStateUpgradableImpl of + dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + IDojoInitImpl::dojo_init(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__ContractImpl__contract_name as contract_name; + pub use super::__wrapper__ContractImpl__namespace as namespace; + pub use super::__wrapper__ContractImpl__tag as tag; + pub use super::__wrapper__ContractImpl__name_hash as name_hash; + pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__ContractImpl__selector as selector; + pub use super::__wrapper__WorldProviderImpl__world as world; + pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } + +impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { + fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { + @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { + dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() + } + fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { + let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); + let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); + } +} +impl IDojoInitDispatcherCopy of core::traits::Copy::; +impl IDojoInitDispatcherDrop of core::traits::Drop::; +impl IDojoInitDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} +impl ContractStorageBaseDrop of core::traits::Drop::; +impl ContractStorageBaseCopy of core::traits::Copy::; +impl ContractStorageBaseMutDrop of core::traits::Drop::; +impl ContractStorageBaseMutCopy of core::traits::Copy::; + + } + + #[starknet::contract] + mod withevent { + use dojo::world; + use dojo::world::IWorldDispatcher; + use dojo::world::IWorldDispatcherTrait; + use dojo::world::IWorldProvider; + use dojo::contract::IContract; + + #[abi(embed_v0)] + impl ContractImpl of IContract { + fn contract_name(self: @ContractState) -> ByteArray { + "withevent" + } + + fn namespace(self: @ContractState) -> ByteArray { + "test_package" + } + + fn tag(self: @ContractState) -> ByteArray { + "test_package-withevent" + } + + fn name_hash(self: @ContractState) -> felt252 { + 2196275886623691942883456540767114081898043897719876113518403014973431884540 + } + + fn namespace_hash(self: @ContractState) -> felt252 { + 3061092720893075933752785490401950953836105364709575990296000909161416686979 + } + + fn selector(self: @ContractState) -> felt252 { + 2302995054894169641868030754357260737170491794196617685355614288827933407674 + } + } + + #[abi(embed_v0)] + impl WorldProviderImpl of IWorldProvider { + fn world(self: @ContractState) -> IWorldDispatcher { + self.world_dispatcher.read() + } + } + + #[abi(embed_v0)] + impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; + + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, + TestEvent: TestEvent + } + + #[derive(Drop, starknet::Event)] + struct TestEvent { + address: ContractAddress, + } + + #[starknet::interface] + trait IDojoInit { + fn dojo_init(self: @ContractState); + } + + #[abi(embed_v0)] + impl IDojoInitImpl of IDojoInit { + fn dojo_init(self: @ContractState) { + assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); + } + } +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + Event::UpgradeableEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + Event::TestEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("TestEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + if __selector__ == selector!("UpgradeableEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::UpgradeableEvent(val)); + } + if __selector__ == selector!("TestEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::TestEvent(val)); + } + Option::None + } +} +impl EventUpgradeableEventIntoEvent of Into { + fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { + Event::UpgradeableEvent(self) + } +} +impl EventTestEventIntoEvent of Into { + fn into(self: TestEvent) -> Event { + Event::TestEvent(self) + } +} +impl TestEventDrop of core::traits::Drop::; +impl TestEventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @TestEvent, ref keys: Array, ref data: Array + ) { + core::serde::Serde::serialize(self.address, ref data); + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let address = core::serde::Serde::deserialize( + ref data + )?; + Option::Some(TestEvent {address, }) + } +} +trait IDojoInitDispatcherTrait { + fn dojo_init(self: T); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitLibraryDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +trait IDojoInitSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn dojo_init(self: T) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +pub struct Storage { + pub world_dispatcher: IWorldDispatcher, + pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, +} + +#[derive(Drop, Copy)] +pub struct ContractStorageBase { + pub world_dispatcher: starknet::storage::StorageBase, + pub upgradeable: starknet::storage::StorageBase, +} +#[derive(Drop, Copy)] +pub struct ContractStorageBaseMut { + pub world_dispatcher: starknet::storage::StorageBase>, + pub upgradeable: starknet::storage::StorageBase>, +} +impl StorageBaseImpl of starknet::storage::StorageBaseTrait { + type BaseType = ContractStorageBase; + type BaseMutType = ContractStorageBaseMut; + fn storage_base(self: @ContractState) -> ContractStorageBase { + ContractStorageBase { + world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, + upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, + } + } + fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { + ContractStorageBaseMut { + world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, + upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, + } + } +} +pub struct ContractState { + pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = ContractStorageBase; + fn snapshot_deref(self: @ContractState) -> ContractStorageBase { + self.storage_base() + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = ContractStorageBaseMut; + fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { + self.storage_base_mut() + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), + } +} + +use starknet::storage::{ + StorageMapReadAccessTrait, StorageMapWriteAccessTrait, + StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess +}; +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::contract_name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = WorldProviderImpl::world(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +impl ContractStateUpgradableImpl of + dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + IDojoInitImpl::dojo_init(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__ContractImpl__contract_name as contract_name; + pub use super::__wrapper__ContractImpl__namespace as namespace; + pub use super::__wrapper__ContractImpl__tag as tag; + pub use super::__wrapper__ContractImpl__name_hash as name_hash; + pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__ContractImpl__selector as selector; + pub use super::__wrapper__WorldProviderImpl__world as world; + pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } + +impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { + fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { + @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { + dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() + } + fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { + let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); + let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); + } +} +impl IDojoInitDispatcherCopy of core::traits::Copy::; +impl IDojoInitDispatcherDrop of core::traits::Drop::; +impl IDojoInitDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} +impl ContractStorageBaseDrop of core::traits::Drop::; +impl ContractStorageBaseCopy of core::traits::Copy::; +impl ContractStorageBaseMutDrop of core::traits::Drop::; +impl ContractStorageBaseMutCopy of core::traits::Copy::; + + } + + #[starknet::contract] + mod withcomponent { + use dojo::world; + use dojo::world::IWorldDispatcher; + use dojo::world::IWorldDispatcherTrait; + use dojo::world::IWorldProvider; + use dojo::contract::IContract; + + #[abi(embed_v0)] + impl ContractImpl of IContract { + fn contract_name(self: @ContractState) -> ByteArray { + "withcomponent" + } + + fn namespace(self: @ContractState) -> ByteArray { + "test_package" + } + + fn tag(self: @ContractState) -> ByteArray { + "test_package-withcomponent" + } + + fn name_hash(self: @ContractState) -> felt252 { + 999850881662666048155666650426666132968026605763740651763663703103974774091 + } + + fn namespace_hash(self: @ContractState) -> felt252 { + 3061092720893075933752785490401950953836105364709575990296000909161416686979 + } + + fn selector(self: @ContractState) -> felt252 { + 795804664978713707757807985251114311939501109833092725925763852713460388378 + } + } + + #[abi(embed_v0)] + impl WorldProviderImpl of IWorldProvider { + fn world(self: @ContractState) -> IWorldDispatcher { + self.world_dispatcher.read() + } + } + + #[abi(embed_v0)] + impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, + #[flat] + testcomponent1_event: testcomponent1::Event, + testcomponent2_event: testcomponent2::Event + } + + #[starknet::interface] + trait IDojoInit { + fn dojo_init(self: @ContractState); + } + + #[abi(embed_v0)] + impl IDojoInitImpl of IDojoInit { + fn dojo_init(self: @ContractState) { + assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); + } + } + + +pub struct Storage { + pub world_dispatcher: IWorldDispatcher, + pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, + pub testcomponent1_storage: testcomponent1::Storage, + pub testcomponent2_storage: testcomponent2::Storage, +} + +#[derive(Drop, Copy)] +pub struct ContractStorageBase { + pub world_dispatcher: starknet::storage::StorageBase, + pub upgradeable: starknet::storage::StorageBase, + pub testcomponent1_storage: starknet::storage::StorageBase, + pub testcomponent2_storage: starknet::storage::StorageBase, +} +#[derive(Drop, Copy)] +pub struct ContractStorageBaseMut { + pub world_dispatcher: starknet::storage::StorageBase>, + pub upgradeable: starknet::storage::StorageBase>, + pub testcomponent1_storage: starknet::storage::StorageBase>, + pub testcomponent2_storage: starknet::storage::StorageBase>, +} +impl StorageBaseImpl of starknet::storage::StorageBaseTrait { + type BaseType = ContractStorageBase; + type BaseMutType = ContractStorageBaseMut; + fn storage_base(self: @ContractState) -> ContractStorageBase { + ContractStorageBase { + world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, + upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, + testcomponent1_storage: starknet::storage::StorageBase{ address: selector!("testcomponent1_storage") }, + testcomponent2_storage: starknet::storage::StorageBase{ address: selector!("testcomponent2_storage") }, + } + } + fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { + ContractStorageBaseMut { + world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, + upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, + testcomponent1_storage: starknet::storage::StorageBase{ address: selector!("testcomponent1_storage") }, + testcomponent2_storage: starknet::storage::StorageBase{ address: selector!("testcomponent2_storage") }, + } + } +} +pub struct ContractState { + pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, + pub testcomponent1_storage: testcomponent1::ComponentState, + pub testcomponent2_storage: testcomponent2::ComponentState, +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = ContractStorageBase; + fn snapshot_deref(self: @ContractState) -> ContractStorageBase { + self.storage_base() + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = ContractStorageBaseMut; + fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { + self.storage_base_mut() + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), + testcomponent1_storage: testcomponent1::unsafe_new_component_state::(), + testcomponent2_storage: testcomponent2::unsafe_new_component_state::(), + } +} + +use starknet::storage::{ + StorageMapReadAccessTrait, StorageMapWriteAccessTrait, + StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess +}; +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::contract_name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = WorldProviderImpl::world(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +impl ContractStateUpgradableImpl of + dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + IDojoInitImpl::dojo_init(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__ContractImpl__contract_name as contract_name; + pub use super::__wrapper__ContractImpl__namespace as namespace; + pub use super::__wrapper__ContractImpl__tag as tag; + pub use super::__wrapper__ContractImpl__name_hash as name_hash; + pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__ContractImpl__selector as selector; + pub use super::__wrapper__WorldProviderImpl__world as world; + pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } + +impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { + fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { + @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { + dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() + } + fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { + let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); + let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); + } +} +impl HasComponentImpl_testcomponent1 of testcomponent1::HasComponent { + fn get_component(self: @ContractState) -> @testcomponent1::ComponentState { + @testcomponent1::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> testcomponent1::ComponentState { + testcomponent1::unsafe_new_component_state::() + } + fn get_contract(self: @testcomponent1::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: testcomponent1::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: testcomponent1::ComponentState, event: S) { + let event: testcomponent1::Event = core::traits::Into::into(event); + let mut contract = testcomponent1::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::testcomponent1_event(event)); + } +} +impl HasComponentImpl_testcomponent2 of testcomponent2::HasComponent { + fn get_component(self: @ContractState) -> @testcomponent2::ComponentState { + @testcomponent2::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> testcomponent2::ComponentState { + testcomponent2::unsafe_new_component_state::() + } + fn get_contract(self: @testcomponent2::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: testcomponent2::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: testcomponent2::ComponentState, event: S) { + let event: testcomponent2::Event = core::traits::Into::into(event); + let mut contract = testcomponent2::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::testcomponent2_event(event)); + } +} +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + Event::UpgradeableEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + Event::testcomponent1_event(val) => { + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + Event::testcomponent2_event(val) => { + core::array::ArrayTrait::append(ref keys, selector!("testcomponent2_event")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + { + let mut keys = keys; + let mut data = data; + match starknet::Event::deserialize(ref keys, ref data) { + Option::Some(val) => { + return Option::Some(Event::testcomponent1_event(val)); + }, + Option::None => {}, + }; + } + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + if __selector__ == selector!("UpgradeableEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::UpgradeableEvent(val)); + } + if __selector__ == selector!("testcomponent2_event") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::testcomponent2_event(val)); + } + Option::None + } +} +impl EventUpgradeableEventIntoEvent of Into { + fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { + Event::UpgradeableEvent(self) + } +} +impl Eventtestcomponent1_eventIntoEvent of Into { + fn into(self: testcomponent1::Event) -> Event { + Event::testcomponent1_event(self) + } +} +impl Eventtestcomponent2_eventIntoEvent of Into { + fn into(self: testcomponent2::Event) -> Event { + Event::testcomponent2_event(self) + } +} +trait IDojoInitDispatcherTrait { + fn dojo_init(self: T); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitLibraryDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +trait IDojoInitSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn dojo_init(self: T) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +impl ContractStorageBaseDrop of core::traits::Drop::; +impl ContractStorageBaseCopy of core::traits::Copy::; +impl ContractStorageBaseMutDrop of core::traits::Drop::; +impl ContractStorageBaseMutCopy of core::traits::Copy::; +impl IDojoInitDispatcherCopy of core::traits::Copy::; +impl IDojoInitDispatcherDrop of core::traits::Drop::; +impl IDojoInitDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} + + } + + #[starknet::interface] + trait IEmptyTrait {} + + #[starknet::interface] + trait IFaultyTrait { + fn do_with_attrs(self: @TContractState, p1: u8) -> u16; + } + + #[starknet::interface] + trait INominalTrait { + fn do_no_param(self: @TContractState) -> felt252;fn do_no_param_but_world(self: @TContractState) -> felt252;fn do_no_param_but_world_ref(ref self: TContractState) -> felt252;fn do_params_no_world(self: @TContractState, p1: felt252, p2: u8) -> felt252;fn do_params_and_world(self: @TContractState, p2: u8) -> felt252;fn do_params_and_world_ref(ref self: TContractState, p2: u8) -> felt252;fn do_with_self(self: @ContractState) -> felt252;fn do_with_ref_self(ref self: ContractState) -> felt252; + } + + #[starknet::interface] + trait IFaultyTrait { + fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252;fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252;fn do_with_self_and_world_inv(self: @TContractState, self: @ContractState) -> felt252;fn do_with_ref_self_and_world_inv(ref self: TContractState, ref self: ContractState +) -> felt252;fn do_with_several_world_dispatchers(self: @TContractState, vec: Vec2, ref another_world: IWorldDispatcher +) -> felt252;fn do_with_world_not_named_world(self: @TContractState, another_world: @IWorldDispatcher) -> felt252;fn do_with_world_not_first(self: @TContractState, vec: Vec2, ref world: IWorldDispatcher) -> felt252; + } + + #[starknet::contract] + mod MyFaultyContract { + use dojo::world; + use dojo::world::IWorldDispatcher; + use dojo::world::IWorldDispatcherTrait; + use dojo::world::IWorldProvider; + use dojo::contract::IContract; + + #[abi(embed_v0)] + impl ContractImpl of IContract { + fn contract_name(self: @ContractState) -> ByteArray { + "MyFaultyContract" + } + + fn namespace(self: @ContractState) -> ByteArray { + "test_package" + } + + fn tag(self: @ContractState) -> ByteArray { + "test_package-MyFaultyContract" + } + + fn name_hash(self: @ContractState) -> felt252 { + 3439743807865759203015037013733809315384408083697880336790137144257764256358 + } + + fn namespace_hash(self: @ContractState) -> felt252 { + 3061092720893075933752785490401950953836105364709575990296000909161416686979 + } + + fn selector(self: @ContractState) -> felt252 { + 1862046669446530718410691364259438011386499031689246339557998041337203828246 + } + } + + #[abi(embed_v0)] + impl WorldProviderImpl of IWorldProvider { + fn world(self: @ContractState) -> IWorldDispatcher { + self.world_dispatcher.read() + } + } + + #[abi(embed_v0)] + impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; + + #[abi(embed_v0)] + impl TestFaultyImpl of IFaultyTrait {fn do_with_self_and_world(self: @ContractState) -> felt252 { 'land' +}fn do_with_ref_self_and_world( ref self: ContractState) -> felt252 { 'land' +}fn do_with_self_and_world_inv(self: @ContractState, self: @ContractState) -> felt252 {let world = self.world_dispatcher.read(); 'land' +}fn do_with_ref_self_and_world_inv(ref self: ContractState, ref self: ContractState +) -> felt252 {let world = self.world_dispatcher.read(); 'land' +}fn do_with_several_world_dispatchers(self: @ContractState, vec: Vec2, ref another_world: IWorldDispatcher +) -> felt252 {let world = self.world_dispatcher.read(); 'land' +}fn do_with_world_not_named_world(self: @ContractState, another_world: @IWorldDispatcher) -> felt252 { 'land' +}fn do_with_world_not_first(self: @ContractState, vec: Vec2) -> felt252 { 'land' +}} + #[generate_trait] + impl InternalImplBad of InternalUtils {fn bad_func_using_generate(self: @ContractState) -> felt252 {let world = self.world_dispatcher.read(); 'land' +}} + #[starknet::interface] + trait IDojoInit { + fn dojo_init(self: @ContractState); + } + + #[abi(embed_v0)] + impl IDojoInitImpl of IDojoInit { + fn dojo_init(self: @ContractState) { + assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); + } + } + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, + } + trait InternalUtils{fn bad_func_using_generate(self: @ContractState) -> felt252; +} +trait IDojoInitDispatcherTrait { + fn dojo_init(self: T); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitLibraryDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +trait IDojoInitSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn dojo_init(self: T) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + Event::UpgradeableEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + if __selector__ == selector!("UpgradeableEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::UpgradeableEvent(val)); + } + Option::None + } +} +impl EventUpgradeableEventIntoEvent of Into { + fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { + Event::UpgradeableEvent(self) + } +} + + +pub struct Storage { + pub world_dispatcher: IWorldDispatcher, + pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, +} + +#[derive(Drop, Copy)] +pub struct ContractStorageBase { + pub world_dispatcher: starknet::storage::StorageBase, + pub upgradeable: starknet::storage::StorageBase, +} +#[derive(Drop, Copy)] +pub struct ContractStorageBaseMut { + pub world_dispatcher: starknet::storage::StorageBase>, + pub upgradeable: starknet::storage::StorageBase>, +} +impl StorageBaseImpl of starknet::storage::StorageBaseTrait { + type BaseType = ContractStorageBase; + type BaseMutType = ContractStorageBaseMut; + fn storage_base(self: @ContractState) -> ContractStorageBase { + ContractStorageBase { + world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, + upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, + } + } + fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { + ContractStorageBaseMut { + world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, + upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, + } + } +} +pub struct ContractState { + pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = ContractStorageBase; + fn snapshot_deref(self: @ContractState) -> ContractStorageBase { + self.storage_base() + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = ContractStorageBaseMut; + fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { + self.storage_base_mut() + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), + } +} + +use starknet::storage::{ + StorageMapReadAccessTrait, StorageMapWriteAccessTrait, + StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess +}; +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::contract_name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = WorldProviderImpl::world(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +impl ContractStateUpgradableImpl of + dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__TestFaultyImpl__do_with_self_and_world(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = TestFaultyImpl::do_with_self_and_world(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__TestFaultyImpl__do_with_ref_self_and_world(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = TestFaultyImpl::do_with_ref_self_and_world(ref contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__TestFaultyImpl__do_with_self_and_world_inv(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_self = core::option::OptionTraitImpl::expect( + core::serde::Serde::<@ContractState>::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = TestFaultyImpl::do_with_self_and_world_inv(@contract_state, __arg_self); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__TestFaultyImpl__do_with_ref_self_and_world_inv(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let mut __arg_self = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = TestFaultyImpl::do_with_ref_self_and_world_inv(ref contract_state, ref __arg_self); + let mut arr = ArrayTrait::new(); + // References. + core::serde::Serde::::serialize(@__arg_self, ref arr); + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__TestFaultyImpl__do_with_several_world_dispatchers(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_vec = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + let mut __arg_another_world = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #2' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = TestFaultyImpl::do_with_several_world_dispatchers(@contract_state, __arg_vec, ref __arg_another_world); + let mut arr = ArrayTrait::new(); + // References. + core::serde::Serde::::serialize(@__arg_another_world, ref arr); + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__TestFaultyImpl__do_with_world_not_named_world(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_another_world = core::option::OptionTraitImpl::expect( + core::serde::Serde::<@IWorldDispatcher>::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = TestFaultyImpl::do_with_world_not_named_world(@contract_state, __arg_another_world); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__TestFaultyImpl__do_with_world_not_first(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_vec = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = TestFaultyImpl::do_with_world_not_first(@contract_state, __arg_vec); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + IDojoInitImpl::dojo_init(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__ContractImpl__contract_name as contract_name; + pub use super::__wrapper__ContractImpl__namespace as namespace; + pub use super::__wrapper__ContractImpl__tag as tag; + pub use super::__wrapper__ContractImpl__name_hash as name_hash; + pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__ContractImpl__selector as selector; + pub use super::__wrapper__WorldProviderImpl__world as world; + pub use super::__wrapper__TestFaultyImpl__do_with_self_and_world as do_with_self_and_world; + pub use super::__wrapper__TestFaultyImpl__do_with_ref_self_and_world as do_with_ref_self_and_world; + pub use super::__wrapper__TestFaultyImpl__do_with_self_and_world_inv as do_with_self_and_world_inv; + pub use super::__wrapper__TestFaultyImpl__do_with_ref_self_and_world_inv as do_with_ref_self_and_world_inv; + pub use super::__wrapper__TestFaultyImpl__do_with_several_world_dispatchers as do_with_several_world_dispatchers; + pub use super::__wrapper__TestFaultyImpl__do_with_world_not_named_world as do_with_world_not_named_world; + pub use super::__wrapper__TestFaultyImpl__do_with_world_not_first as do_with_world_not_first; + pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } + +impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { + fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { + @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { + dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() + } + fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { + let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); + let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); + } +} +impl IDojoInitDispatcherCopy of core::traits::Copy::; +impl IDojoInitDispatcherDrop of core::traits::Drop::; +impl IDojoInitDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} +impl ContractStorageBaseDrop of core::traits::Drop::; +impl ContractStorageBaseCopy of core::traits::Copy::; +impl ContractStorageBaseMutDrop of core::traits::Drop::; +impl ContractStorageBaseMutCopy of core::traits::Copy::; + + } + + #[starknet::contract] + mod MyNominalContract { + use dojo::world; + use dojo::world::IWorldDispatcher; + use dojo::world::IWorldDispatcherTrait; + use dojo::world::IWorldProvider; + use dojo::contract::IContract; + + #[abi(embed_v0)] + impl ContractImpl of IContract { + fn contract_name(self: @ContractState) -> ByteArray { + "MyNominalContract" + } + + fn namespace(self: @ContractState) -> ByteArray { + "test_package" + } + + fn tag(self: @ContractState) -> ByteArray { + "test_package-MyNominalContract" + } + + fn name_hash(self: @ContractState) -> felt252 { + 1172628497499445169993220559087829230676589931723677494032285307738203070578 + } + + fn namespace_hash(self: @ContractState) -> felt252 { + 3061092720893075933752785490401950953836105364709575990296000909161416686979 + } + + fn selector(self: @ContractState) -> felt252 { + 2020162355936884646880401248118384176803981589166410970216209297939905305278 + } + } + + #[abi(embed_v0)] + impl WorldProviderImpl of IWorldProvider { + fn world(self: @ContractState) -> IWorldDispatcher { + self.world_dispatcher.read() + } + } + + #[abi(embed_v0)] + impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; + + #[derive(Drop)] + struct Action { + damage: u8 + } + + #[abi(embed_v0)] + impl TestNominalImpl of INominalTrait {fn do_no_param(self: @ContractState) -> felt252 { 'land' +}fn do_no_param_but_world(self: @ContractState) -> felt252 {let world = self.world_dispatcher.read(); 'land' +}fn do_no_param_but_world_ref(ref self: ContractState) -> felt252 {let world = self.world_dispatcher.read(); 'land' +}fn do_params_no_world(self: @ContractState, p1: felt252, p2: u8) -> felt252 { 'land' +}fn do_params_and_world(self: @ContractState, p2: u8) -> felt252 {let world = self.world_dispatcher.read(); 'land' +}fn do_params_and_world_ref(ref self: ContractState, p2: u8) -> felt252 {let world = self.world_dispatcher.read(); 'land' +}fn do_with_self(self: @ContractState) -> felt252 { 'land' +}fn do_with_ref_self(ref self: ContractState) -> felt252 { 'land' +}} + #[generate_trait] + impl ImplInternalNoContractState of InternalNoContractState { + fn func1(world: IWorldDispatcher) -> felt252 { + let _w = world; + 42 + } + } + + #[starknet::interface] + trait IDojoInit { + fn dojo_init(self: @ContractState); + } + + #[abi(embed_v0)] + impl IDojoInitImpl of IDojoInit { + fn dojo_init(self: @ContractState) { + assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); + } + } + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, + } +impl ActionDrop of core::traits::Drop::; + trait InternalNoContractState { + fn func1(world: IWorldDispatcher) -> felt252; + } +trait IDojoInitDispatcherTrait { + fn dojo_init(self: T); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitLibraryDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +trait IDojoInitSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn dojo_init(self: T) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + Event::UpgradeableEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + if __selector__ == selector!("UpgradeableEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::UpgradeableEvent(val)); + } + Option::None + } +} +impl EventUpgradeableEventIntoEvent of Into { + fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { + Event::UpgradeableEvent(self) + } +} + + +pub struct Storage { + pub world_dispatcher: IWorldDispatcher, + pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, +} + +#[derive(Drop, Copy)] +pub struct ContractStorageBase { + pub world_dispatcher: starknet::storage::StorageBase, + pub upgradeable: starknet::storage::StorageBase, +} +#[derive(Drop, Copy)] +pub struct ContractStorageBaseMut { + pub world_dispatcher: starknet::storage::StorageBase>, + pub upgradeable: starknet::storage::StorageBase>, +} +impl StorageBaseImpl of starknet::storage::StorageBaseTrait { + type BaseType = ContractStorageBase; + type BaseMutType = ContractStorageBaseMut; + fn storage_base(self: @ContractState) -> ContractStorageBase { + ContractStorageBase { + world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, + upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, + } + } + fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { + ContractStorageBaseMut { + world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, + upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, + } + } +} +pub struct ContractState { + pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = ContractStorageBase; + fn snapshot_deref(self: @ContractState) -> ContractStorageBase { + self.storage_base() + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = ContractStorageBaseMut; + fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { + self.storage_base_mut() + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), + } +} + +use starknet::storage::{ + StorageMapReadAccessTrait, StorageMapWriteAccessTrait, + StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess +}; +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::contract_name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = WorldProviderImpl::world(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +impl ContractStateUpgradableImpl of + dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__TestNominalImpl__do_no_param(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = TestNominalImpl::do_no_param(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__TestNominalImpl__do_no_param_but_world(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = TestNominalImpl::do_no_param_but_world(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__TestNominalImpl__do_no_param_but_world_ref(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = TestNominalImpl::do_no_param_but_world_ref(ref contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__TestNominalImpl__do_params_no_world(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_p1 = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + let __arg_p2 = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #2' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = TestNominalImpl::do_params_no_world(@contract_state, __arg_p1, __arg_p2); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__TestNominalImpl__do_params_and_world(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_p2 = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = TestNominalImpl::do_params_and_world(@contract_state, __arg_p2); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__TestNominalImpl__do_params_and_world_ref(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_p2 = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = TestNominalImpl::do_params_and_world_ref(ref contract_state, __arg_p2); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__TestNominalImpl__do_with_self(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = TestNominalImpl::do_with_self(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__TestNominalImpl__do_with_ref_self(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = TestNominalImpl::do_with_ref_self(ref contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + IDojoInitImpl::dojo_init(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__ContractImpl__contract_name as contract_name; + pub use super::__wrapper__ContractImpl__namespace as namespace; + pub use super::__wrapper__ContractImpl__tag as tag; + pub use super::__wrapper__ContractImpl__name_hash as name_hash; + pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__ContractImpl__selector as selector; + pub use super::__wrapper__WorldProviderImpl__world as world; + pub use super::__wrapper__TestNominalImpl__do_no_param as do_no_param; + pub use super::__wrapper__TestNominalImpl__do_no_param_but_world as do_no_param_but_world; + pub use super::__wrapper__TestNominalImpl__do_no_param_but_world_ref as do_no_param_but_world_ref; + pub use super::__wrapper__TestNominalImpl__do_params_no_world as do_params_no_world; + pub use super::__wrapper__TestNominalImpl__do_params_and_world as do_params_and_world; + pub use super::__wrapper__TestNominalImpl__do_params_and_world_ref as do_params_and_world_ref; + pub use super::__wrapper__TestNominalImpl__do_with_self as do_with_self; + pub use super::__wrapper__TestNominalImpl__do_with_ref_self as do_with_ref_self; + pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } + +impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { + fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { + @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { + dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() + } + fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { + let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); + let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); + } +} +impl IDojoInitDispatcherCopy of core::traits::Copy::; +impl IDojoInitDispatcherDrop of core::traits::Drop::; +impl IDojoInitDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} +impl ContractStorageBaseDrop of core::traits::Drop::; +impl ContractStorageBaseCopy of core::traits::Copy::; +impl ContractStorageBaseMutDrop of core::traits::Drop::; +impl ContractStorageBaseMutCopy of core::traits::Copy::; + + } + + #[starknet::contract] + mod init_test { + use dojo::world; + use dojo::world::IWorldDispatcher; + use dojo::world::IWorldDispatcherTrait; + use dojo::world::IWorldProvider; + use dojo::contract::IContract; + + #[abi(embed_v0)] + impl ContractImpl of IContract { + fn contract_name(self: @ContractState) -> ByteArray { + "init_test" + } + + fn namespace(self: @ContractState) -> ByteArray { + "test_package" + } + + fn tag(self: @ContractState) -> ByteArray { + "test_package-init_test" + } + + fn name_hash(self: @ContractState) -> felt252 { + 1673722391095039242574232979635399085098867563460816803458086922970092209409 + } + + fn namespace_hash(self: @ContractState) -> felt252 { + 3061092720893075933752785490401950953836105364709575990296000909161416686979 + } + + fn selector(self: @ContractState) -> felt252 { + 799876284284394866912776672431802324689156187217902437477103298743064217162 + } + } + + #[abi(embed_v0)] + impl WorldProviderImpl of IWorldProvider { + fn world(self: @ContractState) -> IWorldDispatcher { + self.world_dispatcher.read() + } + } + + #[abi(embed_v0)] + impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; + + #[starknet::interface] + trait IDojoInit { + fn dojo_init(self: @ContractState, actions_address: ContractAddress, actions_class: ClassHash, value: u8 +); + } + + #[abi(embed_v0)] + impl IDojoInitImpl of IDojoInit { + fn dojo_init(self: @ContractState, actions_address: ContractAddress, actions_class: ClassHash, value: u8 +) {let world = self.world_dispatcher.read();assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); emit!( + world, + ContractInitialized { + contract_address: actions_address, contract_class: actions_class, value + } + ); +} +} + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, + } +trait IDojoInitDispatcherTrait { + fn dojo_init(self: T, actions_address: ContractAddress, actions_class: ClassHash, value: u8 +); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitDispatcher, actions_address: ContractAddress, actions_class: ClassHash, value: u8 +) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@actions_address, ref __calldata__); + core::serde::Serde::::serialize(@actions_class, ref __calldata__); + core::serde::Serde::::serialize(@value, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitLibraryDispatcher, actions_address: ContractAddress, actions_class: ClassHash, value: u8 +) { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@actions_address, ref __calldata__); + core::serde::Serde::::serialize(@actions_class, ref __calldata__); + core::serde::Serde::::serialize(@value, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +trait IDojoInitSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn dojo_init(self: T, actions_address: ContractAddress, actions_class: ClassHash, value: u8 +) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeLibraryDispatcher, actions_address: ContractAddress, actions_class: ClassHash, value: u8 +) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@actions_address, ref __calldata__); + core::serde::Serde::::serialize(@actions_class, ref __calldata__); + core::serde::Serde::::serialize(@value, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeDispatcher, actions_address: ContractAddress, actions_class: ClassHash, value: u8 +) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@actions_address, ref __calldata__); + core::serde::Serde::::serialize(@actions_class, ref __calldata__); + core::serde::Serde::::serialize(@value, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + Event::UpgradeableEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + if __selector__ == selector!("UpgradeableEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::UpgradeableEvent(val)); + } + Option::None + } +} +impl EventUpgradeableEventIntoEvent of Into { + fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { + Event::UpgradeableEvent(self) + } +} + + +pub struct Storage { + pub world_dispatcher: IWorldDispatcher, + pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, +} + +#[derive(Drop, Copy)] +pub struct ContractStorageBase { + pub world_dispatcher: starknet::storage::StorageBase, + pub upgradeable: starknet::storage::StorageBase, +} +#[derive(Drop, Copy)] +pub struct ContractStorageBaseMut { + pub world_dispatcher: starknet::storage::StorageBase>, + pub upgradeable: starknet::storage::StorageBase>, +} +impl StorageBaseImpl of starknet::storage::StorageBaseTrait { + type BaseType = ContractStorageBase; + type BaseMutType = ContractStorageBaseMut; + fn storage_base(self: @ContractState) -> ContractStorageBase { + ContractStorageBase { + world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, + upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, + } + } + fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { + ContractStorageBaseMut { + world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, + upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, + } + } +} +pub struct ContractState { + pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = ContractStorageBase; + fn snapshot_deref(self: @ContractState) -> ContractStorageBase { + self.storage_base() + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = ContractStorageBaseMut; + fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { + self.storage_base_mut() + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), + } +} + +use starknet::storage::{ + StorageMapReadAccessTrait, StorageMapWriteAccessTrait, + StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess +}; +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::contract_name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = WorldProviderImpl::world(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +impl ContractStateUpgradableImpl of + dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + let __arg_actions_address = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #1' + ); + let __arg_actions_class = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #2' + ); + let __arg_value = core::option::OptionTraitImpl::expect( + core::serde::Serde::::deserialize(ref data), + 'Failed to deserialize param #3' + ); + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + IDojoInitImpl::dojo_init(@contract_state, __arg_actions_address, __arg_actions_class, __arg_value); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__ContractImpl__contract_name as contract_name; + pub use super::__wrapper__ContractImpl__namespace as namespace; + pub use super::__wrapper__ContractImpl__tag as tag; + pub use super::__wrapper__ContractImpl__name_hash as name_hash; + pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__ContractImpl__selector as selector; + pub use super::__wrapper__WorldProviderImpl__world as world; + pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } + +impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { + fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { + @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { + dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() + } + fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { + let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); + let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); + } +} +impl IDojoInitDispatcherCopy of core::traits::Copy::; +impl IDojoInitDispatcherDrop of core::traits::Drop::; +impl IDojoInitDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} +impl ContractStorageBaseDrop of core::traits::Drop::; +impl ContractStorageBaseCopy of core::traits::Copy::; +impl ContractStorageBaseMutDrop of core::traits::Drop::; +impl ContractStorageBaseMutCopy of core::traits::Copy::; + + } + + #[starknet::contract] + mod no_init_test { + use dojo::world; + use dojo::world::IWorldDispatcher; + use dojo::world::IWorldDispatcherTrait; + use dojo::world::IWorldProvider; + use dojo::contract::IContract; + + #[abi(embed_v0)] + impl ContractImpl of IContract { + fn contract_name(self: @ContractState) -> ByteArray { + "no_init_test" + } + + fn namespace(self: @ContractState) -> ByteArray { + "test_package" + } + + fn tag(self: @ContractState) -> ByteArray { + "test_package-no_init_test" + } + + fn name_hash(self: @ContractState) -> felt252 { + 2188407785440294979090510634648735461326850740369373015349552249835679156474 + } + + fn namespace_hash(self: @ContractState) -> felt252 { + 3061092720893075933752785490401950953836105364709575990296000909161416686979 + } + + fn selector(self: @ContractState) -> felt252 { + 3269287263937103915837903451864388946886384011514094502724942119672327217364 + } + } + + #[abi(embed_v0)] + impl WorldProviderImpl of IWorldProvider { + fn world(self: @ContractState) -> IWorldDispatcher { + self.world_dispatcher.read() + } + } + + #[abi(embed_v0)] + impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; + + + #[starknet::interface] + trait IDojoInit { + fn dojo_init(self: @ContractState); + } + + #[abi(embed_v0)] + impl IDojoInitImpl of IDojoInit { + fn dojo_init(self: @ContractState) { + assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); + } + } + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, + } +trait IDojoInitDispatcherTrait { + fn dojo_init(self: T); +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { + fn dojo_init(self: IDojoInitLibraryDispatcher) { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + () + } + +} + +trait IDojoInitSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn dojo_init(self: T) -> starknet::SyscallResult<()>; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IDojoInitSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { + fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("dojo_init"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok(()) + } + +} +impl EventDrop of core::traits::Drop::; +impl EventIsEvent of starknet::Event { + fn append_keys_and_data( + self: @Event, ref keys: Array, ref data: Array + ) { + match self { + Event::UpgradeableEvent(val) => { + core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); + starknet::Event::append_keys_and_data( + val, ref keys, ref data + ); + }, + } + } + fn deserialize( + ref keys: Span, ref data: Span, + ) -> Option { + let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; + if __selector__ == selector!("UpgradeableEvent") { + let val = starknet::Event::deserialize( + ref keys, ref data + )?; + return Option::Some(Event::UpgradeableEvent(val)); + } + Option::None + } +} +impl EventUpgradeableEventIntoEvent of Into { + fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { + Event::UpgradeableEvent(self) + } +} + + +pub struct Storage { + pub world_dispatcher: IWorldDispatcher, + pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, +} + +#[derive(Drop, Copy)] +pub struct ContractStorageBase { + pub world_dispatcher: starknet::storage::StorageBase, + pub upgradeable: starknet::storage::StorageBase, +} +#[derive(Drop, Copy)] +pub struct ContractStorageBaseMut { + pub world_dispatcher: starknet::storage::StorageBase>, + pub upgradeable: starknet::storage::StorageBase>, +} +impl StorageBaseImpl of starknet::storage::StorageBaseTrait { + type BaseType = ContractStorageBase; + type BaseMutType = ContractStorageBaseMut; + fn storage_base(self: @ContractState) -> ContractStorageBase { + ContractStorageBase { + world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, + upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, + } + } + fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { + ContractStorageBaseMut { + world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, + upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, + } + } +} +pub struct ContractState { + pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, +} + +impl ContractStateDrop of Drop {} + +impl ContractStateDeref of core::ops::SnapshotDeref { + type Target = ContractStorageBase; + fn snapshot_deref(self: @ContractState) -> ContractStorageBase { + self.storage_base() + } +} +impl ContractStateDerefMut of core::ops::DerefMut { + type Target = ContractStorageBaseMut; + fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { + self.storage_base_mut() + } +} +pub fn unsafe_new_contract_state() -> ContractState { + ContractState { + upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), + } +} + +use starknet::storage::{ + StorageMapReadAccessTrait, StorageMapWriteAccessTrait, + StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess +}; +// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. +#[deprecated( + feature: "deprecated_legacy_map", + note: "Use `starknet::storage::Map` instead." +)] +use starknet::storage::Map as LegacyMap; + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::contract_name(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::tag(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::name_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::namespace_hash(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = ContractImpl::selector(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + let res = WorldProviderImpl::world(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::serde::Serde::::serialize(@res, ref arr); + core::array::ArrayTrait::span(@arr) +} + +impl ContractStateUpgradableImpl of + dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { + fn unsafe_new_contract_state() -> ContractState { + unsafe_new_contract_state() + } +} +#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] +fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { + core::internal::require_implicit::(); + core::internal::revoke_ap_tracking(); + core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); + + assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); + core::option::OptionTraitImpl::expect( + core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', + ); + let mut contract_state = unsafe_new_contract_state(); + IDojoInitImpl::dojo_init(@contract_state, ); + let mut arr = ArrayTrait::new(); + // References. + // Result. + core::array::ArrayTrait::span(@arr) +} + + +pub mod __external { + pub use super::__wrapper__ContractImpl__contract_name as contract_name; + pub use super::__wrapper__ContractImpl__namespace as namespace; + pub use super::__wrapper__ContractImpl__tag as tag; + pub use super::__wrapper__ContractImpl__name_hash as name_hash; + pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; + pub use super::__wrapper__ContractImpl__selector as selector; + pub use super::__wrapper__WorldProviderImpl__world as world; + pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; +} +pub mod __l1_handler { +} +pub mod __constructor { +} + impl ContractStateEventEmitter of starknet::event::EventEmitter< + ContractState, Event + > { + fn emit>( + ref self: ContractState, event: S + ) { + let event: Event = core::traits::Into::into(event); + let mut keys = Default::::default(); + let mut data = Default::::default(); + starknet::Event::append_keys_and_data(@event, ref keys, ref data); + starknet::SyscallResultTrait::unwrap_syscall( + starknet::syscalls::emit_event_syscall( + core::array::ArrayTrait::span(@keys), + core::array::ArrayTrait::span(@data), + ) + ) + } + } + +impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { + fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { + @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() + } + fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { + dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() + } + fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { + @unsafe_new_contract_state() + } + fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { + unsafe_new_contract_state() + } + fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { + let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); + let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); + ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); + } +} +impl IDojoInitDispatcherCopy of core::traits::Copy::; +impl IDojoInitDispatcherDrop of core::traits::Drop::; +impl IDojoInitDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; +impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; +impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IDojoInitSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIDojoInitSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IDojoInitSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} +impl ContractStorageBaseDrop of core::traits::Drop::; +impl ContractStorageBaseCopy of core::traits::Copy::; +impl ContractStorageBaseMutDrop of core::traits::Drop::; +impl ContractStorageBaseMutCopy of core::traits::Copy::; + + } +trait IEmptyTraitDispatcherTrait { +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IEmptyTraitDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IEmptyTraitDispatcherImpl of IEmptyTraitDispatcherTrait { + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IEmptyTraitLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IEmptyTraitLibraryDispatcherImpl of IEmptyTraitDispatcherTrait { + +} + +trait IEmptyTraitSafeDispatcherTrait { +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IEmptyTraitSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IEmptyTraitSafeLibraryDispatcherImpl of IEmptyTraitSafeDispatcherTrait { + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IEmptyTraitSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IEmptyTraitSafeDispatcherImpl of IEmptyTraitSafeDispatcherTrait { + +} +trait IFaultyTraitDispatcherTrait { + fn do_with_attrs(self: T, p1: u8) -> u16; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IFaultyTraitDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IFaultyTraitDispatcherImpl of IFaultyTraitDispatcherTrait { + fn do_with_attrs(self: IFaultyTraitDispatcher, p1: u8) -> u16 { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@p1, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_with_attrs"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IFaultyTraitLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IFaultyTraitLibraryDispatcherImpl of IFaultyTraitDispatcherTrait { + fn do_with_attrs(self: IFaultyTraitLibraryDispatcher, p1: u8) -> u16 { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@p1, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_with_attrs"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } + +} + +trait IFaultyTraitSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn do_with_attrs(self: T, p1: u8) -> starknet::SyscallResult; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IFaultyTraitSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IFaultyTraitSafeLibraryDispatcherImpl of IFaultyTraitSafeDispatcherTrait { + fn do_with_attrs(self: IFaultyTraitSafeLibraryDispatcher, p1: u8) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@p1, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_with_attrs"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IFaultyTraitSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IFaultyTraitSafeDispatcherImpl of IFaultyTraitSafeDispatcherTrait { + fn do_with_attrs(self: IFaultyTraitSafeDispatcher, p1: u8) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@p1, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_with_attrs"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } + +} +trait INominalTraitDispatcherTrait { + fn do_no_param(self: T) -> felt252; +fn do_no_param_but_world(self: T) -> felt252; +fn do_no_param_but_world_ref(self: T) -> felt252; +fn do_params_no_world(self: T, p1: felt252, p2: u8) -> felt252; +fn do_params_and_world(self: T, p2: u8) -> felt252; +fn do_params_and_world_ref(self: T, p2: u8) -> felt252; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct INominalTraitDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl INominalTraitDispatcherImpl of INominalTraitDispatcherTrait { + fn do_no_param(self: INominalTraitDispatcher) -> felt252 { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_no_param"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } +fn do_no_param_but_world(self: INominalTraitDispatcher) -> felt252 { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_no_param_but_world"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } +fn do_no_param_but_world_ref(self: INominalTraitDispatcher) -> felt252 { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_no_param_but_world_ref"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } +fn do_params_no_world(self: INominalTraitDispatcher, p1: felt252, p2: u8) -> felt252 { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@p1, ref __calldata__); + core::serde::Serde::::serialize(@p2, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_params_no_world"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } +fn do_params_and_world(self: INominalTraitDispatcher, p2: u8) -> felt252 { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@p2, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_params_and_world"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } +fn do_params_and_world_ref(self: INominalTraitDispatcher, p2: u8) -> felt252 { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@p2, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_params_and_world_ref"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct INominalTraitLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl INominalTraitLibraryDispatcherImpl of INominalTraitDispatcherTrait { + fn do_no_param(self: INominalTraitLibraryDispatcher) -> felt252 { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_no_param"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } +fn do_no_param_but_world(self: INominalTraitLibraryDispatcher) -> felt252 { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_no_param_but_world"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } +fn do_no_param_but_world_ref(self: INominalTraitLibraryDispatcher) -> felt252 { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_no_param_but_world_ref"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } +fn do_params_no_world(self: INominalTraitLibraryDispatcher, p1: felt252, p2: u8) -> felt252 { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@p1, ref __calldata__); + core::serde::Serde::::serialize(@p2, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_params_no_world"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } +fn do_params_and_world(self: INominalTraitLibraryDispatcher, p2: u8) -> felt252 { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@p2, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_params_and_world"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } +fn do_params_and_world_ref(self: INominalTraitLibraryDispatcher, p2: u8) -> felt252 { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@p2, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_params_and_world_ref"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } + +} + +trait INominalTraitSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] + fn do_no_param(self: T) -> starknet::SyscallResult; + #[unstable(feature: "safe_dispatcher")] +fn do_no_param_but_world(self: T) -> starknet::SyscallResult; + #[unstable(feature: "safe_dispatcher")] +fn do_no_param_but_world_ref(self: T) -> starknet::SyscallResult; + #[unstable(feature: "safe_dispatcher")] +fn do_params_no_world(self: T, p1: felt252, p2: u8) -> starknet::SyscallResult; + #[unstable(feature: "safe_dispatcher")] +fn do_params_and_world(self: T, p2: u8) -> starknet::SyscallResult; + #[unstable(feature: "safe_dispatcher")] +fn do_params_and_world_ref(self: T, p2: u8) -> starknet::SyscallResult; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct INominalTraitSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl INominalTraitSafeLibraryDispatcherImpl of INominalTraitSafeDispatcherTrait { + fn do_no_param(self: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_no_param"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } +fn do_no_param_but_world(self: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_no_param_but_world"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } +fn do_no_param_but_world_ref(self: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_no_param_but_world_ref"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } +fn do_params_no_world(self: INominalTraitSafeLibraryDispatcher, p1: felt252, p2: u8) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@p1, ref __calldata__); + core::serde::Serde::::serialize(@p2, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_params_no_world"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } +fn do_params_and_world(self: INominalTraitSafeLibraryDispatcher, p2: u8) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@p2, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_params_and_world"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } +fn do_params_and_world_ref(self: INominalTraitSafeLibraryDispatcher, p2: u8) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@p2, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_params_and_world_ref"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct INominalTraitSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl INominalTraitSafeDispatcherImpl of INominalTraitSafeDispatcherTrait { + fn do_no_param(self: INominalTraitSafeDispatcher) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_no_param"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } +fn do_no_param_but_world(self: INominalTraitSafeDispatcher) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_no_param_but_world"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } +fn do_no_param_but_world_ref(self: INominalTraitSafeDispatcher) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_no_param_but_world_ref"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } +fn do_params_no_world(self: INominalTraitSafeDispatcher, p1: felt252, p2: u8) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@p1, ref __calldata__); + core::serde::Serde::::serialize(@p2, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_params_no_world"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } +fn do_params_and_world(self: INominalTraitSafeDispatcher, p2: u8) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@p2, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_params_and_world"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } +fn do_params_and_world_ref(self: INominalTraitSafeDispatcher, p2: u8) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::::serialize(@p2, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_params_and_world_ref"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } + +} +trait IFaultyTraitDispatcherTrait { +fn do_with_self_and_world_inv(self: T, self: @ContractState) -> felt252; +fn do_with_world_not_named_world(self: T, another_world: @IWorldDispatcher) -> felt252; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IFaultyTraitDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IFaultyTraitDispatcherImpl of IFaultyTraitDispatcherTrait { +fn do_with_self_and_world_inv(self: IFaultyTraitDispatcher, self: @ContractState) -> felt252 { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::<@ContractState>::serialize(@self, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_with_self_and_world_inv"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } +fn do_with_world_not_named_world(self: IFaultyTraitDispatcher, another_world: @IWorldDispatcher) -> felt252 { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::<@IWorldDispatcher>::serialize(@another_world, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_with_world_not_named_world"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } + +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IFaultyTraitLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IFaultyTraitLibraryDispatcherImpl of IFaultyTraitDispatcherTrait { +fn do_with_self_and_world_inv(self: IFaultyTraitLibraryDispatcher, self: @ContractState) -> felt252 { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::<@ContractState>::serialize(@self, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_with_self_and_world_inv"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } +fn do_with_world_not_named_world(self: IFaultyTraitLibraryDispatcher, another_world: @IWorldDispatcher) -> felt252 { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::<@IWorldDispatcher>::serialize(@another_world, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_with_world_not_named_world"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + } + +} + +trait IFaultyTraitSafeDispatcherTrait { + #[unstable(feature: "safe_dispatcher")] +fn do_with_self_and_world_inv(self: T, self: @ContractState) -> starknet::SyscallResult; + #[unstable(feature: "safe_dispatcher")] +fn do_with_world_not_named_world(self: T, another_world: @IWorldDispatcher) -> starknet::SyscallResult; +} + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IFaultyTraitSafeLibraryDispatcher { + pub class_hash: starknet::ClassHash, +} + +impl IFaultyTraitSafeLibraryDispatcherImpl of IFaultyTraitSafeDispatcherTrait { +fn do_with_self_and_world_inv(self: IFaultyTraitSafeLibraryDispatcher, self: @ContractState) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::<@ContractState>::serialize(@self, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_with_self_and_world_inv"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } +fn do_with_world_not_named_world(self: IFaultyTraitSafeLibraryDispatcher, another_world: @IWorldDispatcher) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::<@IWorldDispatcher>::serialize(@another_world, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( + self.class_hash, + selector!("do_with_world_not_named_world"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } + +} + + +#[derive(Copy, Drop, starknet::Store, Serde)] +struct IFaultyTraitSafeDispatcher { + pub contract_address: starknet::ContractAddress, +} + +impl IFaultyTraitSafeDispatcherImpl of IFaultyTraitSafeDispatcherTrait { +fn do_with_self_and_world_inv(self: IFaultyTraitSafeDispatcher, self: @ContractState) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::<@ContractState>::serialize(@self, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_with_self_and_world_inv"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } +fn do_with_world_not_named_world(self: IFaultyTraitSafeDispatcher, another_world: @IWorldDispatcher) -> starknet::SyscallResult { + let mut __calldata__ = core::traits::Default::default(); + core::serde::Serde::<@IWorldDispatcher>::serialize(@another_world, ref __calldata__); + + let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( + self.contract_address, + selector!("do_with_world_not_named_world"), + core::array::ArrayTrait::span(@__calldata__), + ); + let mut __dispatcher_return_data__ = __dispatcher_return_data__?; + Result::Ok( + core::option::OptionTrait::expect( + core::serde::Serde::::deserialize(ref __dispatcher_return_data__), + 'Returned data too short', + ) + ) + } + +} +impl IEmptyTraitDispatcherCopy of core::traits::Copy::; +impl IEmptyTraitDispatcherDrop of core::traits::Drop::; +impl IEmptyTraitDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IEmptyTraitDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IEmptyTraitDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIEmptyTraitDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IEmptyTraitDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IEmptyTraitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IEmptyTraitDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IEmptyTraitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIEmptyTraitDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IEmptyTraitLibraryDispatcherCopy of core::traits::Copy::; +impl IEmptyTraitLibraryDispatcherDrop of core::traits::Drop::; +impl IEmptyTraitLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IEmptyTraitLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IEmptyTraitLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIEmptyTraitLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IEmptyTraitLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IEmptyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IEmptyTraitLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IEmptyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIEmptyTraitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IEmptyTraitSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IEmptyTraitSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IEmptyTraitSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IEmptyTraitSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IEmptyTraitSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIEmptyTraitSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IEmptyTraitSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IEmptyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IEmptyTraitSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IEmptyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIEmptyTraitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IEmptyTraitSafeDispatcherCopy of core::traits::Copy::; +impl IEmptyTraitSafeDispatcherDrop of core::traits::Drop::; +impl IEmptyTraitSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IEmptyTraitSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IEmptyTraitSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIEmptyTraitSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IEmptyTraitSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IEmptyTraitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IEmptyTraitSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IEmptyTraitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIEmptyTraitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IFaultyTraitDispatcherCopy of core::traits::Copy::; +impl IFaultyTraitDispatcherDrop of core::traits::Drop::; +impl IFaultyTraitDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IFaultyTraitDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IFaultyTraitDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIFaultyTraitDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IFaultyTraitDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IFaultyTraitDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIFaultyTraitDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IFaultyTraitLibraryDispatcherCopy of core::traits::Copy::; +impl IFaultyTraitLibraryDispatcherDrop of core::traits::Drop::; +impl IFaultyTraitLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IFaultyTraitLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IFaultyTraitLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIFaultyTraitLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IFaultyTraitLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IFaultyTraitLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIFaultyTraitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IFaultyTraitSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IFaultyTraitSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IFaultyTraitSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IFaultyTraitSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IFaultyTraitSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIFaultyTraitSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IFaultyTraitSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IFaultyTraitSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIFaultyTraitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IFaultyTraitSafeDispatcherCopy of core::traits::Copy::; +impl IFaultyTraitSafeDispatcherDrop of core::traits::Drop::; +impl IFaultyTraitSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IFaultyTraitSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IFaultyTraitSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIFaultyTraitSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IFaultyTraitSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IFaultyTraitSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIFaultyTraitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} +impl INominalTraitDispatcherCopy of core::traits::Copy::; +impl INominalTraitDispatcherDrop of core::traits::Drop::; +impl INominalTraitDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @INominalTraitDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(INominalTraitDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreINominalTraitDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + INominalTraitDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: INominalTraitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + INominalTraitDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: INominalTraitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageINominalTraitDispatcher of starknet::storage_access::DeriveStorage:: {} +impl INominalTraitLibraryDispatcherCopy of core::traits::Copy::; +impl INominalTraitLibraryDispatcherDrop of core::traits::Drop::; +impl INominalTraitLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @INominalTraitLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(INominalTraitLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreINominalTraitLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + INominalTraitLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: INominalTraitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + INominalTraitLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: INominalTraitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageINominalTraitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl INominalTraitSafeLibraryDispatcherCopy of core::traits::Copy::; +impl INominalTraitSafeLibraryDispatcherDrop of core::traits::Drop::; +impl INominalTraitSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @INominalTraitSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(INominalTraitSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreINominalTraitSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + INominalTraitSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + INominalTraitSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageINominalTraitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl INominalTraitSafeDispatcherCopy of core::traits::Copy::; +impl INominalTraitSafeDispatcherDrop of core::traits::Drop::; +impl INominalTraitSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @INominalTraitSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(INominalTraitSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreINominalTraitSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + INominalTraitSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: INominalTraitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + INominalTraitSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: INominalTraitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageINominalTraitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IFaultyTraitDispatcherCopy of core::traits::Copy::; +impl IFaultyTraitDispatcherDrop of core::traits::Drop::; +impl IFaultyTraitDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IFaultyTraitDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IFaultyTraitDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIFaultyTraitDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IFaultyTraitDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IFaultyTraitDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIFaultyTraitDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IFaultyTraitLibraryDispatcherCopy of core::traits::Copy::; +impl IFaultyTraitLibraryDispatcherDrop of core::traits::Drop::; +impl IFaultyTraitLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IFaultyTraitLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IFaultyTraitLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIFaultyTraitLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IFaultyTraitLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IFaultyTraitLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIFaultyTraitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IFaultyTraitSafeLibraryDispatcherCopy of core::traits::Copy::; +impl IFaultyTraitSafeLibraryDispatcherDrop of core::traits::Drop::; +impl IFaultyTraitSafeLibraryDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IFaultyTraitSafeLibraryDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.class_hash, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IFaultyTraitSafeLibraryDispatcher { + class_hash: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIFaultyTraitSafeLibraryDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IFaultyTraitSafeLibraryDispatcher { + class_hash, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IFaultyTraitSafeLibraryDispatcher { + class_hash, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIFaultyTraitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} +impl IFaultyTraitSafeDispatcherCopy of core::traits::Copy::; +impl IFaultyTraitSafeDispatcherDrop of core::traits::Drop::; +impl IFaultyTraitSafeDispatcherSerde of core::serde::Serde:: { + fn serialize(self: @IFaultyTraitSafeDispatcher, ref output: core::array::Array) { + core::serde::Serde::serialize(self.contract_address, ref output) + } + fn deserialize(ref serialized: core::array::Span) -> core::option::Option { + core::option::Option::Some(IFaultyTraitSafeDispatcher { + contract_address: core::serde::Serde::deserialize(ref serialized)?, + }) + } +} +impl StoreIFaultyTraitSafeDispatcher of starknet::Store:: { + fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read(address_domain, base)?; + starknet::SyscallResult::Ok( + IFaultyTraitSafeDispatcher { + contract_address, + } + ) + } + fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write(address_domain, base, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { + let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; + starknet::SyscallResult::Ok( + IFaultyTraitSafeDispatcher { + contract_address, + } + ) + } + #[inline(always)] + fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitSafeDispatcher) -> starknet::SyscallResult<()> { + starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; + starknet::SyscallResult::Ok(()) + } + #[inline(always)] + fn size() -> u8 { + starknet::Store::::size() + } +} +#[feature("derive-storage")] +impl DeriveStorageIFaultyTraitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} diff --git a/crates/dojo-lang/src/semantics/test_data/get b/crates/dojo-lang/src/semantics/test_data/get index db57604909..a3ef799153 100644 --- a/crates/dojo-lang/src/semantics/test_data/get +++ b/crates/dojo-lang/src/semantics/test_data/get @@ -29,37 +29,37 @@ Missing( ) //! > semantic_diagnostics -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") --> lib.cairo:1:1 use array::ArrayTrait; ^********************^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") --> lib.cairo:2:1 use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; ^*********************************************************^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") --> lib.cairo:4:1 #[derive(Copy, Drop, Serde, Introspect)] ^**************************************^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") --> lib.cairo:10:1 fn test_func() { let key: felt252 = 0xb0b; ^****************************************^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") --> lib.cairo:3:1 ^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") --> lib.cairo:3:1 ^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") --> lib.cairo:3:1 ^ @@ -112,37 +112,37 @@ Missing( ) //! > semantic_diagnostics -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") --> lib.cairo:1:1 use array::ArrayTrait; ^********************^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") --> lib.cairo:2:1 use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; ^*********************************************************^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") --> lib.cairo:4:1 #[derive(Copy, Drop, Serde, Introspect)] ^**************************************^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") --> lib.cairo:10:1 fn test_func() { let key: felt252 = 0xb0b; ^****************************************^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") --> lib.cairo:3:1 ^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") --> lib.cairo:3:1 ^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") --> lib.cairo:3:1 ^ @@ -321,37 +321,37 @@ Block( ) //! > semantic_diagnostics -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") --> lib.cairo:1:1 use array::ArrayTrait; ^********************^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") --> lib.cairo:2:1 use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; ^*********************************************************^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") --> lib.cairo:4:1 #[derive(Copy, Drop, Serde, Introspect)] ^**************************************^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") --> lib.cairo:10:1 fn test_func() { let key: felt252 = 0xb0b; ^****************************************^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") --> lib.cairo:3:1 ^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") --> lib.cairo:3:1 ^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") --> lib.cairo:3:1 ^ diff --git a/crates/dojo-lang/src/semantics/test_data/set b/crates/dojo-lang/src/semantics/test_data/set index ce115d64e6..f430a81f6c 100644 --- a/crates/dojo-lang/src/semantics/test_data/set +++ b/crates/dojo-lang/src/semantics/test_data/set @@ -18,7 +18,7 @@ Missing( ) //! > semantic_diagnostics -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") --> lib.cairo:1:1 fn test_func() { { ^*****************^ @@ -50,7 +50,7 @@ Missing( ) //! > semantic_diagnostics -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") --> lib.cairo:1:1 fn test_func() { { ^*****************^ @@ -234,7 +234,7 @@ Block( ) //! > semantic_diagnostics -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") --> lib.cairo:1:1 use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; ^*********************************************************^ @@ -244,27 +244,27 @@ error: Plugin diagnostic: Unknown derive `Model` - a plugin might be missing. #[derive(Copy, Drop, Serde, Model)] ^***^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") --> lib.cairo:3:1 #[derive(Copy, Drop, Serde, Model)] ^*********************************^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") --> lib.cairo:9:1 fn test_func() { let key: felt252 = 0xb0b; ^****************************************^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") --> lib.cairo:2:1 ^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") --> lib.cairo:2:1 ^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. +error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") --> lib.cairo:2:1 ^ diff --git a/crates/dojo-lang/src/utils.rs b/crates/dojo-lang/src/utils.rs index e8eaa50991..a48f6e5611 100644 --- a/crates/dojo-lang/src/utils.rs +++ b/crates/dojo-lang/src/utils.rs @@ -65,6 +65,8 @@ pub fn get_namespace_config(db: &dyn SyntaxGroup) -> Result { } Err(anyhow::anyhow!( - "Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid.", + "Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. \ + {:?}", + configuration.root )) } From 73201e8d29ada3a359353c53fb363af81914fcff Mon Sep 17 00:00:00 2001 From: glihm Date: Fri, 12 Jul 2024 17:16:34 -0600 Subject: [PATCH 09/15] feat: add nomapping argument to dojo model and contract attributes --- crates/dojo-core/src/world_test.cairo | 4 ++-- crates/dojo-lang/src/contract.rs | 15 ++++++++++++--- crates/dojo-lang/src/model.rs | 20 ++++++++++++++++---- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/crates/dojo-core/src/world_test.cairo b/crates/dojo-core/src/world_test.cairo index 1958726cfd..3b6d76f837 100644 --- a/crates/dojo-core/src/world_test.cairo +++ b/crates/dojo-core/src/world_test.cairo @@ -45,7 +45,7 @@ struct Foo { } #[derive(Copy, Drop, Serde)] -#[dojo::model(namespace: "another_namespace")] +#[dojo::model(namespace: "another_namespace", nomapping: true)] struct Buzz { #[key] caller: ContractAddress, @@ -940,7 +940,7 @@ trait IDojoInit { #[dojo::contract] mod test_contract {} -#[dojo::contract(namespace: "buzz_namespace")] +#[dojo::contract(namespace: "buzz_namespace", nomapping: true)] mod buzz_contract {} #[test] diff --git a/crates/dojo-lang/src/contract.rs b/crates/dojo-lang/src/contract.rs index 4467486b0a..4f8cca2aae 100644 --- a/crates/dojo-lang/src/contract.rs +++ b/crates/dojo-lang/src/contract.rs @@ -24,10 +24,12 @@ use crate::syntax::{self_param, utils as syntax_utils}; const DOJO_INIT_FN: &str = "dojo_init"; const CONTRACT_NAMESPACE: &str = "namespace"; +const CONTRACT_NOMAPPING: &str = "nomapping"; #[derive(Debug, Clone, Default)] pub struct ContractParameters { namespace: Option, + nomapping: bool, } #[derive(Debug)] @@ -56,9 +58,13 @@ impl DojoContract { let unmapped_namespace = parameters.namespace.unwrap_or(namespace_config.default.clone()); - // Maps namespace from the tag to ensure higher precision on matching namespace mappings. - let contract_namespace = - namespace_config.get_mapping(&naming::get_tag(&unmapped_namespace, &name)); + let contract_namespace = if parameters.nomapping { + unmapped_namespace + } else { + // Maps namespace from the tag to ensure higher precision on matching namespace + // mappings. + namespace_config.get_mapping(&naming::get_tag(&unmapped_namespace, &name)) + }; for (id, value) in [("name", &name.to_string()), ("namespace", &contract_namespace)] { if !is_name_valid(value) { @@ -667,6 +673,9 @@ fn get_parameters( parameters.namespace = get_contract_namespace(db, arg_value, diagnostics); } + CONTRACT_NOMAPPING => { + parameters.nomapping = true; + } _ => { diagnostics.push(PluginDiagnostic { message: format!( diff --git a/crates/dojo-lang/src/model.rs b/crates/dojo-lang/src/model.rs index e501699087..72730edfeb 100644 --- a/crates/dojo-lang/src/model.rs +++ b/crates/dojo-lang/src/model.rs @@ -19,15 +19,21 @@ const DEFAULT_MODEL_VERSION: u8 = 1; const MODEL_VERSION_NAME: &str = "version"; const MODEL_NAMESPACE: &str = "namespace"; +const MODEL_NOMAPPING: &str = "nomapping"; struct ModelParameters { version: u8, namespace: Option, + nomapping: bool, } impl Default for ModelParameters { fn default() -> ModelParameters { - ModelParameters { version: DEFAULT_MODEL_VERSION, namespace: Option::None } + ModelParameters { + version: DEFAULT_MODEL_VERSION, + namespace: Option::None, + nomapping: false, + } } } @@ -143,6 +149,9 @@ fn get_model_parameters( MODEL_NAMESPACE => { parameters.namespace = get_model_namespace(db, arg_value, diagnostics); } + MODEL_NOMAPPING => { + parameters.nomapping = true; + } _ => { diagnostics.push(PluginDiagnostic { message: format!( @@ -201,9 +210,12 @@ pub fn handle_model_struct( let model_name = struct_ast.name(db).as_syntax_node().get_text(db).trim().to_string(); let unmapped_namespace = parameters.namespace.unwrap_or(namespace_config.default.clone()); - // Maps namespace from the tag to ensure higher precision on matching namespace mappings. - let model_namespace = - namespace_config.get_mapping(&naming::get_tag(&unmapped_namespace, &model_name)); + let model_namespace = if parameters.nomapping { + unmapped_namespace + } else { + // Maps namespace from the tag to ensure higher precision on matching namespace mappings. + namespace_config.get_mapping(&naming::get_tag(&unmapped_namespace, &model_name)) + }; for (id, value) in [("name", &model_name), ("namespace", &model_namespace)] { if !is_name_valid(value) { From 52746cb521c608d5907541c1691ba2f41fa2c45e Mon Sep 17 00:00:00 2001 From: glihm Date: Fri, 12 Jul 2024 18:16:10 -0600 Subject: [PATCH 10/15] fix: change contract identification with selector + contract registry --- crates/dojo-core/src/base_test.cairo | 21 +++--- crates/dojo-core/src/world.cairo | 41 +++++++---- crates/dojo-core/src/world_test.cairo | 17 +++++ crates/dojo-lang/src/inline_macros/mod.rs | 1 + .../src/inline_macros/selector_from_tag.rs | 71 +++++++++++++++++++ crates/dojo-lang/src/plugin.rs | 4 +- crates/dojo-world/src/contracts/naming.rs | 27 +++++++ 7 files changed, 157 insertions(+), 25 deletions(-) create mode 100644 crates/dojo-lang/src/inline_macros/selector_from_tag.rs diff --git a/crates/dojo-core/src/base_test.cairo b/crates/dojo-core/src/base_test.cairo index 40b6414822..f517a85c8b 100644 --- a/crates/dojo-core/src/base_test.cairo +++ b/crates/dojo-core/src/base_test.cairo @@ -68,7 +68,8 @@ fn test_upgrade_from_world() { ); let new_class_hash: ClassHash = contract_upgrade::TEST_CLASS_HASH.try_into().unwrap(); - world.upgrade_contract(base_address, new_class_hash); + let selector = selector_from_tag!("dojo-test_contract"); + world.upgrade_contract(selector, new_class_hash); let quantum_dispatcher = IQuantumLeapDispatcher { contract_address: base_address }; assert(quantum_dispatcher.plz_more_tps() == 'daddy', 'quantum leap failed'); @@ -82,13 +83,14 @@ fn test_upgrade_from_world() { fn test_upgrade_from_world_not_world_provider() { let world = deploy_world(); - let base_address = world + let _ = world .deploy_contract( 'salt', test_contract::TEST_CLASS_HASH.try_into().unwrap(), array![].span() ); let new_class_hash: ClassHash = contract_invalid_upgrade::TEST_CLASS_HASH.try_into().unwrap(); - world.upgrade_contract(base_address, new_class_hash); + let selector = selector_from_tag!("dojo-test_contract"); + world.upgrade_contract(selector, new_class_hash); } #[test] @@ -176,9 +178,9 @@ mod invalid_model { #[abi(embed_v0)] impl InvalidModelSelector of super::IMetadataOnly { fn selector(self: @ContractState) -> felt252 { - // NOTE: Need to update this value if address changes - // Pre-computed address of a contract deployed through the world. - 0x21b19f95ff0f382a069dc7034f95584b300133665ee506789c76ba729e42b66 + // Use the resource identifier of the contract deployed through the world + // instead of the address. + selector_from_tag!("dojo-test_contract") } fn namespace(self: @ContractState) -> ByteArray { @@ -228,14 +230,9 @@ mod invalid_model_world { fn test_deploy_from_world_invalid_model() { let world = deploy_world(); - let contract_address = world + let _ = world .deploy_contract(0, test_contract::TEST_CLASS_HASH.try_into().unwrap(), array![].span()); - // This print allows to know the address of the deployed contract which must be returned - // by the selector() function of invalid model, to simulate a ACL issue - // (see register_model function) - contract_address.print(); - world.register_model(invalid_model::TEST_CLASS_HASH.try_into().unwrap()); } diff --git a/crates/dojo-core/src/world.cairo b/crates/dojo-core/src/world.cairo index 2db09d2f80..884c3f3082 100644 --- a/crates/dojo-core/src/world.cairo +++ b/crates/dojo-core/src/world.cairo @@ -8,12 +8,13 @@ trait IWorld { fn metadata(self: @T, resource_id: felt252) -> ResourceMetadata; fn set_metadata(ref self: T, metadata: ResourceMetadata); fn model(self: @T, selector: felt252) -> (ClassHash, ContractAddress); + fn contract(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; - fn upgrade_contract(ref self: T, address: ContractAddress, class_hash: ClassHash) -> ClassHash; + fn upgrade_contract(ref self: T, selector: felt252, class_hash: ClassHash) -> ClassHash; fn uuid(ref self: T) -> usize; fn emit(self: @T, keys: Array, values: Span); fn entity( @@ -238,7 +239,7 @@ mod world { #[derive(Drop, starknet::Store, Default, Debug)] enum ResourceData { Model: (ClassHash, ContractAddress), - Contract, + Contract: (ClassHash, ContractAddress), Namespace, #[default] None, @@ -259,7 +260,9 @@ mod world { let creator = starknet::get_tx_info().unbox().account_contract_address; self.contract_base.write(contract_base); - self.resources.write(WORLD, ResourceData::Contract); + self + .resources + .write(WORLD, ResourceData::Contract((0.try_into().unwrap(), 0.try_into().unwrap()))); self .resources .write( @@ -623,6 +626,15 @@ mod world { } } + fn contract(self: @ContractState, selector: felt252) -> (ClassHash, ContractAddress) { + // 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::Contract(c) => c, + _ => panic_with_felt252(Errors::INVALID_RESOURCE_SELECTOR) + } + } + /// Deploys a contract associated with the world. /// /// # Arguments @@ -658,17 +670,19 @@ mod world { Errors::NO_NAMESPACE_WRITE_ACCESS ); - if self.initialized_contract.read(contract_address.into()) { + let selector = dispatcher.selector(); + + if self.initialized_contract.read(selector) { panic!("Contract has already been initialized"); } else { starknet::call_contract_syscall(contract_address, DOJO_INIT_SELECTOR, init_calldata) .unwrap_syscall(); - self.initialized_contract.write(contract_address.into(), true); + self.initialized_contract.write(selector, true); } - self.owners.write((contract_address.into(), get_caller_address()), true); + self.owners.write((selector, get_caller_address()), true); - self.resources.write(contract_address.into(), ResourceData::Contract); + self.resources.write(selector, ResourceData::Contract((class_hash, contract_address))); EventEmitter::emit( ref self, @@ -682,18 +696,21 @@ mod world { /// /// # Arguments /// - /// * `address` - The contract address of the contract to upgrade. + /// * `selector` - The selector of the contract to upgrade. /// * `class_hash` - The class hash of the contract. /// /// # Returns /// /// * `ClassHash` - The new class hash of the contract. fn upgrade_contract( - ref self: ContractState, address: ContractAddress, class_hash: ClassHash + ref self: ContractState, selector: felt252, class_hash: ClassHash ) -> ClassHash { - 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 }); + assert(self.is_account_owner(selector), Errors::NOT_OWNER); + let (_, contract_address) = self.contract(selector); + IUpgradeableDispatcher { contract_address }.upgrade(class_hash); + EventEmitter::emit( + ref self, ContractUpgraded { class_hash, address: contract_address } + ); class_hash } diff --git a/crates/dojo-core/src/world_test.cairo b/crates/dojo-core/src/world_test.cairo index 3b6d76f837..cc46957bfe 100644 --- a/crates/dojo-core/src/world_test.cairo +++ b/crates/dojo-core/src/world_test.cairo @@ -423,6 +423,23 @@ fn test_delete() { } use core::debug::PrintTrait; +#[test] +#[available_gas(6000000)] +fn test_contract_getter() { + let world = deploy_world(); + + let _ = world + .deploy_contract( + 'salt1', test_contract::TEST_CLASS_HASH.try_into().unwrap(), array![].span() + ); + + let (class_hash, _) = world.contract(selector_from_tag!("dojo-test_contract")); + assert( + class_hash == test_contract::TEST_CLASS_HASH.try_into().unwrap(), + 'invalid contract class hash' + ); +} + #[test] #[available_gas(6000000)] fn test_model_class_hash_getter() { diff --git a/crates/dojo-lang/src/inline_macros/mod.rs b/crates/dojo-lang/src/inline_macros/mod.rs index 047a9d0f58..fc8e0dc560 100644 --- a/crates/dojo-lang/src/inline_macros/mod.rs +++ b/crates/dojo-lang/src/inline_macros/mod.rs @@ -8,6 +8,7 @@ pub mod delete; pub mod emit; pub mod get; pub mod set; +pub mod selector_from_tag; pub mod utils; const CAIRO_ERR_MSG_LEN: usize = 31; diff --git a/crates/dojo-lang/src/inline_macros/selector_from_tag.rs b/crates/dojo-lang/src/inline_macros/selector_from_tag.rs new file mode 100644 index 0000000000..1e51bb9dc7 --- /dev/null +++ b/crates/dojo-lang/src/inline_macros/selector_from_tag.rs @@ -0,0 +1,71 @@ +use cairo_lang_defs::patcher::PatchBuilder; +use cairo_lang_defs::plugin::{ + InlineMacroExprPlugin, InlinePluginResult, NamedPlugin, PluginDiagnostic, PluginGeneratedFile, +}; +use cairo_lang_defs::plugin_utils::unsupported_bracket_diagnostic; +use cairo_lang_diagnostics::Severity; +use cairo_lang_syntax::node::{ast, TypedStablePtr, TypedSyntaxNode}; +use dojo_world::contracts::naming; + +#[derive(Debug, Default)] +pub struct SelectorFromTagMacro; + +impl NamedPlugin for SelectorFromTagMacro { + const NAME: &'static str = "selector_from_tag"; +} + +impl InlineMacroExprPlugin for SelectorFromTagMacro { + fn generate_code( + &self, + db: &dyn cairo_lang_syntax::node::db::SyntaxGroup, + syntax: &ast::ExprInlineMacro, + ) -> InlinePluginResult { + let ast::WrappedArgList::ParenthesizedArgList(arg_list) = syntax.arguments(db) else { + return unsupported_bracket_diagnostic(db, syntax); + }; + + let args = arg_list.arguments(db).elements(db); + + if args.len() != 1 { + return InlinePluginResult { + code: None, + diagnostics: vec![PluginDiagnostic { + stable_ptr: syntax.stable_ptr().untyped(), + message: "Invalid arguments. Expected \"selector_from_tag!(\"tag\")\"" + .to_string(), + severity: Severity::Error, + }], + }; + } + + let tag = &args[0].as_syntax_node().get_text(db).replace('\"', ""); + + if !naming::is_valid_tag(tag) { + return InlinePluginResult { + code: None, + diagnostics: vec![PluginDiagnostic { + stable_ptr: syntax.stable_ptr().untyped(), + message: "Invalid tag. Tag must be in the format of `namespace-name`.".to_string(), + severity: Severity::Error, + }], + }; + } + + let selector = naming::compute_selector_from_tag(tag); + + let mut builder = PatchBuilder::new(db, syntax); + builder.add_str(&format!("{:#64x}", selector)); + + let (code, code_mappings) = builder.build(); + + InlinePluginResult { + code: Some(PluginGeneratedFile { + name: "selector_from_tag_macro".into(), + content: code, + code_mappings, + aux_data: None, + }), + diagnostics: vec![], + } + } +} diff --git a/crates/dojo-lang/src/plugin.rs b/crates/dojo-lang/src/plugin.rs index 0f3e2641b4..983b753ff0 100644 --- a/crates/dojo-lang/src/plugin.rs +++ b/crates/dojo-lang/src/plugin.rs @@ -32,6 +32,7 @@ use crate::inline_macros::delete::DeleteMacro; use crate::inline_macros::emit::EmitMacro; use crate::inline_macros::get::GetMacro; use crate::inline_macros::set::SetMacro; +use crate::inline_macros::selector_from_tag::SelectorFromTagMacro; use crate::interface::DojoInterface; use crate::introspect::{handle_introspect_enum, handle_introspect_struct}; use crate::model::handle_model_struct; @@ -264,7 +265,8 @@ pub fn dojo_plugin_suite() -> PluginSuite { .add_inline_macro_plugin::() .add_inline_macro_plugin::() .add_inline_macro_plugin::() - .add_inline_macro_plugin::(); + .add_inline_macro_plugin::() + .add_inline_macro_plugin::(); suite } diff --git a/crates/dojo-world/src/contracts/naming.rs b/crates/dojo-world/src/contracts/naming.rs index d910e98837..4255450643 100644 --- a/crates/dojo-world/src/contracts/naming.rs +++ b/crates/dojo-world/src/contracts/naming.rs @@ -29,6 +29,17 @@ pub fn get_tag(namespace: &str, name: &str) -> String { format!("{namespace}{TAG_SEPARATOR}{name}") } +pub fn is_valid_tag(tag: &str) -> bool { + let (namespace, name) = match split_tag(tag) { + Ok((nm, n)) => (nm, n), + Err(_) => return false, + }; + + let re = regex::Regex::new(r"^[a-zA-Z0-9_]+$").unwrap(); + + re.is_match(&namespace) && re.is_match(&name) +} + /// Get the namespace and the name of a world element from its tag. pub fn split_tag(tag: &str) -> Result<(String, String)> { let parts: Vec<&str> = tag.split(TAG_SEPARATOR).collect(); @@ -140,4 +151,20 @@ mod tests { .unwrap() ); } + + #[test] + fn test_is_valid_tag_success() { + assert!(is_valid_tag("namespace-model")); + assert!(is_valid_tag("dojo-world")); + assert!(is_valid_tag("dojo_examples-base_test")); + } + + #[test] + fn test_is_valid_tag_failure() { + assert!(!is_valid_tag("invalid tag")); + assert!(!is_valid_tag("invalid@tag")); + assert!(!is_valid_tag("invalid-")); + assert!(!is_valid_tag("-invalid")); + assert!(!is_valid_tag("")); + } } From b3c3bbb6e0fa9ad6083efa374fb49aae7c8d5210 Mon Sep 17 00:00:00 2001 From: glihm Date: Fri, 12 Jul 2024 19:46:25 -0600 Subject: [PATCH 11/15] feat: add selector_from_tag macro and fix semantic tests --- crates/dojo-lang/src/inline_macros/mod.rs | 2 +- .../src/inline_macros/selector_from_tag.rs | 3 +- crates/dojo-lang/src/plugin.rs | 2 +- .../src/semantics/test_data/array_cap | 154 ------------------ crates/dojo-lang/src/semantics/test_data/get | 105 ------------ .../src/semantics/test_data/selector_from_tag | 86 ++++++++++ crates/dojo-lang/src/semantics/test_data/set | 40 ----- crates/dojo-lang/src/semantics/test_utils.rs | 4 +- crates/dojo-lang/src/semantics/tests.rs | 2 + 9 files changed, 95 insertions(+), 303 deletions(-) delete mode 100644 crates/dojo-lang/src/semantics/test_data/array_cap create mode 100644 crates/dojo-lang/src/semantics/test_data/selector_from_tag diff --git a/crates/dojo-lang/src/inline_macros/mod.rs b/crates/dojo-lang/src/inline_macros/mod.rs index fc8e0dc560..35bef33321 100644 --- a/crates/dojo-lang/src/inline_macros/mod.rs +++ b/crates/dojo-lang/src/inline_macros/mod.rs @@ -7,8 +7,8 @@ use smol_str::SmolStr; pub mod delete; pub mod emit; pub mod get; -pub mod set; pub mod selector_from_tag; +pub mod set; pub mod utils; const CAIRO_ERR_MSG_LEN: usize = 31; diff --git a/crates/dojo-lang/src/inline_macros/selector_from_tag.rs b/crates/dojo-lang/src/inline_macros/selector_from_tag.rs index 1e51bb9dc7..b0a5f9dc06 100644 --- a/crates/dojo-lang/src/inline_macros/selector_from_tag.rs +++ b/crates/dojo-lang/src/inline_macros/selector_from_tag.rs @@ -45,7 +45,8 @@ impl InlineMacroExprPlugin for SelectorFromTagMacro { code: None, diagnostics: vec![PluginDiagnostic { stable_ptr: syntax.stable_ptr().untyped(), - message: "Invalid tag. Tag must be in the format of `namespace-name`.".to_string(), + message: "Invalid tag. Tag must be in the format of `namespace-name`." + .to_string(), severity: Severity::Error, }], }; diff --git a/crates/dojo-lang/src/plugin.rs b/crates/dojo-lang/src/plugin.rs index 983b753ff0..b607c25e7f 100644 --- a/crates/dojo-lang/src/plugin.rs +++ b/crates/dojo-lang/src/plugin.rs @@ -31,8 +31,8 @@ use crate::event::handle_event_struct; use crate::inline_macros::delete::DeleteMacro; use crate::inline_macros::emit::EmitMacro; use crate::inline_macros::get::GetMacro; -use crate::inline_macros::set::SetMacro; use crate::inline_macros::selector_from_tag::SelectorFromTagMacro; +use crate::inline_macros::set::SetMacro; use crate::interface::DojoInterface; use crate::introspect::{handle_introspect_enum, handle_introspect_struct}; use crate::model::handle_model_struct; diff --git a/crates/dojo-lang/src/semantics/test_data/array_cap b/crates/dojo-lang/src/semantics/test_data/array_cap deleted file mode 100644 index c3b99ac28b..0000000000 --- a/crates/dojo-lang/src/semantics/test_data/array_cap +++ /dev/null @@ -1,154 +0,0 @@ -//! > no params - -//! > test_runner_name -test_semantics - -//! > expression -array_cap!() - -//! > expected -Missing( - ExprMissing { - ty: , - }, -) - -//! > semantic_diagnostics -error: Plugin diagnostic: Invalid arguments. Expected "(capacity, (values,))" - --> lib.cairo:2:12 -array_cap!() - ^ - -//! > ========================================================================== - -//! > Capacity exceeded - -//! > test_runner_name -test_semantics - -//! > expression -array_cap!(1, (1, 2, 3)) - -//! > expected -Missing( - ExprMissing { - ty: , - }, -) - -//! > semantic_diagnostics -error: Plugin diagnostic: Number of values is exceeded the capacity - --> lib.cairo:2:22 -array_cap!(1, (1, 2, 3)) - ^ - -//! > ========================================================================== - -//! > set successful expansion - -//! > no_diagnostics -true - -//! > test_runner_name -test_semantics - -//! > expression -array_cap!(1, (0xfe, 2)) - -//! > expected -Block( - ExprBlock { - statements: [ - Let( - StatementLet { - pattern: Variable( - __array_with_cap__, - ), - expr: Block( - ExprBlock { - statements: [ - Let( - StatementLet { - pattern: Variable( - __array_builder_macro_result__, - ), - expr: FunctionCall( - ExprFunctionCall { - function: core::array::ArrayImpl::::new, - args: [], - coupon_arg: None, - ty: core::array::Array::, - }, - ), - }, - ), - ], - tail: Some( - Var( - LocalVarId(test::__array_builder_macro_result__), - ), - ), - ty: core::array::Array::, - }, - ), - }, - ), - Expr( - StatementExpr { - expr: FunctionCall( - ExprFunctionCall { - function: core::array::ArrayImpl::::append, - args: [ - Reference( - LocalVarId(test::__array_with_cap__), - ), - Value( - Literal( - ExprLiteral { - value: 254, - ty: core::felt252, - }, - ), - ), - ], - coupon_arg: None, - ty: (), - }, - ), - }, - ), - Expr( - StatementExpr { - expr: FunctionCall( - ExprFunctionCall { - function: core::array::ArrayImpl::::append, - args: [ - Reference( - LocalVarId(test::__array_with_cap__), - ), - Value( - Literal( - ExprLiteral { - value: 2, - ty: core::felt252, - }, - ), - ), - ], - coupon_arg: None, - ty: (), - }, - ), - }, - ), - ], - tail: Some( - Var( - LocalVarId(test::__array_with_cap__), - ), - ), - ty: core::array::Array::, - }, -) - -//! > semantic_diagnostics diff --git a/crates/dojo-lang/src/semantics/test_data/get b/crates/dojo-lang/src/semantics/test_data/get index a3ef799153..5f90c0d359 100644 --- a/crates/dojo-lang/src/semantics/test_data/get +++ b/crates/dojo-lang/src/semantics/test_data/get @@ -29,41 +29,6 @@ Missing( ) //! > semantic_diagnostics -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") - --> lib.cairo:1:1 -use array::ArrayTrait; -^********************^ - -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") - --> lib.cairo:2:1 -use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; -^*********************************************************^ - -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") - --> lib.cairo:4:1 -#[derive(Copy, Drop, Serde, Introspect)] -^**************************************^ - -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") - --> lib.cairo:10:1 -fn test_func() { let key: felt252 = 0xb0b; -^****************************************^ - -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") - --> lib.cairo:3:1 - -^ - -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") - --> lib.cairo:3:1 - -^ - -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") - --> lib.cairo:3:1 - -^ - error: Plugin diagnostic: Invalid arguments. Expected "get!(world, keys, (models,))" --> lib.cairo:12:1 get!() @@ -112,41 +77,6 @@ Missing( ) //! > semantic_diagnostics -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") - --> lib.cairo:1:1 -use array::ArrayTrait; -^********************^ - -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") - --> lib.cairo:2:1 -use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; -^*********************************************************^ - -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") - --> lib.cairo:4:1 -#[derive(Copy, Drop, Serde, Introspect)] -^**************************************^ - -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") - --> lib.cairo:10:1 -fn test_func() { let key: felt252 = 0xb0b; -^****************************************^ - -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") - --> lib.cairo:3:1 - -^ - -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") - --> lib.cairo:3:1 - -^ - -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") - --> lib.cairo:3:1 - -^ - error: Plugin diagnostic: Invalid arguments. Expected "get!(world, keys, (models,))" --> lib.cairo:12:1 get!(world) @@ -321,41 +251,6 @@ Block( ) //! > semantic_diagnostics -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") - --> lib.cairo:1:1 -use array::ArrayTrait; -^********************^ - -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") - --> lib.cairo:2:1 -use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; -^*********************************************************^ - -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") - --> lib.cairo:4:1 -#[derive(Copy, Drop, Serde, Introspect)] -^**************************************^ - -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") - --> lib.cairo:10:1 -fn test_func() { let key: felt252 = 0xb0b; -^****************************************^ - -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") - --> lib.cairo:3:1 - -^ - -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") - --> lib.cairo:3:1 - -^ - -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") - --> lib.cairo:3:1 - -^ - error: Trait has no implementation in context: dojo::model::Model::. --> lib.cairo:12:1 get!(world, key, (Health)) diff --git a/crates/dojo-lang/src/semantics/test_data/selector_from_tag b/crates/dojo-lang/src/semantics/test_data/selector_from_tag new file mode 100644 index 0000000000..a5694605de --- /dev/null +++ b/crates/dojo-lang/src/semantics/test_data/selector_from_tag @@ -0,0 +1,86 @@ +//! > Test ok + +//! > test_runner_name +test_semantics + +//! > expression +selector_from_tag!("dojo-test_contract") + +//! > expected +Literal( + ExprLiteral { + value: 2368393732245529956313345237151518608283468650081902115301417183793437311044, + ty: core::felt252, + }, +) + +//! > semantic_diagnostics + +//! > ========================================================================== + +//! > Test no params + +//! > test_runner_name +test_semantics + +//! > expression +selector_from_tag!() + +//! > expected +Missing( + ExprMissing { + ty: , + }, +) + +//! > semantic_diagnostics +error: Plugin diagnostic: Invalid arguments. Expected "selector_from_tag!("tag")" + --> lib.cairo:2:1 +selector_from_tag!() +^******************^ + +//! > ========================================================================== + +//! > Test invalid tag + +//! > test_runner_name +test_semantics + +//! > expression +selector_from_tag!("invalid tag") + +//! > expected +Missing( + ExprMissing { + ty: , + }, +) + +//! > semantic_diagnostics +error: Plugin diagnostic: Invalid tag. Tag must be in the format of `namespace-name`. + --> lib.cairo:2:1 +selector_from_tag!("invalid tag") +^*******************************^ + +//! > ========================================================================== + +//! > Test wrong param + +//! > test_runner_name +test_semantics + +//! > expression +selector_from_tag!("name", "namespace") + +//! > expected +Missing( + ExprMissing { + ty: , + }, +) + +//! > semantic_diagnostics +error: Plugin diagnostic: Invalid arguments. Expected "selector_from_tag!("tag")" + --> lib.cairo:2:1 +selector_from_tag!("name", "namespace") +^*************************************^ diff --git a/crates/dojo-lang/src/semantics/test_data/set b/crates/dojo-lang/src/semantics/test_data/set index f430a81f6c..d41133d396 100644 --- a/crates/dojo-lang/src/semantics/test_data/set +++ b/crates/dojo-lang/src/semantics/test_data/set @@ -18,11 +18,6 @@ Missing( ) //! > semantic_diagnostics -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") - --> lib.cairo:1:1 -fn test_func() { { -^*****************^ - error: Plugin diagnostic: Invalid arguments. Expected "(world, (models,))" --> lib.cairo:2:6 set!() @@ -50,11 +45,6 @@ Missing( ) //! > semantic_diagnostics -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") - --> lib.cairo:1:1 -fn test_func() { { -^*****************^ - error: Plugin diagnostic: Invalid arguments. Expected "(world, (models,))" --> lib.cairo:2:6 set!(world) @@ -234,41 +224,11 @@ Block( ) //! > semantic_diagnostics -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") - --> lib.cairo:1:1 -use dojo::world::{IWorldDispatcher, IWorldDispatcherTrait}; -^*********************************************************^ - error: Plugin diagnostic: Unknown derive `Model` - a plugin might be missing. --> lib.cairo:3:29 #[derive(Copy, Drop, Serde, Model)] ^***^ -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") - --> lib.cairo:3:1 -#[derive(Copy, Drop, Serde, Model)] -^*********************************^ - -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") - --> lib.cairo:9:1 -fn test_func() { let key: felt252 = 0xb0b; -^****************************************^ - -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") - --> lib.cairo:2:1 - -^ - -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") - --> lib.cairo:2:1 - -^ - -error: Plugin diagnostic: Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. Real("/var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmppLGAlA/registry/std/43cf361d9/core/src") - --> lib.cairo:2:1 - -^ - warning[E0001]: Unused variable. Consider ignoring by prefixing with `_`. --> lib.cairo:9:22 fn test_func() { let key: felt252 = 0xb0b; diff --git a/crates/dojo-lang/src/semantics/test_utils.rs b/crates/dojo-lang/src/semantics/test_utils.rs index e497417f55..8ef9b9409a 100644 --- a/crates/dojo-lang/src/semantics/test_utils.rs +++ b/crates/dojo-lang/src/semantics/test_utils.rs @@ -52,14 +52,16 @@ impl DojoSemanticDatabase { db.set_inline_macro_plugins(suite.inline_macro_plugins.into()); db.set_analyzer_plugins(suite.analyzer_plugins); - init_dev_corelib(&mut db, corelib()); let dojo_path = Utf8PathBuf::from_path_buf("../../crates/dojo-core/src".into()).unwrap(); let dojo_path: PathBuf = dojo_path.canonicalize_utf8().unwrap().into(); let core_crate = db.intern_crate(CrateLongId::Real("dojo".into())); let core_root_dir = Directory::Real(dojo_path); + // Ensure the crate[0] is dojo, to enable parsing of the Scarb.toml. db.set_crate_config(core_crate, Some(CrateConfiguration::default_for_root(core_root_dir))); + init_dev_corelib(&mut db, corelib()); + db } /// Snapshots the db for read only. diff --git a/crates/dojo-lang/src/semantics/tests.rs b/crates/dojo-lang/src/semantics/tests.rs index 604c87e6d0..518def9ba7 100644 --- a/crates/dojo-lang/src/semantics/tests.rs +++ b/crates/dojo-lang/src/semantics/tests.rs @@ -16,6 +16,8 @@ test_file_test!( get: "get", set: "set", + + selector_from_tag: "selector_from_tag", }, test_semantics ); From f9ea0e0a470fa298376cc223d07e01d5d41afce2 Mon Sep 17 00:00:00 2001 From: glihm Date: Fri, 12 Jul 2024 19:53:52 -0600 Subject: [PATCH 12/15] fix: rebuild tests with new world address --- .../manifests/dev/base/abis/dojo-world.json | 20 ++++++++- .../manifests/dev/base/dojo-world.toml | 4 +- .../dojo-lang/src/plugin_test_data/introspect | 16 +++---- crates/dojo-lang/src/plugin_test_data/model | 22 +++++----- crates/dojo-lang/src/plugin_test_data/print | 8 ++-- crates/dojo-lang/src/plugin_test_data/system | 44 +++++++++---------- crates/dojo-world/src/contracts/abi/world.rs | 20 ++++++++- examples/spawn-and-move/Scarb.toml | 2 +- .../manifests/dev/base/abis/dojo-world.json | 20 ++++++++- .../manifests/dev/base/dojo-world.toml | 4 +- .../dev/deployment/abis/dojo-world.json | 20 ++++++++- .../manifests/dev/deployment/manifest.json | 36 ++++++++++----- .../manifests/dev/deployment/manifest.toml | 16 +++---- .../release/base/abis/dojo-world.json | 20 ++++++++- .../manifests/release/base/dojo-world.toml | 4 +- 15 files changed, 176 insertions(+), 80 deletions(-) diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-world.json b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-world.json index 0e5e96210e..996795c619 100644 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-world.json +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-world.json @@ -182,6 +182,22 @@ ], "state_mutability": "view" }, + { + "type": "function", + "name": "contract", + "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", @@ -235,8 +251,8 @@ "name": "upgrade_contract", "inputs": [ { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" + "name": "selector", + "type": "core::felt252" }, { "name": "class_hash", diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-world.toml b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-world.toml index 83a7a20228..e54ed9889c 100644 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-world.toml +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-world.toml @@ -1,6 +1,6 @@ kind = "Class" -class_hash = "0x210dd8e484e5555dc74a4a600b17878fc108911719b04139309acc874160c51" -original_class_hash = "0x210dd8e484e5555dc74a4a600b17878fc108911719b04139309acc874160c51" +class_hash = "0x25f8aa71a18dff4615cf3bb7231014f58500b69c6d746d8e26d8ddae739cdb8" +original_class_hash = "0x25f8aa71a18dff4615cf3bb7231014f58500b69c6d746d8e26d8ddae739cdb8" abi = "manifests/dev/base/abis/dojo-world.json" tag = "dojo-world" manifest_name = "dojo-world" diff --git a/crates/dojo-lang/src/plugin_test_data/introspect b/crates/dojo-lang/src/plugin_test_data/introspect index 705b66abf9..deecbf3089 100644 --- a/crates/dojo-lang/src/plugin_test_data/introspect +++ b/crates/dojo-lang/src/plugin_test_data/introspect @@ -2901,41 +2901,41 @@ impl EnumNotPackable1Introspect<> of dojo::database::introspect::Introspect expected_diagnostics error: Option cannot be used with tuples. Prefer using a struct. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp7Umie1/src/lib.cairo:171:6 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp17oXak/src/lib.cairo:171:6 x: Option<(u8, u16)> ^*****************^ error: Option cannot be used with tuples. Prefer using a struct. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp7Umie1/src/lib.cairo:176:10 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp17oXak/src/lib.cairo:176:10 first: Option<(u8, u16)>, ^*****************^ error: Introspect and IntrospectPacked attributes cannot be used at a same time. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp7Umie1/src/lib.cairo:180:6 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp17oXak/src/lib.cairo:180:6 enum EnumIncompatibleAttrs {} ^*******************^ error: Introspect and IntrospectPacked attributes cannot be used at a same time. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp7Umie1/src/lib.cairo:183:8 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp17oXak/src/lib.cairo:183:8 struct StructIncompatibleAttrs {} ^*********************^ error: Introspect and IntrospectPacked attributes cannot be used at a same time. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp7Umie1/src/lib.cairo:187:8 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp17oXak/src/lib.cairo:187:8 struct StructIncompatibleAttrs2 {} ^**********************^ error: Introspect and IntrospectPacked attributes cannot be used at a same time. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp7Umie1/src/lib.cairo:191:6 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp17oXak/src/lib.cairo:191:6 enum EnumIncompatibleAttrs2 {} ^********************^ error: Array field cannot be packed. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp7Umie1/src/lib.cairo:213:6 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp17oXak/src/lib.cairo:213:6 y: Array ^**********^ error: To be packed, all variants must have fixed layout of same size. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp7Umie1/src/lib.cairo:250:6 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp17oXak/src/lib.cairo:250:6 enum EnumNotPackable1 { ^**************^ diff --git a/crates/dojo-lang/src/plugin_test_data/model b/crates/dojo-lang/src/plugin_test_data/model index f2630da9cb..ffba06f8be 100644 --- a/crates/dojo-lang/src/plugin_test_data/model +++ b/crates/dojo-lang/src/plugin_test_data/model @@ -17073,56 +17073,56 @@ impl DeriveStorageImodel_with_tuple_no_primitivesSafeDispatcher of starknet::sto //! > expected_diagnostics error: A Dojo model must have zero or one dojo::model attribute. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpkivhTu/src/lib.cairo:1:1 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpdsPcty/src/lib.cairo:1:1 #[dojo::model(version: 0)] ^************************^ error: Too many 'version' attributes for dojo::model - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpkivhTu/src/lib.cairo:9:1 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpdsPcty/src/lib.cairo:9:1 #[dojo::model(version: 0, version: 0)] ^************************************^ error: The argument 'version' of dojo::model must be an integer - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpkivhTu/src/lib.cairo:16:24 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpdsPcty/src/lib.cairo:16:24 #[dojo::model(version: hello)] ^***^ error: Unexpected argument 'version' for dojo::model - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpkivhTu/src/lib.cairo:23:15 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpdsPcty/src/lib.cairo:23:15 #[dojo::model(version)] ^*****^ error: Unexpected argument 'my_arg' for dojo::model - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpkivhTu/src/lib.cairo:30:15 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpdsPcty/src/lib.cairo:30:15 #[dojo::model(my_arg: 1)] ^*******^ error: Unexpected argument 'my_arg' for dojo::model - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpkivhTu/src/lib.cairo:37:15 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpdsPcty/src/lib.cairo:37:15 #[dojo::model(my_arg)] ^****^ error: dojo::model version 2 not supported - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpkivhTu/src/lib.cairo:44:24 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpdsPcty/src/lib.cairo:44:24 #[dojo::model(version: 2)] ^ error: Model must define at least one #[key] attribute - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpkivhTu/src/lib.cairo:87:8 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpdsPcty/src/lib.cairo:87:8 struct Roles { ^***^ error: Model must define at least one member that is not a key - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpkivhTu/src/lib.cairo:92:8 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpdsPcty/src/lib.cairo:92:8 struct OnlyKeyModel { ^**********^ error: Model must define at least one member that is not a key - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpkivhTu/src/lib.cairo:98:8 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpdsPcty/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. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpkivhTu/src/lib.cairo:98:8 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpdsPcty/src/lib.cairo:98:8 struct U256KeyModel { ^**********^ diff --git a/crates/dojo-lang/src/plugin_test_data/print b/crates/dojo-lang/src/plugin_test_data/print index 402b2b9345..8b8df081c2 100644 --- a/crates/dojo-lang/src/plugin_test_data/print +++ b/crates/dojo-lang/src/plugin_test_data/print @@ -113,21 +113,21 @@ Enemy::OtherPlayer(v) => { core::debug::PrintTrait::print('OtherPlayer'); core:: //! > expected_diagnostics error: Unknown derive `Print` - a plugin might be missing. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpACPmcs/src/lib.cairo:4:10 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpgD6ee2/src/lib.cairo:4:10 #[derive(Print)] ^***^ error: Unknown derive `Print` - a plugin might be missing. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpACPmcs/src/lib.cairo:12:10 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpgD6ee2/src/lib.cairo:12:10 #[derive(Print)] ^***^ error: Unknown derive `Print` - a plugin might be missing. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpACPmcs/src/lib.cairo:19:10 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpgD6ee2/src/lib.cairo:19:10 #[derive(Print)] ^***^ error: Unknown derive `Print` - a plugin might be missing. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpACPmcs/src/lib.cairo:28:10 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpgD6ee2/src/lib.cairo:28:10 #[derive(Print)] ^***^ diff --git a/crates/dojo-lang/src/plugin_test_data/system b/crates/dojo-lang/src/plugin_test_data/system index 464bba89d9..5d5931c8a9 100644 --- a/crates/dojo-lang/src/plugin_test_data/system +++ b/crates/dojo-lang/src/plugin_test_data/system @@ -356,112 +356,112 @@ mod ctxnamed { //! > expected_diagnostics error: Anything other than functions is not supported in a dojo::interface - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:90:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:90:5 const ONE: u8; ^************^ error: World parameter must be the first parameter. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:111:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:111:5 fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252; ^***********************************************************************************^ error: World parameter must be the first parameter. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:112:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:112:5 fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; ^*********************************************************************************************^ error: You cannot use `self` and `world` parameters together. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:113:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:113:5 fn do_with_self_and_world_inv(world: @IWorldDispatcher, self: @ContractState) -> felt252; ^***************************************************************************************^ error: You cannot use `self` and `world` parameters together. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:114:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:114:5 fn do_with_ref_self_and_world_inv( ^********************************^ error: World parameter must be the first parameter. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:121:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:121:5 fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252; ^****************************************************************************^ error: World parameter must be the first parameter. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:128:9 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:128:9 fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252 { ^************************************************************************************^ error: World parameter must be the first parameter. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:132:9 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:132:9 fn do_with_ref_self_and_world( ^****************************^ error: You cannot use `self` and `world` parameters together. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:138:9 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:138:9 fn do_with_self_and_world_inv(world: @IWorldDispatcher, self: @ContractState) -> felt252 { ^****************************************************************************************^ error: You cannot use `self` and `world` parameters together. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:142:9 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:142:9 fn do_with_ref_self_and_world_inv( ^********************************^ error: World parameter must be the first parameter. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:158:9 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:158:9 fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252 { ^*****************************************************************************^ error: You cannot use `world` and `#[generate_trait]` together. Use `self` instead. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:165:9 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:165:9 fn bad_func_using_generate(world: @IWorldDispatcher) -> felt252 { ^***************************************************************^ error: World parameter must be a snapshot if `ref` is not used. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:224:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:224:5 fn dojo_init( ^***********^ error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:105:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:105:5 fn do_with_self(self: @ContractState) -> felt252; ^**********************************************^ error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:106:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:106:5 fn do_with_ref_self(ref self: ContractState) -> felt252; ^*****************************************************^ error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:111:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:111:5 fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252; ^**********************************************************************************^ error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:112:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:112:5 fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; ^********************************************************************************************^ error: `starknet::interface` functions don't support `ref` parameters other than the first one. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:112:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:112:5 fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; ^********************************************************************************************^ error: `starknet::interface` functions don't support `ref` parameters other than the first one. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:114:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:114:5 fn do_with_ref_self_and_world_inv( ^********************************^ error: `starknet::interface` functions don't support `ref` parameters other than the first one. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:117:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:117:5 fn do_with_several_world_dispatchers( ^***********************************^ error: `starknet::interface` functions don't support `ref` parameters other than the first one. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:121:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:121:5 fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252; ^***************************************************************************^ error: Generated trait must have generic args matching the impl's generic params. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpDGHlJ4/src/lib.cairo:163:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:163:5 #[generate_trait] ^***************^ diff --git a/crates/dojo-world/src/contracts/abi/world.rs b/crates/dojo-world/src/contracts/abi/world.rs index f681f1ab97..30c4440ae2 100644 --- a/crates/dojo-world/src/contracts/abi/world.rs +++ b/crates/dojo-world/src/contracts/abi/world.rs @@ -188,6 +188,22 @@ abigen!( ], "state_mutability": "view" }, + { + "type": "function", + "name": "contract", + "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", @@ -241,8 +257,8 @@ abigen!( "name": "upgrade_contract", "inputs": [ { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" + "name": "selector", + "type": "core::felt252" }, { "name": "class_hash", diff --git a/examples/spawn-and-move/Scarb.toml b/examples/spawn-and-move/Scarb.toml index a41276f6bf..c426e5b96d 100644 --- a/examples/spawn-and-move/Scarb.toml +++ b/examples/spawn-and-move/Scarb.toml @@ -43,7 +43,7 @@ rpc_url = "http://localhost:5050/" # Default account for katana with seed = 0 account_address = "0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03" private_key = "0x1800000000300000180000000000030000000000003006001800006600" -world_address = "0x504b804eeac62e68d12dc030e56b8f62cb047950c346e60a974da02795f6aba" +world_address = "0x70049a301d80957caf359bc84171911ae8132cdb43405163754c154e9c37f26" [profile.release.tool.dojo] # for more info on how `merge-strategy` works see: diff --git a/examples/spawn-and-move/manifests/dev/base/abis/dojo-world.json b/examples/spawn-and-move/manifests/dev/base/abis/dojo-world.json index 0e5e96210e..996795c619 100644 --- a/examples/spawn-and-move/manifests/dev/base/abis/dojo-world.json +++ b/examples/spawn-and-move/manifests/dev/base/abis/dojo-world.json @@ -182,6 +182,22 @@ ], "state_mutability": "view" }, + { + "type": "function", + "name": "contract", + "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", @@ -235,8 +251,8 @@ "name": "upgrade_contract", "inputs": [ { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" + "name": "selector", + "type": "core::felt252" }, { "name": "class_hash", diff --git a/examples/spawn-and-move/manifests/dev/base/dojo-world.toml b/examples/spawn-and-move/manifests/dev/base/dojo-world.toml index 83a7a20228..e54ed9889c 100644 --- a/examples/spawn-and-move/manifests/dev/base/dojo-world.toml +++ b/examples/spawn-and-move/manifests/dev/base/dojo-world.toml @@ -1,6 +1,6 @@ kind = "Class" -class_hash = "0x210dd8e484e5555dc74a4a600b17878fc108911719b04139309acc874160c51" -original_class_hash = "0x210dd8e484e5555dc74a4a600b17878fc108911719b04139309acc874160c51" +class_hash = "0x25f8aa71a18dff4615cf3bb7231014f58500b69c6d746d8e26d8ddae739cdb8" +original_class_hash = "0x25f8aa71a18dff4615cf3bb7231014f58500b69c6d746d8e26d8ddae739cdb8" abi = "manifests/dev/base/abis/dojo-world.json" tag = "dojo-world" manifest_name = "dojo-world" diff --git a/examples/spawn-and-move/manifests/dev/deployment/abis/dojo-world.json b/examples/spawn-and-move/manifests/dev/deployment/abis/dojo-world.json index 0e5e96210e..996795c619 100644 --- a/examples/spawn-and-move/manifests/dev/deployment/abis/dojo-world.json +++ b/examples/spawn-and-move/manifests/dev/deployment/abis/dojo-world.json @@ -182,6 +182,22 @@ ], "state_mutability": "view" }, + { + "type": "function", + "name": "contract", + "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", @@ -235,8 +251,8 @@ "name": "upgrade_contract", "inputs": [ { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" + "name": "selector", + "type": "core::felt252" }, { "name": "class_hash", diff --git a/examples/spawn-and-move/manifests/dev/deployment/manifest.json b/examples/spawn-and-move/manifests/dev/deployment/manifest.json index 6271eddae0..8e1f3e528a 100644 --- a/examples/spawn-and-move/manifests/dev/deployment/manifest.json +++ b/examples/spawn-and-move/manifests/dev/deployment/manifest.json @@ -1,8 +1,8 @@ { "world": { "kind": "WorldContract", - "class_hash": "0x210dd8e484e5555dc74a4a600b17878fc108911719b04139309acc874160c51", - "original_class_hash": "0x210dd8e484e5555dc74a4a600b17878fc108911719b04139309acc874160c51", + "class_hash": "0x25f8aa71a18dff4615cf3bb7231014f58500b69c6d746d8e26d8ddae739cdb8", + "original_class_hash": "0x25f8aa71a18dff4615cf3bb7231014f58500b69c6d746d8e26d8ddae739cdb8", "abi": [ { "type": "impl", @@ -187,6 +187,22 @@ ], "state_mutability": "view" }, + { + "type": "function", + "name": "contract", + "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", @@ -240,8 +256,8 @@ "name": "upgrade_contract", "inputs": [ { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" + "name": "selector", + "type": "core::felt252" }, { "name": "class_hash", @@ -1108,8 +1124,8 @@ ] } ], - "address": "0x504b804eeac62e68d12dc030e56b8f62cb047950c346e60a974da02795f6aba", - "transaction_hash": "0x65168705b42b38a0b9e290dfb079e023fa1960febb9fd7069fce5e369e3b56f", + "address": "0x70049a301d80957caf359bc84171911ae8132cdb43405163754c154e9c37f26", + "transaction_hash": "0x63339a79058617ccb845d7cc70e6d40c851fb1f740dfe267e929df10dc71180", "block_number": 3, "seed": "dojo_examples", "metadata": { @@ -1129,7 +1145,7 @@ "contracts": [ { "kind": "DojoContract", - "address": "0x2e85647f570d2a4abdffdd668823702548d20d1d6aaef74b6a4eb9670a32798", + "address": "0x2b924027af667457a3438958f2b9a58adbe10b9dc2aa0eba7638ac59367c822", "class_hash": "0x2c975b0d681861edd6caad5fbc0b42dc3e8b034b6c0b0a7628fb3a7bedf1e8d", "original_class_hash": "0x2c975b0d681861edd6caad5fbc0b42dc3e8b034b6c0b0a7628fb3a7bedf1e8d", "base_class_hash": "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4", @@ -1536,7 +1552,7 @@ }, { "kind": "DojoContract", - "address": "0x4f38db968d53b073189760e1256d827195de3904542cf62d60e6bd3707f8504", + "address": "0x5279a43866827e5d4bb4bb6f358ab5020c1b29e0ea62de65a80a1d3557bd77f", "class_hash": "0x14b3096b82a761f63dd47277c2b5ac18925dea43586418483939a2f1f57f674", "original_class_hash": "0x14b3096b82a761f63dd47277c2b5ac18925dea43586418483939a2f1f57f674", "base_class_hash": "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4", @@ -1773,7 +1789,7 @@ }, { "kind": "DojoContract", - "address": "0x6a06eb156f956f1691bce4a4573c97b1a5f08d3bfa65fc25c4ed4b55d3e61a1", + "address": "0x306dcf2361031881a2d42185bd522e85bb313baa0603953f7c75010760f792c", "class_hash": "0x97cd4fb3acfe9e6a024589ea34db2fc587586d699ef3732ce627e1771158ef", "original_class_hash": "0x97cd4fb3acfe9e6a024589ea34db2fc587586d699ef3732ce627e1771158ef", "base_class_hash": "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4", @@ -1992,7 +2008,7 @@ }, { "kind": "DojoContract", - "address": "0x6359537114e0a62c63f52f2fb3c0e6241c9a2fcbd9dc9df221c867662aa31e9", + "address": "0x6dca4b6ed01bd16984a04ca71e1725ad617323a4089367ff9c020369785b3b", "class_hash": "0x479bfb12dcba5398d77303e7a665fc3fedb16f2d7f9cb1f5d7e2beb3b7e2ba7", "original_class_hash": "0x479bfb12dcba5398d77303e7a665fc3fedb16f2d7f9cb1f5d7e2beb3b7e2ba7", "base_class_hash": "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4", diff --git a/examples/spawn-and-move/manifests/dev/deployment/manifest.toml b/examples/spawn-and-move/manifests/dev/deployment/manifest.toml index 72dc3f36d0..fc48f1f603 100644 --- a/examples/spawn-and-move/manifests/dev/deployment/manifest.toml +++ b/examples/spawn-and-move/manifests/dev/deployment/manifest.toml @@ -1,10 +1,10 @@ [world] kind = "WorldContract" -class_hash = "0x210dd8e484e5555dc74a4a600b17878fc108911719b04139309acc874160c51" -original_class_hash = "0x210dd8e484e5555dc74a4a600b17878fc108911719b04139309acc874160c51" +class_hash = "0x25f8aa71a18dff4615cf3bb7231014f58500b69c6d746d8e26d8ddae739cdb8" +original_class_hash = "0x25f8aa71a18dff4615cf3bb7231014f58500b69c6d746d8e26d8ddae739cdb8" abi = "manifests/dev/deployment/abis/dojo-world.json" -address = "0x504b804eeac62e68d12dc030e56b8f62cb047950c346e60a974da02795f6aba" -transaction_hash = "0x65168705b42b38a0b9e290dfb079e023fa1960febb9fd7069fce5e369e3b56f" +address = "0x70049a301d80957caf359bc84171911ae8132cdb43405163754c154e9c37f26" +transaction_hash = "0x63339a79058617ccb845d7cc70e6d40c851fb1f740dfe267e929df10dc71180" block_number = 3 seed = "dojo_examples" manifest_name = "dojo-world" @@ -23,7 +23,7 @@ manifest_name = "dojo-base" [[contracts]] kind = "DojoContract" -address = "0x2e85647f570d2a4abdffdd668823702548d20d1d6aaef74b6a4eb9670a32798" +address = "0x2b924027af667457a3438958f2b9a58adbe10b9dc2aa0eba7638ac59367c822" class_hash = "0x2c975b0d681861edd6caad5fbc0b42dc3e8b034b6c0b0a7628fb3a7bedf1e8d" original_class_hash = "0x2c975b0d681861edd6caad5fbc0b42dc3e8b034b6c0b0a7628fb3a7bedf1e8d" base_class_hash = "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4" @@ -40,7 +40,7 @@ manifest_name = "dojo_examples-actions-40b6994c" [[contracts]] kind = "DojoContract" -address = "0x4f38db968d53b073189760e1256d827195de3904542cf62d60e6bd3707f8504" +address = "0x5279a43866827e5d4bb4bb6f358ab5020c1b29e0ea62de65a80a1d3557bd77f" class_hash = "0x14b3096b82a761f63dd47277c2b5ac18925dea43586418483939a2f1f57f674" original_class_hash = "0x14b3096b82a761f63dd47277c2b5ac18925dea43586418483939a2f1f57f674" base_class_hash = "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4" @@ -54,7 +54,7 @@ manifest_name = "dojo_examples-dungeon-6620e0e6" [[contracts]] kind = "DojoContract" -address = "0x6a06eb156f956f1691bce4a4573c97b1a5f08d3bfa65fc25c4ed4b55d3e61a1" +address = "0x306dcf2361031881a2d42185bd522e85bb313baa0603953f7c75010760f792c" class_hash = "0x97cd4fb3acfe9e6a024589ea34db2fc587586d699ef3732ce627e1771158ef" original_class_hash = "0x97cd4fb3acfe9e6a024589ea34db2fc587586d699ef3732ce627e1771158ef" base_class_hash = "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4" @@ -68,7 +68,7 @@ manifest_name = "dojo_examples-mock_token-31599eb2" [[contracts]] kind = "DojoContract" -address = "0x6359537114e0a62c63f52f2fb3c0e6241c9a2fcbd9dc9df221c867662aa31e9" +address = "0x6dca4b6ed01bd16984a04ca71e1725ad617323a4089367ff9c020369785b3b" class_hash = "0x479bfb12dcba5398d77303e7a665fc3fedb16f2d7f9cb1f5d7e2beb3b7e2ba7" original_class_hash = "0x479bfb12dcba5398d77303e7a665fc3fedb16f2d7f9cb1f5d7e2beb3b7e2ba7" base_class_hash = "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4" diff --git a/examples/spawn-and-move/manifests/release/base/abis/dojo-world.json b/examples/spawn-and-move/manifests/release/base/abis/dojo-world.json index 0e5e96210e..996795c619 100644 --- a/examples/spawn-and-move/manifests/release/base/abis/dojo-world.json +++ b/examples/spawn-and-move/manifests/release/base/abis/dojo-world.json @@ -182,6 +182,22 @@ ], "state_mutability": "view" }, + { + "type": "function", + "name": "contract", + "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", @@ -235,8 +251,8 @@ "name": "upgrade_contract", "inputs": [ { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" + "name": "selector", + "type": "core::felt252" }, { "name": "class_hash", diff --git a/examples/spawn-and-move/manifests/release/base/dojo-world.toml b/examples/spawn-and-move/manifests/release/base/dojo-world.toml index 97f4f8c522..160ec61c7f 100644 --- a/examples/spawn-and-move/manifests/release/base/dojo-world.toml +++ b/examples/spawn-and-move/manifests/release/base/dojo-world.toml @@ -1,6 +1,6 @@ kind = "Class" -class_hash = "0x210dd8e484e5555dc74a4a600b17878fc108911719b04139309acc874160c51" -original_class_hash = "0x210dd8e484e5555dc74a4a600b17878fc108911719b04139309acc874160c51" +class_hash = "0x25f8aa71a18dff4615cf3bb7231014f58500b69c6d746d8e26d8ddae739cdb8" +original_class_hash = "0x25f8aa71a18dff4615cf3bb7231014f58500b69c6d746d8e26d8ddae739cdb8" abi = "manifests/release/base/abis/dojo-world.json" tag = "dojo-world" manifest_name = "dojo-world" From 5450ef46243dcb7b65e89e7407fd591f40645f09 Mon Sep 17 00:00:00 2001 From: glihm Date: Fri, 12 Jul 2024 20:18:27 -0600 Subject: [PATCH 13/15] feat: add write permission check from contract selector --- crates/dojo-core/src/world.cairo | 99 +++++++++++++++---- .../manifests/dev/base/abis/dojo-world.json | 24 ++++- .../manifests/dev/base/dojo-world.toml | 4 +- .../dojo-lang/src/plugin_test_data/introspect | 16 +-- crates/dojo-lang/src/plugin_test_data/model | 22 ++--- crates/dojo-lang/src/plugin_test_data/print | 8 +- crates/dojo-lang/src/plugin_test_data/system | 44 ++++----- crates/dojo-world/src/contracts/abi/world.rs | 24 ++++- examples/spawn-and-move/Scarb.toml | 2 +- .../manifests/dev/base/abis/dojo-world.json | 24 ++++- .../manifests/dev/base/dojo-world.toml | 4 +- .../dev/deployment/abis/dojo-world.json | 24 ++++- .../manifests/dev/deployment/manifest.json | 40 ++++++-- .../manifests/dev/deployment/manifest.toml | 16 +-- .../release/base/abis/dojo-world.json | 24 ++++- .../manifests/release/base/dojo-world.toml | 4 +- 16 files changed, 279 insertions(+), 100 deletions(-) diff --git a/crates/dojo-core/src/world.cairo b/crates/dojo-core/src/world.cairo index 884c3f3082..ef51eb0a4a 100644 --- a/crates/dojo-core/src/world.cairo +++ b/crates/dojo-core/src/world.cairo @@ -44,8 +44,9 @@ trait IWorld { 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; + fn can_write_model(self: @T, selector: felt252, contract: ContractAddress) -> bool; + fn can_write_contract(self: @T, selector: felt252, contract: ContractAddress) -> bool; + fn can_write_namespace(self: @T, selector: felt252, contract: ContractAddress) -> bool; } #[starknet::interface] @@ -241,6 +242,7 @@ mod world { Model: (ClassHash, ContractAddress), Contract: (ClassHash, ContractAddress), Namespace, + World, #[default] None, } @@ -260,9 +262,7 @@ mod world { let creator = starknet::get_tx_info().unbox().account_contract_address; self.contract_base.write(contract_base); - self - .resources - .write(WORLD, ResourceData::Contract((0.try_into().unwrap(), 0.try_into().unwrap()))); + self.resources.write(WORLD, ResourceData::World); self .resources .write( @@ -462,8 +462,10 @@ mod world { 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::Contract((_, contract_address)) => self + ._check_contract_write_access(resource_id, contract_address, contract), + ResourceData::Namespace => self._check_basic_write_access(resource_id, contract), + ResourceData::World => self._check_basic_write_access(WORLD, contract), ResourceData::None => panic_with_felt252(Errors::INVALID_RESOURCE_SELECTOR) } } @@ -476,20 +478,46 @@ mod world { /// /// # Arguments /// - /// * `model_id` - The model selector. + /// * `selector` - 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 + self: @ContractState, selector: 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); + let resource: ResourceData = self.resources.read(selector); match resource { ResourceData::Model((_, model_address)) => self - ._check_model_write_access(model_id, model_address, contract), + ._check_model_write_access(selector, model_address, contract), + _ => panic_with_felt252(Errors::INVALID_RESOURCE_SELECTOR) + } + } + + /// Checks if the provided contract can write to the contract. + /// It panics if the resource selector is not a contract. + /// + /// Note: Contrary to `is_writer`, this function checks if the contract is a write/owner of the contract, + /// OR a write/owner of the namespace. + /// + /// # Arguments + /// + /// * `selector` - The contract selector. + /// * `contract` - The name of the contract. + /// + /// # Returns + /// + /// * `bool` - True if the contract can write to the model, false otherwise + fn can_write_contract( + self: @ContractState, selector: 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(selector); + match resource { + ResourceData::Contract((_, contract_address)) => self + ._check_contract_write_access(selector, contract_address, contract), _ => panic_with_felt252(Errors::INVALID_RESOURCE_SELECTOR) } } @@ -502,19 +530,19 @@ mod world { /// /// # Arguments /// - /// * `namespace_id` - The namespace selector. + /// * `selector` - 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 + self: @ContractState, selector: 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); + let resource: ResourceData = self.resources.read(selector); match resource { - ResourceData::Namespace => self._check_basic_write_access(namespace_id, contract), + ResourceData::Namespace => self._check_basic_write_access(selector, contract), _ => panic_with_felt252(Errors::INVALID_RESOURCE_SELECTOR) } } @@ -961,7 +989,7 @@ mod world { /// - the calling account has the owner and/or writer role for the model namespace. /// /// # Arguments - /// * `model_id` - the model selector to check. + /// * `model_selector` - the model selector to check. /// * `model_address` - the model contract address. /// * `contract` - the calling contract. /// @@ -970,13 +998,13 @@ mod world { /// fn _check_model_write_access( self: @ContractState, - model_id: felt252, + model_selector: 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) { + if !self.is_writer(model_selector, contract) + && !self.is_account_owner(model_selector) + && !self.is_account_writer(model_selector) { let model = IModelDispatcher { contract_address: model_address }; self._check_basic_write_access(model.namespace_hash(), contract) } else { @@ -984,6 +1012,37 @@ mod world { } } + /// Check contract write access. + /// That means, check if: + /// - the calling contract has the writer role for the contract OR, + /// - the calling account has the owner and/or writer role for the contract OR, + /// - the calling contract has the writer role for the contract namespace OR + /// - the calling account has the owner and/or writer role for the model namespace. + /// + /// # Arguments + /// * `contract_selector` - the contract selector to check. + /// * `contract_address` - the contract contract address. + /// * `contract` - the calling contract. + /// + /// # Returns + /// `true` if the write access is allowed, false otherwise. + /// + fn _check_contract_write_access( + self: @ContractState, + contract_selector: felt252, + contract_address: ContractAddress, + contract: ContractAddress + ) -> bool { + if !self.is_writer(contract_selector, contract) + && !self.is_account_owner(contract_selector) + && !self.is_account_writer(contract_selector) { + let dispatcher = IContractDispatcher { contract_address }; + self._check_basic_write_access(dispatcher.namespace_hash(), contract) + } else { + true + } + } + /// Check basic resource write access. /// That means, check if: /// - the calling contract has the writer role for the resource OR, diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-world.json b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-world.json index 996795c619..25197b7bbb 100644 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-world.json +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/abis/dojo-world.json @@ -501,7 +501,27 @@ "name": "can_write_model", "inputs": [ { - "name": "model_id", + "name": "selector", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "can_write_contract", + "inputs": [ + { + "name": "selector", "type": "core::felt252" }, { @@ -521,7 +541,7 @@ "name": "can_write_namespace", "inputs": [ { - "name": "namespace_id", + "name": "selector", "type": "core::felt252" }, { diff --git a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-world.toml b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-world.toml index e54ed9889c..69caa32e86 100644 --- a/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-world.toml +++ b/crates/dojo-lang/src/manifest_test_data/compiler_cairo/manifests/dev/base/dojo-world.toml @@ -1,6 +1,6 @@ kind = "Class" -class_hash = "0x25f8aa71a18dff4615cf3bb7231014f58500b69c6d746d8e26d8ddae739cdb8" -original_class_hash = "0x25f8aa71a18dff4615cf3bb7231014f58500b69c6d746d8e26d8ddae739cdb8" +class_hash = "0xa2a68c8a36082692ff56aece7e4e14dfa533b7c565c749ae8045000e1bf381" +original_class_hash = "0xa2a68c8a36082692ff56aece7e4e14dfa533b7c565c749ae8045000e1bf381" abi = "manifests/dev/base/abis/dojo-world.json" tag = "dojo-world" manifest_name = "dojo-world" diff --git a/crates/dojo-lang/src/plugin_test_data/introspect b/crates/dojo-lang/src/plugin_test_data/introspect index deecbf3089..926f6ccc4f 100644 --- a/crates/dojo-lang/src/plugin_test_data/introspect +++ b/crates/dojo-lang/src/plugin_test_data/introspect @@ -2901,41 +2901,41 @@ impl EnumNotPackable1Introspect<> of dojo::database::introspect::Introspect expected_diagnostics error: Option cannot be used with tuples. Prefer using a struct. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp17oXak/src/lib.cairo:171:6 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmplz9vkI/src/lib.cairo:171:6 x: Option<(u8, u16)> ^*****************^ error: Option cannot be used with tuples. Prefer using a struct. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp17oXak/src/lib.cairo:176:10 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmplz9vkI/src/lib.cairo:176:10 first: Option<(u8, u16)>, ^*****************^ error: Introspect and IntrospectPacked attributes cannot be used at a same time. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp17oXak/src/lib.cairo:180:6 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmplz9vkI/src/lib.cairo:180:6 enum EnumIncompatibleAttrs {} ^*******************^ error: Introspect and IntrospectPacked attributes cannot be used at a same time. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp17oXak/src/lib.cairo:183:8 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmplz9vkI/src/lib.cairo:183:8 struct StructIncompatibleAttrs {} ^*********************^ error: Introspect and IntrospectPacked attributes cannot be used at a same time. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp17oXak/src/lib.cairo:187:8 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmplz9vkI/src/lib.cairo:187:8 struct StructIncompatibleAttrs2 {} ^**********************^ error: Introspect and IntrospectPacked attributes cannot be used at a same time. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp17oXak/src/lib.cairo:191:6 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmplz9vkI/src/lib.cairo:191:6 enum EnumIncompatibleAttrs2 {} ^********************^ error: Array field cannot be packed. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp17oXak/src/lib.cairo:213:6 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmplz9vkI/src/lib.cairo:213:6 y: Array ^**********^ error: To be packed, all variants must have fixed layout of same size. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp17oXak/src/lib.cairo:250:6 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmplz9vkI/src/lib.cairo:250:6 enum EnumNotPackable1 { ^**************^ diff --git a/crates/dojo-lang/src/plugin_test_data/model b/crates/dojo-lang/src/plugin_test_data/model index ffba06f8be..a720467dea 100644 --- a/crates/dojo-lang/src/plugin_test_data/model +++ b/crates/dojo-lang/src/plugin_test_data/model @@ -17073,56 +17073,56 @@ impl DeriveStorageImodel_with_tuple_no_primitivesSafeDispatcher of starknet::sto //! > expected_diagnostics error: A Dojo model must have zero or one dojo::model attribute. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpdsPcty/src/lib.cairo:1:1 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpqaC28y/src/lib.cairo:1:1 #[dojo::model(version: 0)] ^************************^ error: Too many 'version' attributes for dojo::model - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpdsPcty/src/lib.cairo:9:1 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpqaC28y/src/lib.cairo:9:1 #[dojo::model(version: 0, version: 0)] ^************************************^ error: The argument 'version' of dojo::model must be an integer - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpdsPcty/src/lib.cairo:16:24 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpqaC28y/src/lib.cairo:16:24 #[dojo::model(version: hello)] ^***^ error: Unexpected argument 'version' for dojo::model - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpdsPcty/src/lib.cairo:23:15 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpqaC28y/src/lib.cairo:23:15 #[dojo::model(version)] ^*****^ error: Unexpected argument 'my_arg' for dojo::model - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpdsPcty/src/lib.cairo:30:15 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpqaC28y/src/lib.cairo:30:15 #[dojo::model(my_arg: 1)] ^*******^ error: Unexpected argument 'my_arg' for dojo::model - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpdsPcty/src/lib.cairo:37:15 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpqaC28y/src/lib.cairo:37:15 #[dojo::model(my_arg)] ^****^ error: dojo::model version 2 not supported - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpdsPcty/src/lib.cairo:44:24 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpqaC28y/src/lib.cairo:44:24 #[dojo::model(version: 2)] ^ error: Model must define at least one #[key] attribute - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpdsPcty/src/lib.cairo:87:8 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpqaC28y/src/lib.cairo:87:8 struct Roles { ^***^ error: Model must define at least one member that is not a key - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpdsPcty/src/lib.cairo:92:8 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpqaC28y/src/lib.cairo:92:8 struct OnlyKeyModel { ^**********^ error: Model must define at least one member that is not a key - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpdsPcty/src/lib.cairo:98:8 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpqaC28y/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. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpdsPcty/src/lib.cairo:98:8 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpqaC28y/src/lib.cairo:98:8 struct U256KeyModel { ^**********^ diff --git a/crates/dojo-lang/src/plugin_test_data/print b/crates/dojo-lang/src/plugin_test_data/print index 8b8df081c2..6f555f8451 100644 --- a/crates/dojo-lang/src/plugin_test_data/print +++ b/crates/dojo-lang/src/plugin_test_data/print @@ -113,21 +113,21 @@ Enemy::OtherPlayer(v) => { core::debug::PrintTrait::print('OtherPlayer'); core:: //! > expected_diagnostics error: Unknown derive `Print` - a plugin might be missing. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpgD6ee2/src/lib.cairo:4:10 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp7o69VE/src/lib.cairo:4:10 #[derive(Print)] ^***^ error: Unknown derive `Print` - a plugin might be missing. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpgD6ee2/src/lib.cairo:12:10 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp7o69VE/src/lib.cairo:12:10 #[derive(Print)] ^***^ error: Unknown derive `Print` - a plugin might be missing. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpgD6ee2/src/lib.cairo:19:10 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp7o69VE/src/lib.cairo:19:10 #[derive(Print)] ^***^ error: Unknown derive `Print` - a plugin might be missing. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpgD6ee2/src/lib.cairo:28:10 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp7o69VE/src/lib.cairo:28:10 #[derive(Print)] ^***^ diff --git a/crates/dojo-lang/src/plugin_test_data/system b/crates/dojo-lang/src/plugin_test_data/system index 5d5931c8a9..8ca32eaeda 100644 --- a/crates/dojo-lang/src/plugin_test_data/system +++ b/crates/dojo-lang/src/plugin_test_data/system @@ -356,112 +356,112 @@ mod ctxnamed { //! > expected_diagnostics error: Anything other than functions is not supported in a dojo::interface - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:90:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:90:5 const ONE: u8; ^************^ error: World parameter must be the first parameter. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:111:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:111:5 fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252; ^***********************************************************************************^ error: World parameter must be the first parameter. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:112:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:112:5 fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; ^*********************************************************************************************^ error: You cannot use `self` and `world` parameters together. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:113:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:113:5 fn do_with_self_and_world_inv(world: @IWorldDispatcher, self: @ContractState) -> felt252; ^***************************************************************************************^ error: You cannot use `self` and `world` parameters together. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:114:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:114:5 fn do_with_ref_self_and_world_inv( ^********************************^ error: World parameter must be the first parameter. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:121:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:121:5 fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252; ^****************************************************************************^ error: World parameter must be the first parameter. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:128:9 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:128:9 fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252 { ^************************************************************************************^ error: World parameter must be the first parameter. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:132:9 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:132:9 fn do_with_ref_self_and_world( ^****************************^ error: You cannot use `self` and `world` parameters together. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:138:9 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:138:9 fn do_with_self_and_world_inv(world: @IWorldDispatcher, self: @ContractState) -> felt252 { ^****************************************************************************************^ error: You cannot use `self` and `world` parameters together. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:142:9 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:142:9 fn do_with_ref_self_and_world_inv( ^********************************^ error: World parameter must be the first parameter. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:158:9 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:158:9 fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252 { ^*****************************************************************************^ error: You cannot use `world` and `#[generate_trait]` together. Use `self` instead. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:165:9 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:165:9 fn bad_func_using_generate(world: @IWorldDispatcher) -> felt252 { ^***************************************************************^ error: World parameter must be a snapshot if `ref` is not used. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:224:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:224:5 fn dojo_init( ^***********^ error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:105:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:105:5 fn do_with_self(self: @ContractState) -> felt252; ^**********************************************^ error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:106:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:106:5 fn do_with_ref_self(ref self: ContractState) -> felt252; ^*****************************************************^ error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:111:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:111:5 fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252; ^**********************************************************************************^ error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:112:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:112:5 fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; ^********************************************************************************************^ error: `starknet::interface` functions don't support `ref` parameters other than the first one. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:112:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:112:5 fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; ^********************************************************************************************^ error: `starknet::interface` functions don't support `ref` parameters other than the first one. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:114:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:114:5 fn do_with_ref_self_and_world_inv( ^********************************^ error: `starknet::interface` functions don't support `ref` parameters other than the first one. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:117:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:117:5 fn do_with_several_world_dispatchers( ^***********************************^ error: `starknet::interface` functions don't support `ref` parameters other than the first one. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:121:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:121:5 fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252; ^***************************************************************************^ error: Generated trait must have generic args matching the impl's generic params. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpn6wrlH/src/lib.cairo:163:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:163:5 #[generate_trait] ^***************^ diff --git a/crates/dojo-world/src/contracts/abi/world.rs b/crates/dojo-world/src/contracts/abi/world.rs index 30c4440ae2..a3a75a5ee2 100644 --- a/crates/dojo-world/src/contracts/abi/world.rs +++ b/crates/dojo-world/src/contracts/abi/world.rs @@ -507,7 +507,27 @@ abigen!( "name": "can_write_model", "inputs": [ { - "name": "model_id", + "name": "selector", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "can_write_contract", + "inputs": [ + { + "name": "selector", "type": "core::felt252" }, { @@ -527,7 +547,7 @@ abigen!( "name": "can_write_namespace", "inputs": [ { - "name": "namespace_id", + "name": "selector", "type": "core::felt252" }, { diff --git a/examples/spawn-and-move/Scarb.toml b/examples/spawn-and-move/Scarb.toml index c426e5b96d..2c7ec1784d 100644 --- a/examples/spawn-and-move/Scarb.toml +++ b/examples/spawn-and-move/Scarb.toml @@ -43,7 +43,7 @@ rpc_url = "http://localhost:5050/" # Default account for katana with seed = 0 account_address = "0x6162896d1d7ab204c7ccac6dd5f8e9e7c25ecd5ae4fcb4ad32e57786bb46e03" private_key = "0x1800000000300000180000000000030000000000003006001800006600" -world_address = "0x70049a301d80957caf359bc84171911ae8132cdb43405163754c154e9c37f26" +world_address = "0x221d9c1ca42fe008cd124d38d5987d5bd3751adf43bec52d1fbb41288203cd5" [profile.release.tool.dojo] # for more info on how `merge-strategy` works see: diff --git a/examples/spawn-and-move/manifests/dev/base/abis/dojo-world.json b/examples/spawn-and-move/manifests/dev/base/abis/dojo-world.json index 996795c619..25197b7bbb 100644 --- a/examples/spawn-and-move/manifests/dev/base/abis/dojo-world.json +++ b/examples/spawn-and-move/manifests/dev/base/abis/dojo-world.json @@ -501,7 +501,27 @@ "name": "can_write_model", "inputs": [ { - "name": "model_id", + "name": "selector", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "can_write_contract", + "inputs": [ + { + "name": "selector", "type": "core::felt252" }, { @@ -521,7 +541,7 @@ "name": "can_write_namespace", "inputs": [ { - "name": "namespace_id", + "name": "selector", "type": "core::felt252" }, { diff --git a/examples/spawn-and-move/manifests/dev/base/dojo-world.toml b/examples/spawn-and-move/manifests/dev/base/dojo-world.toml index e54ed9889c..69caa32e86 100644 --- a/examples/spawn-and-move/manifests/dev/base/dojo-world.toml +++ b/examples/spawn-and-move/manifests/dev/base/dojo-world.toml @@ -1,6 +1,6 @@ kind = "Class" -class_hash = "0x25f8aa71a18dff4615cf3bb7231014f58500b69c6d746d8e26d8ddae739cdb8" -original_class_hash = "0x25f8aa71a18dff4615cf3bb7231014f58500b69c6d746d8e26d8ddae739cdb8" +class_hash = "0xa2a68c8a36082692ff56aece7e4e14dfa533b7c565c749ae8045000e1bf381" +original_class_hash = "0xa2a68c8a36082692ff56aece7e4e14dfa533b7c565c749ae8045000e1bf381" abi = "manifests/dev/base/abis/dojo-world.json" tag = "dojo-world" manifest_name = "dojo-world" diff --git a/examples/spawn-and-move/manifests/dev/deployment/abis/dojo-world.json b/examples/spawn-and-move/manifests/dev/deployment/abis/dojo-world.json index 996795c619..25197b7bbb 100644 --- a/examples/spawn-and-move/manifests/dev/deployment/abis/dojo-world.json +++ b/examples/spawn-and-move/manifests/dev/deployment/abis/dojo-world.json @@ -501,7 +501,27 @@ "name": "can_write_model", "inputs": [ { - "name": "model_id", + "name": "selector", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "can_write_contract", + "inputs": [ + { + "name": "selector", "type": "core::felt252" }, { @@ -521,7 +541,7 @@ "name": "can_write_namespace", "inputs": [ { - "name": "namespace_id", + "name": "selector", "type": "core::felt252" }, { diff --git a/examples/spawn-and-move/manifests/dev/deployment/manifest.json b/examples/spawn-and-move/manifests/dev/deployment/manifest.json index 8e1f3e528a..d29ac5c4cb 100644 --- a/examples/spawn-and-move/manifests/dev/deployment/manifest.json +++ b/examples/spawn-and-move/manifests/dev/deployment/manifest.json @@ -1,8 +1,8 @@ { "world": { "kind": "WorldContract", - "class_hash": "0x25f8aa71a18dff4615cf3bb7231014f58500b69c6d746d8e26d8ddae739cdb8", - "original_class_hash": "0x25f8aa71a18dff4615cf3bb7231014f58500b69c6d746d8e26d8ddae739cdb8", + "class_hash": "0xa2a68c8a36082692ff56aece7e4e14dfa533b7c565c749ae8045000e1bf381", + "original_class_hash": "0xa2a68c8a36082692ff56aece7e4e14dfa533b7c565c749ae8045000e1bf381", "abi": [ { "type": "impl", @@ -506,7 +506,27 @@ "name": "can_write_model", "inputs": [ { - "name": "model_id", + "name": "selector", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "can_write_contract", + "inputs": [ + { + "name": "selector", "type": "core::felt252" }, { @@ -526,7 +546,7 @@ "name": "can_write_namespace", "inputs": [ { - "name": "namespace_id", + "name": "selector", "type": "core::felt252" }, { @@ -1124,8 +1144,8 @@ ] } ], - "address": "0x70049a301d80957caf359bc84171911ae8132cdb43405163754c154e9c37f26", - "transaction_hash": "0x63339a79058617ccb845d7cc70e6d40c851fb1f740dfe267e929df10dc71180", + "address": "0x221d9c1ca42fe008cd124d38d5987d5bd3751adf43bec52d1fbb41288203cd5", + "transaction_hash": "0x1de80bae5a65c23715b7ca20ecc775b6bb62a844d8569acf91ff2d3b93f1c9c", "block_number": 3, "seed": "dojo_examples", "metadata": { @@ -1145,7 +1165,7 @@ "contracts": [ { "kind": "DojoContract", - "address": "0x2b924027af667457a3438958f2b9a58adbe10b9dc2aa0eba7638ac59367c822", + "address": "0x64839f1b5e1958354ee257bbd7c07e0403ff6098145a92ddb9b093fc35662c4", "class_hash": "0x2c975b0d681861edd6caad5fbc0b42dc3e8b034b6c0b0a7628fb3a7bedf1e8d", "original_class_hash": "0x2c975b0d681861edd6caad5fbc0b42dc3e8b034b6c0b0a7628fb3a7bedf1e8d", "base_class_hash": "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4", @@ -1552,7 +1572,7 @@ }, { "kind": "DojoContract", - "address": "0x5279a43866827e5d4bb4bb6f358ab5020c1b29e0ea62de65a80a1d3557bd77f", + "address": "0x5c4e7bb5f60d58c22c96aba611cb2f53462dcd59f7ade5d1675be5f8c20226b", "class_hash": "0x14b3096b82a761f63dd47277c2b5ac18925dea43586418483939a2f1f57f674", "original_class_hash": "0x14b3096b82a761f63dd47277c2b5ac18925dea43586418483939a2f1f57f674", "base_class_hash": "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4", @@ -1789,7 +1809,7 @@ }, { "kind": "DojoContract", - "address": "0x306dcf2361031881a2d42185bd522e85bb313baa0603953f7c75010760f792c", + "address": "0x4b1371f328d8d86f6007f4ee8bd7d8a2f1c9f482531266b2df294dc55044d20", "class_hash": "0x97cd4fb3acfe9e6a024589ea34db2fc587586d699ef3732ce627e1771158ef", "original_class_hash": "0x97cd4fb3acfe9e6a024589ea34db2fc587586d699ef3732ce627e1771158ef", "base_class_hash": "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4", @@ -2008,7 +2028,7 @@ }, { "kind": "DojoContract", - "address": "0x6dca4b6ed01bd16984a04ca71e1725ad617323a4089367ff9c020369785b3b", + "address": "0x3ba8ab3546affa46b8094e7822459537c6e348af82fb3f35a32f42f820f3bfe", "class_hash": "0x479bfb12dcba5398d77303e7a665fc3fedb16f2d7f9cb1f5d7e2beb3b7e2ba7", "original_class_hash": "0x479bfb12dcba5398d77303e7a665fc3fedb16f2d7f9cb1f5d7e2beb3b7e2ba7", "base_class_hash": "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4", diff --git a/examples/spawn-and-move/manifests/dev/deployment/manifest.toml b/examples/spawn-and-move/manifests/dev/deployment/manifest.toml index fc48f1f603..83fc9287a8 100644 --- a/examples/spawn-and-move/manifests/dev/deployment/manifest.toml +++ b/examples/spawn-and-move/manifests/dev/deployment/manifest.toml @@ -1,10 +1,10 @@ [world] kind = "WorldContract" -class_hash = "0x25f8aa71a18dff4615cf3bb7231014f58500b69c6d746d8e26d8ddae739cdb8" -original_class_hash = "0x25f8aa71a18dff4615cf3bb7231014f58500b69c6d746d8e26d8ddae739cdb8" +class_hash = "0xa2a68c8a36082692ff56aece7e4e14dfa533b7c565c749ae8045000e1bf381" +original_class_hash = "0xa2a68c8a36082692ff56aece7e4e14dfa533b7c565c749ae8045000e1bf381" abi = "manifests/dev/deployment/abis/dojo-world.json" -address = "0x70049a301d80957caf359bc84171911ae8132cdb43405163754c154e9c37f26" -transaction_hash = "0x63339a79058617ccb845d7cc70e6d40c851fb1f740dfe267e929df10dc71180" +address = "0x221d9c1ca42fe008cd124d38d5987d5bd3751adf43bec52d1fbb41288203cd5" +transaction_hash = "0x1de80bae5a65c23715b7ca20ecc775b6bb62a844d8569acf91ff2d3b93f1c9c" block_number = 3 seed = "dojo_examples" manifest_name = "dojo-world" @@ -23,7 +23,7 @@ manifest_name = "dojo-base" [[contracts]] kind = "DojoContract" -address = "0x2b924027af667457a3438958f2b9a58adbe10b9dc2aa0eba7638ac59367c822" +address = "0x64839f1b5e1958354ee257bbd7c07e0403ff6098145a92ddb9b093fc35662c4" class_hash = "0x2c975b0d681861edd6caad5fbc0b42dc3e8b034b6c0b0a7628fb3a7bedf1e8d" original_class_hash = "0x2c975b0d681861edd6caad5fbc0b42dc3e8b034b6c0b0a7628fb3a7bedf1e8d" base_class_hash = "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4" @@ -40,7 +40,7 @@ manifest_name = "dojo_examples-actions-40b6994c" [[contracts]] kind = "DojoContract" -address = "0x5279a43866827e5d4bb4bb6f358ab5020c1b29e0ea62de65a80a1d3557bd77f" +address = "0x5c4e7bb5f60d58c22c96aba611cb2f53462dcd59f7ade5d1675be5f8c20226b" class_hash = "0x14b3096b82a761f63dd47277c2b5ac18925dea43586418483939a2f1f57f674" original_class_hash = "0x14b3096b82a761f63dd47277c2b5ac18925dea43586418483939a2f1f57f674" base_class_hash = "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4" @@ -54,7 +54,7 @@ manifest_name = "dojo_examples-dungeon-6620e0e6" [[contracts]] kind = "DojoContract" -address = "0x306dcf2361031881a2d42185bd522e85bb313baa0603953f7c75010760f792c" +address = "0x4b1371f328d8d86f6007f4ee8bd7d8a2f1c9f482531266b2df294dc55044d20" class_hash = "0x97cd4fb3acfe9e6a024589ea34db2fc587586d699ef3732ce627e1771158ef" original_class_hash = "0x97cd4fb3acfe9e6a024589ea34db2fc587586d699ef3732ce627e1771158ef" base_class_hash = "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4" @@ -68,7 +68,7 @@ manifest_name = "dojo_examples-mock_token-31599eb2" [[contracts]] kind = "DojoContract" -address = "0x6dca4b6ed01bd16984a04ca71e1725ad617323a4089367ff9c020369785b3b" +address = "0x3ba8ab3546affa46b8094e7822459537c6e348af82fb3f35a32f42f820f3bfe" class_hash = "0x479bfb12dcba5398d77303e7a665fc3fedb16f2d7f9cb1f5d7e2beb3b7e2ba7" original_class_hash = "0x479bfb12dcba5398d77303e7a665fc3fedb16f2d7f9cb1f5d7e2beb3b7e2ba7" base_class_hash = "0x26a4f5d2d9638877a2648297339275df5eaab0adb3cdf0010887c2dbf2be4" diff --git a/examples/spawn-and-move/manifests/release/base/abis/dojo-world.json b/examples/spawn-and-move/manifests/release/base/abis/dojo-world.json index 996795c619..25197b7bbb 100644 --- a/examples/spawn-and-move/manifests/release/base/abis/dojo-world.json +++ b/examples/spawn-and-move/manifests/release/base/abis/dojo-world.json @@ -501,7 +501,27 @@ "name": "can_write_model", "inputs": [ { - "name": "model_id", + "name": "selector", + "type": "core::felt252" + }, + { + "name": "contract", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "can_write_contract", + "inputs": [ + { + "name": "selector", "type": "core::felt252" }, { @@ -521,7 +541,7 @@ "name": "can_write_namespace", "inputs": [ { - "name": "namespace_id", + "name": "selector", "type": "core::felt252" }, { diff --git a/examples/spawn-and-move/manifests/release/base/dojo-world.toml b/examples/spawn-and-move/manifests/release/base/dojo-world.toml index 160ec61c7f..a66555ad64 100644 --- a/examples/spawn-and-move/manifests/release/base/dojo-world.toml +++ b/examples/spawn-and-move/manifests/release/base/dojo-world.toml @@ -1,6 +1,6 @@ kind = "Class" -class_hash = "0x25f8aa71a18dff4615cf3bb7231014f58500b69c6d746d8e26d8ddae739cdb8" -original_class_hash = "0x25f8aa71a18dff4615cf3bb7231014f58500b69c6d746d8e26d8ddae739cdb8" +class_hash = "0xa2a68c8a36082692ff56aece7e4e14dfa533b7c565c749ae8045000e1bf381" +original_class_hash = "0xa2a68c8a36082692ff56aece7e4e14dfa533b7c565c749ae8045000e1bf381" abi = "manifests/release/base/abis/dojo-world.json" tag = "dojo-world" manifest_name = "dojo-world" From 64ef17accf722bdc9fc8873b3fab0d01dcc7111e Mon Sep 17 00:00:00 2001 From: glihm Date: Fri, 12 Jul 2024 21:10:32 -0600 Subject: [PATCH 14/15] fix: fix metadata upload with contract selector instead of address --- .../dojo-lang/src/plugin_test_data/introspect | 16 +- crates/dojo-lang/src/plugin_test_data/model | 22 +- crates/dojo-lang/src/plugin_test_data/print | 8 +- crates/dojo-lang/src/plugin_test_data/system | 44 +- crates/dojo-lang/src/utils.rs | 7 +- crates/sozo/ops/src/migration/migrate.rs | 4 +- .../dojo_examples-something-71cfad55.json | 224 ---------- .../dojo_examples-Flatbow-3632af69.json | 411 ----------------- .../models/dojo_examples-ModelA-689f21bc.json | 407 ----------------- .../dojo_examples-RiverSkale-27fcbc29.json | 415 ------------------ scripts/rebuild_test_artifacts.sh | 10 +- 11 files changed, 52 insertions(+), 1516 deletions(-) delete mode 100644 examples/spawn-and-move/manifests/dev/deployment/abis/contracts/dojo_examples-something-71cfad55.json delete mode 100644 examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-Flatbow-3632af69.json delete mode 100644 examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-ModelA-689f21bc.json delete mode 100644 examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-RiverSkale-27fcbc29.json diff --git a/crates/dojo-lang/src/plugin_test_data/introspect b/crates/dojo-lang/src/plugin_test_data/introspect index 926f6ccc4f..e007296554 100644 --- a/crates/dojo-lang/src/plugin_test_data/introspect +++ b/crates/dojo-lang/src/plugin_test_data/introspect @@ -2901,41 +2901,41 @@ impl EnumNotPackable1Introspect<> of dojo::database::introspect::Introspect expected_diagnostics error: Option cannot be used with tuples. Prefer using a struct. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmplz9vkI/src/lib.cairo:171:6 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpv506xu/src/lib.cairo:171:6 x: Option<(u8, u16)> ^*****************^ error: Option cannot be used with tuples. Prefer using a struct. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmplz9vkI/src/lib.cairo:176:10 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpv506xu/src/lib.cairo:176:10 first: Option<(u8, u16)>, ^*****************^ error: Introspect and IntrospectPacked attributes cannot be used at a same time. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmplz9vkI/src/lib.cairo:180:6 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpv506xu/src/lib.cairo:180:6 enum EnumIncompatibleAttrs {} ^*******************^ error: Introspect and IntrospectPacked attributes cannot be used at a same time. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmplz9vkI/src/lib.cairo:183:8 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpv506xu/src/lib.cairo:183:8 struct StructIncompatibleAttrs {} ^*********************^ error: Introspect and IntrospectPacked attributes cannot be used at a same time. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmplz9vkI/src/lib.cairo:187:8 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpv506xu/src/lib.cairo:187:8 struct StructIncompatibleAttrs2 {} ^**********************^ error: Introspect and IntrospectPacked attributes cannot be used at a same time. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmplz9vkI/src/lib.cairo:191:6 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpv506xu/src/lib.cairo:191:6 enum EnumIncompatibleAttrs2 {} ^********************^ error: Array field cannot be packed. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmplz9vkI/src/lib.cairo:213:6 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpv506xu/src/lib.cairo:213:6 y: Array ^**********^ error: To be packed, all variants must have fixed layout of same size. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmplz9vkI/src/lib.cairo:250:6 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpv506xu/src/lib.cairo:250:6 enum EnumNotPackable1 { ^**************^ diff --git a/crates/dojo-lang/src/plugin_test_data/model b/crates/dojo-lang/src/plugin_test_data/model index a720467dea..bd44ad425c 100644 --- a/crates/dojo-lang/src/plugin_test_data/model +++ b/crates/dojo-lang/src/plugin_test_data/model @@ -17073,56 +17073,56 @@ impl DeriveStorageImodel_with_tuple_no_primitivesSafeDispatcher of starknet::sto //! > expected_diagnostics error: A Dojo model must have zero or one dojo::model attribute. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpqaC28y/src/lib.cairo:1:1 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmprp9jML/src/lib.cairo:1:1 #[dojo::model(version: 0)] ^************************^ error: Too many 'version' attributes for dojo::model - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpqaC28y/src/lib.cairo:9:1 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmprp9jML/src/lib.cairo:9:1 #[dojo::model(version: 0, version: 0)] ^************************************^ error: The argument 'version' of dojo::model must be an integer - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpqaC28y/src/lib.cairo:16:24 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmprp9jML/src/lib.cairo:16:24 #[dojo::model(version: hello)] ^***^ error: Unexpected argument 'version' for dojo::model - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpqaC28y/src/lib.cairo:23:15 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmprp9jML/src/lib.cairo:23:15 #[dojo::model(version)] ^*****^ error: Unexpected argument 'my_arg' for dojo::model - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpqaC28y/src/lib.cairo:30:15 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmprp9jML/src/lib.cairo:30:15 #[dojo::model(my_arg: 1)] ^*******^ error: Unexpected argument 'my_arg' for dojo::model - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpqaC28y/src/lib.cairo:37:15 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmprp9jML/src/lib.cairo:37:15 #[dojo::model(my_arg)] ^****^ error: dojo::model version 2 not supported - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpqaC28y/src/lib.cairo:44:24 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmprp9jML/src/lib.cairo:44:24 #[dojo::model(version: 2)] ^ error: Model must define at least one #[key] attribute - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpqaC28y/src/lib.cairo:87:8 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmprp9jML/src/lib.cairo:87:8 struct Roles { ^***^ error: Model must define at least one member that is not a key - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpqaC28y/src/lib.cairo:92:8 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmprp9jML/src/lib.cairo:92:8 struct OnlyKeyModel { ^**********^ error: Model must define at least one member that is not a key - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpqaC28y/src/lib.cairo:98:8 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmprp9jML/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. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpqaC28y/src/lib.cairo:98:8 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmprp9jML/src/lib.cairo:98:8 struct U256KeyModel { ^**********^ diff --git a/crates/dojo-lang/src/plugin_test_data/print b/crates/dojo-lang/src/plugin_test_data/print index 6f555f8451..771240c8f4 100644 --- a/crates/dojo-lang/src/plugin_test_data/print +++ b/crates/dojo-lang/src/plugin_test_data/print @@ -113,21 +113,21 @@ Enemy::OtherPlayer(v) => { core::debug::PrintTrait::print('OtherPlayer'); core:: //! > expected_diagnostics error: Unknown derive `Print` - a plugin might be missing. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp7o69VE/src/lib.cairo:4:10 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpeCk3PZ/src/lib.cairo:4:10 #[derive(Print)] ^***^ error: Unknown derive `Print` - a plugin might be missing. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp7o69VE/src/lib.cairo:12:10 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpeCk3PZ/src/lib.cairo:12:10 #[derive(Print)] ^***^ error: Unknown derive `Print` - a plugin might be missing. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp7o69VE/src/lib.cairo:19:10 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpeCk3PZ/src/lib.cairo:19:10 #[derive(Print)] ^***^ error: Unknown derive `Print` - a plugin might be missing. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp7o69VE/src/lib.cairo:28:10 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpeCk3PZ/src/lib.cairo:28:10 #[derive(Print)] ^***^ diff --git a/crates/dojo-lang/src/plugin_test_data/system b/crates/dojo-lang/src/plugin_test_data/system index 8ca32eaeda..1e8d0758d3 100644 --- a/crates/dojo-lang/src/plugin_test_data/system +++ b/crates/dojo-lang/src/plugin_test_data/system @@ -356,112 +356,112 @@ mod ctxnamed { //! > expected_diagnostics error: Anything other than functions is not supported in a dojo::interface - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:90:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpIWICKl/src/lib.cairo:90:5 const ONE: u8; ^************^ error: World parameter must be the first parameter. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:111:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpIWICKl/src/lib.cairo:111:5 fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252; ^***********************************************************************************^ error: World parameter must be the first parameter. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:112:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpIWICKl/src/lib.cairo:112:5 fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; ^*********************************************************************************************^ error: You cannot use `self` and `world` parameters together. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:113:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpIWICKl/src/lib.cairo:113:5 fn do_with_self_and_world_inv(world: @IWorldDispatcher, self: @ContractState) -> felt252; ^***************************************************************************************^ error: You cannot use `self` and `world` parameters together. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:114:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpIWICKl/src/lib.cairo:114:5 fn do_with_ref_self_and_world_inv( ^********************************^ error: World parameter must be the first parameter. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:121:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpIWICKl/src/lib.cairo:121:5 fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252; ^****************************************************************************^ error: World parameter must be the first parameter. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:128:9 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpIWICKl/src/lib.cairo:128:9 fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252 { ^************************************************************************************^ error: World parameter must be the first parameter. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:132:9 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpIWICKl/src/lib.cairo:132:9 fn do_with_ref_self_and_world( ^****************************^ error: You cannot use `self` and `world` parameters together. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:138:9 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpIWICKl/src/lib.cairo:138:9 fn do_with_self_and_world_inv(world: @IWorldDispatcher, self: @ContractState) -> felt252 { ^****************************************************************************************^ error: You cannot use `self` and `world` parameters together. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:142:9 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpIWICKl/src/lib.cairo:142:9 fn do_with_ref_self_and_world_inv( ^********************************^ error: World parameter must be the first parameter. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:158:9 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpIWICKl/src/lib.cairo:158:9 fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252 { ^*****************************************************************************^ error: You cannot use `world` and `#[generate_trait]` together. Use `self` instead. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:165:9 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpIWICKl/src/lib.cairo:165:9 fn bad_func_using_generate(world: @IWorldDispatcher) -> felt252 { ^***************************************************************^ error: World parameter must be a snapshot if `ref` is not used. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:224:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpIWICKl/src/lib.cairo:224:5 fn dojo_init( ^***********^ error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:105:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpIWICKl/src/lib.cairo:105:5 fn do_with_self(self: @ContractState) -> felt252; ^**********************************************^ error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:106:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpIWICKl/src/lib.cairo:106:5 fn do_with_ref_self(ref self: ContractState) -> felt252; ^*****************************************************^ error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:111:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpIWICKl/src/lib.cairo:111:5 fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252; ^**********************************************************************************^ error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:112:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpIWICKl/src/lib.cairo:112:5 fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; ^********************************************************************************************^ error: `starknet::interface` functions don't support `ref` parameters other than the first one. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:112:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpIWICKl/src/lib.cairo:112:5 fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; ^********************************************************************************************^ error: `starknet::interface` functions don't support `ref` parameters other than the first one. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:114:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpIWICKl/src/lib.cairo:114:5 fn do_with_ref_self_and_world_inv( ^********************************^ error: `starknet::interface` functions don't support `ref` parameters other than the first one. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:117:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpIWICKl/src/lib.cairo:117:5 fn do_with_several_world_dispatchers( ^***********************************^ error: `starknet::interface` functions don't support `ref` parameters other than the first one. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:121:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpIWICKl/src/lib.cairo:121:5 fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252; ^***************************************************************************^ error: Generated trait must have generic args matching the impl's generic params. - --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmp229p2n/src/lib.cairo:163:5 + --> /var/folders/3j/41jlhmds1yvc3z3m5_sgch6w0000gn/T/.tmpIWICKl/src/lib.cairo:163:5 #[generate_trait] ^***************^ diff --git a/crates/dojo-lang/src/utils.rs b/crates/dojo-lang/src/utils.rs index a48f6e5611..4398c2677f 100644 --- a/crates/dojo-lang/src/utils.rs +++ b/crates/dojo-lang/src/utils.rs @@ -64,9 +64,10 @@ pub fn get_namespace_config(db: &dyn SyntaxGroup) -> Result { } } + // For debugging, adding the configuration.root can help to inspect the + // crate path and it's content. But it must not be used otherwise, as it + // can be a different path due to tmp dirs being used. Err(anyhow::anyhow!( - "Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid. \ - {:?}", - configuration.root + "Namespace configuration expected at tool.dojo.world.namespace, but not found or invalid.", )) } diff --git a/crates/sozo/ops/src/migration/migrate.rs b/crates/sozo/ops/src/migration/migrate.rs index 90e61b5c8c..5cb9bf5b6a 100644 --- a/crates/sozo/ops/src/migration/migrate.rs +++ b/crates/sozo/ops/src/migration/migrate.rs @@ -5,7 +5,7 @@ use cainome::cairo_serde::ByteArray; use camino::Utf8PathBuf; use dojo_world::contracts::abi::world; use dojo_world::contracts::naming::{ - compute_selector_from_tag, get_name_from_tag, get_namespace_from_tag, + self, compute_selector_from_tag, get_name_from_tag, get_namespace_from_tag, }; use dojo_world::contracts::{cairo_utils, WorldContract}; use dojo_world::manifest::{ @@ -359,7 +359,7 @@ where if let Some(m) = dojo_metadata.resources_artifacts.get(&contract.tag) { ipfs.push(upload_on_ipfs_and_create_resource( &ui, - contract.contract_address, + naming::compute_selector_from_tag(&contract.tag), m.clone(), )); } diff --git a/examples/spawn-and-move/manifests/dev/deployment/abis/contracts/dojo_examples-something-71cfad55.json b/examples/spawn-and-move/manifests/dev/deployment/abis/contracts/dojo_examples-something-71cfad55.json deleted file mode 100644 index fc1c520022..0000000000 --- a/examples/spawn-and-move/manifests/dev/deployment/abis/contracts/dojo_examples-something-71cfad55.json +++ /dev/null @@ -1,224 +0,0 @@ -[ - { - "type": "impl", - "name": "ContractImpl", - "interface_name": "dojo::contract::IContract" - }, - { - "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::contract::IContract", - "items": [ - { - "type": "function", - "name": "contract_name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "selector", - "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": "ISomethingImpl", - "interface_name": "dojo_examples::something::ISomething" - }, - { - "type": "interface", - "name": "dojo_examples::something::ISomething", - "items": [ - { - "type": "function", - "name": "something", - "inputs": [], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "IDojoInitImpl", - "interface_name": "dojo_examples::something::something::IDojoInit" - }, - { - "type": "interface", - "name": "dojo_examples::something::something::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::something::something::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/deployment/abis/models/dojo_examples-Flatbow-3632af69.json b/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-Flatbow-3632af69.json deleted file mode 100644 index 50d5861a0a..0000000000 --- a/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-Flatbow-3632af69.json +++ /dev/null @@ -1,411 +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": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "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": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "flatbowImpl", - "interface_name": "armory::Iflatbow" - }, - { - "type": "struct", - "name": "armory::Flatbow", - "members": [ - { - "name": "id", - "type": "core::integer::u32" - }, - { - "name": "atk_speek", - "type": "core::integer::u32" - }, - { - "name": "range", - "type": "core::integer::u32" - } - ] - }, - { - "type": "interface", - "name": "armory::Iflatbow", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "armory::Flatbow" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "armory::flatbow::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-ModelA-689f21bc.json b/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-ModelA-689f21bc.json deleted file mode 100644 index ee60a6f0a8..0000000000 --- a/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-ModelA-689f21bc.json +++ /dev/null @@ -1,407 +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": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "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": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "model_aImpl", - "interface_name": "simple_lib::Imodel_a" - }, - { - "type": "struct", - "name": "simple_lib::ModelA", - "members": [ - { - "name": "player", - "type": "core::starknet::contract_address::ContractAddress" - }, - { - "name": "data", - "type": "core::integer::u32" - } - ] - }, - { - "type": "interface", - "name": "simple_lib::Imodel_a", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "simple_lib::ModelA" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "simple_lib::model_a::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-RiverSkale-27fcbc29.json b/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-RiverSkale-27fcbc29.json deleted file mode 100644 index 4d4a41214e..0000000000 --- a/examples/spawn-and-move/manifests/dev/deployment/abis/models/dojo_examples-RiverSkale-27fcbc29.json +++ /dev/null @@ -1,415 +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": "name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "tag", - "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": "selector", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "name_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "namespace_hash", - "inputs": [], - "outputs": [ - { - "type": "core::felt252" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "unpacked_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "packed_size", - "inputs": [], - "outputs": [ - { - "type": "core::option::Option::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "layout", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Layout" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "schema", - "inputs": [], - "outputs": [ - { - "type": "dojo::database::introspect::Ty" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "river_skaleImpl", - "interface_name": "bestiary::Iriver_skale" - }, - { - "type": "struct", - "name": "bestiary::RiverSkale", - "members": [ - { - "name": "id", - "type": "core::integer::u32" - }, - { - "name": "health", - "type": "core::integer::u32" - }, - { - "name": "armor", - "type": "core::integer::u32" - }, - { - "name": "attack", - "type": "core::integer::u32" - } - ] - }, - { - "type": "interface", - "name": "bestiary::Iriver_skale", - "items": [ - { - "type": "function", - "name": "ensure_abi", - "inputs": [ - { - "name": "model", - "type": "bestiary::RiverSkale" - } - ], - "outputs": [], - "state_mutability": "view" - } - ] - }, - { - "type": "event", - "name": "bestiary::river_skale::Event", - "kind": "enum", - "variants": [] - } -] \ No newline at end of file diff --git a/scripts/rebuild_test_artifacts.sh b/scripts/rebuild_test_artifacts.sh index addbdd1b72..d52c5938ab 100755 --- a/scripts/rebuild_test_artifacts.sh +++ b/scripts/rebuild_test_artifacts.sh @@ -9,15 +9,7 @@ # Cleanup rm -rf examples/spawn-and-move/target -rm -rf examples/spawn-and-move/manifests/dev/abis -rm -rf examples/spawn-and-move/manifests/dev/base -rm -rf examples/spawn-and-move/manifests/dev/manifest.json -rm -rf examples/spawn-and-move/manifests/dev/manifest.toml - -rm -rf examples/spawn-and-move/manifests/release/abis -rm -rf examples/spawn-and-move/manifests/release/base -rm -rf examples/spawn-and-move/manifests/release/manifest.json -rm -rf examples/spawn-and-move/manifests/release/manifest.toml +rm -rf examples/spawn-and-move/manifests/ rm -rf crates/torii/types-test/target rm -rf crates/torii/types-test/manifests From 3bc5cf62f93ff7436c72ab0fe48020c85c01cde3 Mon Sep 17 00:00:00 2001 From: glihm Date: Sun, 14 Jul 2024 21:44:19 -0600 Subject: [PATCH 15/15] fix: fix plugin tests --- .../dojo-lang/src/plugin_test_data/introspect | 8877 +--------------- crates/dojo-lang/src/plugin_test_data/model | 8877 +--------------- crates/dojo-lang/src/plugin_test_data/print | 8882 +---------------- crates/dojo-lang/src/plugin_test_data/system | 8877 +--------------- 4 files changed, 192 insertions(+), 35321 deletions(-) diff --git a/crates/dojo-lang/src/plugin_test_data/introspect b/crates/dojo-lang/src/plugin_test_data/introspect index 01dd50e5fc..9ae98554ab 100644 --- a/crates/dojo-lang/src/plugin_test_data/introspect +++ b/crates/dojo-lang/src/plugin_test_data/introspect @@ -259,8848 +259,57 @@ enum EnumNotPackable1 { } //! > expanded_cairo_code +use serde::Serde; +use debug::PrintTrait; -#[starknet::component] -mod testcomponent1 { -#[event] -#[derive(Drop, starknet::Event)] -pub enum Event {} - - -pub struct Storage { -} - -#[derive(Drop, Copy)] -pub struct ComponentStorageBase { -} -#[derive(Drop, Copy)] -pub struct ComponentStorageBaseMut { -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait> { - type BaseType = ComponentStorageBase; - type BaseMutType = ComponentStorageBaseMut; - fn storage_base(self: @ComponentState) -> ComponentStorageBase { - ComponentStorageBase { - } - } - fn storage_base_mut(ref self: ComponentState) -> ComponentStorageBaseMut { - ComponentStorageBaseMut { - } - } -} -pub struct ComponentState { -} - -impl ComponentStateDrop of Drop> {} - -impl ComponentStateDeref of core::ops::SnapshotDeref> { - type Target = ComponentStorageBase; - fn snapshot_deref(self: @ComponentState) -> ComponentStorageBase { - self.storage_base() - } -} -impl ComponentStateDerefMut of core::ops::DerefMut> { - type Target = ComponentStorageBaseMut; - fn deref_mut(ref self: ComponentState) -> ComponentStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_component_state() -> ComponentState { - ComponentState:: { - } -} - - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; -pub trait HasComponent { - fn get_component(self: @TContractState) -> @ComponentState; - fn get_component_mut(ref self: TContractState) -> ComponentState; - fn get_contract(self: @ComponentState) -> @TContractState; - fn get_contract_mut(ref self: ComponentState) -> TContractState; - fn emit>(ref self: ComponentState, event: S); -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - Option::None - } -} -impl ComponentStorageBaseDrop of core::traits::Drop::; -impl ComponentStorageBaseCopy of core::traits::Copy::; -impl ComponentStorageBaseMutDrop of core::traits::Drop::; -impl ComponentStorageBaseMutCopy of core::traits::Copy::; -} - -#[starknet::component] -mod testcomponent2 { -#[event] -#[derive(Drop, starknet::Event)] -pub enum Event {} - - -pub struct Storage { -} - -#[derive(Drop, Copy)] -pub struct ComponentStorageBase { -} -#[derive(Drop, Copy)] -pub struct ComponentStorageBaseMut { -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait> { - type BaseType = ComponentStorageBase; - type BaseMutType = ComponentStorageBaseMut; - fn storage_base(self: @ComponentState) -> ComponentStorageBase { - ComponentStorageBase { - } - } - fn storage_base_mut(ref self: ComponentState) -> ComponentStorageBaseMut { - ComponentStorageBaseMut { - } - } -} -pub struct ComponentState { -} - -impl ComponentStateDrop of Drop> {} - -impl ComponentStateDeref of core::ops::SnapshotDeref> { - type Target = ComponentStorageBase; - fn snapshot_deref(self: @ComponentState) -> ComponentStorageBase { - self.storage_base() - } -} -impl ComponentStateDerefMut of core::ops::DerefMut> { - type Target = ComponentStorageBaseMut; - fn deref_mut(ref self: ComponentState) -> ComponentStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_component_state() -> ComponentState { - ComponentState:: { - } -} - - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; -pub trait HasComponent { - fn get_component(self: @TContractState) -> @ComponentState; - fn get_component_mut(ref self: TContractState) -> ComponentState; - fn get_contract(self: @ComponentState) -> @TContractState; - fn get_contract_mut(ref self: ComponentState) -> TContractState; - fn emit>(ref self: ComponentState, event: S); -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - Option::None - } -} -impl ComponentStorageBaseDrop of core::traits::Drop::; -impl ComponentStorageBaseCopy of core::traits::Copy::; -impl ComponentStorageBaseMutDrop of core::traits::Drop::; -impl ComponentStorageBaseMutCopy of core::traits::Copy::; -} - - #[starknet::contract] - mod bad_namespace_format { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "bad_namespace_format" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-bad_namespace_format" - } - - fn name_hash(self: @ContractState) -> felt252 { - 2014299465256018364248618312205774234949844604916563661777686628154176783488 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 2931670046498875274448874829231097042977275875153600823491451406128208153107 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - use traits::Into; - use dojo::world::Context; - - fn execute(ctx: Context, name: felt252) { - return (); - } - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - mod spawn { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "spawn" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-spawn" - } - - fn name_hash(self: @ContractState) -> felt252 { - 2776321589048333240377325502911505147617911439383944762363370901236132332849 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 2472087249524108479557800499207886557849609293388925195637428170796835731505 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - use traits::Into; - use dojo::world::Context; - - fn execute(ctx: Context, name: felt252) { - return (); - } - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - mod proxy { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "proxy" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-proxy" - } - - fn name_hash(self: @ContractState) -> felt252 { - 379211399603323842291430789821178524592027629543381998047225121027704003915 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 3522586352349720867166847576673128733430338006217587257445073829693434546448 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - fn execute(value: felt252) -> felt252 { - value - } - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - mod ctxnamed { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "ctxnamed" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-ctxnamed" - } - - fn name_hash(self: @ContractState) -> felt252 { - 1120614286815912604239420768209466007446460277061516527925636408561239543041 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 882574079468045629402181499911470715863025356910172410020020548741739455774 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - use traits::Into; - use dojo::world::Context; - - fn execute(ctx2: Context, name: felt252) { - return (); - } - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - mod withevent { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "withevent" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-withevent" - } - - fn name_hash(self: @ContractState) -> felt252 { - 2196275886623691942883456540767114081898043897719876113518403014973431884540 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 2302995054894169641868030754357260737170491794196617685355614288827933407674 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - TestEvent: TestEvent - } - - #[derive(Drop, starknet::Event)] - struct TestEvent { - address: ContractAddress, - } - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - Event::TestEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("TestEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - if __selector__ == selector!("TestEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::TestEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} -impl EventTestEventIntoEvent of Into { - fn into(self: TestEvent) -> Event { - Event::TestEvent(self) - } -} -impl TestEventDrop of core::traits::Drop::; -impl TestEventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @TestEvent, ref keys: Array, ref data: Array - ) { - core::serde::Serde::serialize(self.address, ref data); - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let address = core::serde::Serde::deserialize( - ref data - )?; - Option::Some(TestEvent {address, }) - } -} -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - mod withcomponent { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "withcomponent" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-withcomponent" - } - - fn name_hash(self: @ContractState) -> felt252 { - 999850881662666048155666650426666132968026605763740651763663703103974774091 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 795804664978713707757807985251114311939501109833092725925763852713460388378 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - #[flat] - testcomponent1_event: testcomponent1::Event, - testcomponent2_event: testcomponent2::Event - } - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, - pub testcomponent1_storage: testcomponent1::Storage, - pub testcomponent2_storage: testcomponent2::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, - pub testcomponent1_storage: starknet::storage::StorageBase, - pub testcomponent2_storage: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, - pub testcomponent1_storage: starknet::storage::StorageBase>, - pub testcomponent2_storage: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - testcomponent1_storage: starknet::storage::StorageBase{ address: selector!("testcomponent1_storage") }, - testcomponent2_storage: starknet::storage::StorageBase{ address: selector!("testcomponent2_storage") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - testcomponent1_storage: starknet::storage::StorageBase{ address: selector!("testcomponent1_storage") }, - testcomponent2_storage: starknet::storage::StorageBase{ address: selector!("testcomponent2_storage") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, - pub testcomponent1_storage: testcomponent1::ComponentState, - pub testcomponent2_storage: testcomponent2::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - testcomponent1_storage: testcomponent1::unsafe_new_component_state::(), - testcomponent2_storage: testcomponent2::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl HasComponentImpl_testcomponent1 of testcomponent1::HasComponent { - fn get_component(self: @ContractState) -> @testcomponent1::ComponentState { - @testcomponent1::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> testcomponent1::ComponentState { - testcomponent1::unsafe_new_component_state::() - } - fn get_contract(self: @testcomponent1::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: testcomponent1::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: testcomponent1::ComponentState, event: S) { - let event: testcomponent1::Event = core::traits::Into::into(event); - let mut contract = testcomponent1::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::testcomponent1_event(event)); - } -} -impl HasComponentImpl_testcomponent2 of testcomponent2::HasComponent { - fn get_component(self: @ContractState) -> @testcomponent2::ComponentState { - @testcomponent2::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> testcomponent2::ComponentState { - testcomponent2::unsafe_new_component_state::() - } - fn get_contract(self: @testcomponent2::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: testcomponent2::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: testcomponent2::ComponentState, event: S) { - let event: testcomponent2::Event = core::traits::Into::into(event); - let mut contract = testcomponent2::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::testcomponent2_event(event)); - } -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - Event::testcomponent1_event(val) => { - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - Event::testcomponent2_event(val) => { - core::array::ArrayTrait::append(ref keys, selector!("testcomponent2_event")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - { - let mut keys = keys; - let mut data = data; - match starknet::Event::deserialize(ref keys, ref data) { - Option::Some(val) => { - return Option::Some(Event::testcomponent1_event(val)); - }, - Option::None => {}, - }; - } - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - if __selector__ == selector!("testcomponent2_event") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::testcomponent2_event(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} -impl Eventtestcomponent1_eventIntoEvent of Into { - fn into(self: testcomponent1::Event) -> Event { - Event::testcomponent1_event(self) - } -} -impl Eventtestcomponent2_eventIntoEvent of Into { - fn into(self: testcomponent2::Event) -> Event { - Event::testcomponent2_event(self) - } -} -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} - - } - - #[starknet::interface] - trait IEmptyTrait {} - - #[starknet::interface] - trait IFaultyTrait { - fn do_with_attrs(self: @TContractState, p1: u8) -> u16; - } - - #[starknet::interface] - trait INominalTrait { - fn do_no_param(self: @TContractState) -> felt252;fn do_no_param_but_world(self: @TContractState) -> felt252;fn do_no_param_but_world_ref(ref self: TContractState) -> felt252;fn do_params_no_world(self: @TContractState, p1: felt252, p2: u8) -> felt252;fn do_params_and_world(self: @TContractState, p2: u8) -> felt252;fn do_params_and_world_ref(ref self: TContractState, p2: u8) -> felt252;fn do_with_self(self: @ContractState) -> felt252;fn do_with_ref_self(ref self: ContractState) -> felt252; - } - - #[starknet::interface] - trait IFaultyTrait { - fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252;fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252;fn do_with_self_and_world_inv(self: @TContractState, self: @ContractState) -> felt252;fn do_with_ref_self_and_world_inv(ref self: TContractState, ref self: ContractState -) -> felt252;fn do_with_several_world_dispatchers(self: @TContractState, vec: Vec2, ref another_world: IWorldDispatcher -) -> felt252;fn do_with_world_not_named_world(self: @TContractState, another_world: @IWorldDispatcher) -> felt252;fn do_with_world_not_first(self: @TContractState, vec: Vec2, ref world: IWorldDispatcher) -> felt252; - } - - #[starknet::contract] - mod MyFaultyContract { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "MyFaultyContract" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-MyFaultyContract" - } - - fn name_hash(self: @ContractState) -> felt252 { - 3439743807865759203015037013733809315384408083697880336790137144257764256358 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 1862046669446530718410691364259438011386499031689246339557998041337203828246 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - #[abi(embed_v0)] - impl TestFaultyImpl of IFaultyTrait {fn do_with_self_and_world(self: @ContractState) -> felt252 { 'land' -}fn do_with_ref_self_and_world( ref self: ContractState) -> felt252 { 'land' -}fn do_with_self_and_world_inv(self: @ContractState, self: @ContractState) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_with_ref_self_and_world_inv(ref self: ContractState, ref self: ContractState -) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_with_several_world_dispatchers(self: @ContractState, vec: Vec2, ref another_world: IWorldDispatcher -) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_with_world_not_named_world(self: @ContractState, another_world: @IWorldDispatcher) -> felt252 { 'land' -}fn do_with_world_not_first(self: @ContractState, vec: Vec2) -> felt252 { 'land' -}} - #[generate_trait] - impl InternalImplBad of InternalUtils {fn bad_func_using_generate(self: @ContractState) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}} - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } - trait InternalUtils{fn bad_func_using_generate(self: @ContractState) -> felt252; -} -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_self_and_world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_self_and_world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_ref_self_and_world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_ref_self_and_world(ref contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_self_and_world_inv(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_self = core::option::OptionTraitImpl::expect( - core::serde::Serde::<@ContractState>::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_self_and_world_inv(@contract_state, __arg_self); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_ref_self_and_world_inv(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let mut __arg_self = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_ref_self_and_world_inv(ref contract_state, ref __arg_self); - let mut arr = ArrayTrait::new(); - // References. - core::serde::Serde::::serialize(@__arg_self, ref arr); - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_several_world_dispatchers(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_vec = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - let mut __arg_another_world = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #2' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_several_world_dispatchers(@contract_state, __arg_vec, ref __arg_another_world); - let mut arr = ArrayTrait::new(); - // References. - core::serde::Serde::::serialize(@__arg_another_world, ref arr); - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_world_not_named_world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_another_world = core::option::OptionTraitImpl::expect( - core::serde::Serde::<@IWorldDispatcher>::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_world_not_named_world(@contract_state, __arg_another_world); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_world_not_first(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_vec = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_world_not_first(@contract_state, __arg_vec); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__TestFaultyImpl__do_with_self_and_world as do_with_self_and_world; - pub use super::__wrapper__TestFaultyImpl__do_with_ref_self_and_world as do_with_ref_self_and_world; - pub use super::__wrapper__TestFaultyImpl__do_with_self_and_world_inv as do_with_self_and_world_inv; - pub use super::__wrapper__TestFaultyImpl__do_with_ref_self_and_world_inv as do_with_ref_self_and_world_inv; - pub use super::__wrapper__TestFaultyImpl__do_with_several_world_dispatchers as do_with_several_world_dispatchers; - pub use super::__wrapper__TestFaultyImpl__do_with_world_not_named_world as do_with_world_not_named_world; - pub use super::__wrapper__TestFaultyImpl__do_with_world_not_first as do_with_world_not_first; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - mod MyNominalContract { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "MyNominalContract" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-MyNominalContract" - } - - fn name_hash(self: @ContractState) -> felt252 { - 1172628497499445169993220559087829230676589931723677494032285307738203070578 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 2020162355936884646880401248118384176803981589166410970216209297939905305278 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - #[derive(Drop)] - struct Action { - damage: u8 - } - - #[abi(embed_v0)] - impl TestNominalImpl of INominalTrait {fn do_no_param(self: @ContractState) -> felt252 { 'land' -}fn do_no_param_but_world(self: @ContractState) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_no_param_but_world_ref(ref self: ContractState) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_params_no_world(self: @ContractState, p1: felt252, p2: u8) -> felt252 { 'land' -}fn do_params_and_world(self: @ContractState, p2: u8) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_params_and_world_ref(ref self: ContractState, p2: u8) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_with_self(self: @ContractState) -> felt252 { 'land' -}fn do_with_ref_self(ref self: ContractState) -> felt252 { 'land' -}} - #[generate_trait] - impl ImplInternalNoContractState of InternalNoContractState { - fn func1(world: IWorldDispatcher) -> felt252 { - let _w = world; - 42 - } - } - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } -impl ActionDrop of core::traits::Drop::; - trait InternalNoContractState { - fn func1(world: IWorldDispatcher) -> felt252; - } -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_no_param(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_no_param(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_no_param_but_world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_no_param_but_world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_no_param_but_world_ref(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_no_param_but_world_ref(ref contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_params_no_world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_p1 = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - let __arg_p2 = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #2' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_params_no_world(@contract_state, __arg_p1, __arg_p2); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_params_and_world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_p2 = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_params_and_world(@contract_state, __arg_p2); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_params_and_world_ref(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_p2 = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_params_and_world_ref(ref contract_state, __arg_p2); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_with_self(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_with_self(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_with_ref_self(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_with_ref_self(ref contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__TestNominalImpl__do_no_param as do_no_param; - pub use super::__wrapper__TestNominalImpl__do_no_param_but_world as do_no_param_but_world; - pub use super::__wrapper__TestNominalImpl__do_no_param_but_world_ref as do_no_param_but_world_ref; - pub use super::__wrapper__TestNominalImpl__do_params_no_world as do_params_no_world; - pub use super::__wrapper__TestNominalImpl__do_params_and_world as do_params_and_world; - pub use super::__wrapper__TestNominalImpl__do_params_and_world_ref as do_params_and_world_ref; - pub use super::__wrapper__TestNominalImpl__do_with_self as do_with_self; - pub use super::__wrapper__TestNominalImpl__do_with_ref_self as do_with_ref_self; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - mod init_test { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "init_test" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-init_test" - } - - fn name_hash(self: @ContractState) -> felt252 { - 1673722391095039242574232979635399085098867563460816803458086922970092209409 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 799876284284394866912776672431802324689156187217902437477103298743064217162 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -) {let world = self.world_dispatcher.read();assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); emit!( - world, - ContractInitialized { - contract_address: actions_address, contract_class: actions_class, value - } - ); -} -} - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@actions_address, ref __calldata__); - core::serde::Serde::::serialize(@actions_class, ref __calldata__); - core::serde::Serde::::serialize(@value, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@actions_address, ref __calldata__); - core::serde::Serde::::serialize(@actions_class, ref __calldata__); - core::serde::Serde::::serialize(@value, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@actions_address, ref __calldata__); - core::serde::Serde::::serialize(@actions_class, ref __calldata__); - core::serde::Serde::::serialize(@value, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@actions_address, ref __calldata__); - core::serde::Serde::::serialize(@actions_class, ref __calldata__); - core::serde::Serde::::serialize(@value, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_actions_address = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - let __arg_actions_class = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #2' - ); - let __arg_value = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #3' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, __arg_actions_address, __arg_actions_class, __arg_value); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - mod no_init_test { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "no_init_test" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-no_init_test" - } - - fn name_hash(self: @ContractState) -> felt252 { - 2188407785440294979090510634648735461326850740369373015349552249835679156474 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 3269287263937103915837903451864388946886384011514094502724942119672327217364 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } -trait IEmptyTraitDispatcherTrait { -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IEmptyTraitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IEmptyTraitDispatcherImpl of IEmptyTraitDispatcherTrait { - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IEmptyTraitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IEmptyTraitLibraryDispatcherImpl of IEmptyTraitDispatcherTrait { - -} - -trait IEmptyTraitSafeDispatcherTrait { -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IEmptyTraitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IEmptyTraitSafeLibraryDispatcherImpl of IEmptyTraitSafeDispatcherTrait { - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IEmptyTraitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IEmptyTraitSafeDispatcherImpl of IEmptyTraitSafeDispatcherTrait { - -} -trait IFaultyTraitDispatcherTrait { - fn do_with_attrs(self: T, p1: u8) -> u16; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IFaultyTraitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IFaultyTraitDispatcherImpl of IFaultyTraitDispatcherTrait { - fn do_with_attrs(self: IFaultyTraitDispatcher, p1: u8) -> u16 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_with_attrs"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IFaultyTraitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IFaultyTraitLibraryDispatcherImpl of IFaultyTraitDispatcherTrait { - fn do_with_attrs(self: IFaultyTraitLibraryDispatcher, p1: u8) -> u16 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_with_attrs"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } - -} - -trait IFaultyTraitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn do_with_attrs(self: T, p1: u8) -> starknet::SyscallResult; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IFaultyTraitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IFaultyTraitSafeLibraryDispatcherImpl of IFaultyTraitSafeDispatcherTrait { - fn do_with_attrs(self: IFaultyTraitSafeLibraryDispatcher, p1: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_with_attrs"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IFaultyTraitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IFaultyTraitSafeDispatcherImpl of IFaultyTraitSafeDispatcherTrait { - fn do_with_attrs(self: IFaultyTraitSafeDispatcher, p1: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_with_attrs"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } - -} -trait INominalTraitDispatcherTrait { - fn do_no_param(self: T) -> felt252; -fn do_no_param_but_world(self: T) -> felt252; -fn do_no_param_but_world_ref(self: T) -> felt252; -fn do_params_no_world(self: T, p1: felt252, p2: u8) -> felt252; -fn do_params_and_world(self: T, p2: u8) -> felt252; -fn do_params_and_world_ref(self: T, p2: u8) -> felt252; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct INominalTraitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl INominalTraitDispatcherImpl of INominalTraitDispatcherTrait { - fn do_no_param(self: INominalTraitDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_no_param"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_no_param_but_world(self: INominalTraitDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_no_param_but_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_no_param_but_world_ref(self: INominalTraitDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_no_param_but_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_params_no_world(self: INominalTraitDispatcher, p1: felt252, p2: u8) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_params_no_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_params_and_world(self: INominalTraitDispatcher, p2: u8) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_params_and_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_params_and_world_ref(self: INominalTraitDispatcher, p2: u8) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_params_and_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct INominalTraitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl INominalTraitLibraryDispatcherImpl of INominalTraitDispatcherTrait { - fn do_no_param(self: INominalTraitLibraryDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_no_param"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_no_param_but_world(self: INominalTraitLibraryDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_no_param_but_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_no_param_but_world_ref(self: INominalTraitLibraryDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_no_param_but_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_params_no_world(self: INominalTraitLibraryDispatcher, p1: felt252, p2: u8) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_params_no_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_params_and_world(self: INominalTraitLibraryDispatcher, p2: u8) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_params_and_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_params_and_world_ref(self: INominalTraitLibraryDispatcher, p2: u8) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_params_and_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } - -} - -trait INominalTraitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn do_no_param(self: T) -> starknet::SyscallResult; - #[unstable(feature: "safe_dispatcher")] -fn do_no_param_but_world(self: T) -> starknet::SyscallResult; - #[unstable(feature: "safe_dispatcher")] -fn do_no_param_but_world_ref(self: T) -> starknet::SyscallResult; - #[unstable(feature: "safe_dispatcher")] -fn do_params_no_world(self: T, p1: felt252, p2: u8) -> starknet::SyscallResult; - #[unstable(feature: "safe_dispatcher")] -fn do_params_and_world(self: T, p2: u8) -> starknet::SyscallResult; - #[unstable(feature: "safe_dispatcher")] -fn do_params_and_world_ref(self: T, p2: u8) -> starknet::SyscallResult; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct INominalTraitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl INominalTraitSafeLibraryDispatcherImpl of INominalTraitSafeDispatcherTrait { - fn do_no_param(self: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_no_param"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_no_param_but_world(self: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_no_param_but_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_no_param_but_world_ref(self: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_no_param_but_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_params_no_world(self: INominalTraitSafeLibraryDispatcher, p1: felt252, p2: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_params_no_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_params_and_world(self: INominalTraitSafeLibraryDispatcher, p2: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_params_and_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_params_and_world_ref(self: INominalTraitSafeLibraryDispatcher, p2: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_params_and_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct INominalTraitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl INominalTraitSafeDispatcherImpl of INominalTraitSafeDispatcherTrait { - fn do_no_param(self: INominalTraitSafeDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_no_param"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_no_param_but_world(self: INominalTraitSafeDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_no_param_but_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_no_param_but_world_ref(self: INominalTraitSafeDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_no_param_but_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_params_no_world(self: INominalTraitSafeDispatcher, p1: felt252, p2: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_params_no_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_params_and_world(self: INominalTraitSafeDispatcher, p2: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_params_and_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_params_and_world_ref(self: INominalTraitSafeDispatcher, p2: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_params_and_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } - -} -trait IFaultyTraitDispatcherTrait { -fn do_with_self_and_world_inv(self: T, self: @ContractState) -> felt252; -fn do_with_world_not_named_world(self: T, another_world: @IWorldDispatcher) -> felt252; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IFaultyTraitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IFaultyTraitDispatcherImpl of IFaultyTraitDispatcherTrait { -fn do_with_self_and_world_inv(self: IFaultyTraitDispatcher, self: @ContractState) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@ContractState>::serialize(@self, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_with_self_and_world_inv"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_with_world_not_named_world(self: IFaultyTraitDispatcher, another_world: @IWorldDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@IWorldDispatcher>::serialize(@another_world, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_with_world_not_named_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IFaultyTraitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IFaultyTraitLibraryDispatcherImpl of IFaultyTraitDispatcherTrait { -fn do_with_self_and_world_inv(self: IFaultyTraitLibraryDispatcher, self: @ContractState) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@ContractState>::serialize(@self, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_with_self_and_world_inv"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_with_world_not_named_world(self: IFaultyTraitLibraryDispatcher, another_world: @IWorldDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@IWorldDispatcher>::serialize(@another_world, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_with_world_not_named_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } - -} - -trait IFaultyTraitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] -fn do_with_self_and_world_inv(self: T, self: @ContractState) -> starknet::SyscallResult; - #[unstable(feature: "safe_dispatcher")] -fn do_with_world_not_named_world(self: T, another_world: @IWorldDispatcher) -> starknet::SyscallResult; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IFaultyTraitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, +#[derive(Print)] +struct Position { + #[key] + id: felt252, + x: felt252, + y: felt252 } -impl IFaultyTraitSafeLibraryDispatcherImpl of IFaultyTraitSafeDispatcherTrait { -fn do_with_self_and_world_inv(self: IFaultyTraitSafeLibraryDispatcher, self: @ContractState) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@ContractState>::serialize(@self, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_with_self_and_world_inv"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_with_world_not_named_world(self: IFaultyTraitSafeLibraryDispatcher, another_world: @IWorldDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@IWorldDispatcher>::serialize(@another_world, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_with_world_not_named_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } - +#[derive(Print)] +struct Roles { + role_ids: Array } +use starknet::ContractAddress; -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IFaultyTraitSafeDispatcher { - pub contract_address: starknet::ContractAddress, +#[derive(Print)] +struct Player { + #[key] + game: felt252, + #[key] + player: ContractAddress, + name: felt252, } -impl IFaultyTraitSafeDispatcherImpl of IFaultyTraitSafeDispatcherTrait { -fn do_with_self_and_world_inv(self: IFaultyTraitSafeDispatcher, self: @ContractState) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@ContractState>::serialize(@self, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_with_self_and_world_inv"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_with_world_not_named_world(self: IFaultyTraitSafeDispatcher, another_world: @IWorldDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@IWorldDispatcher>::serialize(@another_world, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_with_world_not_named_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } - -} -impl IEmptyTraitDispatcherCopy of core::traits::Copy::; -impl IEmptyTraitDispatcherDrop of core::traits::Drop::; -impl IEmptyTraitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IEmptyTraitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IEmptyTraitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIEmptyTraitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IEmptyTraitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IEmptyTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IEmptyTraitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IEmptyTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIEmptyTraitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IEmptyTraitLibraryDispatcherCopy of core::traits::Copy::; -impl IEmptyTraitLibraryDispatcherDrop of core::traits::Drop::; -impl IEmptyTraitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IEmptyTraitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IEmptyTraitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIEmptyTraitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IEmptyTraitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IEmptyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IEmptyTraitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IEmptyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIEmptyTraitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IEmptyTraitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IEmptyTraitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IEmptyTraitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IEmptyTraitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IEmptyTraitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIEmptyTraitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IEmptyTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IEmptyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IEmptyTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IEmptyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIEmptyTraitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IEmptyTraitSafeDispatcherCopy of core::traits::Copy::; -impl IEmptyTraitSafeDispatcherDrop of core::traits::Drop::; -impl IEmptyTraitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IEmptyTraitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IEmptyTraitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIEmptyTraitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IEmptyTraitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IEmptyTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IEmptyTraitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IEmptyTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIEmptyTraitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IFaultyTraitDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIFaultyTraitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IFaultyTraitLibraryDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitLibraryDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIFaultyTraitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IFaultyTraitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIFaultyTraitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IFaultyTraitSafeDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitSafeDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIFaultyTraitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl INominalTraitDispatcherCopy of core::traits::Copy::; -impl INominalTraitDispatcherDrop of core::traits::Drop::; -impl INominalTraitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @INominalTraitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(INominalTraitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreINominalTraitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - INominalTraitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: INominalTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - INominalTraitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: INominalTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageINominalTraitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl INominalTraitLibraryDispatcherCopy of core::traits::Copy::; -impl INominalTraitLibraryDispatcherDrop of core::traits::Drop::; -impl INominalTraitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @INominalTraitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(INominalTraitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreINominalTraitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - INominalTraitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: INominalTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - INominalTraitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: INominalTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageINominalTraitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl INominalTraitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl INominalTraitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl INominalTraitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @INominalTraitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(INominalTraitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } +#[derive(Print)] +enum Enemy { + Unknown, + Bot: felt252, + OtherPlayer: ContractAddress, } -impl StoreINominalTraitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - INominalTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - INominalTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageINominalTraitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl INominalTraitSafeDispatcherCopy of core::traits::Copy::; -impl INominalTraitSafeDispatcherDrop of core::traits::Drop::; -impl INominalTraitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @INominalTraitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(INominalTraitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreINominalTraitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - INominalTraitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: INominalTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - INominalTraitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: INominalTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageINominalTraitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IFaultyTraitDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIFaultyTraitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IFaultyTraitLibraryDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitLibraryDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIFaultyTraitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IFaultyTraitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIFaultyTraitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IFaultyTraitSafeDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitSafeDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIFaultyTraitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} //! > expected_diagnostics -error: Anything other than functions is not supported in a dojo::interface - --> /tmp/plugin_test/src/lib.cairo:90:5 - const ONE: u8; - ^************^ - -error: World parameter must be the first parameter. - --> /tmp/plugin_test/src/lib.cairo:111:5 - fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252; - ^***********************************************************************************^ - -error: World parameter must be the first parameter. - --> /tmp/plugin_test/src/lib.cairo:112:5 - fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; - ^*********************************************************************************************^ - -error: You cannot use `self` and `world` parameters together. - --> /tmp/plugin_test/src/lib.cairo:113:5 - fn do_with_self_and_world_inv(world: @IWorldDispatcher, self: @ContractState) -> felt252; - ^***************************************************************************************^ - -error: You cannot use `self` and `world` parameters together. - --> /tmp/plugin_test/src/lib.cairo:114:5 - fn do_with_ref_self_and_world_inv( - ^********************************^ - -error: World parameter must be the first parameter. - --> /tmp/plugin_test/src/lib.cairo:121:5 - fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252; - ^****************************************************************************^ - -error: World parameter must be the first parameter. - --> /tmp/plugin_test/src/lib.cairo:128:9 - fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252 { - ^************************************************************************************^ - -error: World parameter must be the first parameter. - --> /tmp/plugin_test/src/lib.cairo:132:9 - fn do_with_ref_self_and_world( - ^****************************^ - -error: You cannot use `self` and `world` parameters together. - --> /tmp/plugin_test/src/lib.cairo:138:9 - fn do_with_self_and_world_inv(world: @IWorldDispatcher, self: @ContractState) -> felt252 { - ^****************************************************************************************^ - -error: You cannot use `self` and `world` parameters together. - --> /tmp/plugin_test/src/lib.cairo:142:9 - fn do_with_ref_self_and_world_inv( - ^********************************^ - -error: World parameter must be the first parameter. - --> /tmp/plugin_test/src/lib.cairo:158:9 - fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252 { - ^*****************************************************************************^ - -error: You cannot use `world` and `#[generate_trait]` together. Use `self` instead. - --> /tmp/plugin_test/src/lib.cairo:165:9 - fn bad_func_using_generate(world: @IWorldDispatcher) -> felt252 { - ^***************************************************************^ - -error: World parameter must be a snapshot if `ref` is not used. - --> /tmp/plugin_test/src/lib.cairo:224:5 - fn dojo_init( - ^***********^ - -error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. - --> /tmp/plugin_test/src/lib.cairo:105:5 - fn do_with_self(self: @ContractState) -> felt252; - ^**********************************************^ - -error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. - --> /tmp/plugin_test/src/lib.cairo:106:5 - fn do_with_ref_self(ref self: ContractState) -> felt252; - ^*****************************************************^ - -error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. - --> /tmp/plugin_test/src/lib.cairo:111:5 - fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252; - ^**********************************************************************************^ - -error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. - --> /tmp/plugin_test/src/lib.cairo:112:5 - fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; - ^********************************************************************************************^ - -error: `starknet::interface` functions don't support `ref` parameters other than the first one. - --> /tmp/plugin_test/src/lib.cairo:112:5 - fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; - ^********************************************************************************************^ - -error: `starknet::interface` functions don't support `ref` parameters other than the first one. - --> /tmp/plugin_test/src/lib.cairo:114:5 - fn do_with_ref_self_and_world_inv( - ^********************************^ - -error: `starknet::interface` functions don't support `ref` parameters other than the first one. - --> /tmp/plugin_test/src/lib.cairo:117:5 - fn do_with_several_world_dispatchers( - ^***********************************^ - -error: `starknet::interface` functions don't support `ref` parameters other than the first one. - --> /tmp/plugin_test/src/lib.cairo:121:5 - fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252; - ^***************************************************************************^ - -error: Generated trait must have generic args matching the impl's generic params. - --> /tmp/plugin_test/src/lib.cairo:163:5 - #[generate_trait] - ^***************^ +error: Unknown derive `Print` - a plugin might be missing. + --> /tmp/plugin_test/src/lib.cairo:4:10 +#[derive(Print)] + ^***^ + +error: Unknown derive `Print` - a plugin might be missing. + --> /tmp/plugin_test/src/lib.cairo:12:10 +#[derive(Print)] + ^***^ + +error: Unknown derive `Print` - a plugin might be missing. + --> /tmp/plugin_test/src/lib.cairo:19:10 +#[derive(Print)] + ^***^ + +error: Unknown derive `Print` - a plugin might be missing. + --> /tmp/plugin_test/src/lib.cairo:28:10 +#[derive(Print)] + ^***^ diff --git a/crates/dojo-lang/src/plugin_test_data/model b/crates/dojo-lang/src/plugin_test_data/model index 9a5f042596..5f6de6f1d7 100644 --- a/crates/dojo-lang/src/plugin_test_data/model +++ b/crates/dojo-lang/src/plugin_test_data/model @@ -159,8848 +159,57 @@ struct ModelWithTupleNoPrimitives { } //! > expanded_cairo_code +use serde::Serde; +use debug::PrintTrait; -#[starknet::component] -mod testcomponent1 { -#[event] -#[derive(Drop, starknet::Event)] -pub enum Event {} - - -pub struct Storage { -} - -#[derive(Drop, Copy)] -pub struct ComponentStorageBase { -} -#[derive(Drop, Copy)] -pub struct ComponentStorageBaseMut { -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait> { - type BaseType = ComponentStorageBase; - type BaseMutType = ComponentStorageBaseMut; - fn storage_base(self: @ComponentState) -> ComponentStorageBase { - ComponentStorageBase { - } - } - fn storage_base_mut(ref self: ComponentState) -> ComponentStorageBaseMut { - ComponentStorageBaseMut { - } - } -} -pub struct ComponentState { -} - -impl ComponentStateDrop of Drop> {} - -impl ComponentStateDeref of core::ops::SnapshotDeref> { - type Target = ComponentStorageBase; - fn snapshot_deref(self: @ComponentState) -> ComponentStorageBase { - self.storage_base() - } -} -impl ComponentStateDerefMut of core::ops::DerefMut> { - type Target = ComponentStorageBaseMut; - fn deref_mut(ref self: ComponentState) -> ComponentStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_component_state() -> ComponentState { - ComponentState:: { - } -} - - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; -pub trait HasComponent { - fn get_component(self: @TContractState) -> @ComponentState; - fn get_component_mut(ref self: TContractState) -> ComponentState; - fn get_contract(self: @ComponentState) -> @TContractState; - fn get_contract_mut(ref self: ComponentState) -> TContractState; - fn emit>(ref self: ComponentState, event: S); -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - Option::None - } -} -impl ComponentStorageBaseDrop of core::traits::Drop::; -impl ComponentStorageBaseCopy of core::traits::Copy::; -impl ComponentStorageBaseMutDrop of core::traits::Drop::; -impl ComponentStorageBaseMutCopy of core::traits::Copy::; -} - -#[starknet::component] -mod testcomponent2 { -#[event] -#[derive(Drop, starknet::Event)] -pub enum Event {} - - -pub struct Storage { -} - -#[derive(Drop, Copy)] -pub struct ComponentStorageBase { -} -#[derive(Drop, Copy)] -pub struct ComponentStorageBaseMut { -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait> { - type BaseType = ComponentStorageBase; - type BaseMutType = ComponentStorageBaseMut; - fn storage_base(self: @ComponentState) -> ComponentStorageBase { - ComponentStorageBase { - } - } - fn storage_base_mut(ref self: ComponentState) -> ComponentStorageBaseMut { - ComponentStorageBaseMut { - } - } -} -pub struct ComponentState { -} - -impl ComponentStateDrop of Drop> {} - -impl ComponentStateDeref of core::ops::SnapshotDeref> { - type Target = ComponentStorageBase; - fn snapshot_deref(self: @ComponentState) -> ComponentStorageBase { - self.storage_base() - } -} -impl ComponentStateDerefMut of core::ops::DerefMut> { - type Target = ComponentStorageBaseMut; - fn deref_mut(ref self: ComponentState) -> ComponentStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_component_state() -> ComponentState { - ComponentState:: { - } -} - - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; -pub trait HasComponent { - fn get_component(self: @TContractState) -> @ComponentState; - fn get_component_mut(ref self: TContractState) -> ComponentState; - fn get_contract(self: @ComponentState) -> @TContractState; - fn get_contract_mut(ref self: ComponentState) -> TContractState; - fn emit>(ref self: ComponentState, event: S); -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - Option::None - } -} -impl ComponentStorageBaseDrop of core::traits::Drop::; -impl ComponentStorageBaseCopy of core::traits::Copy::; -impl ComponentStorageBaseMutDrop of core::traits::Drop::; -impl ComponentStorageBaseMutCopy of core::traits::Copy::; -} - - #[starknet::contract] - mod bad_namespace_format { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "bad_namespace_format" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-bad_namespace_format" - } - - fn name_hash(self: @ContractState) -> felt252 { - 2014299465256018364248618312205774234949844604916563661777686628154176783488 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 2931670046498875274448874829231097042977275875153600823491451406128208153107 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - use traits::Into; - use dojo::world::Context; - - fn execute(ctx: Context, name: felt252) { - return (); - } - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - mod spawn { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "spawn" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-spawn" - } - - fn name_hash(self: @ContractState) -> felt252 { - 2776321589048333240377325502911505147617911439383944762363370901236132332849 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 2472087249524108479557800499207886557849609293388925195637428170796835731505 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - use traits::Into; - use dojo::world::Context; - - fn execute(ctx: Context, name: felt252) { - return (); - } - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - mod proxy { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "proxy" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-proxy" - } - - fn name_hash(self: @ContractState) -> felt252 { - 379211399603323842291430789821178524592027629543381998047225121027704003915 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 3522586352349720867166847576673128733430338006217587257445073829693434546448 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - fn execute(value: felt252) -> felt252 { - value - } - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - mod ctxnamed { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "ctxnamed" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-ctxnamed" - } - - fn name_hash(self: @ContractState) -> felt252 { - 1120614286815912604239420768209466007446460277061516527925636408561239543041 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 882574079468045629402181499911470715863025356910172410020020548741739455774 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - use traits::Into; - use dojo::world::Context; - - fn execute(ctx2: Context, name: felt252) { - return (); - } - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - mod withevent { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "withevent" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-withevent" - } - - fn name_hash(self: @ContractState) -> felt252 { - 2196275886623691942883456540767114081898043897719876113518403014973431884540 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 2302995054894169641868030754357260737170491794196617685355614288827933407674 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - TestEvent: TestEvent - } - - #[derive(Drop, starknet::Event)] - struct TestEvent { - address: ContractAddress, - } - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - Event::TestEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("TestEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - if __selector__ == selector!("TestEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::TestEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} -impl EventTestEventIntoEvent of Into { - fn into(self: TestEvent) -> Event { - Event::TestEvent(self) - } -} -impl TestEventDrop of core::traits::Drop::; -impl TestEventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @TestEvent, ref keys: Array, ref data: Array - ) { - core::serde::Serde::serialize(self.address, ref data); - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let address = core::serde::Serde::deserialize( - ref data - )?; - Option::Some(TestEvent {address, }) - } -} -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - mod withcomponent { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "withcomponent" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-withcomponent" - } - - fn name_hash(self: @ContractState) -> felt252 { - 999850881662666048155666650426666132968026605763740651763663703103974774091 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 795804664978713707757807985251114311939501109833092725925763852713460388378 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - #[flat] - testcomponent1_event: testcomponent1::Event, - testcomponent2_event: testcomponent2::Event - } - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, - pub testcomponent1_storage: testcomponent1::Storage, - pub testcomponent2_storage: testcomponent2::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, - pub testcomponent1_storage: starknet::storage::StorageBase, - pub testcomponent2_storage: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, - pub testcomponent1_storage: starknet::storage::StorageBase>, - pub testcomponent2_storage: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - testcomponent1_storage: starknet::storage::StorageBase{ address: selector!("testcomponent1_storage") }, - testcomponent2_storage: starknet::storage::StorageBase{ address: selector!("testcomponent2_storage") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - testcomponent1_storage: starknet::storage::StorageBase{ address: selector!("testcomponent1_storage") }, - testcomponent2_storage: starknet::storage::StorageBase{ address: selector!("testcomponent2_storage") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, - pub testcomponent1_storage: testcomponent1::ComponentState, - pub testcomponent2_storage: testcomponent2::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - testcomponent1_storage: testcomponent1::unsafe_new_component_state::(), - testcomponent2_storage: testcomponent2::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl HasComponentImpl_testcomponent1 of testcomponent1::HasComponent { - fn get_component(self: @ContractState) -> @testcomponent1::ComponentState { - @testcomponent1::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> testcomponent1::ComponentState { - testcomponent1::unsafe_new_component_state::() - } - fn get_contract(self: @testcomponent1::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: testcomponent1::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: testcomponent1::ComponentState, event: S) { - let event: testcomponent1::Event = core::traits::Into::into(event); - let mut contract = testcomponent1::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::testcomponent1_event(event)); - } -} -impl HasComponentImpl_testcomponent2 of testcomponent2::HasComponent { - fn get_component(self: @ContractState) -> @testcomponent2::ComponentState { - @testcomponent2::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> testcomponent2::ComponentState { - testcomponent2::unsafe_new_component_state::() - } - fn get_contract(self: @testcomponent2::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: testcomponent2::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: testcomponent2::ComponentState, event: S) { - let event: testcomponent2::Event = core::traits::Into::into(event); - let mut contract = testcomponent2::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::testcomponent2_event(event)); - } -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - Event::testcomponent1_event(val) => { - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - Event::testcomponent2_event(val) => { - core::array::ArrayTrait::append(ref keys, selector!("testcomponent2_event")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - { - let mut keys = keys; - let mut data = data; - match starknet::Event::deserialize(ref keys, ref data) { - Option::Some(val) => { - return Option::Some(Event::testcomponent1_event(val)); - }, - Option::None => {}, - }; - } - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - if __selector__ == selector!("testcomponent2_event") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::testcomponent2_event(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} -impl Eventtestcomponent1_eventIntoEvent of Into { - fn into(self: testcomponent1::Event) -> Event { - Event::testcomponent1_event(self) - } -} -impl Eventtestcomponent2_eventIntoEvent of Into { - fn into(self: testcomponent2::Event) -> Event { - Event::testcomponent2_event(self) - } -} -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} - - } - - #[starknet::interface] - trait IEmptyTrait {} - - #[starknet::interface] - trait IFaultyTrait { - fn do_with_attrs(self: @TContractState, p1: u8) -> u16; - } - - #[starknet::interface] - trait INominalTrait { - fn do_no_param(self: @TContractState) -> felt252;fn do_no_param_but_world(self: @TContractState) -> felt252;fn do_no_param_but_world_ref(ref self: TContractState) -> felt252;fn do_params_no_world(self: @TContractState, p1: felt252, p2: u8) -> felt252;fn do_params_and_world(self: @TContractState, p2: u8) -> felt252;fn do_params_and_world_ref(ref self: TContractState, p2: u8) -> felt252;fn do_with_self(self: @ContractState) -> felt252;fn do_with_ref_self(ref self: ContractState) -> felt252; - } - - #[starknet::interface] - trait IFaultyTrait { - fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252;fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252;fn do_with_self_and_world_inv(self: @TContractState, self: @ContractState) -> felt252;fn do_with_ref_self_and_world_inv(ref self: TContractState, ref self: ContractState -) -> felt252;fn do_with_several_world_dispatchers(self: @TContractState, vec: Vec2, ref another_world: IWorldDispatcher -) -> felt252;fn do_with_world_not_named_world(self: @TContractState, another_world: @IWorldDispatcher) -> felt252;fn do_with_world_not_first(self: @TContractState, vec: Vec2, ref world: IWorldDispatcher) -> felt252; - } - - #[starknet::contract] - mod MyFaultyContract { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "MyFaultyContract" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-MyFaultyContract" - } - - fn name_hash(self: @ContractState) -> felt252 { - 3439743807865759203015037013733809315384408083697880336790137144257764256358 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 1862046669446530718410691364259438011386499031689246339557998041337203828246 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - #[abi(embed_v0)] - impl TestFaultyImpl of IFaultyTrait {fn do_with_self_and_world(self: @ContractState) -> felt252 { 'land' -}fn do_with_ref_self_and_world( ref self: ContractState) -> felt252 { 'land' -}fn do_with_self_and_world_inv(self: @ContractState, self: @ContractState) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_with_ref_self_and_world_inv(ref self: ContractState, ref self: ContractState -) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_with_several_world_dispatchers(self: @ContractState, vec: Vec2, ref another_world: IWorldDispatcher -) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_with_world_not_named_world(self: @ContractState, another_world: @IWorldDispatcher) -> felt252 { 'land' -}fn do_with_world_not_first(self: @ContractState, vec: Vec2) -> felt252 { 'land' -}} - #[generate_trait] - impl InternalImplBad of InternalUtils {fn bad_func_using_generate(self: @ContractState) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}} - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } - trait InternalUtils{fn bad_func_using_generate(self: @ContractState) -> felt252; -} -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_self_and_world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_self_and_world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_ref_self_and_world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_ref_self_and_world(ref contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_self_and_world_inv(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_self = core::option::OptionTraitImpl::expect( - core::serde::Serde::<@ContractState>::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_self_and_world_inv(@contract_state, __arg_self); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_ref_self_and_world_inv(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let mut __arg_self = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_ref_self_and_world_inv(ref contract_state, ref __arg_self); - let mut arr = ArrayTrait::new(); - // References. - core::serde::Serde::::serialize(@__arg_self, ref arr); - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_several_world_dispatchers(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_vec = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - let mut __arg_another_world = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #2' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_several_world_dispatchers(@contract_state, __arg_vec, ref __arg_another_world); - let mut arr = ArrayTrait::new(); - // References. - core::serde::Serde::::serialize(@__arg_another_world, ref arr); - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_world_not_named_world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_another_world = core::option::OptionTraitImpl::expect( - core::serde::Serde::<@IWorldDispatcher>::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_world_not_named_world(@contract_state, __arg_another_world); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_world_not_first(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_vec = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_world_not_first(@contract_state, __arg_vec); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__TestFaultyImpl__do_with_self_and_world as do_with_self_and_world; - pub use super::__wrapper__TestFaultyImpl__do_with_ref_self_and_world as do_with_ref_self_and_world; - pub use super::__wrapper__TestFaultyImpl__do_with_self_and_world_inv as do_with_self_and_world_inv; - pub use super::__wrapper__TestFaultyImpl__do_with_ref_self_and_world_inv as do_with_ref_self_and_world_inv; - pub use super::__wrapper__TestFaultyImpl__do_with_several_world_dispatchers as do_with_several_world_dispatchers; - pub use super::__wrapper__TestFaultyImpl__do_with_world_not_named_world as do_with_world_not_named_world; - pub use super::__wrapper__TestFaultyImpl__do_with_world_not_first as do_with_world_not_first; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - mod MyNominalContract { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "MyNominalContract" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-MyNominalContract" - } - - fn name_hash(self: @ContractState) -> felt252 { - 1172628497499445169993220559087829230676589931723677494032285307738203070578 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 2020162355936884646880401248118384176803981589166410970216209297939905305278 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - #[derive(Drop)] - struct Action { - damage: u8 - } - - #[abi(embed_v0)] - impl TestNominalImpl of INominalTrait {fn do_no_param(self: @ContractState) -> felt252 { 'land' -}fn do_no_param_but_world(self: @ContractState) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_no_param_but_world_ref(ref self: ContractState) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_params_no_world(self: @ContractState, p1: felt252, p2: u8) -> felt252 { 'land' -}fn do_params_and_world(self: @ContractState, p2: u8) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_params_and_world_ref(ref self: ContractState, p2: u8) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_with_self(self: @ContractState) -> felt252 { 'land' -}fn do_with_ref_self(ref self: ContractState) -> felt252 { 'land' -}} - #[generate_trait] - impl ImplInternalNoContractState of InternalNoContractState { - fn func1(world: IWorldDispatcher) -> felt252 { - let _w = world; - 42 - } - } - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } -impl ActionDrop of core::traits::Drop::; - trait InternalNoContractState { - fn func1(world: IWorldDispatcher) -> felt252; - } -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_no_param(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_no_param(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_no_param_but_world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_no_param_but_world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_no_param_but_world_ref(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_no_param_but_world_ref(ref contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_params_no_world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_p1 = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - let __arg_p2 = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #2' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_params_no_world(@contract_state, __arg_p1, __arg_p2); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_params_and_world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_p2 = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_params_and_world(@contract_state, __arg_p2); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_params_and_world_ref(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_p2 = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_params_and_world_ref(ref contract_state, __arg_p2); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_with_self(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_with_self(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_with_ref_self(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_with_ref_self(ref contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__TestNominalImpl__do_no_param as do_no_param; - pub use super::__wrapper__TestNominalImpl__do_no_param_but_world as do_no_param_but_world; - pub use super::__wrapper__TestNominalImpl__do_no_param_but_world_ref as do_no_param_but_world_ref; - pub use super::__wrapper__TestNominalImpl__do_params_no_world as do_params_no_world; - pub use super::__wrapper__TestNominalImpl__do_params_and_world as do_params_and_world; - pub use super::__wrapper__TestNominalImpl__do_params_and_world_ref as do_params_and_world_ref; - pub use super::__wrapper__TestNominalImpl__do_with_self as do_with_self; - pub use super::__wrapper__TestNominalImpl__do_with_ref_self as do_with_ref_self; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - mod init_test { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "init_test" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-init_test" - } - - fn name_hash(self: @ContractState) -> felt252 { - 1673722391095039242574232979635399085098867563460816803458086922970092209409 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 799876284284394866912776672431802324689156187217902437477103298743064217162 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -) {let world = self.world_dispatcher.read();assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); emit!( - world, - ContractInitialized { - contract_address: actions_address, contract_class: actions_class, value - } - ); -} -} - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@actions_address, ref __calldata__); - core::serde::Serde::::serialize(@actions_class, ref __calldata__); - core::serde::Serde::::serialize(@value, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@actions_address, ref __calldata__); - core::serde::Serde::::serialize(@actions_class, ref __calldata__); - core::serde::Serde::::serialize(@value, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@actions_address, ref __calldata__); - core::serde::Serde::::serialize(@actions_class, ref __calldata__); - core::serde::Serde::::serialize(@value, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@actions_address, ref __calldata__); - core::serde::Serde::::serialize(@actions_class, ref __calldata__); - core::serde::Serde::::serialize(@value, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_actions_address = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - let __arg_actions_class = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #2' - ); - let __arg_value = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #3' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, __arg_actions_address, __arg_actions_class, __arg_value); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - mod no_init_test { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "no_init_test" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-no_init_test" - } - - fn name_hash(self: @ContractState) -> felt252 { - 2188407785440294979090510634648735461326850740369373015349552249835679156474 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 3269287263937103915837903451864388946886384011514094502724942119672327217364 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } -trait IEmptyTraitDispatcherTrait { -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IEmptyTraitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IEmptyTraitDispatcherImpl of IEmptyTraitDispatcherTrait { - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IEmptyTraitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IEmptyTraitLibraryDispatcherImpl of IEmptyTraitDispatcherTrait { - -} - -trait IEmptyTraitSafeDispatcherTrait { -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IEmptyTraitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IEmptyTraitSafeLibraryDispatcherImpl of IEmptyTraitSafeDispatcherTrait { - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IEmptyTraitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IEmptyTraitSafeDispatcherImpl of IEmptyTraitSafeDispatcherTrait { - -} -trait IFaultyTraitDispatcherTrait { - fn do_with_attrs(self: T, p1: u8) -> u16; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IFaultyTraitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IFaultyTraitDispatcherImpl of IFaultyTraitDispatcherTrait { - fn do_with_attrs(self: IFaultyTraitDispatcher, p1: u8) -> u16 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_with_attrs"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IFaultyTraitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IFaultyTraitLibraryDispatcherImpl of IFaultyTraitDispatcherTrait { - fn do_with_attrs(self: IFaultyTraitLibraryDispatcher, p1: u8) -> u16 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_with_attrs"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } - -} - -trait IFaultyTraitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn do_with_attrs(self: T, p1: u8) -> starknet::SyscallResult; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IFaultyTraitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IFaultyTraitSafeLibraryDispatcherImpl of IFaultyTraitSafeDispatcherTrait { - fn do_with_attrs(self: IFaultyTraitSafeLibraryDispatcher, p1: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_with_attrs"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IFaultyTraitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IFaultyTraitSafeDispatcherImpl of IFaultyTraitSafeDispatcherTrait { - fn do_with_attrs(self: IFaultyTraitSafeDispatcher, p1: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_with_attrs"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } - -} -trait INominalTraitDispatcherTrait { - fn do_no_param(self: T) -> felt252; -fn do_no_param_but_world(self: T) -> felt252; -fn do_no_param_but_world_ref(self: T) -> felt252; -fn do_params_no_world(self: T, p1: felt252, p2: u8) -> felt252; -fn do_params_and_world(self: T, p2: u8) -> felt252; -fn do_params_and_world_ref(self: T, p2: u8) -> felt252; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct INominalTraitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl INominalTraitDispatcherImpl of INominalTraitDispatcherTrait { - fn do_no_param(self: INominalTraitDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_no_param"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_no_param_but_world(self: INominalTraitDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_no_param_but_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_no_param_but_world_ref(self: INominalTraitDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_no_param_but_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_params_no_world(self: INominalTraitDispatcher, p1: felt252, p2: u8) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_params_no_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_params_and_world(self: INominalTraitDispatcher, p2: u8) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_params_and_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_params_and_world_ref(self: INominalTraitDispatcher, p2: u8) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_params_and_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct INominalTraitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl INominalTraitLibraryDispatcherImpl of INominalTraitDispatcherTrait { - fn do_no_param(self: INominalTraitLibraryDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_no_param"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_no_param_but_world(self: INominalTraitLibraryDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_no_param_but_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_no_param_but_world_ref(self: INominalTraitLibraryDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_no_param_but_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_params_no_world(self: INominalTraitLibraryDispatcher, p1: felt252, p2: u8) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_params_no_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_params_and_world(self: INominalTraitLibraryDispatcher, p2: u8) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_params_and_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_params_and_world_ref(self: INominalTraitLibraryDispatcher, p2: u8) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_params_and_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } - -} - -trait INominalTraitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn do_no_param(self: T) -> starknet::SyscallResult; - #[unstable(feature: "safe_dispatcher")] -fn do_no_param_but_world(self: T) -> starknet::SyscallResult; - #[unstable(feature: "safe_dispatcher")] -fn do_no_param_but_world_ref(self: T) -> starknet::SyscallResult; - #[unstable(feature: "safe_dispatcher")] -fn do_params_no_world(self: T, p1: felt252, p2: u8) -> starknet::SyscallResult; - #[unstable(feature: "safe_dispatcher")] -fn do_params_and_world(self: T, p2: u8) -> starknet::SyscallResult; - #[unstable(feature: "safe_dispatcher")] -fn do_params_and_world_ref(self: T, p2: u8) -> starknet::SyscallResult; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct INominalTraitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl INominalTraitSafeLibraryDispatcherImpl of INominalTraitSafeDispatcherTrait { - fn do_no_param(self: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_no_param"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_no_param_but_world(self: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_no_param_but_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_no_param_but_world_ref(self: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_no_param_but_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_params_no_world(self: INominalTraitSafeLibraryDispatcher, p1: felt252, p2: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_params_no_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_params_and_world(self: INominalTraitSafeLibraryDispatcher, p2: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_params_and_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_params_and_world_ref(self: INominalTraitSafeLibraryDispatcher, p2: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_params_and_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct INominalTraitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl INominalTraitSafeDispatcherImpl of INominalTraitSafeDispatcherTrait { - fn do_no_param(self: INominalTraitSafeDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_no_param"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_no_param_but_world(self: INominalTraitSafeDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_no_param_but_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_no_param_but_world_ref(self: INominalTraitSafeDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_no_param_but_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_params_no_world(self: INominalTraitSafeDispatcher, p1: felt252, p2: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_params_no_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_params_and_world(self: INominalTraitSafeDispatcher, p2: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_params_and_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_params_and_world_ref(self: INominalTraitSafeDispatcher, p2: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_params_and_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } - -} -trait IFaultyTraitDispatcherTrait { -fn do_with_self_and_world_inv(self: T, self: @ContractState) -> felt252; -fn do_with_world_not_named_world(self: T, another_world: @IWorldDispatcher) -> felt252; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IFaultyTraitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IFaultyTraitDispatcherImpl of IFaultyTraitDispatcherTrait { -fn do_with_self_and_world_inv(self: IFaultyTraitDispatcher, self: @ContractState) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@ContractState>::serialize(@self, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_with_self_and_world_inv"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_with_world_not_named_world(self: IFaultyTraitDispatcher, another_world: @IWorldDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@IWorldDispatcher>::serialize(@another_world, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_with_world_not_named_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IFaultyTraitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IFaultyTraitLibraryDispatcherImpl of IFaultyTraitDispatcherTrait { -fn do_with_self_and_world_inv(self: IFaultyTraitLibraryDispatcher, self: @ContractState) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@ContractState>::serialize(@self, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_with_self_and_world_inv"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_with_world_not_named_world(self: IFaultyTraitLibraryDispatcher, another_world: @IWorldDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@IWorldDispatcher>::serialize(@another_world, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_with_world_not_named_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } - -} - -trait IFaultyTraitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] -fn do_with_self_and_world_inv(self: T, self: @ContractState) -> starknet::SyscallResult; - #[unstable(feature: "safe_dispatcher")] -fn do_with_world_not_named_world(self: T, another_world: @IWorldDispatcher) -> starknet::SyscallResult; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IFaultyTraitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, +#[derive(Print)] +struct Position { + #[key] + id: felt252, + x: felt252, + y: felt252 } -impl IFaultyTraitSafeLibraryDispatcherImpl of IFaultyTraitSafeDispatcherTrait { -fn do_with_self_and_world_inv(self: IFaultyTraitSafeLibraryDispatcher, self: @ContractState) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@ContractState>::serialize(@self, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_with_self_and_world_inv"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_with_world_not_named_world(self: IFaultyTraitSafeLibraryDispatcher, another_world: @IWorldDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@IWorldDispatcher>::serialize(@another_world, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_with_world_not_named_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } - +#[derive(Print)] +struct Roles { + role_ids: Array } +use starknet::ContractAddress; -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IFaultyTraitSafeDispatcher { - pub contract_address: starknet::ContractAddress, +#[derive(Print)] +struct Player { + #[key] + game: felt252, + #[key] + player: ContractAddress, + name: felt252, } -impl IFaultyTraitSafeDispatcherImpl of IFaultyTraitSafeDispatcherTrait { -fn do_with_self_and_world_inv(self: IFaultyTraitSafeDispatcher, self: @ContractState) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@ContractState>::serialize(@self, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_with_self_and_world_inv"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_with_world_not_named_world(self: IFaultyTraitSafeDispatcher, another_world: @IWorldDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@IWorldDispatcher>::serialize(@another_world, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_with_world_not_named_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } - -} -impl IEmptyTraitDispatcherCopy of core::traits::Copy::; -impl IEmptyTraitDispatcherDrop of core::traits::Drop::; -impl IEmptyTraitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IEmptyTraitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IEmptyTraitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIEmptyTraitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IEmptyTraitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IEmptyTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IEmptyTraitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IEmptyTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIEmptyTraitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IEmptyTraitLibraryDispatcherCopy of core::traits::Copy::; -impl IEmptyTraitLibraryDispatcherDrop of core::traits::Drop::; -impl IEmptyTraitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IEmptyTraitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IEmptyTraitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIEmptyTraitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IEmptyTraitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IEmptyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IEmptyTraitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IEmptyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIEmptyTraitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IEmptyTraitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IEmptyTraitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IEmptyTraitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IEmptyTraitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IEmptyTraitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIEmptyTraitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IEmptyTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IEmptyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IEmptyTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IEmptyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIEmptyTraitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IEmptyTraitSafeDispatcherCopy of core::traits::Copy::; -impl IEmptyTraitSafeDispatcherDrop of core::traits::Drop::; -impl IEmptyTraitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IEmptyTraitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IEmptyTraitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIEmptyTraitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IEmptyTraitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IEmptyTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IEmptyTraitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IEmptyTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIEmptyTraitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IFaultyTraitDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIFaultyTraitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IFaultyTraitLibraryDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitLibraryDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIFaultyTraitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IFaultyTraitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIFaultyTraitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IFaultyTraitSafeDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitSafeDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIFaultyTraitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl INominalTraitDispatcherCopy of core::traits::Copy::; -impl INominalTraitDispatcherDrop of core::traits::Drop::; -impl INominalTraitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @INominalTraitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(INominalTraitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreINominalTraitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - INominalTraitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: INominalTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - INominalTraitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: INominalTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageINominalTraitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl INominalTraitLibraryDispatcherCopy of core::traits::Copy::; -impl INominalTraitLibraryDispatcherDrop of core::traits::Drop::; -impl INominalTraitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @INominalTraitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(INominalTraitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreINominalTraitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - INominalTraitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: INominalTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - INominalTraitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: INominalTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageINominalTraitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl INominalTraitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl INominalTraitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl INominalTraitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @INominalTraitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(INominalTraitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } +#[derive(Print)] +enum Enemy { + Unknown, + Bot: felt252, + OtherPlayer: ContractAddress, } -impl StoreINominalTraitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - INominalTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - INominalTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageINominalTraitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl INominalTraitSafeDispatcherCopy of core::traits::Copy::; -impl INominalTraitSafeDispatcherDrop of core::traits::Drop::; -impl INominalTraitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @INominalTraitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(INominalTraitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreINominalTraitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - INominalTraitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: INominalTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - INominalTraitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: INominalTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageINominalTraitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IFaultyTraitDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIFaultyTraitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IFaultyTraitLibraryDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitLibraryDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIFaultyTraitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IFaultyTraitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIFaultyTraitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IFaultyTraitSafeDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitSafeDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIFaultyTraitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} //! > expected_diagnostics -error: Anything other than functions is not supported in a dojo::interface - --> /tmp/plugin_test/src/lib.cairo:90:5 - const ONE: u8; - ^************^ - -error: World parameter must be the first parameter. - --> /tmp/plugin_test/src/lib.cairo:111:5 - fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252; - ^***********************************************************************************^ - -error: World parameter must be the first parameter. - --> /tmp/plugin_test/src/lib.cairo:112:5 - fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; - ^*********************************************************************************************^ - -error: You cannot use `self` and `world` parameters together. - --> /tmp/plugin_test/src/lib.cairo:113:5 - fn do_with_self_and_world_inv(world: @IWorldDispatcher, self: @ContractState) -> felt252; - ^***************************************************************************************^ - -error: You cannot use `self` and `world` parameters together. - --> /tmp/plugin_test/src/lib.cairo:114:5 - fn do_with_ref_self_and_world_inv( - ^********************************^ - -error: World parameter must be the first parameter. - --> /tmp/plugin_test/src/lib.cairo:121:5 - fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252; - ^****************************************************************************^ - -error: World parameter must be the first parameter. - --> /tmp/plugin_test/src/lib.cairo:128:9 - fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252 { - ^************************************************************************************^ - -error: World parameter must be the first parameter. - --> /tmp/plugin_test/src/lib.cairo:132:9 - fn do_with_ref_self_and_world( - ^****************************^ - -error: You cannot use `self` and `world` parameters together. - --> /tmp/plugin_test/src/lib.cairo:138:9 - fn do_with_self_and_world_inv(world: @IWorldDispatcher, self: @ContractState) -> felt252 { - ^****************************************************************************************^ - -error: You cannot use `self` and `world` parameters together. - --> /tmp/plugin_test/src/lib.cairo:142:9 - fn do_with_ref_self_and_world_inv( - ^********************************^ - -error: World parameter must be the first parameter. - --> /tmp/plugin_test/src/lib.cairo:158:9 - fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252 { - ^*****************************************************************************^ - -error: You cannot use `world` and `#[generate_trait]` together. Use `self` instead. - --> /tmp/plugin_test/src/lib.cairo:165:9 - fn bad_func_using_generate(world: @IWorldDispatcher) -> felt252 { - ^***************************************************************^ - -error: World parameter must be a snapshot if `ref` is not used. - --> /tmp/plugin_test/src/lib.cairo:224:5 - fn dojo_init( - ^***********^ - -error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. - --> /tmp/plugin_test/src/lib.cairo:105:5 - fn do_with_self(self: @ContractState) -> felt252; - ^**********************************************^ - -error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. - --> /tmp/plugin_test/src/lib.cairo:106:5 - fn do_with_ref_self(ref self: ContractState) -> felt252; - ^*****************************************************^ - -error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. - --> /tmp/plugin_test/src/lib.cairo:111:5 - fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252; - ^**********************************************************************************^ - -error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. - --> /tmp/plugin_test/src/lib.cairo:112:5 - fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; - ^********************************************************************************************^ - -error: `starknet::interface` functions don't support `ref` parameters other than the first one. - --> /tmp/plugin_test/src/lib.cairo:112:5 - fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; - ^********************************************************************************************^ - -error: `starknet::interface` functions don't support `ref` parameters other than the first one. - --> /tmp/plugin_test/src/lib.cairo:114:5 - fn do_with_ref_self_and_world_inv( - ^********************************^ - -error: `starknet::interface` functions don't support `ref` parameters other than the first one. - --> /tmp/plugin_test/src/lib.cairo:117:5 - fn do_with_several_world_dispatchers( - ^***********************************^ - -error: `starknet::interface` functions don't support `ref` parameters other than the first one. - --> /tmp/plugin_test/src/lib.cairo:121:5 - fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252; - ^***************************************************************************^ - -error: Generated trait must have generic args matching the impl's generic params. - --> /tmp/plugin_test/src/lib.cairo:163:5 - #[generate_trait] - ^***************^ +error: Unknown derive `Print` - a plugin might be missing. + --> /tmp/plugin_test/src/lib.cairo:4:10 +#[derive(Print)] + ^***^ + +error: Unknown derive `Print` - a plugin might be missing. + --> /tmp/plugin_test/src/lib.cairo:12:10 +#[derive(Print)] + ^***^ + +error: Unknown derive `Print` - a plugin might be missing. + --> /tmp/plugin_test/src/lib.cairo:19:10 +#[derive(Print)] + ^***^ + +error: Unknown derive `Print` - a plugin might be missing. + --> /tmp/plugin_test/src/lib.cairo:28:10 +#[derive(Print)] + ^***^ diff --git a/crates/dojo-lang/src/plugin_test_data/print b/crates/dojo-lang/src/plugin_test_data/print index 70740435fb..ea73b15ed5 100644 --- a/crates/dojo-lang/src/plugin_test_data/print +++ b/crates/dojo-lang/src/plugin_test_data/print @@ -42,8848 +42,92 @@ enum Enemy { } //! > expanded_cairo_code +use serde::Serde; +use debug::PrintTrait; -#[starknet::component] -mod testcomponent1 { -#[event] -#[derive(Drop, starknet::Event)] -pub enum Event {} - - -pub struct Storage { -} - -#[derive(Drop, Copy)] -pub struct ComponentStorageBase { -} -#[derive(Drop, Copy)] -pub struct ComponentStorageBaseMut { -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait> { - type BaseType = ComponentStorageBase; - type BaseMutType = ComponentStorageBaseMut; - fn storage_base(self: @ComponentState) -> ComponentStorageBase { - ComponentStorageBase { - } - } - fn storage_base_mut(ref self: ComponentState) -> ComponentStorageBaseMut { - ComponentStorageBaseMut { - } - } -} -pub struct ComponentState { -} - -impl ComponentStateDrop of Drop> {} - -impl ComponentStateDeref of core::ops::SnapshotDeref> { - type Target = ComponentStorageBase; - fn snapshot_deref(self: @ComponentState) -> ComponentStorageBase { - self.storage_base() - } -} -impl ComponentStateDerefMut of core::ops::DerefMut> { - type Target = ComponentStorageBaseMut; - fn deref_mut(ref self: ComponentState) -> ComponentStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_component_state() -> ComponentState { - ComponentState:: { - } -} - - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; -pub trait HasComponent { - fn get_component(self: @TContractState) -> @ComponentState; - fn get_component_mut(ref self: TContractState) -> ComponentState; - fn get_contract(self: @ComponentState) -> @TContractState; - fn get_contract_mut(ref self: ComponentState) -> TContractState; - fn emit>(ref self: ComponentState, event: S); -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - Option::None - } -} -impl ComponentStorageBaseDrop of core::traits::Drop::; -impl ComponentStorageBaseCopy of core::traits::Copy::; -impl ComponentStorageBaseMutDrop of core::traits::Drop::; -impl ComponentStorageBaseMutCopy of core::traits::Copy::; -} - -#[starknet::component] -mod testcomponent2 { -#[event] -#[derive(Drop, starknet::Event)] -pub enum Event {} - - -pub struct Storage { -} - -#[derive(Drop, Copy)] -pub struct ComponentStorageBase { -} -#[derive(Drop, Copy)] -pub struct ComponentStorageBaseMut { -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait> { - type BaseType = ComponentStorageBase; - type BaseMutType = ComponentStorageBaseMut; - fn storage_base(self: @ComponentState) -> ComponentStorageBase { - ComponentStorageBase { - } - } - fn storage_base_mut(ref self: ComponentState) -> ComponentStorageBaseMut { - ComponentStorageBaseMut { - } - } -} -pub struct ComponentState { -} - -impl ComponentStateDrop of Drop> {} - -impl ComponentStateDeref of core::ops::SnapshotDeref> { - type Target = ComponentStorageBase; - fn snapshot_deref(self: @ComponentState) -> ComponentStorageBase { - self.storage_base() - } -} -impl ComponentStateDerefMut of core::ops::DerefMut> { - type Target = ComponentStorageBaseMut; - fn deref_mut(ref self: ComponentState) -> ComponentStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_component_state() -> ComponentState { - ComponentState:: { - } +#[derive(Print)] +struct Position { + #[key] + id: felt252, + x: felt252, + y: felt252 } - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; -pub trait HasComponent { - fn get_component(self: @TContractState) -> @ComponentState; - fn get_component_mut(ref self: TContractState) -> ComponentState; - fn get_contract(self: @ComponentState) -> @TContractState; - fn get_contract_mut(ref self: ComponentState) -> TContractState; - fn emit>(ref self: ComponentState, event: S); -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - Option::None - } -} -impl ComponentStorageBaseDrop of core::traits::Drop::; -impl ComponentStorageBaseCopy of core::traits::Copy::; -impl ComponentStorageBaseMutDrop of core::traits::Drop::; -impl ComponentStorageBaseMutCopy of core::traits::Copy::; +#[derive(Print)] +struct Roles { + role_ids: Array } - #[starknet::contract] - mod bad_namespace_format { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "bad_namespace_format" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-bad_namespace_format" - } - - fn name_hash(self: @ContractState) -> felt252 { - 2014299465256018364248618312205774234949844604916563661777686628154176783488 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 2931670046498875274448874829231097042977275875153600823491451406128208153107 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - use traits::Into; - use dojo::world::Context; - - fn execute(ctx: Context, name: felt252) { - return (); - } - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } +use starknet::ContractAddress; - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); +#[derive(Print)] +struct Player { + #[key] + game: felt252, + #[key] + player: ContractAddress, + name: felt252, } -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, +#[derive(Print)] +enum Enemy { + Unknown, + Bot: felt252, + OtherPlayer: ContractAddress, } - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () +#[cfg(test)] +impl PositionStructPrintImpl of core::debug::PrintTrait { + fn print(self: Position) { + core::debug::PrintTrait::print('id'); core::debug::PrintTrait::print(self.id); +core::debug::PrintTrait::print('x'); core::debug::PrintTrait::print(self.x); +core::debug::PrintTrait::print('y'); core::debug::PrintTrait::print(self.y); } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, } -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () +#[cfg(test)] +impl RolesStructPrintImpl of core::debug::PrintTrait { + fn print(self: Roles) { + core::debug::PrintTrait::print('role_ids'); core::debug::PrintTrait::print(self.role_ids); } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, } -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) +#[cfg(test)] +impl PlayerStructPrintImpl of core::debug::PrintTrait { + fn print(self: Player) { + core::debug::PrintTrait::print('game'); core::debug::PrintTrait::print(self.game); +core::debug::PrintTrait::print('player'); core::debug::PrintTrait::print(self.player); +core::debug::PrintTrait::print('name'); core::debug::PrintTrait::print(self.name); } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, } -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { +#[cfg(test)] +impl EnemyEnumPrintImpl of core::debug::PrintTrait { + fn print(self: Enemy) { match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) + Enemy::Unknown => { core::debug::PrintTrait::print('Unknown'); }, +Enemy::Bot(v) => { core::debug::PrintTrait::print('Bot'); core::debug::PrintTrait::print(v); }, +Enemy::OtherPlayer(v) => { core::debug::PrintTrait::print('OtherPlayer'); core::debug::PrintTrait::print(v); } } } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - mod spawn { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "spawn" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-spawn" - } - - fn name_hash(self: @ContractState) -> felt252 { - 2776321589048333240377325502911505147617911439383944762363370901236132332849 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 2472087249524108479557800499207886557849609293388925195637428170796835731505 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - use traits::Into; - use dojo::world::Context; - - fn execute(ctx: Context, name: felt252) { - return (); - } - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - } -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} +//! > expected_diagnostics +error: Unknown derive `Print` - a plugin might be missing. + --> /tmp/plugin_test/src/lib.cairo:4:10 +#[derive(Print)] + ^***^ -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); +error: Unknown derive `Print` - a plugin might be missing. + --> /tmp/plugin_test/src/lib.cairo:12:10 +#[derive(Print)] + ^***^ - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } +error: Unknown derive `Print` - a plugin might be missing. + --> /tmp/plugin_test/src/lib.cairo:19:10 +#[derive(Print)] + ^***^ -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - mod proxy { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "proxy" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-proxy" - } - - fn name_hash(self: @ContractState) -> felt252 { - 379211399603323842291430789821178524592027629543381998047225121027704003915 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 3522586352349720867166847576673128733430338006217587257445073829693434546448 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - fn execute(value: felt252) -> felt252 { - value - } - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - mod ctxnamed { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "ctxnamed" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-ctxnamed" - } - - fn name_hash(self: @ContractState) -> felt252 { - 1120614286815912604239420768209466007446460277061516527925636408561239543041 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 882574079468045629402181499911470715863025356910172410020020548741739455774 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - use traits::Into; - use dojo::world::Context; - - fn execute(ctx2: Context, name: felt252) { - return (); - } - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - mod withevent { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "withevent" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-withevent" - } - - fn name_hash(self: @ContractState) -> felt252 { - 2196275886623691942883456540767114081898043897719876113518403014973431884540 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 2302995054894169641868030754357260737170491794196617685355614288827933407674 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - TestEvent: TestEvent - } - - #[derive(Drop, starknet::Event)] - struct TestEvent { - address: ContractAddress, - } - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - Event::TestEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("TestEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - if __selector__ == selector!("TestEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::TestEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} -impl EventTestEventIntoEvent of Into { - fn into(self: TestEvent) -> Event { - Event::TestEvent(self) - } -} -impl TestEventDrop of core::traits::Drop::; -impl TestEventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @TestEvent, ref keys: Array, ref data: Array - ) { - core::serde::Serde::serialize(self.address, ref data); - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let address = core::serde::Serde::deserialize( - ref data - )?; - Option::Some(TestEvent {address, }) - } -} -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - mod withcomponent { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "withcomponent" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-withcomponent" - } - - fn name_hash(self: @ContractState) -> felt252 { - 999850881662666048155666650426666132968026605763740651763663703103974774091 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 795804664978713707757807985251114311939501109833092725925763852713460388378 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - #[flat] - testcomponent1_event: testcomponent1::Event, - testcomponent2_event: testcomponent2::Event - } - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, - pub testcomponent1_storage: testcomponent1::Storage, - pub testcomponent2_storage: testcomponent2::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, - pub testcomponent1_storage: starknet::storage::StorageBase, - pub testcomponent2_storage: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, - pub testcomponent1_storage: starknet::storage::StorageBase>, - pub testcomponent2_storage: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - testcomponent1_storage: starknet::storage::StorageBase{ address: selector!("testcomponent1_storage") }, - testcomponent2_storage: starknet::storage::StorageBase{ address: selector!("testcomponent2_storage") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - testcomponent1_storage: starknet::storage::StorageBase{ address: selector!("testcomponent1_storage") }, - testcomponent2_storage: starknet::storage::StorageBase{ address: selector!("testcomponent2_storage") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, - pub testcomponent1_storage: testcomponent1::ComponentState, - pub testcomponent2_storage: testcomponent2::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - testcomponent1_storage: testcomponent1::unsafe_new_component_state::(), - testcomponent2_storage: testcomponent2::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl HasComponentImpl_testcomponent1 of testcomponent1::HasComponent { - fn get_component(self: @ContractState) -> @testcomponent1::ComponentState { - @testcomponent1::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> testcomponent1::ComponentState { - testcomponent1::unsafe_new_component_state::() - } - fn get_contract(self: @testcomponent1::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: testcomponent1::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: testcomponent1::ComponentState, event: S) { - let event: testcomponent1::Event = core::traits::Into::into(event); - let mut contract = testcomponent1::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::testcomponent1_event(event)); - } -} -impl HasComponentImpl_testcomponent2 of testcomponent2::HasComponent { - fn get_component(self: @ContractState) -> @testcomponent2::ComponentState { - @testcomponent2::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> testcomponent2::ComponentState { - testcomponent2::unsafe_new_component_state::() - } - fn get_contract(self: @testcomponent2::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: testcomponent2::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: testcomponent2::ComponentState, event: S) { - let event: testcomponent2::Event = core::traits::Into::into(event); - let mut contract = testcomponent2::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::testcomponent2_event(event)); - } -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - Event::testcomponent1_event(val) => { - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - Event::testcomponent2_event(val) => { - core::array::ArrayTrait::append(ref keys, selector!("testcomponent2_event")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - { - let mut keys = keys; - let mut data = data; - match starknet::Event::deserialize(ref keys, ref data) { - Option::Some(val) => { - return Option::Some(Event::testcomponent1_event(val)); - }, - Option::None => {}, - }; - } - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - if __selector__ == selector!("testcomponent2_event") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::testcomponent2_event(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} -impl Eventtestcomponent1_eventIntoEvent of Into { - fn into(self: testcomponent1::Event) -> Event { - Event::testcomponent1_event(self) - } -} -impl Eventtestcomponent2_eventIntoEvent of Into { - fn into(self: testcomponent2::Event) -> Event { - Event::testcomponent2_event(self) - } -} -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} - - } - - #[starknet::interface] - trait IEmptyTrait {} - - #[starknet::interface] - trait IFaultyTrait { - fn do_with_attrs(self: @TContractState, p1: u8) -> u16; - } - - #[starknet::interface] - trait INominalTrait { - fn do_no_param(self: @TContractState) -> felt252;fn do_no_param_but_world(self: @TContractState) -> felt252;fn do_no_param_but_world_ref(ref self: TContractState) -> felt252;fn do_params_no_world(self: @TContractState, p1: felt252, p2: u8) -> felt252;fn do_params_and_world(self: @TContractState, p2: u8) -> felt252;fn do_params_and_world_ref(ref self: TContractState, p2: u8) -> felt252;fn do_with_self(self: @ContractState) -> felt252;fn do_with_ref_self(ref self: ContractState) -> felt252; - } - - #[starknet::interface] - trait IFaultyTrait { - fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252;fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252;fn do_with_self_and_world_inv(self: @TContractState, self: @ContractState) -> felt252;fn do_with_ref_self_and_world_inv(ref self: TContractState, ref self: ContractState -) -> felt252;fn do_with_several_world_dispatchers(self: @TContractState, vec: Vec2, ref another_world: IWorldDispatcher -) -> felt252;fn do_with_world_not_named_world(self: @TContractState, another_world: @IWorldDispatcher) -> felt252;fn do_with_world_not_first(self: @TContractState, vec: Vec2, ref world: IWorldDispatcher) -> felt252; - } - - #[starknet::contract] - mod MyFaultyContract { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "MyFaultyContract" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-MyFaultyContract" - } - - fn name_hash(self: @ContractState) -> felt252 { - 3439743807865759203015037013733809315384408083697880336790137144257764256358 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 1862046669446530718410691364259438011386499031689246339557998041337203828246 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - #[abi(embed_v0)] - impl TestFaultyImpl of IFaultyTrait {fn do_with_self_and_world(self: @ContractState) -> felt252 { 'land' -}fn do_with_ref_self_and_world( ref self: ContractState) -> felt252 { 'land' -}fn do_with_self_and_world_inv(self: @ContractState, self: @ContractState) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_with_ref_self_and_world_inv(ref self: ContractState, ref self: ContractState -) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_with_several_world_dispatchers(self: @ContractState, vec: Vec2, ref another_world: IWorldDispatcher -) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_with_world_not_named_world(self: @ContractState, another_world: @IWorldDispatcher) -> felt252 { 'land' -}fn do_with_world_not_first(self: @ContractState, vec: Vec2) -> felt252 { 'land' -}} - #[generate_trait] - impl InternalImplBad of InternalUtils {fn bad_func_using_generate(self: @ContractState) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}} - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } - trait InternalUtils{fn bad_func_using_generate(self: @ContractState) -> felt252; -} -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_self_and_world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_self_and_world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_ref_self_and_world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_ref_self_and_world(ref contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_self_and_world_inv(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_self = core::option::OptionTraitImpl::expect( - core::serde::Serde::<@ContractState>::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_self_and_world_inv(@contract_state, __arg_self); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_ref_self_and_world_inv(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let mut __arg_self = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_ref_self_and_world_inv(ref contract_state, ref __arg_self); - let mut arr = ArrayTrait::new(); - // References. - core::serde::Serde::::serialize(@__arg_self, ref arr); - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_several_world_dispatchers(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_vec = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - let mut __arg_another_world = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #2' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_several_world_dispatchers(@contract_state, __arg_vec, ref __arg_another_world); - let mut arr = ArrayTrait::new(); - // References. - core::serde::Serde::::serialize(@__arg_another_world, ref arr); - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_world_not_named_world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_another_world = core::option::OptionTraitImpl::expect( - core::serde::Serde::<@IWorldDispatcher>::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_world_not_named_world(@contract_state, __arg_another_world); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_world_not_first(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_vec = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_world_not_first(@contract_state, __arg_vec); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__TestFaultyImpl__do_with_self_and_world as do_with_self_and_world; - pub use super::__wrapper__TestFaultyImpl__do_with_ref_self_and_world as do_with_ref_self_and_world; - pub use super::__wrapper__TestFaultyImpl__do_with_self_and_world_inv as do_with_self_and_world_inv; - pub use super::__wrapper__TestFaultyImpl__do_with_ref_self_and_world_inv as do_with_ref_self_and_world_inv; - pub use super::__wrapper__TestFaultyImpl__do_with_several_world_dispatchers as do_with_several_world_dispatchers; - pub use super::__wrapper__TestFaultyImpl__do_with_world_not_named_world as do_with_world_not_named_world; - pub use super::__wrapper__TestFaultyImpl__do_with_world_not_first as do_with_world_not_first; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - mod MyNominalContract { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "MyNominalContract" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-MyNominalContract" - } - - fn name_hash(self: @ContractState) -> felt252 { - 1172628497499445169993220559087829230676589931723677494032285307738203070578 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 2020162355936884646880401248118384176803981589166410970216209297939905305278 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - #[derive(Drop)] - struct Action { - damage: u8 - } - - #[abi(embed_v0)] - impl TestNominalImpl of INominalTrait {fn do_no_param(self: @ContractState) -> felt252 { 'land' -}fn do_no_param_but_world(self: @ContractState) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_no_param_but_world_ref(ref self: ContractState) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_params_no_world(self: @ContractState, p1: felt252, p2: u8) -> felt252 { 'land' -}fn do_params_and_world(self: @ContractState, p2: u8) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_params_and_world_ref(ref self: ContractState, p2: u8) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_with_self(self: @ContractState) -> felt252 { 'land' -}fn do_with_ref_self(ref self: ContractState) -> felt252 { 'land' -}} - #[generate_trait] - impl ImplInternalNoContractState of InternalNoContractState { - fn func1(world: IWorldDispatcher) -> felt252 { - let _w = world; - 42 - } - } - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } -impl ActionDrop of core::traits::Drop::; - trait InternalNoContractState { - fn func1(world: IWorldDispatcher) -> felt252; - } -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_no_param(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_no_param(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_no_param_but_world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_no_param_but_world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_no_param_but_world_ref(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_no_param_but_world_ref(ref contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_params_no_world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_p1 = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - let __arg_p2 = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #2' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_params_no_world(@contract_state, __arg_p1, __arg_p2); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_params_and_world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_p2 = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_params_and_world(@contract_state, __arg_p2); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_params_and_world_ref(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_p2 = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_params_and_world_ref(ref contract_state, __arg_p2); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_with_self(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_with_self(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_with_ref_self(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_with_ref_self(ref contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__TestNominalImpl__do_no_param as do_no_param; - pub use super::__wrapper__TestNominalImpl__do_no_param_but_world as do_no_param_but_world; - pub use super::__wrapper__TestNominalImpl__do_no_param_but_world_ref as do_no_param_but_world_ref; - pub use super::__wrapper__TestNominalImpl__do_params_no_world as do_params_no_world; - pub use super::__wrapper__TestNominalImpl__do_params_and_world as do_params_and_world; - pub use super::__wrapper__TestNominalImpl__do_params_and_world_ref as do_params_and_world_ref; - pub use super::__wrapper__TestNominalImpl__do_with_self as do_with_self; - pub use super::__wrapper__TestNominalImpl__do_with_ref_self as do_with_ref_self; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - mod init_test { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "init_test" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-init_test" - } - - fn name_hash(self: @ContractState) -> felt252 { - 1673722391095039242574232979635399085098867563460816803458086922970092209409 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 799876284284394866912776672431802324689156187217902437477103298743064217162 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -) {let world = self.world_dispatcher.read();assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); emit!( - world, - ContractInitialized { - contract_address: actions_address, contract_class: actions_class, value - } - ); -} -} - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@actions_address, ref __calldata__); - core::serde::Serde::::serialize(@actions_class, ref __calldata__); - core::serde::Serde::::serialize(@value, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@actions_address, ref __calldata__); - core::serde::Serde::::serialize(@actions_class, ref __calldata__); - core::serde::Serde::::serialize(@value, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@actions_address, ref __calldata__); - core::serde::Serde::::serialize(@actions_class, ref __calldata__); - core::serde::Serde::::serialize(@value, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@actions_address, ref __calldata__); - core::serde::Serde::::serialize(@actions_class, ref __calldata__); - core::serde::Serde::::serialize(@value, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_actions_address = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - let __arg_actions_class = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #2' - ); - let __arg_value = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #3' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, __arg_actions_address, __arg_actions_class, __arg_value); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - mod no_init_test { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "no_init_test" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-no_init_test" - } - - fn name_hash(self: @ContractState) -> felt252 { - 2188407785440294979090510634648735461326850740369373015349552249835679156474 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 3269287263937103915837903451864388946886384011514094502724942119672327217364 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } -trait IEmptyTraitDispatcherTrait { -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IEmptyTraitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IEmptyTraitDispatcherImpl of IEmptyTraitDispatcherTrait { - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IEmptyTraitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IEmptyTraitLibraryDispatcherImpl of IEmptyTraitDispatcherTrait { - -} - -trait IEmptyTraitSafeDispatcherTrait { -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IEmptyTraitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IEmptyTraitSafeLibraryDispatcherImpl of IEmptyTraitSafeDispatcherTrait { - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IEmptyTraitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IEmptyTraitSafeDispatcherImpl of IEmptyTraitSafeDispatcherTrait { - -} -trait IFaultyTraitDispatcherTrait { - fn do_with_attrs(self: T, p1: u8) -> u16; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IFaultyTraitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IFaultyTraitDispatcherImpl of IFaultyTraitDispatcherTrait { - fn do_with_attrs(self: IFaultyTraitDispatcher, p1: u8) -> u16 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_with_attrs"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IFaultyTraitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IFaultyTraitLibraryDispatcherImpl of IFaultyTraitDispatcherTrait { - fn do_with_attrs(self: IFaultyTraitLibraryDispatcher, p1: u8) -> u16 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_with_attrs"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } - -} - -trait IFaultyTraitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn do_with_attrs(self: T, p1: u8) -> starknet::SyscallResult; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IFaultyTraitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IFaultyTraitSafeLibraryDispatcherImpl of IFaultyTraitSafeDispatcherTrait { - fn do_with_attrs(self: IFaultyTraitSafeLibraryDispatcher, p1: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_with_attrs"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IFaultyTraitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IFaultyTraitSafeDispatcherImpl of IFaultyTraitSafeDispatcherTrait { - fn do_with_attrs(self: IFaultyTraitSafeDispatcher, p1: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_with_attrs"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } - -} -trait INominalTraitDispatcherTrait { - fn do_no_param(self: T) -> felt252; -fn do_no_param_but_world(self: T) -> felt252; -fn do_no_param_but_world_ref(self: T) -> felt252; -fn do_params_no_world(self: T, p1: felt252, p2: u8) -> felt252; -fn do_params_and_world(self: T, p2: u8) -> felt252; -fn do_params_and_world_ref(self: T, p2: u8) -> felt252; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct INominalTraitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl INominalTraitDispatcherImpl of INominalTraitDispatcherTrait { - fn do_no_param(self: INominalTraitDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_no_param"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_no_param_but_world(self: INominalTraitDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_no_param_but_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_no_param_but_world_ref(self: INominalTraitDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_no_param_but_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_params_no_world(self: INominalTraitDispatcher, p1: felt252, p2: u8) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_params_no_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_params_and_world(self: INominalTraitDispatcher, p2: u8) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_params_and_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_params_and_world_ref(self: INominalTraitDispatcher, p2: u8) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_params_and_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct INominalTraitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl INominalTraitLibraryDispatcherImpl of INominalTraitDispatcherTrait { - fn do_no_param(self: INominalTraitLibraryDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_no_param"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_no_param_but_world(self: INominalTraitLibraryDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_no_param_but_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_no_param_but_world_ref(self: INominalTraitLibraryDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_no_param_but_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_params_no_world(self: INominalTraitLibraryDispatcher, p1: felt252, p2: u8) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_params_no_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_params_and_world(self: INominalTraitLibraryDispatcher, p2: u8) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_params_and_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_params_and_world_ref(self: INominalTraitLibraryDispatcher, p2: u8) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_params_and_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } - -} - -trait INominalTraitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn do_no_param(self: T) -> starknet::SyscallResult; - #[unstable(feature: "safe_dispatcher")] -fn do_no_param_but_world(self: T) -> starknet::SyscallResult; - #[unstable(feature: "safe_dispatcher")] -fn do_no_param_but_world_ref(self: T) -> starknet::SyscallResult; - #[unstable(feature: "safe_dispatcher")] -fn do_params_no_world(self: T, p1: felt252, p2: u8) -> starknet::SyscallResult; - #[unstable(feature: "safe_dispatcher")] -fn do_params_and_world(self: T, p2: u8) -> starknet::SyscallResult; - #[unstable(feature: "safe_dispatcher")] -fn do_params_and_world_ref(self: T, p2: u8) -> starknet::SyscallResult; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct INominalTraitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl INominalTraitSafeLibraryDispatcherImpl of INominalTraitSafeDispatcherTrait { - fn do_no_param(self: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_no_param"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_no_param_but_world(self: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_no_param_but_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_no_param_but_world_ref(self: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_no_param_but_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_params_no_world(self: INominalTraitSafeLibraryDispatcher, p1: felt252, p2: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_params_no_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_params_and_world(self: INominalTraitSafeLibraryDispatcher, p2: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_params_and_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_params_and_world_ref(self: INominalTraitSafeLibraryDispatcher, p2: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_params_and_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct INominalTraitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl INominalTraitSafeDispatcherImpl of INominalTraitSafeDispatcherTrait { - fn do_no_param(self: INominalTraitSafeDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_no_param"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_no_param_but_world(self: INominalTraitSafeDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_no_param_but_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_no_param_but_world_ref(self: INominalTraitSafeDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_no_param_but_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_params_no_world(self: INominalTraitSafeDispatcher, p1: felt252, p2: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_params_no_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_params_and_world(self: INominalTraitSafeDispatcher, p2: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_params_and_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_params_and_world_ref(self: INominalTraitSafeDispatcher, p2: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_params_and_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } - -} -trait IFaultyTraitDispatcherTrait { -fn do_with_self_and_world_inv(self: T, self: @ContractState) -> felt252; -fn do_with_world_not_named_world(self: T, another_world: @IWorldDispatcher) -> felt252; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IFaultyTraitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IFaultyTraitDispatcherImpl of IFaultyTraitDispatcherTrait { -fn do_with_self_and_world_inv(self: IFaultyTraitDispatcher, self: @ContractState) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@ContractState>::serialize(@self, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_with_self_and_world_inv"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_with_world_not_named_world(self: IFaultyTraitDispatcher, another_world: @IWorldDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@IWorldDispatcher>::serialize(@another_world, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_with_world_not_named_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IFaultyTraitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IFaultyTraitLibraryDispatcherImpl of IFaultyTraitDispatcherTrait { -fn do_with_self_and_world_inv(self: IFaultyTraitLibraryDispatcher, self: @ContractState) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@ContractState>::serialize(@self, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_with_self_and_world_inv"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_with_world_not_named_world(self: IFaultyTraitLibraryDispatcher, another_world: @IWorldDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@IWorldDispatcher>::serialize(@another_world, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_with_world_not_named_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } - -} - -trait IFaultyTraitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] -fn do_with_self_and_world_inv(self: T, self: @ContractState) -> starknet::SyscallResult; - #[unstable(feature: "safe_dispatcher")] -fn do_with_world_not_named_world(self: T, another_world: @IWorldDispatcher) -> starknet::SyscallResult; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IFaultyTraitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IFaultyTraitSafeLibraryDispatcherImpl of IFaultyTraitSafeDispatcherTrait { -fn do_with_self_and_world_inv(self: IFaultyTraitSafeLibraryDispatcher, self: @ContractState) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@ContractState>::serialize(@self, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_with_self_and_world_inv"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_with_world_not_named_world(self: IFaultyTraitSafeLibraryDispatcher, another_world: @IWorldDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@IWorldDispatcher>::serialize(@another_world, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_with_world_not_named_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IFaultyTraitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IFaultyTraitSafeDispatcherImpl of IFaultyTraitSafeDispatcherTrait { -fn do_with_self_and_world_inv(self: IFaultyTraitSafeDispatcher, self: @ContractState) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@ContractState>::serialize(@self, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_with_self_and_world_inv"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_with_world_not_named_world(self: IFaultyTraitSafeDispatcher, another_world: @IWorldDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@IWorldDispatcher>::serialize(@another_world, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_with_world_not_named_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } - -} -impl IEmptyTraitDispatcherCopy of core::traits::Copy::; -impl IEmptyTraitDispatcherDrop of core::traits::Drop::; -impl IEmptyTraitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IEmptyTraitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IEmptyTraitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIEmptyTraitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IEmptyTraitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IEmptyTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IEmptyTraitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IEmptyTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIEmptyTraitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IEmptyTraitLibraryDispatcherCopy of core::traits::Copy::; -impl IEmptyTraitLibraryDispatcherDrop of core::traits::Drop::; -impl IEmptyTraitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IEmptyTraitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IEmptyTraitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIEmptyTraitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IEmptyTraitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IEmptyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IEmptyTraitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IEmptyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIEmptyTraitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IEmptyTraitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IEmptyTraitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IEmptyTraitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IEmptyTraitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IEmptyTraitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIEmptyTraitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IEmptyTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IEmptyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IEmptyTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IEmptyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIEmptyTraitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IEmptyTraitSafeDispatcherCopy of core::traits::Copy::; -impl IEmptyTraitSafeDispatcherDrop of core::traits::Drop::; -impl IEmptyTraitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IEmptyTraitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IEmptyTraitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIEmptyTraitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IEmptyTraitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IEmptyTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IEmptyTraitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IEmptyTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIEmptyTraitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IFaultyTraitDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIFaultyTraitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IFaultyTraitLibraryDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitLibraryDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIFaultyTraitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IFaultyTraitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIFaultyTraitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IFaultyTraitSafeDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitSafeDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIFaultyTraitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl INominalTraitDispatcherCopy of core::traits::Copy::; -impl INominalTraitDispatcherDrop of core::traits::Drop::; -impl INominalTraitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @INominalTraitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(INominalTraitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreINominalTraitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - INominalTraitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: INominalTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - INominalTraitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: INominalTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageINominalTraitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl INominalTraitLibraryDispatcherCopy of core::traits::Copy::; -impl INominalTraitLibraryDispatcherDrop of core::traits::Drop::; -impl INominalTraitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @INominalTraitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(INominalTraitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreINominalTraitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - INominalTraitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: INominalTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - INominalTraitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: INominalTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageINominalTraitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl INominalTraitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl INominalTraitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl INominalTraitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @INominalTraitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(INominalTraitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreINominalTraitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - INominalTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - INominalTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageINominalTraitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl INominalTraitSafeDispatcherCopy of core::traits::Copy::; -impl INominalTraitSafeDispatcherDrop of core::traits::Drop::; -impl INominalTraitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @INominalTraitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(INominalTraitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreINominalTraitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - INominalTraitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: INominalTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - INominalTraitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: INominalTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageINominalTraitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IFaultyTraitDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIFaultyTraitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IFaultyTraitLibraryDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitLibraryDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIFaultyTraitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IFaultyTraitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIFaultyTraitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IFaultyTraitSafeDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitSafeDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIFaultyTraitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} - -//! > expected_diagnostics -error: Anything other than functions is not supported in a dojo::interface - --> /tmp/plugin_test/src/lib.cairo:90:5 - const ONE: u8; - ^************^ - -error: World parameter must be the first parameter. - --> /tmp/plugin_test/src/lib.cairo:111:5 - fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252; - ^***********************************************************************************^ - -error: World parameter must be the first parameter. - --> /tmp/plugin_test/src/lib.cairo:112:5 - fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; - ^*********************************************************************************************^ - -error: You cannot use `self` and `world` parameters together. - --> /tmp/plugin_test/src/lib.cairo:113:5 - fn do_with_self_and_world_inv(world: @IWorldDispatcher, self: @ContractState) -> felt252; - ^***************************************************************************************^ - -error: You cannot use `self` and `world` parameters together. - --> /tmp/plugin_test/src/lib.cairo:114:5 - fn do_with_ref_self_and_world_inv( - ^********************************^ - -error: World parameter must be the first parameter. - --> /tmp/plugin_test/src/lib.cairo:121:5 - fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252; - ^****************************************************************************^ - -error: World parameter must be the first parameter. - --> /tmp/plugin_test/src/lib.cairo:128:9 - fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252 { - ^************************************************************************************^ - -error: World parameter must be the first parameter. - --> /tmp/plugin_test/src/lib.cairo:132:9 - fn do_with_ref_self_and_world( - ^****************************^ - -error: You cannot use `self` and `world` parameters together. - --> /tmp/plugin_test/src/lib.cairo:138:9 - fn do_with_self_and_world_inv(world: @IWorldDispatcher, self: @ContractState) -> felt252 { - ^****************************************************************************************^ - -error: You cannot use `self` and `world` parameters together. - --> /tmp/plugin_test/src/lib.cairo:142:9 - fn do_with_ref_self_and_world_inv( - ^********************************^ - -error: World parameter must be the first parameter. - --> /tmp/plugin_test/src/lib.cairo:158:9 - fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252 { - ^*****************************************************************************^ - -error: You cannot use `world` and `#[generate_trait]` together. Use `self` instead. - --> /tmp/plugin_test/src/lib.cairo:165:9 - fn bad_func_using_generate(world: @IWorldDispatcher) -> felt252 { - ^***************************************************************^ - -error: World parameter must be a snapshot if `ref` is not used. - --> /tmp/plugin_test/src/lib.cairo:224:5 - fn dojo_init( - ^***********^ - -error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. - --> /tmp/plugin_test/src/lib.cairo:105:5 - fn do_with_self(self: @ContractState) -> felt252; - ^**********************************************^ - -error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. - --> /tmp/plugin_test/src/lib.cairo:106:5 - fn do_with_ref_self(ref self: ContractState) -> felt252; - ^*****************************************************^ - -error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. - --> /tmp/plugin_test/src/lib.cairo:111:5 - fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252; - ^**********************************************************************************^ - -error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. - --> /tmp/plugin_test/src/lib.cairo:112:5 - fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; - ^********************************************************************************************^ - -error: `starknet::interface` functions don't support `ref` parameters other than the first one. - --> /tmp/plugin_test/src/lib.cairo:112:5 - fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; - ^********************************************************************************************^ - -error: `starknet::interface` functions don't support `ref` parameters other than the first one. - --> /tmp/plugin_test/src/lib.cairo:114:5 - fn do_with_ref_self_and_world_inv( - ^********************************^ - -error: `starknet::interface` functions don't support `ref` parameters other than the first one. - --> /tmp/plugin_test/src/lib.cairo:117:5 - fn do_with_several_world_dispatchers( - ^***********************************^ - -error: `starknet::interface` functions don't support `ref` parameters other than the first one. - --> /tmp/plugin_test/src/lib.cairo:121:5 - fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252; - ^***************************************************************************^ - -error: Generated trait must have generic args matching the impl's generic params. - --> /tmp/plugin_test/src/lib.cairo:163:5 - #[generate_trait] - ^***************^ +error: Unknown derive `Print` - a plugin might be missing. + --> /tmp/plugin_test/src/lib.cairo:28:10 +#[derive(Print)] + ^***^ diff --git a/crates/dojo-lang/src/plugin_test_data/system b/crates/dojo-lang/src/plugin_test_data/system index 3afc5e4b39..b7eb73e2cf 100644 --- a/crates/dojo-lang/src/plugin_test_data/system +++ b/crates/dojo-lang/src/plugin_test_data/system @@ -355,8848 +355,57 @@ mod ctxnamed { } //! > expected_diagnostics -error: Anything other than functions is not supported in a dojo::interface - --> /tmp/plugin_test/src/lib.cairo:90:5 - const ONE: u8; - ^************^ - -error: World parameter must be the first parameter. - --> /tmp/plugin_test/src/lib.cairo:111:5 - fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252; - ^***********************************************************************************^ - -error: World parameter must be the first parameter. - --> /tmp/plugin_test/src/lib.cairo:112:5 - fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; - ^*********************************************************************************************^ - -error: You cannot use `self` and `world` parameters together. - --> /tmp/plugin_test/src/lib.cairo:113:5 - fn do_with_self_and_world_inv(world: @IWorldDispatcher, self: @ContractState) -> felt252; - ^***************************************************************************************^ - -error: You cannot use `self` and `world` parameters together. - --> /tmp/plugin_test/src/lib.cairo:114:5 - fn do_with_ref_self_and_world_inv( - ^********************************^ - -error: World parameter must be the first parameter. - --> /tmp/plugin_test/src/lib.cairo:121:5 - fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252; - ^****************************************************************************^ - -error: World parameter must be the first parameter. - --> /tmp/plugin_test/src/lib.cairo:128:9 - fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252 { - ^************************************************************************************^ - -error: World parameter must be the first parameter. - --> /tmp/plugin_test/src/lib.cairo:132:9 - fn do_with_ref_self_and_world( - ^****************************^ - -error: You cannot use `self` and `world` parameters together. - --> /tmp/plugin_test/src/lib.cairo:138:9 - fn do_with_self_and_world_inv(world: @IWorldDispatcher, self: @ContractState) -> felt252 { - ^****************************************************************************************^ - -error: You cannot use `self` and `world` parameters together. - --> /tmp/plugin_test/src/lib.cairo:142:9 - fn do_with_ref_self_and_world_inv( - ^********************************^ - -error: World parameter must be the first parameter. - --> /tmp/plugin_test/src/lib.cairo:158:9 - fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252 { - ^*****************************************************************************^ - -error: You cannot use `world` and `#[generate_trait]` together. Use `self` instead. - --> /tmp/plugin_test/src/lib.cairo:165:9 - fn bad_func_using_generate(world: @IWorldDispatcher) -> felt252 { - ^***************************************************************^ - -error: World parameter must be a snapshot if `ref` is not used. - --> /tmp/plugin_test/src/lib.cairo:224:5 - fn dojo_init( - ^***********^ - -error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. - --> /tmp/plugin_test/src/lib.cairo:105:5 - fn do_with_self(self: @ContractState) -> felt252; - ^**********************************************^ - -error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. - --> /tmp/plugin_test/src/lib.cairo:106:5 - fn do_with_ref_self(ref self: ContractState) -> felt252; - ^*****************************************************^ - -error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. - --> /tmp/plugin_test/src/lib.cairo:111:5 - fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252; - ^**********************************************************************************^ - -error: `starknet::interface` function first parameter must be a reference to the trait's generic parameter or a snapshot of it. - --> /tmp/plugin_test/src/lib.cairo:112:5 - fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; - ^********************************************************************************************^ - -error: `starknet::interface` functions don't support `ref` parameters other than the first one. - --> /tmp/plugin_test/src/lib.cairo:112:5 - fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252; - ^********************************************************************************************^ - -error: `starknet::interface` functions don't support `ref` parameters other than the first one. - --> /tmp/plugin_test/src/lib.cairo:114:5 - fn do_with_ref_self_and_world_inv( - ^********************************^ - -error: `starknet::interface` functions don't support `ref` parameters other than the first one. - --> /tmp/plugin_test/src/lib.cairo:117:5 - fn do_with_several_world_dispatchers( - ^***********************************^ - -error: `starknet::interface` functions don't support `ref` parameters other than the first one. - --> /tmp/plugin_test/src/lib.cairo:121:5 - fn do_with_world_not_first(vec: Vec2, ref world: IWorldDispatcher) -> felt252; - ^***************************************************************************^ - -error: Generated trait must have generic args matching the impl's generic params. - --> /tmp/plugin_test/src/lib.cairo:163:5 - #[generate_trait] - ^***************^ +error: Unknown derive `Print` - a plugin might be missing. + --> /tmp/plugin_test/src/lib.cairo:4:10 +#[derive(Print)] + ^***^ + +error: Unknown derive `Print` - a plugin might be missing. + --> /tmp/plugin_test/src/lib.cairo:12:10 +#[derive(Print)] + ^***^ + +error: Unknown derive `Print` - a plugin might be missing. + --> /tmp/plugin_test/src/lib.cairo:19:10 +#[derive(Print)] + ^***^ + +error: Unknown derive `Print` - a plugin might be missing. + --> /tmp/plugin_test/src/lib.cairo:28:10 +#[derive(Print)] + ^***^ //! > expanded_cairo_code +use serde::Serde; +use debug::PrintTrait; -#[starknet::component] -mod testcomponent1 { -#[event] -#[derive(Drop, starknet::Event)] -pub enum Event {} - - -pub struct Storage { -} - -#[derive(Drop, Copy)] -pub struct ComponentStorageBase { -} -#[derive(Drop, Copy)] -pub struct ComponentStorageBaseMut { -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait> { - type BaseType = ComponentStorageBase; - type BaseMutType = ComponentStorageBaseMut; - fn storage_base(self: @ComponentState) -> ComponentStorageBase { - ComponentStorageBase { - } - } - fn storage_base_mut(ref self: ComponentState) -> ComponentStorageBaseMut { - ComponentStorageBaseMut { - } - } -} -pub struct ComponentState { -} - -impl ComponentStateDrop of Drop> {} - -impl ComponentStateDeref of core::ops::SnapshotDeref> { - type Target = ComponentStorageBase; - fn snapshot_deref(self: @ComponentState) -> ComponentStorageBase { - self.storage_base() - } -} -impl ComponentStateDerefMut of core::ops::DerefMut> { - type Target = ComponentStorageBaseMut; - fn deref_mut(ref self: ComponentState) -> ComponentStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_component_state() -> ComponentState { - ComponentState:: { - } -} - - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; -pub trait HasComponent { - fn get_component(self: @TContractState) -> @ComponentState; - fn get_component_mut(ref self: TContractState) -> ComponentState; - fn get_contract(self: @ComponentState) -> @TContractState; - fn get_contract_mut(ref self: ComponentState) -> TContractState; - fn emit>(ref self: ComponentState, event: S); -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - Option::None - } -} -impl ComponentStorageBaseDrop of core::traits::Drop::; -impl ComponentStorageBaseCopy of core::traits::Copy::; -impl ComponentStorageBaseMutDrop of core::traits::Drop::; -impl ComponentStorageBaseMutCopy of core::traits::Copy::; -} - -#[starknet::component] -mod testcomponent2 { -#[event] -#[derive(Drop, starknet::Event)] -pub enum Event {} - - -pub struct Storage { -} - -#[derive(Drop, Copy)] -pub struct ComponentStorageBase { -} -#[derive(Drop, Copy)] -pub struct ComponentStorageBaseMut { -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait> { - type BaseType = ComponentStorageBase; - type BaseMutType = ComponentStorageBaseMut; - fn storage_base(self: @ComponentState) -> ComponentStorageBase { - ComponentStorageBase { - } - } - fn storage_base_mut(ref self: ComponentState) -> ComponentStorageBaseMut { - ComponentStorageBaseMut { - } - } -} -pub struct ComponentState { -} - -impl ComponentStateDrop of Drop> {} - -impl ComponentStateDeref of core::ops::SnapshotDeref> { - type Target = ComponentStorageBase; - fn snapshot_deref(self: @ComponentState) -> ComponentStorageBase { - self.storage_base() - } -} -impl ComponentStateDerefMut of core::ops::DerefMut> { - type Target = ComponentStorageBaseMut; - fn deref_mut(ref self: ComponentState) -> ComponentStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_component_state() -> ComponentState { - ComponentState:: { - } -} - - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; -pub trait HasComponent { - fn get_component(self: @TContractState) -> @ComponentState; - fn get_component_mut(ref self: TContractState) -> ComponentState; - fn get_contract(self: @ComponentState) -> @TContractState; - fn get_contract_mut(ref self: ComponentState) -> TContractState; - fn emit>(ref self: ComponentState, event: S); -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - Option::None - } -} -impl ComponentStorageBaseDrop of core::traits::Drop::; -impl ComponentStorageBaseCopy of core::traits::Copy::; -impl ComponentStorageBaseMutDrop of core::traits::Drop::; -impl ComponentStorageBaseMutCopy of core::traits::Copy::; -} - - #[starknet::contract] - mod bad_namespace_format { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "bad_namespace_format" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-bad_namespace_format" - } - - fn name_hash(self: @ContractState) -> felt252 { - 2014299465256018364248618312205774234949844604916563661777686628154176783488 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 2931670046498875274448874829231097042977275875153600823491451406128208153107 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - use traits::Into; - use dojo::world::Context; - - fn execute(ctx: Context, name: felt252) { - return (); - } - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) +#[derive(Print)] +struct Position { + #[key] + id: felt252, + x: felt252, + y: felt252 } -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } +#[derive(Print)] +struct Roles { + role_ids: Array } -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } +use starknet::ContractAddress; -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } +#[derive(Print)] +struct Player { + #[key] + game: felt252, + #[key] + player: ContractAddress, + name: felt252, } -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } - #[starknet::contract] - mod spawn { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "spawn" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-spawn" - } - - fn name_hash(self: @ContractState) -> felt252 { - 2776321589048333240377325502911505147617911439383944762363370901236132332849 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 2472087249524108479557800499207886557849609293388925195637428170796835731505 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - use traits::Into; - use dojo::world::Context; - - fn execute(ctx: Context, name: felt252) { - return (); - } - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - mod proxy { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "proxy" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-proxy" - } - - fn name_hash(self: @ContractState) -> felt252 { - 379211399603323842291430789821178524592027629543381998047225121027704003915 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 3522586352349720867166847576673128733430338006217587257445073829693434546448 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - fn execute(value: felt252) -> felt252 { - value - } - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - mod ctxnamed { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "ctxnamed" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-ctxnamed" - } - - fn name_hash(self: @ContractState) -> felt252 { - 1120614286815912604239420768209466007446460277061516527925636408561239543041 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 882574079468045629402181499911470715863025356910172410020020548741739455774 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - use traits::Into; - use dojo::world::Context; - - fn execute(ctx2: Context, name: felt252) { - return (); - } - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - mod withevent { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "withevent" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-withevent" - } - - fn name_hash(self: @ContractState) -> felt252 { - 2196275886623691942883456540767114081898043897719876113518403014973431884540 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 2302995054894169641868030754357260737170491794196617685355614288827933407674 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - TestEvent: TestEvent - } - - #[derive(Drop, starknet::Event)] - struct TestEvent { - address: ContractAddress, - } - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - Event::TestEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("TestEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - if __selector__ == selector!("TestEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::TestEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} -impl EventTestEventIntoEvent of Into { - fn into(self: TestEvent) -> Event { - Event::TestEvent(self) - } -} -impl TestEventDrop of core::traits::Drop::; -impl TestEventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @TestEvent, ref keys: Array, ref data: Array - ) { - core::serde::Serde::serialize(self.address, ref data); - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let address = core::serde::Serde::deserialize( - ref data - )?; - Option::Some(TestEvent {address, }) - } -} -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - mod withcomponent { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "withcomponent" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-withcomponent" - } - - fn name_hash(self: @ContractState) -> felt252 { - 999850881662666048155666650426666132968026605763740651763663703103974774091 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 795804664978713707757807985251114311939501109833092725925763852713460388378 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - #[flat] - testcomponent1_event: testcomponent1::Event, - testcomponent2_event: testcomponent2::Event - } - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, - pub testcomponent1_storage: testcomponent1::Storage, - pub testcomponent2_storage: testcomponent2::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, - pub testcomponent1_storage: starknet::storage::StorageBase, - pub testcomponent2_storage: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, - pub testcomponent1_storage: starknet::storage::StorageBase>, - pub testcomponent2_storage: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - testcomponent1_storage: starknet::storage::StorageBase{ address: selector!("testcomponent1_storage") }, - testcomponent2_storage: starknet::storage::StorageBase{ address: selector!("testcomponent2_storage") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - testcomponent1_storage: starknet::storage::StorageBase{ address: selector!("testcomponent1_storage") }, - testcomponent2_storage: starknet::storage::StorageBase{ address: selector!("testcomponent2_storage") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, - pub testcomponent1_storage: testcomponent1::ComponentState, - pub testcomponent2_storage: testcomponent2::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - testcomponent1_storage: testcomponent1::unsafe_new_component_state::(), - testcomponent2_storage: testcomponent2::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl HasComponentImpl_testcomponent1 of testcomponent1::HasComponent { - fn get_component(self: @ContractState) -> @testcomponent1::ComponentState { - @testcomponent1::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> testcomponent1::ComponentState { - testcomponent1::unsafe_new_component_state::() - } - fn get_contract(self: @testcomponent1::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: testcomponent1::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: testcomponent1::ComponentState, event: S) { - let event: testcomponent1::Event = core::traits::Into::into(event); - let mut contract = testcomponent1::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::testcomponent1_event(event)); - } -} -impl HasComponentImpl_testcomponent2 of testcomponent2::HasComponent { - fn get_component(self: @ContractState) -> @testcomponent2::ComponentState { - @testcomponent2::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> testcomponent2::ComponentState { - testcomponent2::unsafe_new_component_state::() - } - fn get_contract(self: @testcomponent2::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: testcomponent2::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: testcomponent2::ComponentState, event: S) { - let event: testcomponent2::Event = core::traits::Into::into(event); - let mut contract = testcomponent2::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::testcomponent2_event(event)); - } -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - Event::testcomponent1_event(val) => { - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - Event::testcomponent2_event(val) => { - core::array::ArrayTrait::append(ref keys, selector!("testcomponent2_event")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - { - let mut keys = keys; - let mut data = data; - match starknet::Event::deserialize(ref keys, ref data) { - Option::Some(val) => { - return Option::Some(Event::testcomponent1_event(val)); - }, - Option::None => {}, - }; - } - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - if __selector__ == selector!("testcomponent2_event") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::testcomponent2_event(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} -impl Eventtestcomponent1_eventIntoEvent of Into { - fn into(self: testcomponent1::Event) -> Event { - Event::testcomponent1_event(self) - } -} -impl Eventtestcomponent2_eventIntoEvent of Into { - fn into(self: testcomponent2::Event) -> Event { - Event::testcomponent2_event(self) - } -} -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} - - } - - #[starknet::interface] - trait IEmptyTrait {} - - #[starknet::interface] - trait IFaultyTrait { - fn do_with_attrs(self: @TContractState, p1: u8) -> u16; - } - - #[starknet::interface] - trait INominalTrait { - fn do_no_param(self: @TContractState) -> felt252;fn do_no_param_but_world(self: @TContractState) -> felt252;fn do_no_param_but_world_ref(ref self: TContractState) -> felt252;fn do_params_no_world(self: @TContractState, p1: felt252, p2: u8) -> felt252;fn do_params_and_world(self: @TContractState, p2: u8) -> felt252;fn do_params_and_world_ref(ref self: TContractState, p2: u8) -> felt252;fn do_with_self(self: @ContractState) -> felt252;fn do_with_ref_self(ref self: ContractState) -> felt252; - } - - #[starknet::interface] - trait IFaultyTrait { - fn do_with_self_and_world(self: @ContractState, world: @IWorldDispatcher) -> felt252;fn do_with_ref_self_and_world(ref self: ContractState, ref world: IWorldDispatcher) -> felt252;fn do_with_self_and_world_inv(self: @TContractState, self: @ContractState) -> felt252;fn do_with_ref_self_and_world_inv(ref self: TContractState, ref self: ContractState -) -> felt252;fn do_with_several_world_dispatchers(self: @TContractState, vec: Vec2, ref another_world: IWorldDispatcher -) -> felt252;fn do_with_world_not_named_world(self: @TContractState, another_world: @IWorldDispatcher) -> felt252;fn do_with_world_not_first(self: @TContractState, vec: Vec2, ref world: IWorldDispatcher) -> felt252; - } - - #[starknet::contract] - mod MyFaultyContract { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "MyFaultyContract" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-MyFaultyContract" - } - - fn name_hash(self: @ContractState) -> felt252 { - 3439743807865759203015037013733809315384408083697880336790137144257764256358 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 1862046669446530718410691364259438011386499031689246339557998041337203828246 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - #[abi(embed_v0)] - impl TestFaultyImpl of IFaultyTrait {fn do_with_self_and_world(self: @ContractState) -> felt252 { 'land' -}fn do_with_ref_self_and_world( ref self: ContractState) -> felt252 { 'land' -}fn do_with_self_and_world_inv(self: @ContractState, self: @ContractState) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_with_ref_self_and_world_inv(ref self: ContractState, ref self: ContractState -) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_with_several_world_dispatchers(self: @ContractState, vec: Vec2, ref another_world: IWorldDispatcher -) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_with_world_not_named_world(self: @ContractState, another_world: @IWorldDispatcher) -> felt252 { 'land' -}fn do_with_world_not_first(self: @ContractState, vec: Vec2) -> felt252 { 'land' -}} - #[generate_trait] - impl InternalImplBad of InternalUtils {fn bad_func_using_generate(self: @ContractState) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}} - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } - trait InternalUtils{fn bad_func_using_generate(self: @ContractState) -> felt252; -} -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_self_and_world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_self_and_world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_ref_self_and_world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_ref_self_and_world(ref contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_self_and_world_inv(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_self = core::option::OptionTraitImpl::expect( - core::serde::Serde::<@ContractState>::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_self_and_world_inv(@contract_state, __arg_self); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_ref_self_and_world_inv(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let mut __arg_self = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_ref_self_and_world_inv(ref contract_state, ref __arg_self); - let mut arr = ArrayTrait::new(); - // References. - core::serde::Serde::::serialize(@__arg_self, ref arr); - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_several_world_dispatchers(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_vec = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - let mut __arg_another_world = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #2' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_several_world_dispatchers(@contract_state, __arg_vec, ref __arg_another_world); - let mut arr = ArrayTrait::new(); - // References. - core::serde::Serde::::serialize(@__arg_another_world, ref arr); - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_world_not_named_world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_another_world = core::option::OptionTraitImpl::expect( - core::serde::Serde::<@IWorldDispatcher>::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_world_not_named_world(@contract_state, __arg_another_world); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestFaultyImpl__do_with_world_not_first(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_vec = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestFaultyImpl::do_with_world_not_first(@contract_state, __arg_vec); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__TestFaultyImpl__do_with_self_and_world as do_with_self_and_world; - pub use super::__wrapper__TestFaultyImpl__do_with_ref_self_and_world as do_with_ref_self_and_world; - pub use super::__wrapper__TestFaultyImpl__do_with_self_and_world_inv as do_with_self_and_world_inv; - pub use super::__wrapper__TestFaultyImpl__do_with_ref_self_and_world_inv as do_with_ref_self_and_world_inv; - pub use super::__wrapper__TestFaultyImpl__do_with_several_world_dispatchers as do_with_several_world_dispatchers; - pub use super::__wrapper__TestFaultyImpl__do_with_world_not_named_world as do_with_world_not_named_world; - pub use super::__wrapper__TestFaultyImpl__do_with_world_not_first as do_with_world_not_first; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - mod MyNominalContract { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "MyNominalContract" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-MyNominalContract" - } - - fn name_hash(self: @ContractState) -> felt252 { - 1172628497499445169993220559087829230676589931723677494032285307738203070578 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 2020162355936884646880401248118384176803981589166410970216209297939905305278 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - #[derive(Drop)] - struct Action { - damage: u8 - } - - #[abi(embed_v0)] - impl TestNominalImpl of INominalTrait {fn do_no_param(self: @ContractState) -> felt252 { 'land' -}fn do_no_param_but_world(self: @ContractState) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_no_param_but_world_ref(ref self: ContractState) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_params_no_world(self: @ContractState, p1: felt252, p2: u8) -> felt252 { 'land' -}fn do_params_and_world(self: @ContractState, p2: u8) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_params_and_world_ref(ref self: ContractState, p2: u8) -> felt252 {let world = self.world_dispatcher.read(); 'land' -}fn do_with_self(self: @ContractState) -> felt252 { 'land' -}fn do_with_ref_self(ref self: ContractState) -> felt252 { 'land' -}} - #[generate_trait] - impl ImplInternalNoContractState of InternalNoContractState { - fn func1(world: IWorldDispatcher) -> felt252 { - let _w = world; - 42 - } - } - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } -impl ActionDrop of core::traits::Drop::; - trait InternalNoContractState { - fn func1(world: IWorldDispatcher) -> felt252; - } -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_no_param(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_no_param(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_no_param_but_world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_no_param_but_world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_no_param_but_world_ref(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_no_param_but_world_ref(ref contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_params_no_world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_p1 = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - let __arg_p2 = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #2' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_params_no_world(@contract_state, __arg_p1, __arg_p2); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_params_and_world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_p2 = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_params_and_world(@contract_state, __arg_p2); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_params_and_world_ref(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_p2 = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_params_and_world_ref(ref contract_state, __arg_p2); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_with_self(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_with_self(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__TestNominalImpl__do_with_ref_self(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = TestNominalImpl::do_with_ref_self(ref contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__TestNominalImpl__do_no_param as do_no_param; - pub use super::__wrapper__TestNominalImpl__do_no_param_but_world as do_no_param_but_world; - pub use super::__wrapper__TestNominalImpl__do_no_param_but_world_ref as do_no_param_but_world_ref; - pub use super::__wrapper__TestNominalImpl__do_params_no_world as do_params_no_world; - pub use super::__wrapper__TestNominalImpl__do_params_and_world as do_params_and_world; - pub use super::__wrapper__TestNominalImpl__do_params_and_world_ref as do_params_and_world_ref; - pub use super::__wrapper__TestNominalImpl__do_with_self as do_with_self; - pub use super::__wrapper__TestNominalImpl__do_with_ref_self as do_with_ref_self; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - mod init_test { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "init_test" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-init_test" - } - - fn name_hash(self: @ContractState) -> felt252 { - 1673722391095039242574232979635399085098867563460816803458086922970092209409 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 799876284284394866912776672431802324689156187217902437477103298743064217162 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -) {let world = self.world_dispatcher.read();assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); emit!( - world, - ContractInitialized { - contract_address: actions_address, contract_class: actions_class, value - } - ); -} -} - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@actions_address, ref __calldata__); - core::serde::Serde::::serialize(@actions_class, ref __calldata__); - core::serde::Serde::::serialize(@value, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -) { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@actions_address, ref __calldata__); - core::serde::Serde::::serialize(@actions_class, ref __calldata__); - core::serde::Serde::::serialize(@value, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@actions_address, ref __calldata__); - core::serde::Serde::::serialize(@actions_class, ref __calldata__); - core::serde::Serde::::serialize(@value, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher, actions_address: ContractAddress, actions_class: ClassHash, value: u8 -) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@actions_address, ref __calldata__); - core::serde::Serde::::serialize(@actions_class, ref __calldata__); - core::serde::Serde::::serialize(@value, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - let __arg_actions_address = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #1' - ); - let __arg_actions_class = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #2' - ); - let __arg_value = core::option::OptionTraitImpl::expect( - core::serde::Serde::::deserialize(ref data), - 'Failed to deserialize param #3' - ); - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, __arg_actions_address, __arg_actions_class, __arg_value); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } - - #[starknet::contract] - mod no_init_test { - use dojo::world; - use dojo::world::IWorldDispatcher; - use dojo::world::IWorldDispatcherTrait; - use dojo::world::IWorldProvider; - use dojo::contract::IContract; - - #[abi(embed_v0)] - impl ContractImpl of IContract { - fn contract_name(self: @ContractState) -> ByteArray { - "no_init_test" - } - - fn namespace(self: @ContractState) -> ByteArray { - "test_package" - } - - fn tag(self: @ContractState) -> ByteArray { - "test_package-no_init_test" - } - - fn name_hash(self: @ContractState) -> felt252 { - 2188407785440294979090510634648735461326850740369373015349552249835679156474 - } - - fn namespace_hash(self: @ContractState) -> felt252 { - 3061092720893075933752785490401950953836105364709575990296000909161416686979 - } - - fn selector(self: @ContractState) -> felt252 { - 3269287263937103915837903451864388946886384011514094502724942119672327217364 - } - } - - #[abi(embed_v0)] - impl WorldProviderImpl of IWorldProvider { - fn world(self: @ContractState) -> IWorldDispatcher { - self.world_dispatcher.read() - } - } - - #[abi(embed_v0)] - impl UpgradableImpl = dojo::components::upgradeable::upgradeable::UpgradableImpl; - - - #[starknet::interface] - trait IDojoInit { - fn dojo_init(self: @ContractState); - } - - #[abi(embed_v0)] - impl IDojoInitImpl of IDojoInit { - fn dojo_init(self: @ContractState) { - assert(starknet::get_caller_address() == self.world().contract_address, 'Only world can init'); - } - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - UpgradeableEvent: dojo::components::upgradeable::upgradeable::Event, - } -trait IDojoInitDispatcherTrait { - fn dojo_init(self: T); -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitLibraryDispatcherImpl of IDojoInitDispatcherTrait { - fn dojo_init(self: IDojoInitLibraryDispatcher) { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - () - } - -} - -trait IDojoInitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn dojo_init(self: T) -> starknet::SyscallResult<()>; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IDojoInitSafeLibraryDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IDojoInitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IDojoInitSafeDispatcherImpl of IDojoInitSafeDispatcherTrait { - fn dojo_init(self: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("dojo_init"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok(()) - } - -} -impl EventDrop of core::traits::Drop::; -impl EventIsEvent of starknet::Event { - fn append_keys_and_data( - self: @Event, ref keys: Array, ref data: Array - ) { - match self { - Event::UpgradeableEvent(val) => { - core::array::ArrayTrait::append(ref keys, selector!("UpgradeableEvent")); - starknet::Event::append_keys_and_data( - val, ref keys, ref data - ); - }, - } - } - fn deserialize( - ref keys: Span, ref data: Span, - ) -> Option { - let __selector__ = *core::array::SpanTrait::pop_front(ref keys)?; - if __selector__ == selector!("UpgradeableEvent") { - let val = starknet::Event::deserialize( - ref keys, ref data - )?; - return Option::Some(Event::UpgradeableEvent(val)); - } - Option::None - } -} -impl EventUpgradeableEventIntoEvent of Into { - fn into(self: dojo::components::upgradeable::upgradeable::Event) -> Event { - Event::UpgradeableEvent(self) - } -} - - -pub struct Storage { - pub world_dispatcher: IWorldDispatcher, - pub upgradeable: dojo::components::upgradeable::upgradeable::Storage, -} - -#[derive(Drop, Copy)] -pub struct ContractStorageBase { - pub world_dispatcher: starknet::storage::StorageBase, - pub upgradeable: starknet::storage::StorageBase, -} -#[derive(Drop, Copy)] -pub struct ContractStorageBaseMut { - pub world_dispatcher: starknet::storage::StorageBase>, - pub upgradeable: starknet::storage::StorageBase>, -} -impl StorageBaseImpl of starknet::storage::StorageBaseTrait { - type BaseType = ContractStorageBase; - type BaseMutType = ContractStorageBaseMut; - fn storage_base(self: @ContractState) -> ContractStorageBase { - ContractStorageBase { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } - fn storage_base_mut(ref self: ContractState) -> ContractStorageBaseMut { - ContractStorageBaseMut { - world_dispatcher: starknet::storage::StorageBase{ address: selector!("world_dispatcher") }, - upgradeable: starknet::storage::StorageBase{ address: selector!("upgradeable") }, - } - } -} -pub struct ContractState { - pub upgradeable: dojo::components::upgradeable::upgradeable::ComponentState, -} - -impl ContractStateDrop of Drop {} - -impl ContractStateDeref of core::ops::SnapshotDeref { - type Target = ContractStorageBase; - fn snapshot_deref(self: @ContractState) -> ContractStorageBase { - self.storage_base() - } -} -impl ContractStateDerefMut of core::ops::DerefMut { - type Target = ContractStorageBaseMut; - fn deref_mut(ref self: ContractState) -> ContractStorageBaseMut { - self.storage_base_mut() - } -} -pub fn unsafe_new_contract_state() -> ContractState { - ContractState { - upgradeable: dojo::components::upgradeable::upgradeable::unsafe_new_component_state::(), - } -} - -use starknet::storage::{ - StorageMapReadAccessTrait, StorageMapWriteAccessTrait, - StorableStoragePointerReadAccess, StorableStoragePointerWriteAccess -}; -// TODO(Gil): This generates duplicate diagnostics because of the plugin system, squash the duplicates into one. -#[deprecated( - feature: "deprecated_legacy_map", - note: "Use `starknet::storage::Map` instead." -)] -use starknet::storage::Map as LegacyMap; - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__contract_name(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::contract_name(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__tag(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::tag(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__name_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::name_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__namespace_hash(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::namespace_hash(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__ContractImpl__selector(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = ContractImpl::selector(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__WorldProviderImpl__world(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - let res = WorldProviderImpl::world(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::serde::Serde::::serialize(@res, ref arr); - core::array::ArrayTrait::span(@arr) -} - -impl ContractStateUpgradableImpl of - dojo::components::upgradeable::upgradeable::UnsafeNewContractStateTraitForUpgradableImpl { - fn unsafe_new_contract_state() -> ContractState { - unsafe_new_contract_state() - } -} -#[implicit_precedence(Pedersen, RangeCheck, Bitwise, core::ec::EcOp, Poseidon, SegmentArena, core::circuit::RangeCheck96, core::circuit::AddMod, core::circuit::MulMod, GasBuiltin, System)] -fn __wrapper__IDojoInitImpl__dojo_init(mut data: Span::) -> Span:: { - core::internal::require_implicit::(); - core::internal::revoke_ap_tracking(); - core::option::OptionTraitImpl::expect(core::gas::withdraw_gas(), 'Out of gas'); - - assert(core::array::SpanTrait::is_empty(data), 'Input too long for arguments'); - core::option::OptionTraitImpl::expect( - core::gas::withdraw_gas_all(core::gas::get_builtin_costs()), 'Out of gas', - ); - let mut contract_state = unsafe_new_contract_state(); - IDojoInitImpl::dojo_init(@contract_state, ); - let mut arr = ArrayTrait::new(); - // References. - // Result. - core::array::ArrayTrait::span(@arr) -} - - -pub mod __external { - pub use super::__wrapper__ContractImpl__contract_name as contract_name; - pub use super::__wrapper__ContractImpl__namespace as namespace; - pub use super::__wrapper__ContractImpl__tag as tag; - pub use super::__wrapper__ContractImpl__name_hash as name_hash; - pub use super::__wrapper__ContractImpl__namespace_hash as namespace_hash; - pub use super::__wrapper__ContractImpl__selector as selector; - pub use super::__wrapper__WorldProviderImpl__world as world; - pub use super::__wrapper__IDojoInitImpl__dojo_init as dojo_init; -} -pub mod __l1_handler { -} -pub mod __constructor { -} - impl ContractStateEventEmitter of starknet::event::EventEmitter< - ContractState, Event - > { - fn emit>( - ref self: ContractState, event: S - ) { - let event: Event = core::traits::Into::into(event); - let mut keys = Default::::default(); - let mut data = Default::::default(); - starknet::Event::append_keys_and_data(@event, ref keys, ref data); - starknet::SyscallResultTrait::unwrap_syscall( - starknet::syscalls::emit_event_syscall( - core::array::ArrayTrait::span(@keys), - core::array::ArrayTrait::span(@data), - ) - ) - } - } - -impl HasComponentImpl_upgradeable of dojo::components::upgradeable::upgradeable::HasComponent { - fn get_component(self: @ContractState) -> @dojo::components::upgradeable::upgradeable::ComponentState { - @dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_component_mut(ref self: ContractState) -> dojo::components::upgradeable::upgradeable::ComponentState { - dojo::components::upgradeable::upgradeable::unsafe_new_component_state::() - } - fn get_contract(self: @dojo::components::upgradeable::upgradeable::ComponentState) -> @ContractState { - @unsafe_new_contract_state() - } - fn get_contract_mut(ref self: dojo::components::upgradeable::upgradeable::ComponentState) -> ContractState { - unsafe_new_contract_state() - } - fn emit>(ref self: dojo::components::upgradeable::upgradeable::ComponentState, event: S) { - let event: dojo::components::upgradeable::upgradeable::Event = core::traits::Into::into(event); - let mut contract = dojo::components::upgradeable::upgradeable::HasComponent::get_contract_mut(ref self); - ContractStateEventEmitter::emit(ref contract, Event::UpgradeableEvent(event)); - } -} -impl IDojoInitDispatcherCopy of core::traits::Copy::; -impl IDojoInitDispatcherDrop of core::traits::Drop::; -impl IDojoInitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IDojoInitSafeDispatcherCopy of core::traits::Copy::; -impl IDojoInitSafeDispatcherDrop of core::traits::Drop::; -impl IDojoInitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IDojoInitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IDojoInitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIDojoInitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IDojoInitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IDojoInitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIDojoInitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl ContractStorageBaseDrop of core::traits::Drop::; -impl ContractStorageBaseCopy of core::traits::Copy::; -impl ContractStorageBaseMutDrop of core::traits::Drop::; -impl ContractStorageBaseMutCopy of core::traits::Copy::; - - } -trait IEmptyTraitDispatcherTrait { -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IEmptyTraitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IEmptyTraitDispatcherImpl of IEmptyTraitDispatcherTrait { - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IEmptyTraitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IEmptyTraitLibraryDispatcherImpl of IEmptyTraitDispatcherTrait { - -} - -trait IEmptyTraitSafeDispatcherTrait { -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IEmptyTraitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IEmptyTraitSafeLibraryDispatcherImpl of IEmptyTraitSafeDispatcherTrait { - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IEmptyTraitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IEmptyTraitSafeDispatcherImpl of IEmptyTraitSafeDispatcherTrait { - -} -trait IFaultyTraitDispatcherTrait { - fn do_with_attrs(self: T, p1: u8) -> u16; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IFaultyTraitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IFaultyTraitDispatcherImpl of IFaultyTraitDispatcherTrait { - fn do_with_attrs(self: IFaultyTraitDispatcher, p1: u8) -> u16 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_with_attrs"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IFaultyTraitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IFaultyTraitLibraryDispatcherImpl of IFaultyTraitDispatcherTrait { - fn do_with_attrs(self: IFaultyTraitLibraryDispatcher, p1: u8) -> u16 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_with_attrs"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } - -} - -trait IFaultyTraitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn do_with_attrs(self: T, p1: u8) -> starknet::SyscallResult; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IFaultyTraitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IFaultyTraitSafeLibraryDispatcherImpl of IFaultyTraitSafeDispatcherTrait { - fn do_with_attrs(self: IFaultyTraitSafeLibraryDispatcher, p1: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_with_attrs"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IFaultyTraitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IFaultyTraitSafeDispatcherImpl of IFaultyTraitSafeDispatcherTrait { - fn do_with_attrs(self: IFaultyTraitSafeDispatcher, p1: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_with_attrs"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } - -} -trait INominalTraitDispatcherTrait { - fn do_no_param(self: T) -> felt252; -fn do_no_param_but_world(self: T) -> felt252; -fn do_no_param_but_world_ref(self: T) -> felt252; -fn do_params_no_world(self: T, p1: felt252, p2: u8) -> felt252; -fn do_params_and_world(self: T, p2: u8) -> felt252; -fn do_params_and_world_ref(self: T, p2: u8) -> felt252; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct INominalTraitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl INominalTraitDispatcherImpl of INominalTraitDispatcherTrait { - fn do_no_param(self: INominalTraitDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_no_param"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_no_param_but_world(self: INominalTraitDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_no_param_but_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_no_param_but_world_ref(self: INominalTraitDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_no_param_but_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_params_no_world(self: INominalTraitDispatcher, p1: felt252, p2: u8) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_params_no_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_params_and_world(self: INominalTraitDispatcher, p2: u8) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_params_and_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_params_and_world_ref(self: INominalTraitDispatcher, p2: u8) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_params_and_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct INominalTraitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl INominalTraitLibraryDispatcherImpl of INominalTraitDispatcherTrait { - fn do_no_param(self: INominalTraitLibraryDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_no_param"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_no_param_but_world(self: INominalTraitLibraryDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_no_param_but_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_no_param_but_world_ref(self: INominalTraitLibraryDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_no_param_but_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_params_no_world(self: INominalTraitLibraryDispatcher, p1: felt252, p2: u8) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_params_no_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_params_and_world(self: INominalTraitLibraryDispatcher, p2: u8) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_params_and_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_params_and_world_ref(self: INominalTraitLibraryDispatcher, p2: u8) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_params_and_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } - -} - -trait INominalTraitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] - fn do_no_param(self: T) -> starknet::SyscallResult; - #[unstable(feature: "safe_dispatcher")] -fn do_no_param_but_world(self: T) -> starknet::SyscallResult; - #[unstable(feature: "safe_dispatcher")] -fn do_no_param_but_world_ref(self: T) -> starknet::SyscallResult; - #[unstable(feature: "safe_dispatcher")] -fn do_params_no_world(self: T, p1: felt252, p2: u8) -> starknet::SyscallResult; - #[unstable(feature: "safe_dispatcher")] -fn do_params_and_world(self: T, p2: u8) -> starknet::SyscallResult; - #[unstable(feature: "safe_dispatcher")] -fn do_params_and_world_ref(self: T, p2: u8) -> starknet::SyscallResult; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct INominalTraitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl INominalTraitSafeLibraryDispatcherImpl of INominalTraitSafeDispatcherTrait { - fn do_no_param(self: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_no_param"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_no_param_but_world(self: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_no_param_but_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_no_param_but_world_ref(self: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_no_param_but_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_params_no_world(self: INominalTraitSafeLibraryDispatcher, p1: felt252, p2: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_params_no_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_params_and_world(self: INominalTraitSafeLibraryDispatcher, p2: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_params_and_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_params_and_world_ref(self: INominalTraitSafeLibraryDispatcher, p2: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_params_and_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct INominalTraitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl INominalTraitSafeDispatcherImpl of INominalTraitSafeDispatcherTrait { - fn do_no_param(self: INominalTraitSafeDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_no_param"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_no_param_but_world(self: INominalTraitSafeDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_no_param_but_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_no_param_but_world_ref(self: INominalTraitSafeDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_no_param_but_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_params_no_world(self: INominalTraitSafeDispatcher, p1: felt252, p2: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p1, ref __calldata__); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_params_no_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_params_and_world(self: INominalTraitSafeDispatcher, p2: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_params_and_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_params_and_world_ref(self: INominalTraitSafeDispatcher, p2: u8) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::::serialize(@p2, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_params_and_world_ref"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } - -} -trait IFaultyTraitDispatcherTrait { -fn do_with_self_and_world_inv(self: T, self: @ContractState) -> felt252; -fn do_with_world_not_named_world(self: T, another_world: @IWorldDispatcher) -> felt252; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IFaultyTraitDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IFaultyTraitDispatcherImpl of IFaultyTraitDispatcherTrait { -fn do_with_self_and_world_inv(self: IFaultyTraitDispatcher, self: @ContractState) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@ContractState>::serialize(@self, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_with_self_and_world_inv"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_with_world_not_named_world(self: IFaultyTraitDispatcher, another_world: @IWorldDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@IWorldDispatcher>::serialize(@another_world, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_with_world_not_named_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } - -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IFaultyTraitLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IFaultyTraitLibraryDispatcherImpl of IFaultyTraitDispatcherTrait { -fn do_with_self_and_world_inv(self: IFaultyTraitLibraryDispatcher, self: @ContractState) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@ContractState>::serialize(@self, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_with_self_and_world_inv"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } -fn do_with_world_not_named_world(self: IFaultyTraitLibraryDispatcher, another_world: @IWorldDispatcher) -> felt252 { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@IWorldDispatcher>::serialize(@another_world, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_with_world_not_named_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = starknet::SyscallResultTrait::unwrap_syscall(__dispatcher_return_data__); - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - } - -} - -trait IFaultyTraitSafeDispatcherTrait { - #[unstable(feature: "safe_dispatcher")] -fn do_with_self_and_world_inv(self: T, self: @ContractState) -> starknet::SyscallResult; - #[unstable(feature: "safe_dispatcher")] -fn do_with_world_not_named_world(self: T, another_world: @IWorldDispatcher) -> starknet::SyscallResult; -} - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IFaultyTraitSafeLibraryDispatcher { - pub class_hash: starknet::ClassHash, -} - -impl IFaultyTraitSafeLibraryDispatcherImpl of IFaultyTraitSafeDispatcherTrait { -fn do_with_self_and_world_inv(self: IFaultyTraitSafeLibraryDispatcher, self: @ContractState) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@ContractState>::serialize(@self, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_with_self_and_world_inv"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_with_world_not_named_world(self: IFaultyTraitSafeLibraryDispatcher, another_world: @IWorldDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@IWorldDispatcher>::serialize(@another_world, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::library_call_syscall( - self.class_hash, - selector!("do_with_world_not_named_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } - -} - - -#[derive(Copy, Drop, starknet::Store, Serde)] -struct IFaultyTraitSafeDispatcher { - pub contract_address: starknet::ContractAddress, -} - -impl IFaultyTraitSafeDispatcherImpl of IFaultyTraitSafeDispatcherTrait { -fn do_with_self_and_world_inv(self: IFaultyTraitSafeDispatcher, self: @ContractState) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@ContractState>::serialize(@self, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_with_self_and_world_inv"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } -fn do_with_world_not_named_world(self: IFaultyTraitSafeDispatcher, another_world: @IWorldDispatcher) -> starknet::SyscallResult { - let mut __calldata__ = core::traits::Default::default(); - core::serde::Serde::<@IWorldDispatcher>::serialize(@another_world, ref __calldata__); - - let mut __dispatcher_return_data__ = starknet::syscalls::call_contract_syscall( - self.contract_address, - selector!("do_with_world_not_named_world"), - core::array::ArrayTrait::span(@__calldata__), - ); - let mut __dispatcher_return_data__ = __dispatcher_return_data__?; - Result::Ok( - core::option::OptionTrait::expect( - core::serde::Serde::::deserialize(ref __dispatcher_return_data__), - 'Returned data too short', - ) - ) - } - -} -impl IEmptyTraitDispatcherCopy of core::traits::Copy::; -impl IEmptyTraitDispatcherDrop of core::traits::Drop::; -impl IEmptyTraitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IEmptyTraitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IEmptyTraitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIEmptyTraitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IEmptyTraitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IEmptyTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IEmptyTraitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IEmptyTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIEmptyTraitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IEmptyTraitLibraryDispatcherCopy of core::traits::Copy::; -impl IEmptyTraitLibraryDispatcherDrop of core::traits::Drop::; -impl IEmptyTraitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IEmptyTraitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IEmptyTraitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIEmptyTraitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IEmptyTraitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IEmptyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IEmptyTraitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IEmptyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIEmptyTraitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IEmptyTraitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IEmptyTraitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IEmptyTraitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IEmptyTraitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IEmptyTraitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIEmptyTraitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IEmptyTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IEmptyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IEmptyTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IEmptyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIEmptyTraitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IEmptyTraitSafeDispatcherCopy of core::traits::Copy::; -impl IEmptyTraitSafeDispatcherDrop of core::traits::Drop::; -impl IEmptyTraitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IEmptyTraitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IEmptyTraitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIEmptyTraitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IEmptyTraitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IEmptyTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IEmptyTraitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IEmptyTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIEmptyTraitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IFaultyTraitDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIFaultyTraitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IFaultyTraitLibraryDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitLibraryDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIFaultyTraitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IFaultyTraitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIFaultyTraitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IFaultyTraitSafeDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitSafeDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIFaultyTraitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl INominalTraitDispatcherCopy of core::traits::Copy::; -impl INominalTraitDispatcherDrop of core::traits::Drop::; -impl INominalTraitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @INominalTraitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(INominalTraitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreINominalTraitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - INominalTraitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: INominalTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - INominalTraitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: INominalTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageINominalTraitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl INominalTraitLibraryDispatcherCopy of core::traits::Copy::; -impl INominalTraitLibraryDispatcherDrop of core::traits::Drop::; -impl INominalTraitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @INominalTraitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(INominalTraitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreINominalTraitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - INominalTraitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: INominalTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - INominalTraitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: INominalTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageINominalTraitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl INominalTraitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl INominalTraitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl INominalTraitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @INominalTraitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(INominalTraitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreINominalTraitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - INominalTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - INominalTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: INominalTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageINominalTraitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl INominalTraitSafeDispatcherCopy of core::traits::Copy::; -impl INominalTraitSafeDispatcherDrop of core::traits::Drop::; -impl INominalTraitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @INominalTraitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(INominalTraitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreINominalTraitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - INominalTraitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: INominalTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - INominalTraitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: INominalTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageINominalTraitSafeDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IFaultyTraitDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIFaultyTraitDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IFaultyTraitLibraryDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitLibraryDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIFaultyTraitLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IFaultyTraitSafeLibraryDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitSafeLibraryDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitSafeLibraryDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitSafeLibraryDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.class_hash, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitSafeLibraryDispatcher { - class_hash: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitSafeLibraryDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let class_hash = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeLibraryDispatcher { - class_hash, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitSafeLibraryDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.class_hash)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } -} -#[feature("derive-storage")] -impl DeriveStorageIFaultyTraitSafeLibraryDispatcher of starknet::storage_access::DeriveStorage:: {} -impl IFaultyTraitSafeDispatcherCopy of core::traits::Copy::; -impl IFaultyTraitSafeDispatcherDrop of core::traits::Drop::; -impl IFaultyTraitSafeDispatcherSerde of core::serde::Serde:: { - fn serialize(self: @IFaultyTraitSafeDispatcher, ref output: core::array::Array) { - core::serde::Serde::serialize(self.contract_address, ref output) - } - fn deserialize(ref serialized: core::array::Span) -> core::option::Option { - core::option::Option::Some(IFaultyTraitSafeDispatcher { - contract_address: core::serde::Serde::deserialize(ref serialized)?, - }) - } -} -impl StoreIFaultyTraitSafeDispatcher of starknet::Store:: { - fn read(address_domain: u32, base: starknet::storage_access::StorageBaseAddress) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read(address_domain, base)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeDispatcher { - contract_address, - } - ) - } - fn write(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, value: IFaultyTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write(address_domain, base, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - fn read_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8) -> starknet::SyscallResult { - let contract_address = starknet::Store::::read_at_offset(address_domain, base, offset)?; - starknet::SyscallResult::Ok( - IFaultyTraitSafeDispatcher { - contract_address, - } - ) - } - #[inline(always)] - fn write_at_offset(address_domain: u32, base: starknet::storage_access::StorageBaseAddress, offset: u8, value: IFaultyTraitSafeDispatcher) -> starknet::SyscallResult<()> { - starknet::Store::::write_at_offset(address_domain, base, offset, value.contract_address)?; - starknet::SyscallResult::Ok(()) - } - #[inline(always)] - fn size() -> u8 { - starknet::Store::::size() - } +#[derive(Print)] +enum Enemy { + Unknown, + Bot: felt252, + OtherPlayer: ContractAddress, } -#[feature("derive-storage")] -impl DeriveStorageIFaultyTraitSafeDispatcher of starknet::storage_access::DeriveStorage:: {}