From 9164ba84c6b7f17f731b886d3de08112d38804e8 Mon Sep 17 00:00:00 2001 From: PoulavBhowmick03 Date: Mon, 4 Nov 2024 03:41:25 +0530 Subject: [PATCH] initial --- .github/mark-dark.svg | 4 + .github/mark-light.svg | 4 + .github/workflows/release.yml | 43 ++ .github/workflows/test.yaml | 25 + .gitignore | 1 + .vscode/settings.json | 5 + LICENSE | 21 + README.md | 65 ++ Scarb.lock | 31 + Scarb.toml | 22 + assets/cover.png | Bin 0 -> 19098 bytes assets/icon.png | Bin 0 -> 2222 bytes dojo_dev.toml | 26 + dojo_release.toml | 26 + manifest_dev.json | 1367 +++++++++++++++++++++++++++++++++ scripts/move.sh | 10 + scripts/spawn.sh | 10 + src/lib.cairo | 9 + src/models.cairo | 29 + src/systems/actions.cairo | 106 +++ src/tests/test_world.cairo | 83 ++ 21 files changed, 1887 insertions(+) create mode 100644 .github/mark-dark.svg create mode 100644 .github/mark-light.svg create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/test.yaml create mode 100644 .gitignore create mode 100644 .vscode/settings.json create mode 100644 LICENSE create mode 100644 README.md create mode 100644 Scarb.lock create mode 100644 Scarb.toml create mode 100644 assets/cover.png create mode 100644 assets/icon.png create mode 100644 dojo_dev.toml create mode 100644 dojo_release.toml create mode 100644 manifest_dev.json create mode 100755 scripts/move.sh create mode 100755 scripts/spawn.sh create mode 100644 src/lib.cairo create mode 100644 src/models.cairo create mode 100644 src/systems/actions.cairo create mode 100644 src/tests/test_world.cairo diff --git a/.github/mark-dark.svg b/.github/mark-dark.svg new file mode 100644 index 0000000..4fb9b26 --- /dev/null +++ b/.github/mark-dark.svg @@ -0,0 +1,4 @@ + + + + diff --git a/.github/mark-light.svg b/.github/mark-light.svg new file mode 100644 index 0000000..01cb677 --- /dev/null +++ b/.github/mark-light.svg @@ -0,0 +1,4 @@ + + + + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..17be3f2 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,43 @@ +name: Release + +on: + workflow_dispatch: + inputs: + version: + description: 'Version to release (e.g., v1.0.0)' + required: true + type: string + dojo_version: + description: 'Dojo version to use' + required: true + type: string + +jobs: + create-release: + runs-on: ubuntu-latest + env: + DOJO_VERSION: ${{ inputs.dojo_version }} + steps: + - uses: actions/checkout@v3 + + # Setup and test with specified Dojo version + - run: curl -L https://install.dojoengine.org | bash + - run: /home/runner/.config/.dojo/bin/dojoup -v ${{ env.DOJO_VERSION }} + - run: | + /home/runner/.config/.dojo/bin/sozo build + /home/runner/.config/.dojo/bin/sozo test + + # Create tag and release + - name: Create Tag + run: | + git tag ${{ inputs.version }} + git push origin ${{ inputs.version }} + + - name: Create Release + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ inputs.version }} + name: Release ${{ inputs.version }} + draft: false + prerelease: false + generate_release_notes: true \ No newline at end of file diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..182d9cb --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,25 @@ +name: CI + +on: + push: + branches: + - "main" + pull_request: + +jobs: + sozo-test: + runs-on: ubuntu-latest + env: + DOJO_VERSION: v1.0.0-rc.0 + steps: + - uses: actions/checkout@v3 + - run: curl -L https://install.dojoengine.org | bash + - run: /home/runner/.config/.dojo/bin/dojoup -v ${{ env.DOJO_VERSION }} + - run: | + /home/runner/.config/.dojo/bin/sozo build + /home/runner/.config/.dojo/bin/sozo test + if [[ `git status --porcelain` ]]; then + echo The git repo is dirty + echo "Make sure to run \"sozo build\" after changing Scarb.toml" + exit 1 + fi \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1de5659 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +target \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..a47ae42 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "cairo1.enableLanguageServer": true, + "cairo1.enableScarb": true, + "cairo1.languageServerPath": "${userHome}/.dojo/bin/dojo-language-server" +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d29b859 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +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/README.md b/README.md new file mode 100644 index 0000000..ae61c33 --- /dev/null +++ b/README.md @@ -0,0 +1,65 @@ +![Dojo Starter](./assets/cover.png) + + + + Dojo logo + + + + + + + + + +[![discord](https://img.shields.io/badge/join-dojo-green?logo=discord&logoColor=white)](https://discord.gg/PwDa2mKhR4) +[![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 --disable-fee --allowed-origins "*" +``` + +#### Terminal two + +```bash +# Build the example +sozo build + +# Migrate the example +sozo migrate + +# Start Torii +# Replace with the address of the deployed world from the previous step +torii --world --allowed-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/Scarb.lock b/Scarb.lock new file mode 100644 index 0000000..ea64d8c --- /dev/null +++ b/Scarb.lock @@ -0,0 +1,31 @@ +# Code generated by scarb DO NOT EDIT. +version = 1 + +[[package]] +name = "dojo" +version = "1.0.0-rc.0" +source = "git+https://github.com/dojoengine/dojo?tag=v1.0.0-rc.0#f4199aec570a395278b8c8748bc46e2f6be3d0c7" +dependencies = [ + "dojo_plugin", +] + +[[package]] +name = "dojo_cairo_test" +version = "1.0.0-rc.0" +source = "git+https://github.com/dojoengine/dojo?tag=v1.0.0-rc.0#f4199aec570a395278b8c8748bc46e2f6be3d0c7" +dependencies = [ + "dojo", +] + +[[package]] +name = "dojo_plugin" +version = "2.8.4" +source = "git+https://github.com/dojoengine/dojo?tag=v1.0.0-rc.0#f4199aec570a395278b8c8748bc46e2f6be3d0c7" + +[[package]] +name = "dojo_starter" +version = "1.0.0-rc.0" +dependencies = [ + "dojo", + "dojo_cairo_test", +] diff --git a/Scarb.toml b/Scarb.toml new file mode 100644 index 0000000..65bdd32 --- /dev/null +++ b/Scarb.toml @@ -0,0 +1,22 @@ +[package] +cairo-version = "=2.8.4" +name = "dojo_starter" +version = "1.0.0-rc.0" + +[cairo] +sierra-replace-ids = true + +[scripts] +migrate = "sozo build && sozo migrate apply" +spawn = "./scripts/spawn.sh" +move = "./scripts/move.sh" + +[dependencies] +dojo = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-rc.0" } + +[[target.starknet-contract]] +build-external-contracts = ["dojo::world::world_contract::world"] + + +[dev-dependencies] +dojo_cairo_test = { git = "https://github.com/dojoengine/dojo", tag = "v1.0.0-rc.0" } diff --git a/assets/cover.png b/assets/cover.png new file mode 100644 index 0000000000000000000000000000000000000000..8ac043f479414ef58a3cdba11e5fc8ca080ce67e GIT binary patch literal 19098 zcmdqJXH-)``!5P2y^Dy{fHV~(0s<QLkPwj2NueerB-|bK{jc}j^Xaa2*ZFWhWo6IP=9$@h&z|3Jo;$}~9pz;- zWJE+n68RfCDZEL`2HdWLGbW1OG)M+#T&j-nDB@ z0e^J;j<~ysh{PC)h{Pp`h;V^Rag!n<*LRADOkWTY*_$gOq846Ibz&dT&~e=PkOc@s}5U3=**jxvVFWQ|;9ja_97j>>I4A+2{%ddneMBNrJX7rAXG<+gc9>pRLB zAD7>LT3YXr6zG5?=z!ezlhT0j_R~_j2c>ln$^h23os<>IoRrZ&Dr0a=ew&Akp^L1c zi_8{B=`9BpO;4%Yg=-&-)pxmPd@|ecc!u85M72FZvW7=ht^76jUk5qHsaRZ)-*#MW z&sA0H%PN*I!xI_m`@)sM=j6A!sapH%9ZgaOd#PAn(09G3cPvqJf0VXEto+vFvRhA( zvc}zjEQmNAJa96)fL<69JLnHjyyE`z?q}1p8|eo#w0nN_->LXq<(jn=igOtVSz8Nx z%~4QVA1;v_;IH$oAg$`iy2=}oDx2eL0w0*VH6A&$NqonYblVe)mV*i{(iJbIo1T1V z@mSxottnHGU^)f-d~k|{qITjVf-8p!dB=7d1ZdrhKWP0m-e$e8#n_qdjc47Ps~=6G zu@~T&#`n)AIy3DV4+|npr^PE?if;O%*9ql|H)Wb-7$%ZS?=aZXM(iB9V={Qpc-4Z- zJHy3yT#XYClQLkdH)Z-a1FF3T*}U~xw#o3Z><2FI2$S^KvorpW71=x}b?n!(OntYSBtxz0 zdcnigmg*|KEWW=+j9W9S+-`67D`rsOiKe2nl*|C5DVtH~i@;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g#8(46LP1)hivS`Xm~m_ngHj=`d%3jD`7r<9qJNFH?2n{J}J_^E}zd90$ zI=HLzG68iAFjhA>^7iobVxb;!U))B9FB5(7!ok=shz}*z8BM)bRe%N|;q9j@7Y-Lb zKvM4f%!!E3hLXUcT-k~=sIV5RDB-BaUi_i|lUh2EqfU|9%Dx4x9p?J;Iy{J4(`BYZ zEWu}OyT-2}mxKoh1zc=wk9xFgrw4mNs;W0XAutT*4>U2TN|G^-GlDrsaQv6Mu3!+H zwWrHUS`J!i1V>4$l#+tG%xRj^H&R0B|r6$n2>Mf@w7n! zqI7?gueEUS_AP8PtMKZ7wX_M1^t{?**}Yi3&3s)Ze;~zS%V%{T{m0+8#C(P5EW?hH zq1zqN~?j_xu5Rx*d_-A zbr(ko5&y}-k-1Q~)vV88@D50>8O$1-$Dc4J3!sTw+~dFp)c6jG+Q0vKZUVFGrp2aq?Se-lYf&$ ztQ`^B;K}n)su@SpRf&|N$~wWmy>5Q>Qc@{b96GP2DAK&7BfQ2d7#HsBKHqq}>`c>W zK*Swlk!H$sP--w@r(+Jf>t zo{2qy^3;Ny4xpRSZ+0W5G=DK=@+B%G&m^qu5oBg7Z2TzRVPV1%Eh1+tgnSP!8h$rA zCUf+SIbIl13MOoA0y!5-SLAGf0X@-U%pn*sh0@180ur&F7x`waTY50FQPhn&1&+|l}qHJpkjrfT<_{00vl&L-udAW@?Wj}DU*z5?oh zDHrO#vCy{3G@N0lEqzFXMURq~9cVHW%jM8%V!a%?hH{rXgLwXM=Z(KGJ@7PKKEVz? zxl1_93BEL4@vPx_W6k*X|H$7f)qnlZgB_~FmR5~!K)j3jV^q9sNO3trEOtJX@IS1j By|@4X literal 0 HcmV?d00001 diff --git a/dojo_dev.toml b/dojo_dev.toml new file mode 100644 index 0000000..6453db8 --- /dev/null +++ b/dojo_dev.toml @@ -0,0 +1,26 @@ +[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 = "0x3b34889efbdf01f707d5d7421f112e8fb85a42fb6f2e5422c75ce3253148b0e" + +[writers] +"dojo_starter" = ["dojo_starter-actions"] diff --git a/dojo_release.toml b/dojo_release.toml new file mode 100644 index 0000000..39c15ed --- /dev/null +++ b/dojo_release.toml @@ -0,0 +1,26 @@ +[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 = "0xb3ff441a68610b30fd5e2abbf3a1548eb6ba6f3559f2862bf2dc757e5828ca" +private_key = "0x2bbf4f9fd0bbb2e60b0316c1fe0b76cf7a4d0198bd493ced9b8df2a3a24d68a" +# world_address = "0x3fc79ccfd72c1450d2ccb73c5c521a7ec68b6c6af0caf96a0f1c39ce58876c8" # Uncomment and update this line with your world address. + +[writers] +"dojo_starter" = ["dojo_starter-actions"] diff --git a/manifest_dev.json b/manifest_dev.json new file mode 100644 index 0000000..7043a8d --- /dev/null +++ b/manifest_dev.json @@ -0,0 +1,1367 @@ +{ + "world": { + "class_hash": "0x139239a99d627697b19b9856beaef7896fc75375caf3d750dd76982a7afeb78", + "address": "0x6171ed98331e849d6084bf2b3e3186a7ddf35574dd68cab4691053ee8ab69d7", + "seed": "dojo_starter", + "name": "Dojo starter", + "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" + } + ] + }, + { + "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": "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": "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::" + }, + { + "name": "historical", + "type": "core::bool" + } + ], + "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": "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": "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": "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": "historical", + "type": "core::bool", + "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" + } + ] + }, + { + "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": "0x32ae31b916aa0528d040a31ce9ce6d8f3b5f87a93a39aa1a1c5fdee2c2dadad", + "class_hash": "0x436f2cc1c67462f7cce7f917a82c1e45870080eddf94e09609d8b72d52fd8c1", + "abi": [ + { + "type": "impl", + "name": "actions__ContractImpl", + "interface_name": "dojo::contract::interface::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::interface::IContract", + "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::Direction", + "variants": [ + { + "name": "None", + "type": "()" + }, + { + "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::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", + "systems": [] + } + ], + "models": [ + { + "members": [], + "class_hash": "0x7ba1920c35f44c82d82d0ff47cbbf04e60226c28027b1a45731aa07bceea9d1", + "tag": "DirectionsAvailable" + }, + { + "members": [], + "class_hash": "0x469117d9c5cac8ee02e521addae16a36da3571b2d977971395771d4c2db73e0", + "tag": "Moves" + }, + { + "members": [], + "class_hash": "0x445a1f5bdb78726083b9b577e775e066f6145f0240162d59f105a1251c2b016", + "tag": "Position" + } + ], + "events": [ + { + "members": [], + "class_hash": "0x5f6b87c8f5260f907795382b962e1f04ab0e98b754b6946eedcee27921819a9", + "tag": "Moved" + } + ] +} \ No newline at end of file diff --git a/scripts/move.sh b/scripts/move.sh new file mode 100755 index 0000000..69c61b2 --- /dev/null +++ b/scripts/move.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -euo pipefail +pushd $(dirname "$0")/.. + +export RPC_URL="http://localhost:5050"; + +export WORLD_ADDRESS=$(cat ./manifests/dev/manifest.json | jq -r '.world.address') + +# sozo execute --world +sozo execute --world $WORLD_ADDRESS dojo_starter::systems::actions::actions move -c 1 --wait diff --git a/scripts/spawn.sh b/scripts/spawn.sh new file mode 100755 index 0000000..e63f57e --- /dev/null +++ b/scripts/spawn.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -euo pipefail +pushd $(dirname "$0")/.. + +export RPC_URL="http://localhost:5050"; + +export WORLD_ADDRESS=$(cat ./manifests/dev/manifest.json | jq -r '.world.address') + +# sozo execute --world +sozo execute --world $WORLD_ADDRESS dojo_starter::systems::actions::actions spawn --wait diff --git a/src/lib.cairo b/src/lib.cairo new file mode 100644 index 0000000..786bb77 --- /dev/null +++ b/src/lib.cairo @@ -0,0 +1,9 @@ +mod systems { + mod actions; +} + +mod models; + +mod tests { + mod test_world; +} diff --git a/src/models.cairo b/src/models.cairo new file mode 100644 index 0000000..498459a --- /dev/null +++ b/src/models.cairo @@ -0,0 +1,29 @@ +use starknet::ContractAddress; + +#[derive(Copy, Drop, Serde, Debug)] +#[dojo::model] +pub struct PlayerBalance { + #[key] + pub player: ContractAddress, + pub balance: u128, // The balance in STRK tokens + pub total_games: u64, // Total games played + pub wins: u64, // Total wins + pub losses: u64, // Total losses +} + +#[derive(Copy, Drop, Serde, Debug)] +#[dojo::model] +pub struct PlatformFees { + #[key] + pub admin: ContractAddress, + pub fee_percentage: u8, // Platform fee percentage, e.g., 20 +} + +#[derive(Copy, Drop, Serde, Debug)] +#[dojo::model] +pub struct GameOutcome { + #[key] + pub player: ContractAddress, + pub won: bool, // Win or lose status + pub amount_won: u128, // Amount won after deduction +} diff --git a/src/systems/actions.cairo b/src/systems/actions.cairo new file mode 100644 index 0000000..30b6710 --- /dev/null +++ b/src/systems/actions.cairo @@ -0,0 +1,106 @@ +use dojo_starter::models::PlayerBalance; +use dojo_starter::models::PlatformFees; +use dojo_starter::models::GameOutcome; + +// define the interface +#[starknet::interface] +trait IHitThePlay { + fn initialize_platform_fees(ref self: T, fee_percentage: u8); + fn play_game(ref self: T, bet_amount: u128); +} + +// dojo decorator +#[dojo::contract] +pub mod rugged { + use starknet::{ContractAddress, get_caller_address}; + use dojo_starter::models::{PlayerBalance, PlatformFees, GameOutcome}; + use core::traits::TryInto; + + use dojo::model::{ModelStorage, ModelValueStorage}; + use dojo::event::EventStorage; + use super::IHitThePlay; + + #[derive(Copy, Drop, Serde)] + #[dojo::event] + pub enum Event { + GamePlayed: GamePlayed, + } + + #[derive(Copy, Drop, Serde)] + #[dojo::event] + pub struct GamePlayed { + #[key] + player: ContractAddress, + result: bool, // True if won, False if lost + amount: u128, // Amount won/lost + } + + + // // Initializes platform fees + // fn initialize_platform_fees(ref self: ContractState, fee_percentage: u8) { + // let admin = get_caller_address(); + // let mut world = self.world(@"dojo_starter"); + + // // Create and set platform fees + // set!(world, (PlatformFees { admin, fee_percentage, })); + // } + + // Main game logic where the player bets and plays. + fn play_game(ref self: ContractState, bet_amount: u128) { + let player = get_caller_address(); + let mut world = self.world(@"dojo_starter"); + + // Get player balance or initialize new one + let mut player_balance :PlayerBalance = world.read_model(player); + + // Ensure the player has enough balance + assert(player_balance.balance >= bet_amount, 'Insufficient balance'); + + // Deduct bet amount from player balance + player_balance.balance -= bet_amount; + player_balance.total_games += 1; + + // Generate pseudo-random number using block timestamp and player address + let block_timestamp = starknet::get_block_timestamp(); + let seed = pedersen::hash(block_timestamp.into(), player.into()); + let random_value = seed % 10; + + // 30% chance to win (values 0,1,2 represent win) + let won = random_value < 3; + + let mut amount_won: u128 = 0; + if won { + // Get platform fees + let fees = 100; + let fee_percentage: u128 = fees.fee_percentage.into(); + let fee_deduction = (bet_amount * fee_percentage) / 100; + amount_won = bet_amount * 2 - fee_deduction; // Double the bet minus fees + + // Update player stats + player_balance.balance += amount_won; + player_balance.wins += 1; + } else { + player_balance.losses += 1; + } + + // Update world state + let game_outcome = GameOutcome { + player: player, + won: won, + amount_won: amount_won, + }; + world.write_model(@game_outcome); + + let player_balance = PlayerBalance { + player: player, + balance: player_balance.balance, + total_games: player_balance.total_games, + wins: player_balance.wins, + losses: player_balance.losses, + }; + world.write_model(@player_balance); + + // Emit game played event + self.emit(GamePlayed { player, result: won, amount: amount_won }); + } +} diff --git a/src/tests/test_world.cairo b/src/tests/test_world.cairo new file mode 100644 index 0000000..8b4bc0d --- /dev/null +++ b/src/tests/test_world.cairo @@ -0,0 +1,83 @@ +#[cfg(test)] +mod tests { + use dojo::model::{ModelStorage, ModelValueStorage, ModelStorageTest}; + use dojo::world::WorldStorageTrait; + use dojo_cairo_test::{spawn_test_world, NamespaceDef, TestResource, ContractDefTrait}; + + use dojo_starter::systems::actions::{actions, IActionsDispatcher, IActionsDispatcherTrait}; + use dojo_starter::models::{Position, m_Position, Moves, m_Moves, Direction}; + + fn namespace_def() -> NamespaceDef { + let ndef = NamespaceDef { + namespace: "dojo_starter", resources: [ + TestResource::Model(m_Position::TEST_CLASS_HASH.try_into().unwrap()), + TestResource::Model(m_Moves::TEST_CLASS_HASH.try_into().unwrap()), + TestResource::Event(actions::e_Moved::TEST_CLASS_HASH.try_into().unwrap()), + TestResource::Contract( + ContractDefTrait::new(actions::TEST_CLASS_HASH, "actions") + .with_writer_of([dojo::utils::bytearray_hash(@"dojo_starter")].span()) + ) + ].span() + }; + + ndef + } + + #[test] + fn test_world_test_set() { + // Initialize test environment + let caller = starknet::contract_address_const::<0x0>(); + let ndef = namespace_def(); + let mut world = spawn_test_world([ndef].span()); + + // Test initial position + let mut position: Position = world.read_model(caller); + assert(position.vec.x == 0 && position.vec.y == 0, 'initial position wrong'); + + // Test write_model_test + position.vec.x = 122; + position.vec.y = 88; + + world.write_model_test(@position); + + let mut position: Position = world.read_model(caller); + assert(position.vec.y == 88, 'write_value_from_id failed'); + + // Test model deletion + world.erase_model(@position); + let position: Position = world.read_model(caller); + assert(position.vec.x == 0 && position.vec.y == 0, 'erase_model failed'); + } + + #[test] + #[available_gas(30000000)] + fn test_move() { + let caller = starknet::contract_address_const::<0x0>(); + + let ndef = namespace_def(); + let mut world = spawn_test_world([ndef].span()); + + let (contract_address, _) = world.dns(@"actions").unwrap(); + let actions_system = IActionsDispatcher { contract_address }; + + actions_system.spawn(); + let initial_moves: Moves = world.read_model(caller); + let initial_position: Position = world.read_model(caller); + + assert( + initial_position.vec.x == 10 && initial_position.vec.y == 10, 'wrong initial position' + ); + + actions_system.move(Direction::Right(())); + + let moves: Moves = world.read_model(caller); + let right_dir_felt: felt252 = Direction::Right(()).into(); + + assert(moves.remaining == initial_moves.remaining - 1, 'moves is wrong'); + assert(moves.last_direction.into() == right_dir_felt, 'last direction is wrong'); + + let new_position: Position = world.read_model(caller); + assert(new_position.vec.x == initial_position.vec.x + 1, 'position x is wrong'); + assert(new_position.vec.y == initial_position.vec.y, 'position y is wrong'); + } +} \ No newline at end of file