diff --git a/.tool-versions b/.tool-versions deleted file mode 100644 index f6645f9..0000000 --- a/.tool-versions +++ /dev/null @@ -1 +0,0 @@ -scarb 2.9.2 diff --git a/backend/Cover.png b/backend/Cover.png deleted file mode 100644 index a87bd8a..0000000 Binary files a/backend/Cover.png and /dev/null differ diff --git a/backend/LICENSE b/backend/LICENSE deleted file mode 100644 index 0576e4a..0000000 --- a/backend/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2025 AkatsukiLabs - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/backend/dojo_examples/combat_game/LICENSE b/backend/dojo_examples/combat_game/LICENSE deleted file mode 100644 index d29b859..0000000 --- a/backend/dojo_examples/combat_game/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2023 Dojo - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/backend/dojo_examples/combat_game/README.md b/backend/dojo_examples/combat_game/README.md deleted file mode 100644 index 5626d30..0000000 --- a/backend/dojo_examples/combat_game/README.md +++ /dev/null @@ -1,68 +0,0 @@ -![Dojo Starter](./assets/cover.png) - - - - Dojo logo - - - - - - - - - -[![discord](https://img.shields.io/badge/join-dojo-green?logo=discord&logoColor=white)](https://discord.com/invite/dojoengine) -[![Telegram Chat][tg-badge]][tg-url] - -[tg-badge]: https://img.shields.io/endpoint?color=neon&logo=telegram&label=chat&style=flat-square&url=https%3A%2F%2Ftg.sumanjay.workers.dev%2Fdojoengine -[tg-url]: https://t.me/dojoengine - -# Dojo Starter: Official Guide - -A quickstart guide to help you build and deploy your first Dojo provable game. - -Read the full tutorial [here](https://dojoengine.org/tutorial/dojo-starter). - -## Running Locally - -#### Terminal one (Make sure this is running) - -```bash -# Run Katana -katana --dev --dev.no-fee -``` - -#### Terminal two - -```bash -# Build the example -sozo build - -# Inspect the world -sozo inspect - -# Migrate the example -sozo migrate - -# Start Torii -# Replace with the address of the deployed world from the previous step -torii --world --http.cors_origins "*" -``` - ---- - -## Contribution - -1. **Report a Bug** - - - If you think you have encountered a bug, and we should know about it, feel free to report it [here](https://github.com/dojoengine/dojo-starter/issues) and we will take care of it. - -2. **Request a Feature** - - - You can also request for a feature [here](https://github.com/dojoengine/dojo-starter/issues), and if it's viable, it will be picked for development. - -3. **Create a Pull Request** - - It can't get better then this, your pull request will be appreciated by the community. - -Happy coding! diff --git a/backend/dojo_examples/combat_game/Scarb.lock b/backend/dojo_examples/combat_game/Scarb.lock index 1cfac8d..fd7b434 100644 --- a/backend/dojo_examples/combat_game/Scarb.lock +++ b/backend/dojo_examples/combat_game/Scarb.lock @@ -1,18 +1,27 @@ # Code generated by scarb DO NOT EDIT. version = 1 +[[package]] +name = "achievement" +version = "0.0.0" +source = "git+https://github.com/cartridge-gg/arcade?tag=v1.2.1#8b8ccea5ec85ae7f903903ced9cd16e16b8e47cb" +dependencies = [ + "dojo", +] + [[package]] name = "combat_game" -version = "1.1.0" +version = "0.1.0" dependencies = [ + "achievement", "dojo", "dojo_cairo_test", ] [[package]] name = "dojo" -version = "1.1.1" -source = "git+https://github.com/dojoengine/dojo?tag=v1.1.1#dba10f26191bce47bb442ddc626ba7c6e2d8c160" +version = "1.2.1" +source = "git+https://github.com/dojoengine/dojo?tag=v1.2.1#3d4b1a3e662f70679813f9fb65c0b5c7fa5d6f0a" dependencies = [ "dojo_plugin", ] @@ -20,7 +29,7 @@ dependencies = [ [[package]] name = "dojo_cairo_test" version = "1.0.12" -source = "git+https://github.com/dojoengine/dojo?tag=v1.1.1#dba10f26191bce47bb442ddc626ba7c6e2d8c160" +source = "git+https://github.com/dojoengine/dojo?tag=v1.2.1#3d4b1a3e662f70679813f9fb65c0b5c7fa5d6f0a" dependencies = [ "dojo", ] @@ -28,4 +37,4 @@ dependencies = [ [[package]] name = "dojo_plugin" version = "2.9.2" -source = "git+https://github.com/dojoengine/dojo?tag=v1.1.1#dba10f26191bce47bb442ddc626ba7c6e2d8c160" +source = "git+https://github.com/dojoengine/dojo?tag=v1.2.1#3d4b1a3e662f70679813f9fb65c0b5c7fa5d6f0a" diff --git a/backend/dojo_examples/combat_game/Scarb.toml b/backend/dojo_examples/combat_game/Scarb.toml index 794bce2..860a7c3 100644 --- a/backend/dojo_examples/combat_game/Scarb.toml +++ b/backend/dojo_examples/combat_game/Scarb.toml @@ -1,21 +1,28 @@ [package] -cairo-version = "=2.9.2" +cairo-version = "2.9.2" name = "combat_game" -version = "1.1.0" -edition = "2024_07" +version = "0.1.0" +edition = "2023_11" [cairo] sierra-replace-ids = true [scripts] -migrate = "sozo build && sozo migrate" # scarb run migrate +sepolia = "sozo --profile sepolia clean && sozo --profile sepolia build && sozo --profile sepolia migrate --account-address $DEPLOYER_ACCOUNT_ADDRESS --private-key $DEPLOYER_PRIVATE_KEY --fee strk" [dependencies] -dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.1.1" } +dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.2.1" } +achievement = { git = "https://github.com/cartridge-gg/arcade", tag = "v1.2.1" } [[target.starknet-contract]] -build-external-contracts = ["dojo::world::world_contract::world"] +build-external-contracts = [ + "dojo::world::world_contract::world", + "achievement::events::index::e_TrophyCreation", + "achievement::events::index::e_TrophyProgression", +] [dev-dependencies] -cairo_test = "=2.9.2" -dojo_cairo_test = { git = "https://github.com/dojoengine/dojo", tag = "v1.1.1" } +cairo_test = "2.9.2" +dojo_cairo_test = { git = "https://github.com/dojoengine/dojo", tag = "v1.2.1" } + +[profile.sepolia] \ No newline at end of file diff --git a/backend/dojo_examples/combat_game/assets/cover.png b/backend/dojo_examples/combat_game/assets/cover.png deleted file mode 100644 index 8ac043f..0000000 Binary files a/backend/dojo_examples/combat_game/assets/cover.png and /dev/null differ diff --git a/backend/dojo_examples/combat_game/assets/icon.png b/backend/dojo_examples/combat_game/assets/icon.png deleted file mode 100644 index 2169b56..0000000 Binary files a/backend/dojo_examples/combat_game/assets/icon.png and /dev/null differ diff --git a/backend/dojo_examples/combat_game/dojo_dev.toml b/backend/dojo_examples/combat_game/dojo_dev.toml deleted file mode 100644 index da9274d..0000000 --- a/backend/dojo_examples/combat_game/dojo_dev.toml +++ /dev/null @@ -1,26 +0,0 @@ -[world] -name = "Dojo starter" -description = "The official Dojo Starter guide, the quickest and most streamlined way to get your Dojo Autonomous World up and running. This guide will assist you with the initial setup, from cloning the repository to deploying your world." -cover_uri = "file://assets/cover.png" -icon_uri = "file://assets/icon.png" -website = "https://github.com/dojoengine/dojo-starter" -seed = "dojo_starter" - -[world.socials] -x = "https://x.com/ohayo_dojo" -discord = "https://discord.gg/FB2wR6uF" -github = "https://github.com/dojoengine/dojo-starter" -telegram = "https://t.me/dojoengine" - -[namespace] -default = "dojo_starter" - -[env] -rpc_url = "http://localhost:5050/" -# Default account for katana with seed = 0 -account_address = "0x127fd5f1fe78a71f8bcd1fec63e3fe2f0486b6ecd5c86a0466c3a21fa5cfcec" -private_key = "0xc5b2fcab997346f3ea1c00b002ecf6f382c5f9c9659a3894eb783c5320f912" -# world_address = "0x06171ed98331e849d6084bf2b3e3186a7ddf35574dd68cab4691053ee8ab69d7" - -[writers] -"dojo_starter" = ["dojo_starter-actions"] diff --git a/backend/dojo_examples/combat_game/dojo_release.toml b/backend/dojo_examples/combat_game/dojo_release.toml deleted file mode 100644 index 3a24bf4..0000000 --- a/backend/dojo_examples/combat_game/dojo_release.toml +++ /dev/null @@ -1,26 +0,0 @@ -[world] -name = "Dojo starter" -description = "The official Dojo Starter guide, the quickest and most streamlined way to get your Dojo Autonomous World up and running. This guide will assist you with the initial setup, from cloning the repository to deploying your world." -cover_uri = "file://assets/cover.png" -icon_uri = "file://assets/icon.png" -website = "https://github.com/dojoengine/dojo-starter" -seed = "dojo_starter" - -[world.socials] -x = "https://x.com/ohayo_dojo" -discord = "https://discord.gg/FB2wR6uF" -github = "https://github.com/dojoengine/dojo-starter" -telegram = "https://t.me/dojoengine" - -[namespace] -default = "dojo_starter" - -[env] -rpc_url = "http://localhost:5050/" -# Default account for katana with seed = 0 -account_address = "0x127fd5f1fe78a71f8bcd1fec63e3fe2f0486b6ecd5c86a0466c3a21fa5cfcec" -private_key = "0xc5b2fcab997346f3ea1c00b002ecf6f382c5f9c9659a3894eb783c5320f912" -#world_address = "0x06171ed98331e849d6084bf2b3e3186a7ddf35574dd68cab4691053ee8ab69d7" # Uncomment and update this line with your world address. - -[writers] -"dojo_starter" = ["dojo_starter-actions"] diff --git a/backend/dojo_examples/combat_game/dojo_sepolia.toml b/backend/dojo_examples/combat_game/dojo_sepolia.toml new file mode 100644 index 0000000..220ac88 --- /dev/null +++ b/backend/dojo_examples/combat_game/dojo_sepolia.toml @@ -0,0 +1,15 @@ +[world] +name = "Combat Game" +description = "Combat Game is an example game to show Dojo/Cairo capabilities/features to onboard new devs in the ecosystem in a smooth way. Built using Dojo Engine and Cartridge Controller on Starknet." +seed = "combat_game" + +[namespace] +default = "combat_game" + +[env] +rpc_url = "https://api.cartridge.gg/x/starknet/sepolia" + +[writers] +"combat_game" = ["combat_game-game"] +"combat_game-TrophyCreation" = ["combat_game-game"] +"combat_game-TrophyProgression" = ["combat_game-game"] \ No newline at end of file diff --git a/backend/dojo_examples/combat_game/manifest_dev.json b/backend/dojo_examples/combat_game/manifest_dev.json deleted file mode 100644 index 9e6bdbc..0000000 --- a/backend/dojo_examples/combat_game/manifest_dev.json +++ /dev/null @@ -1,1513 +0,0 @@ -{ - "world": { - "class_hash": "0x45575a88cc5cef1e444c77ce60b7b4c9e73a01cbbe20926d5a4c72a94011410", - "address": "0x525177c8afe8680d7ad1da30ca183e482cfcd6404c1e09d83fd3fa2994fd4b8", - "seed": "dojo_starter", - "name": "Dojo starter", - "entrypoints": [ - "uuid", - "set_metadata", - "register_namespace", - "register_event", - "register_model", - "register_contract", - "init_contract", - "upgrade_event", - "upgrade_model", - "upgrade_contract", - "emit_event", - "emit_events", - "set_entity", - "set_entities", - "delete_entity", - "delete_entities", - "grant_owner", - "revoke_owner", - "grant_writer", - "revoke_writer", - "upgrade" - ], - "abi": [ - { - "type": "impl", - "name": "World", - "interface_name": "dojo::world::iworld::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": "enum", - "name": "dojo::world::resource::Resource", - "variants": [ - { - "name": "Model", - "type": "(core::starknet::contract_address::ContractAddress, core::felt252)" - }, - { - "name": "Event", - "type": "(core::starknet::contract_address::ContractAddress, core::felt252)" - }, - { - "name": "Contract", - "type": "(core::starknet::contract_address::ContractAddress, core::felt252)" - }, - { - "name": "Namespace", - "type": "core::byte_array::ByteArray" - }, - { - "name": "World", - "type": "()" - }, - { - "name": "Unregistered", - "type": "()" - } - ] - }, - { - "type": "struct", - "name": "dojo::model::metadata::ResourceMetadata", - "members": [ - { - "name": "resource_id", - "type": "core::felt252" - }, - { - "name": "metadata_uri", - "type": "core::byte_array::ByteArray" - }, - { - "name": "metadata_hash", - "type": "core::felt252" - } - ] - }, - { - "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::model::definition::ModelIndex", - "variants": [ - { - "name": "Keys", - "type": "core::array::Span::" - }, - { - "name": "Id", - "type": "core::felt252" - }, - { - "name": "MemberId", - "type": "(core::felt252, core::felt252)" - } - ] - }, - { - "type": "struct", - "name": "core::array::Span::", - "members": [ - { - "name": "snapshot", - "type": "@core::array::Array::" - } - ] - }, - { - "type": "struct", - "name": "dojo::meta::layout::FieldLayout", - "members": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "layout", - "type": "dojo::meta::layout::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::meta::layout::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": "enum", - "name": "core::bool", - "variants": [ - { - "name": "False", - "type": "()" - }, - { - "name": "True", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo::world::iworld::IWorld", - "items": [ - { - "type": "function", - "name": "resource", - "inputs": [ - { - "name": "selector", - "type": "core::felt252" - } - ], - "outputs": [ - { - "type": "dojo::world::resource::Resource" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "uuid", - "inputs": [], - "outputs": [ - { - "type": "core::integer::u32" - } - ], - "state_mutability": "external" - }, - { - "type": "function", - "name": "metadata", - "inputs": [ - { - "name": "resource_selector", - "type": "core::felt252" - } - ], - "outputs": [ - { - "type": "dojo::model::metadata::ResourceMetadata" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "set_metadata", - "inputs": [ - { - "name": "metadata", - "type": "dojo::model::metadata::ResourceMetadata" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "register_namespace", - "inputs": [ - { - "name": "namespace", - "type": "core::byte_array::ByteArray" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "register_event", - "inputs": [ - { - "name": "namespace", - "type": "core::byte_array::ByteArray" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "register_model", - "inputs": [ - { - "name": "namespace", - "type": "core::byte_array::ByteArray" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "register_contract", - "inputs": [ - { - "name": "salt", - "type": "core::felt252" - }, - { - "name": "namespace", - "type": "core::byte_array::ByteArray" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [ - { - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "state_mutability": "external" - }, - { - "type": "function", - "name": "init_contract", - "inputs": [ - { - "name": "selector", - "type": "core::felt252" - }, - { - "name": "init_calldata", - "type": "core::array::Span::" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "upgrade_event", - "inputs": [ - { - "name": "namespace", - "type": "core::byte_array::ByteArray" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "upgrade_model", - "inputs": [ - { - "name": "namespace", - "type": "core::byte_array::ByteArray" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "upgrade_contract", - "inputs": [ - { - "name": "namespace", - "type": "core::byte_array::ByteArray" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ], - "outputs": [ - { - "type": "core::starknet::class_hash::ClassHash" - } - ], - "state_mutability": "external" - }, - { - "type": "function", - "name": "emit_event", - "inputs": [ - { - "name": "event_selector", - "type": "core::felt252" - }, - { - "name": "keys", - "type": "core::array::Span::" - }, - { - "name": "values", - "type": "core::array::Span::" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "emit_events", - "inputs": [ - { - "name": "event_selector", - "type": "core::felt252" - }, - { - "name": "keys", - "type": "core::array::Span::>" - }, - { - "name": "values", - "type": "core::array::Span::>" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "entity", - "inputs": [ - { - "name": "model_selector", - "type": "core::felt252" - }, - { - "name": "index", - "type": "dojo::model::definition::ModelIndex" - }, - { - "name": "layout", - "type": "dojo::meta::layout::Layout" - } - ], - "outputs": [ - { - "type": "core::array::Span::" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "entities", - "inputs": [ - { - "name": "model_selector", - "type": "core::felt252" - }, - { - "name": "indexes", - "type": "core::array::Span::" - }, - { - "name": "layout", - "type": "dojo::meta::layout::Layout" - } - ], - "outputs": [ - { - "type": "core::array::Span::>" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "set_entity", - "inputs": [ - { - "name": "model_selector", - "type": "core::felt252" - }, - { - "name": "index", - "type": "dojo::model::definition::ModelIndex" - }, - { - "name": "values", - "type": "core::array::Span::" - }, - { - "name": "layout", - "type": "dojo::meta::layout::Layout" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "set_entities", - "inputs": [ - { - "name": "model_selector", - "type": "core::felt252" - }, - { - "name": "indexes", - "type": "core::array::Span::" - }, - { - "name": "values", - "type": "core::array::Span::>" - }, - { - "name": "layout", - "type": "dojo::meta::layout::Layout" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "delete_entity", - "inputs": [ - { - "name": "model_selector", - "type": "core::felt252" - }, - { - "name": "index", - "type": "dojo::model::definition::ModelIndex" - }, - { - "name": "layout", - "type": "dojo::meta::layout::Layout" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "delete_entities", - "inputs": [ - { - "name": "model_selector", - "type": "core::felt252" - }, - { - "name": "indexes", - "type": "core::array::Span::" - }, - { - "name": "layout", - "type": "dojo::meta::layout::Layout" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "is_owner", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [ - { - "type": "core::bool" - } - ], - "state_mutability": "view" - }, - { - "type": "function", - "name": "grant_owner", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "revoke_owner", - "inputs": [ - { - "name": "resource", - "type": "core::felt252" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress" - } - ], - "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": "impl", - "name": "UpgradeableWorld", - "interface_name": "dojo::world::iworld::IUpgradeableWorld" - }, - { - "type": "interface", - "name": "dojo::world::iworld::IUpgradeableWorld", - "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": [ - { - "name": "world_class_hash", - "type": "core::starknet::class_hash::ClassHash" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::WorldSpawned", - "kind": "struct", - "members": [ - { - "name": "creator", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::WorldUpgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::NamespaceRegistered", - "kind": "struct", - "members": [ - { - "name": "namespace", - "type": "core::byte_array::ByteArray", - "kind": "key" - }, - { - "name": "hash", - "type": "core::felt252", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::ModelRegistered", - "kind": "struct", - "members": [ - { - "name": "name", - "type": "core::byte_array::ByteArray", - "kind": "key" - }, - { - "name": "namespace", - "type": "core::byte_array::ByteArray", - "kind": "key" - }, - { - "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_contract::world::EventRegistered", - "kind": "struct", - "members": [ - { - "name": "name", - "type": "core::byte_array::ByteArray", - "kind": "key" - }, - { - "name": "namespace", - "type": "core::byte_array::ByteArray", - "kind": "key" - }, - { - "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_contract::world::ContractRegistered", - "kind": "struct", - "members": [ - { - "name": "name", - "type": "core::byte_array::ByteArray", - "kind": "key" - }, - { - "name": "namespace", - "type": "core::byte_array::ByteArray", - "kind": "key" - }, - { - "name": "address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "data" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - }, - { - "name": "salt", - "type": "core::felt252", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::ModelUpgraded", - "kind": "struct", - "members": [ - { - "name": "selector", - "type": "core::felt252", - "kind": "key" - }, - { - "name": "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_contract::world::EventUpgraded", - "kind": "struct", - "members": [ - { - "name": "selector", - "type": "core::felt252", - "kind": "key" - }, - { - "name": "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_contract::world::ContractUpgraded", - "kind": "struct", - "members": [ - { - "name": "selector", - "type": "core::felt252", - "kind": "key" - }, - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::ContractInitialized", - "kind": "struct", - "members": [ - { - "name": "selector", - "type": "core::felt252", - "kind": "key" - }, - { - "name": "init_calldata", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::EventEmitted", - "kind": "struct", - "members": [ - { - "name": "selector", - "type": "core::felt252", - "kind": "key" - }, - { - "name": "system_address", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "key" - }, - { - "name": "keys", - "type": "core::array::Span::", - "kind": "data" - }, - { - "name": "values", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::MetadataUpdate", - "kind": "struct", - "members": [ - { - "name": "resource", - "type": "core::felt252", - "kind": "key" - }, - { - "name": "uri", - "type": "core::byte_array::ByteArray", - "kind": "data" - }, - { - "name": "hash", - "type": "core::felt252", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::StoreSetRecord", - "kind": "struct", - "members": [ - { - "name": "selector", - "type": "core::felt252", - "kind": "key" - }, - { - "name": "entity_id", - "type": "core::felt252", - "kind": "key" - }, - { - "name": "keys", - "type": "core::array::Span::", - "kind": "data" - }, - { - "name": "values", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::StoreUpdateRecord", - "kind": "struct", - "members": [ - { - "name": "selector", - "type": "core::felt252", - "kind": "key" - }, - { - "name": "entity_id", - "type": "core::felt252", - "kind": "key" - }, - { - "name": "values", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::StoreUpdateMember", - "kind": "struct", - "members": [ - { - "name": "selector", - "type": "core::felt252", - "kind": "key" - }, - { - "name": "entity_id", - "type": "core::felt252", - "kind": "key" - }, - { - "name": "member_selector", - "type": "core::felt252", - "kind": "key" - }, - { - "name": "values", - "type": "core::array::Span::", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::StoreDelRecord", - "kind": "struct", - "members": [ - { - "name": "selector", - "type": "core::felt252", - "kind": "key" - }, - { - "name": "entity_id", - "type": "core::felt252", - "kind": "key" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::WriterUpdated", - "kind": "struct", - "members": [ - { - "name": "resource", - "type": "core::felt252", - "kind": "key" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "key" - }, - { - "name": "value", - "type": "core::bool", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::OwnerUpdated", - "kind": "struct", - "members": [ - { - "name": "resource", - "type": "core::felt252", - "kind": "key" - }, - { - "name": "contract", - "type": "core::starknet::contract_address::ContractAddress", - "kind": "key" - }, - { - "name": "value", - "type": "core::bool", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::world::world_contract::world::Event", - "kind": "enum", - "variants": [ - { - "name": "WorldSpawned", - "type": "dojo::world::world_contract::world::WorldSpawned", - "kind": "nested" - }, - { - "name": "WorldUpgraded", - "type": "dojo::world::world_contract::world::WorldUpgraded", - "kind": "nested" - }, - { - "name": "NamespaceRegistered", - "type": "dojo::world::world_contract::world::NamespaceRegistered", - "kind": "nested" - }, - { - "name": "ModelRegistered", - "type": "dojo::world::world_contract::world::ModelRegistered", - "kind": "nested" - }, - { - "name": "EventRegistered", - "type": "dojo::world::world_contract::world::EventRegistered", - "kind": "nested" - }, - { - "name": "ContractRegistered", - "type": "dojo::world::world_contract::world::ContractRegistered", - "kind": "nested" - }, - { - "name": "ModelUpgraded", - "type": "dojo::world::world_contract::world::ModelUpgraded", - "kind": "nested" - }, - { - "name": "EventUpgraded", - "type": "dojo::world::world_contract::world::EventUpgraded", - "kind": "nested" - }, - { - "name": "ContractUpgraded", - "type": "dojo::world::world_contract::world::ContractUpgraded", - "kind": "nested" - }, - { - "name": "ContractInitialized", - "type": "dojo::world::world_contract::world::ContractInitialized", - "kind": "nested" - }, - { - "name": "EventEmitted", - "type": "dojo::world::world_contract::world::EventEmitted", - "kind": "nested" - }, - { - "name": "MetadataUpdate", - "type": "dojo::world::world_contract::world::MetadataUpdate", - "kind": "nested" - }, - { - "name": "StoreSetRecord", - "type": "dojo::world::world_contract::world::StoreSetRecord", - "kind": "nested" - }, - { - "name": "StoreUpdateRecord", - "type": "dojo::world::world_contract::world::StoreUpdateRecord", - "kind": "nested" - }, - { - "name": "StoreUpdateMember", - "type": "dojo::world::world_contract::world::StoreUpdateMember", - "kind": "nested" - }, - { - "name": "StoreDelRecord", - "type": "dojo::world::world_contract::world::StoreDelRecord", - "kind": "nested" - }, - { - "name": "WriterUpdated", - "type": "dojo::world::world_contract::world::WriterUpdated", - "kind": "nested" - }, - { - "name": "OwnerUpdated", - "type": "dojo::world::world_contract::world::OwnerUpdated", - "kind": "nested" - } - ] - } - ] - }, - "contracts": [ - { - "address": "0x73a20bf1f5ebe9caf16bc08fb07434618300a55a764395a22f4fdde8237a547", - "class_hash": "0x6cbb5ab40ad7b48dff70edeacc4902a9eeae63a9e36456f9f908aedb904fbd2", - "abi": [ - { - "type": "impl", - "name": "actions__ContractImpl", - "interface_name": "dojo::contract::interface::IContract" - }, - { - "type": "interface", - "name": "dojo::contract::interface::IContract", - "items": [] - }, - { - "type": "impl", - "name": "actions__DeployedContractImpl", - "interface_name": "dojo::meta::interface::IDeployedResource" - }, - { - "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::meta::interface::IDeployedResource", - "items": [ - { - "type": "function", - "name": "dojo_name", - "inputs": [], - "outputs": [ - { - "type": "core::byte_array::ByteArray" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "ActionsImpl", - "interface_name": "dojo_starter::systems::actions::IActions" - }, - { - "type": "enum", - "name": "dojo_starter::models::model::Direction", - "variants": [ - { - "name": "Left", - "type": "()" - }, - { - "name": "Right", - "type": "()" - }, - { - "name": "Up", - "type": "()" - }, - { - "name": "Down", - "type": "()" - } - ] - }, - { - "type": "interface", - "name": "dojo_starter::systems::actions::IActions", - "items": [ - { - "type": "function", - "name": "spawn", - "inputs": [], - "outputs": [], - "state_mutability": "external" - }, - { - "type": "function", - "name": "move", - "inputs": [ - { - "name": "direction", - "type": "dojo_starter::models::model::Direction" - } - ], - "outputs": [], - "state_mutability": "external" - } - ] - }, - { - "type": "function", - "name": "dojo_init", - "inputs": [], - "outputs": [], - "state_mutability": "view" - }, - { - "type": "impl", - "name": "WorldProviderImpl", - "interface_name": "dojo::contract::components::world_provider::IWorldProvider" - }, - { - "type": "struct", - "name": "dojo::world::iworld::IWorldDispatcher", - "members": [ - { - "name": "contract_address", - "type": "core::starknet::contract_address::ContractAddress" - } - ] - }, - { - "type": "interface", - "name": "dojo::contract::components::world_provider::IWorldProvider", - "items": [ - { - "type": "function", - "name": "world_dispatcher", - "inputs": [], - "outputs": [ - { - "type": "dojo::world::iworld::IWorldDispatcher" - } - ], - "state_mutability": "view" - } - ] - }, - { - "type": "impl", - "name": "UpgradeableImpl", - "interface_name": "dojo::contract::components::upgradeable::IUpgradeable" - }, - { - "type": "interface", - "name": "dojo::contract::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::contract::components::upgradeable::upgradeable_cpt::Upgraded", - "kind": "struct", - "members": [ - { - "name": "class_hash", - "type": "core::starknet::class_hash::ClassHash", - "kind": "data" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::components::upgradeable::upgradeable_cpt::Event", - "kind": "enum", - "variants": [ - { - "name": "Upgraded", - "type": "dojo::contract::components::upgradeable::upgradeable_cpt::Upgraded", - "kind": "nested" - } - ] - }, - { - "type": "event", - "name": "dojo::contract::components::world_provider::world_provider_cpt::Event", - "kind": "enum", - "variants": [] - }, - { - "type": "event", - "name": "dojo_starter::systems::actions::actions::Event", - "kind": "enum", - "variants": [ - { - "name": "UpgradeableEvent", - "type": "dojo::contract::components::upgradeable::upgradeable_cpt::Event", - "kind": "nested" - }, - { - "name": "WorldProviderEvent", - "type": "dojo::contract::components::world_provider::world_provider_cpt::Event", - "kind": "nested" - } - ] - } - ], - "init_calldata": [], - "tag": "dojo_starter-actions", - "selector": "0x7a1c71029f2d0b38e3ac89b09931d08b6e48417e079c289ff19a8698d0cba33", - "systems": [ - "spawn", - "move", - "upgrade" - ] - } - ], - "models": [ - { - "members": [], - "class_hash": "0x3f52c6cf17db224f4e7f88629adf7e907ff110baa0616c7e8ef17c5aecf1b1b", - "tag": "dojo_starter-DirectionsAvailable", - "selector": "0x77844f1facb51e60e546a9832d56c6bd04fa23be4fd5b57290caae5e9a3c1e4" - }, - { - "members": [], - "class_hash": "0x5f79e21312b142fc289d3bd1e0f4c65ac3c4e532252c6fb1ad48b718d892dc", - "tag": "dojo_starter-Moves", - "selector": "0x2a29373f1af8348bd366a990eb3a342ef2cbe5e85160539eaca3441a673f468" - }, - { - "members": [], - "class_hash": "0x2283c68ecba5c60bbbbd3b00659808a02244468e41a1d2cdba1312d65b83594", - "tag": "dojo_starter-Position", - "selector": "0x2ac8b4c190f7031b9fc44312e6b047a1dce0b3f2957c33a935ca7846a46dd5b" - } - ], - "events": [ - { - "members": [], - "class_hash": "0x3dca5564f84050b20e66a2e5e7619201502d241b223ea73cfc05f29e6e20ea1", - "tag": "dojo_starter-Moved", - "selector": "0x504403e5c02b6442527721fc464d9ea5fc8f1ee600ab5ccd5c0845d36fd45f1" - } - ] -} \ No newline at end of file diff --git a/backend/dojo_examples/combat_game/src/helpers/timestamp.cairo b/backend/dojo_examples/combat_game/src/helpers/timestamp.cairo index 0b3cb26..de5cf1f 100644 --- a/backend/dojo_examples/combat_game/src/helpers/timestamp.cairo +++ b/backend/dojo_examples/combat_game/src/helpers/timestamp.cairo @@ -1,45 +1,12 @@ +// Core imports +use core::traits::TryInto; + +// Constants imports use combat_game::constants; -use core::panic::panic_with_felt252; #[generate_trait] pub impl Timestamp of TimestampTrait { fn unix_timestamp_to_day(timestamp: u64) -> u32 { - // calculate convertion - let days: u64 = timestamp / constants::SECONDS_PER_DAY; - - match days.try_into() { - Result::Ok(day_u32) => day_u32, - // handle error of overflow in size - Result::Err(_) => { - panic_with_felt252('Timestamp conversion overflow'); - } - } - } -} - -#[cfg(test)] -mod tests { - use super::TimestampTrait; - use combat_game::constants; - use core::panic::catch_panic; - - #[test] - fn test_unix_timestamp_to_day_valid() { - // 2 days worth of seconds - let timestamp: u64 = 2 * constants::SECONDS_PER_DAY; - let day = TimestampTrait::unix_timestamp_to_day(timestamp); - assert(day == 2, 'Should return 2 days'); - } - - #[test] - fn test_unix_timestamp_to_day_overflow() { - // This timestamp will result in days > u32::MAX - let timestamp: u64 = (u32::MAX as u64 + 1) * constants::SECONDS_PER_DAY; - let result = catch_panic(|| { - TimestampTrait::unix_timestamp_to_day(timestamp); - }); - assert(result.is_err(), 'Should panic on overflow'); + (timestamp / constants::SECONDS_PER_DAY).try_into().unwrap() } } - - diff --git a/backend/dojo_examples/combat_game/src/lib.cairo b/backend/dojo_examples/combat_game/src/lib.cairo index 957eeaf..387f3d1 100644 --- a/backend/dojo_examples/combat_game/src/lib.cairo +++ b/backend/dojo_examples/combat_game/src/lib.cairo @@ -13,7 +13,9 @@ mod models { } mod systems { - mod battle; + pub mod battle; + pub mod player; + pub mod beast; } mod types { @@ -28,6 +30,7 @@ mod types { mod helpers { pub mod pseudo_random; + pub mod timestamp; } pub mod utils { diff --git a/backend/dojo_examples/combat_game/torii_config.toml b/backend/dojo_examples/combat_game/torii_config.toml new file mode 100644 index 0000000..627eaac --- /dev/null +++ b/backend/dojo_examples/combat_game/torii_config.toml @@ -0,0 +1,19 @@ +# The World address to index. +world_address = "" + +# Default RPC URL configuration +rpc = "https://api.cartridge.gg/x/starknet/sepolia" + +# Indexing Options +[indexing] +allowed_origins = ["*"] +transactions = true +pending = true +polling_interval = 1000 +contracts = [] + +[events] +raw = true + +[sql] +historical = ["combat_game-TrophyProgression"] \ No newline at end of file